use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException in project dcos-commons by mesosphere.
the class DefaultServiceSpecTest method invalidTaskName.
@Test
public void invalidTaskName() throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("invalid-task-name.yml").getFile());
try {
DefaultServiceSpec.newGenerator(file, SCHEDULER_CONFIG).build();
Assert.fail("Expected exception");
} catch (JsonMappingException e) {
Assert.assertTrue(e.getCause().toString(), e.getCause() instanceof JsonParseException);
JsonParseException cause = (JsonParseException) e.getCause();
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Duplicate field 'meta-data-task'"));
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException in project navajo by Dexels.
the class ServletArticleRuntimeImpl method commit.
@Override
public void commit() throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode;
try {
rootNode = mapper.readValue(writer.toString(), JsonNode.class);
} catch (JsonParseException e) {
logger.error("JSON parse error: ", e);
response.getWriter().write("Invalid JSON follows:\n");
response.getWriter().write(writer.toString());
return;
}
ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter();
writer.writeValue(response.getWriter(), rootNode);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException in project elasticsearch by elastic.
the class BaseXContentTestCase method testChecksForDuplicates.
public void testChecksForDuplicates() throws Exception {
assumeTrue("Test only makes sense if XContent parser has strict duplicate checks enabled", XContent.isStrictDuplicateDetectionEnabled());
XContentBuilder builder = builder().startObject().field("key", 1).field("key", 2).endObject();
JsonParseException pex = expectThrows(JsonParseException.class, () -> createParser(builder).map());
assertThat(pex.getMessage(), startsWith("Duplicate field 'key'"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException in project elasticsearch by elastic.
the class FunctionScoreQueryBuilderTests method testMalformedThrowsException.
public void testMalformedThrowsException() throws IOException {
String json = "{\n" + " \"function_score\":{\n" + " \"query\":{\n" + " \"term\":{\n" + " \"name.last\":\"banon\"\n" + " }\n" + " },\n" + " \"functions\": [\n" + " {\n" + " {\n" + " }\n" + " ]\n" + " }\n" + "}";
JsonParseException e = expectThrows(JsonParseException.class, () -> parseQuery(json));
assertThat(e.getMessage(), containsString("Unexpected character ('{"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException in project jackson-core by FasterXML.
the class ParserErrorHandlingTest method _testMangledNumbers.
private void _testMangledNumbers(int mode) throws Exception {
String doc = "123true";
JsonParser p = createParser(mode, doc);
try {
JsonToken t = p.nextToken();
fail("Should have gotten an exception; instead got token: " + t);
} catch (JsonParseException e) {
verifyException(e, "expected space");
}
p.close();
// Also test with floats
doc = "1.5false";
p = createParser(mode, doc);
try {
JsonToken t = p.nextToken();
fail("Should have gotten an exception; instead got token: " + t);
} catch (JsonParseException e) {
verifyException(e, "expected space");
}
p.close();
}
Aggregations