use of org.springframework.oxm.jaxb.Jaxb2Marshaller in project spring-boot by spring-projects.
the class WebServiceMarshallerConfiguration method createJaxbMarshaller.
@Bean
Jaxb2Marshaller createJaxbMarshaller() {
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
jaxb2Marshaller.setClassesToBeBound(Request.class, Response.class);
return jaxb2Marshaller;
}
use of org.springframework.oxm.jaxb.Jaxb2Marshaller in project irida by phac-nml.
the class IridaApiGalaxyTestConfig method workflowDescriptionUnmarshaller.
/**
* Sets up an {@link Unmarshaller} for workflow objects.
*
* @return An {@link Unmarshaller} for workflow objects.
*/
@Bean
public Unmarshaller workflowDescriptionUnmarshaller() {
Jaxb2Marshaller jaxb2marshaller = new Jaxb2Marshaller();
jaxb2marshaller.setPackagesToScan(new String[] { "ca.corefacility.bioinformatics.irida.model.workflow" });
return jaxb2marshaller;
}
use of org.springframework.oxm.jaxb.Jaxb2Marshaller in project irida by phac-nml.
the class IridaRestApiWebConfig method defaultViews.
private List<View> defaultViews() {
List<View> views = new ArrayList<>();
MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
jsonView.setPrettyPrint(true);
// add support for serializing Path data
jsonView.getObjectMapper().registerModule(new Jdk7Module());
views.add(jsonView);
Jaxb2Marshaller jaxb2marshaller = new Jaxb2Marshaller();
jaxb2marshaller.setPackagesToScan(new String[] { "ca.corefacility.bioinformatics.irida.web.assembler.resource" });
MarshallingView marshallingView = new MarshallingView(jaxb2marshaller);
views.add(marshallingView);
views.add(new FastaView());
views.add(new FastqView());
views.add(new GenbankView());
views.add(new NewickFileView());
views.add(new CSVView());
return views;
}
use of org.springframework.oxm.jaxb.Jaxb2Marshaller in project nzbhydra2 by theotherp.
the class WebConfiguration method marshaller.
/**
* Enable pretty printing of returned XML
*/
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
Map<String, Boolean> map = new HashMap<>();
map.put(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setMarshallerProperties(map);
marshaller.setPackagesToScan("org.nzbhydra.mockserver");
return marshaller;
}
use of org.springframework.oxm.jaxb.Jaxb2Marshaller in project spring-framework by spring-projects.
the class ViewResolutionTests method contentNegotiation.
@Test
void contentNegotiation() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(Person.class);
List<View> viewList = new ArrayList<>();
viewList.add(new MappingJackson2JsonView());
viewList.add(new MarshallingView(marshaller));
ContentNegotiationManager manager = new ContentNegotiationManager(new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));
ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
cnViewResolver.setDefaultViews(viewList);
cnViewResolver.setContentNegotiationManager(manager);
cnViewResolver.afterPropertiesSet();
MockMvc mockMvc = standaloneSetup(new PersonController()).setViewResolvers(cnViewResolver, new InternalResourceViewResolver()).build();
mockMvc.perform(get("/person/Corea")).andExpect(status().isOk()).andExpect(model().size(1)).andExpect(model().attributeExists("person")).andExpect(forwardedUrl("person/show"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.person.name").value("Corea"));
mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_XML)).andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
Aggregations