本文整理了Java中com.linecorp.centraldogma.internal.Jackson.readValue()
方法的一些代码示例,展示了Jackson.readValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jackson.readValue()
方法的具体详情如下:
包路径:com.linecorp.centraldogma.internal.Jackson
类名称:Jackson
方法名:readValue
暂无
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
/**
* Creates a new instance from the given configuration file and security config.
*
* @throws IOException if failed to load the configuration from the specified file
*/
public static CentralDogma forConfig(File configFile, @Nullable Ini securityConfig) throws IOException {
requireNonNull(configFile, "configFile");
return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class),
securityConfig);
}
代码示例来源:origin: line/centraldogma
/**
* Creates a new instance from the given configuration file.
*
* @throws IOException if failed to load the configuration from the specified file
*/
public static CentralDogma forConfig(File configFile) throws IOException {
requireNonNull(configFile, "configFile");
return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
/**
* Creates a new instance from the given configuration file.
*
* @throws IOException if failed to load the configuration from the specified file
*/
public static CentralDogma forConfig(File configFile) throws IOException {
requireNonNull(configFile, "configFile");
return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class));
}
代码示例来源:origin: line/centraldogma
private static Revision toRevision(String text) throws IOException {
return readValue(text, Revision.class);
}
}
代码示例来源:origin: line/centraldogma
@Override
public CompletableFuture<Session> get(String sessionId) {
requireNonNull(sessionId, "sessionId");
final Path path = sessionId2Path(sessionId);
if (!isSessionFile(path)) {
return CompletableFuture.completedFuture(null);
}
try {
return CompletableFuture.completedFuture(
Jackson.readValue(Files.readAllBytes(path), Session.class));
} catch (IOException e) {
return CompletableFuture.completedFuture(null);
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
@Override
public CompletableFuture<Session> get(String sessionId) {
requireNonNull(sessionId, "sessionId");
final Path path = sessionId2Path(sessionId);
if (!isSessionFile(path)) {
return CompletableFuture.completedFuture(null);
}
try {
return CompletableFuture.completedFuture(
Jackson.readValue(Files.readAllBytes(path), Session.class));
} catch (IOException e) {
return CompletableFuture.completedFuture(null);
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-common
/**
* Returns the value converted from the JSON representation of the specified content.
*
* @return the value converted from the content
*
* @throws IllegalStateException if the content is {@code null}
* @throws JsonParseException if failed to parse the content as JSON
* @throws JsonMappingException if failed to convert the parsed JSON into {@code valueType}
*/
default <U> U contentAsJson(Class<U> valueType) throws JsonParseException, JsonMappingException {
final T content = content();
if (content instanceof TreeNode) {
return Jackson.treeToValue((TreeNode) content, valueType);
}
return Jackson.readValue(contentAsText(), valueType);
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-common-shaded
/**
* Returns the value converted from the JSON representation of {@link #content()}.
*
* @return the value converted from {@link #content()}
*
* @throws IllegalStateException if this {@link Entry} is a directory
* @throws JsonParseException if failed to parse the {@link #content()} as JSON
* @throws JsonMappingException if failed to convert the parsed JSON into {@code valueType}
*/
public <U> U contentAsJson(Class<U> valueType) throws JsonParseException, JsonMappingException {
final T content = content();
if (content instanceof TreeNode) {
return Jackson.treeToValue((TreeNode) content, valueType);
}
return Jackson.readValue(contentAsText(), valueType);
}
代码示例来源:origin: line/centraldogma
public static <T> void assertJsonConversion(T value, Class<T> valueType, String json) {
assertThatJson(json).isEqualTo(value);
try {
assertEquals(value, Jackson.readValue(json, valueType));
} catch (IOException e) {
throw new IOError(e);
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final UnremoveProjectCommand c = (UnremoveProjectCommand) Jackson.readValue(
'{' +
" \"type\": \"UNREMOVE_PROJECT\"," +
" \"projectName\": \"foo\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final CreateProjectCommand c = (CreateProjectCommand) Jackson.readValue(
'{' +
" \"type\": \"CREATE_PROJECT\"," +
" \"projectName\": \"foo\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final RemoveProjectCommand c = (RemoveProjectCommand) Jackson.readValue(
'{' +
" \"type\": \"REMOVE_PROJECT\"," +
" \"projectName\": \"foo\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final CreateRepositoryCommand c = (CreateRepositoryCommand) Jackson.readValue(
'{' +
" \"type\": \"CREATE_REPOSITORY\"," +
" \"projectName\": \"foo\"," +
" \"repositoryName\": \"bar\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
assertThat(c.repositoryName()).isEqualTo("bar");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final RemovePluginCommand c = (RemovePluginCommand) Jackson.readValue(
'{' +
" \"type\": \"REMOVE_PLUGIN\"," +
" \"projectName\": \"foo\"," +
" \"pluginName\": \"my_plugin\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
assertThat(c.pluginName()).isEqualTo("my_plugin");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final UnremoveRepositoryCommand c = (UnremoveRepositoryCommand) Jackson.readValue(
'{' +
" \"type\": \"UNREMOVE_REPOSITORY\"," +
" \"projectName\": \"foo\"," +
" \"repositoryName\": \"bar\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
assertThat(c.repositoryName()).isEqualTo("bar");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final RemoveNamedQueryCommand c = (RemoveNamedQueryCommand) Jackson.readValue(
'{' +
" \"type\": \"REMOVE_NAMED_QUERY\"," +
" \"projectName\": \"foo\"," +
" \"queryName\": \"bar\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
assertThat(c.queryName()).isEqualTo("bar");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final RemoveRepositoryCommand c = (RemoveRepositoryCommand) Jackson.readValue(
'{' +
" \"type\": \"REMOVE_REPOSITORY\"," +
" \"projectName\": \"foo\"," +
" \"repositoryName\": \"bar\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
assertThat(c.repositoryName()).isEqualTo("bar");
}
}
代码示例来源:origin: line/centraldogma
@Test
public void backwardCompatibility() throws Exception {
final SavePluginCommand c = (SavePluginCommand) Jackson.readValue(
'{' +
" \"type\": \"SAVE_PLUGIN\"," +
" \"projectName\": \"foo\"," +
" \"pluginName\": \"my_plugin\"," +
" \"path\": \"/plugin.json\"" +
'}', Command.class);
assertThat(c.author()).isEqualTo(Author.SYSTEM);
assertThat(c.timestamp()).isNotZero();
assertThat(c.projectName()).isEqualTo("foo");
assertThat(c.pluginName()).isEqualTo("my_plugin");
assertThat(c.path()).isEqualTo("/plugin.json");
}
}
代码示例来源:origin: line/centraldogma
private void loginAndLogout(AggregatedHttpMessage loginRes) throws Exception {
assertThat(loginRes.status()).isEqualTo(HttpStatus.OK);
// Ensure authorization works.
final AccessToken accessToken = Jackson.readValue(loginRes.content().toStringUtf8(), AccessToken.class);
final String sessionId = accessToken.accessToken();
assertThat(usersMe(client, sessionId).status()).isEqualTo(HttpStatus.OK);
// Log out.
assertThat(logout(client, sessionId).status()).isEqualTo(HttpStatus.OK);
assertThat(usersMe(client, sessionId).status()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
代码示例来源:origin: line/centraldogma
@Test
public void tlsConfig() throws Exception {
final String cert = Jackson.escapeText(folder.newFile().getAbsolutePath());
final String key = Jackson.escapeText(folder.newFile().getAbsolutePath());
final String jsonConfig = String.format("{\"tls\": {" +
"\"keyCertChainFile\": \"%s\", " +
"\"keyFile\": \"%s\", " +
"\"keyPassword\": null " +
"}}", cert, key);
final ParentConfig parentConfig = Jackson.readValue(jsonConfig, ParentConfig.class);
final TlsConfig tlsConfig = parentConfig.tlsConfig;
assertThat(tlsConfig.keyCertChainFile()).isNotNull();
assertThat(tlsConfig.keyCertChainFile().canRead()).isTrue();
assertThat(tlsConfig.keyFile()).isNotNull();
assertThat(tlsConfig.keyFile().canRead()).isTrue();
assertThat(tlsConfig.keyPassword()).isNull();
}
内容来源于网络,如有侵权,请联系作者删除!