Java Code Examples for com.fasterxml.jackson.dataformat.xml.XmlMapper#setSerializerFactory()

The following examples show how to use com.fasterxml.jackson.dataformat.xml.XmlMapper#setSerializerFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MappingJackson2XmlViewTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void renderWithCustomSerializerLocatedByFactory() throws Exception {
	SerializerFactory factory = new DelegatingSerializerFactory(null);
	XmlMapper mapper = new XmlMapper();
	mapper.setSerializerFactory(factory);
	view.setObjectMapper(mapper);

	Object bean = new TestBeanSimple();
	Map<String, Object> model = new HashMap<>();
	model.put("foo", bean);

	view.render(model, request, response);

	String result = response.getContentAsString();
	assertTrue(result.length() > 0);
	assertTrue(result.contains("custom</testBeanSimple>"));

	validateResult();
}
 
Example 2
Source File: MappingJackson2XmlViewTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void renderWithCustomSerializerLocatedByFactory() throws Exception {
	SerializerFactory factory = new DelegatingSerializerFactory(null);
	XmlMapper mapper = new XmlMapper();
	mapper.setSerializerFactory(factory);
	view.setObjectMapper(mapper);

	Object bean = new TestBeanSimple();
	Map<String, Object> model = new HashMap<>();
	model.put("foo", bean);

	view.render(model, request, response);

	String result = response.getContentAsString();
	assertTrue(result.length() > 0);
	assertTrue(result.contains("custom</testBeanSimple>"));

	validateResult();
}
 
Example 3
Source File: MappingJackson2XmlViewTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void renderWithCustomSerializerLocatedByFactory() throws Exception {
	SerializerFactory factory = new DelegatingSerializerFactory(null);
	XmlMapper mapper = new XmlMapper();
	mapper.setSerializerFactory(factory);
	view.setObjectMapper(mapper);

	Object bean = new TestBeanSimple();
	Map<String, Object> model = new HashMap<String, Object>();
	model.put("foo", bean);

	view.render(model, request, response);

	String result = response.getContentAsString();
	assertTrue(result.length() > 0);
	assertTrue(result.contains("custom</testBeanSimple>"));

	validateResult();
}