use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project alfresco-remote-api by Alfresco.
the class JsonJacksonTests method testSerializeMultipleObjects.
@Test
public void testSerializeMultipleObjects() throws IOException {
final Collection<Comment> allComments = new ArrayList<Comment>();
Comment aComment = new Comment();
aComment.setContent("<b>There it is</b>");
allComments.add(aComment);
aComment = new Comment();
aComment.setContent("<p>I agree with the author</p>");
allComments.add(aComment);
ByteArrayOutputStream out = new ByteArrayOutputStream();
jsonHelper.withWriter(out, new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
FilterProvider fp = new SimpleFilterProvider().addFilter(JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
objectMapper.writer(fp).writeValue(generator, allComments);
}
});
assertTrue(out.toString().contains("content\":\"<b>There it is</b>"));
assertTrue(out.toString().contains("content\":\"<p>I agree with the author</p>"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project alfresco-remote-api by Alfresco.
the class SerializeTests method writeResponse.
private String writeResponse(final Object respons) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
jsonHelper.withWriter(out, new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
objectMapper.writeValue(generator, respons);
}
});
System.out.println(out.toString());
return out.toString();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project eap-additional-testsuite by jboss-set.
the class SecurityDeserializationTestCase method testSecuirtyDatabind13.
@ATTest({ "modules/testcases/jdkAll/Wildfly/security/src/main/java#19.0.0.Beta1", "modules/testcases/jdkAll/Eap72x-Proposed/security/src/main/java#7.2.6", "modules/testcases/jdkAll/Eap72x/security/src/main/java#7.2.6", "modules/testcases/jdkAll/Eap7/security/src/main/java#7.3.0.GA" })
public void testSecuirtyDatabind13() throws Exception {
final String JSON = aposToQuotes("{'v':['com.zaxxer.hikari.HikariDataSource']}");
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping();
try {
PolyWrapper sc = mapper.readValue(JSON, PolyWrapper.class);
fail("Should not be able to deserialize because of security prevention.");
} catch (JsonMappingException e) {
assertTrue("Fail because of security issues...", e.getMessage().contains("prevented for security reasons"));
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project eap-additional-testsuite by jboss-set.
the class SecurityDeserializationTestCase method testSecuirtyDatabind21.
// @TTest({"modules/testcases/jdkAll/Wildfly/security/src/main/java#20.0.0.Final","modules/testcases/jdkAll/Eap72x/security/src/main/java#7.2.9","modules/testcases/jdkAll/Eap72x-Proposed/security/src/main/java#7.2.9","modules/testcases/jdkAll/Eap7/security/src/main/java#7.3.2"})
public void testSecuirtyDatabind21() throws Exception {
final String JSON = aposToQuotes("{'v':['org.apache.aries.transaction.jms.internal.XaPooledConnectionFactory']}");
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping();
try {
PolyWrapper sc = mapper.readValue(JSON, PolyWrapper.class);
fail("Should not be able to deserialize because of security prevention.");
} catch (JsonMappingException e) {
assertTrue("Fail because of security issues...", e.getMessage().contains("prevented for security reasons"));
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project eap-additional-testsuite by jboss-set.
the class SecurityDeserialization2TestCase method testSecuirtyDatabind2.
@Test
public void testSecuirtyDatabind2() throws Exception {
final String JSON = aposToQuotes("{'v':['java.util.logging.FileHandler','/tmp/foobar.txt']}");
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping();
try {
PolyWrapper sc = mapper.readValue(JSON, PolyWrapper.class);
fail("Should not be able to deserialize because of security prevention.");
} catch (JsonMappingException e) {
assertTrue("Fail because of security issues...", e.getMessage().contains("prevented for security reasons"));
}
}
Aggregations