Java Code Examples for org.springframework.oxm.jaxb.Jaxb2Marshaller#afterPropertiesSet()
The following examples show how to use
org.springframework.oxm.jaxb.Jaxb2Marshaller#afterPropertiesSet() .
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: MarshallingMessageConverterTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Before public void createMarshaller() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(MyBean.class); marshaller.afterPropertiesSet(); this.converter = new MarshallingMessageConverter(marshaller); }
Example 2
Source File: ServletAnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void responseBodyArgMismatch() throws ServletException, IOException { @SuppressWarnings("serial") DispatcherServlet servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(RequestBodyArgMismatchController.class)); Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(A.class, B.class); try { marshaller.afterPropertiesSet(); } catch (Exception ex) { throw new BeanCreationException(ex.getMessage(), ex); } MarshallingHttpMessageConverter messageConverter = new MarshallingHttpMessageConverter(marshaller); RootBeanDefinition adapterDef = new RootBeanDefinition(AnnotationMethodHandlerAdapter.class); adapterDef.getPropertyValues().add("messageConverters", messageConverter); wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something"); String requestBody = "<b/>"; request.setContent(requestBody.getBytes("UTF-8")); request.addHeader("Content-Type", "application/xml; charset=utf-8"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); assertEquals(400, response.getStatus()); }
Example 3
Source File: MarshallingMessageConverterTests.java From spring-analysis-note with MIT License | 4 votes |
@Before public void createMarshaller() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(MyBean.class); marshaller.afterPropertiesSet(); this.converter = new MarshallingMessageConverter(marshaller); }
Example 4
Source File: MarshallingMessageConverterTests.java From java-technology-stack with MIT License | 4 votes |
@Before public void createMarshaller() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(MyBean.class); marshaller.afterPropertiesSet(); this.converter = new MarshallingMessageConverter(marshaller); }