Spring Framework Jaxb2RootElementHttpMessageConverter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework Jaxb2RootElementHttpMessageConverter class.

This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods:
  @Before 
  public void setup() { 
    MockitoAnnotations.initMocks(this); 
 
    this.mockMvc = standaloneSetup(controller) 
            .setMessageConverters(new MappingJackson2HttpMessageConverter(), 
                                  new Jaxb2RootElementHttpMessageConverter()).build(); 
  } 
 
  @Test 
  public void thatViewOrderRendersXMLCorrectly() throws Exception { 
 
    when(orderService.requestOrderDetails(any(RequestOrderDetailsEvent.class))).thenReturn( 
            orderDetailsEvent(key)); 
 
    this.mockMvc.perform( 
            get("/aggregators/orders/{id}", key.toString()) 
                    .accept(MediaType.TEXT_XML)) 
            .andDo(print()) 
            .andExpect(content().contentType(MediaType.TEXT_XML)) 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
  @Before 
  public void setup() { 
    MockitoAnnotations.initMocks(this); 
 
    this.mockMvc = standaloneSetup(controller) 
            .setMessageConverters( 
                    new MappingJackson2HttpMessageConverter(), 
                    new Jaxb2RootElementHttpMessageConverter()).build(); 
  } 
 
  @Test 
  public void thatViewOrderStatusUsesHttpNotFound() throws Exception { 
 
    when(orderService.requestOrderStatus(any(RequestOrderStatusEvent.class))).thenReturn( 
            orderStatusNotFound(key)); 
 
    this.mockMvc.perform( 
            get("/aggregators/orders/{id}/status", key.toString()) 
                    .accept(MediaType.APPLICATION_JSON)) 
            .andExpect(status().isNotFound()); 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	@Test
	public void testNumber() throws Exception {
 
		String composerDouble = "/ns:people/composers/composer[%s]/someDouble";
 
		this.mockServer.expect(requestTo("/composers"))
			.andExpect(content().mimeType("application/xml")) 
			.andExpect(xpath(composerDouble, NS, 1).number(21d))
			.andExpect(xpath(composerDouble, NS, 2).number(.0025))
			.andExpect(xpath(composerDouble, NS, 3).number(1.6035))
			.andExpect(xpath(composerDouble, NS, 4).number(Double.NaN))
			.andExpect(xpath(composerDouble, NS, 1).number(equalTo(21d))) // Hamcrest..
			.andExpect(xpath(composerDouble, NS, 3).number(closeTo(1.6, .01))) // Hamcrest..
			.andRespond(withSuccess()); 
 
		this.restTemplate.put(new URI("/composers"), this.people);
		this.mockServer.verify();
	} 
 
	@Test
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		else if (jacksonPresent) {
			// avoiding import of MappingJacksonHttpMessageConverter to prevent deprecation warning 
			messageConverters.add(new MappingJackson2HttpMessageConverter());
		} 
		if (jaxb2Present) {
			Jaxb2RootElementHttpMessageConverter jaxbConverter = new Jaxb2RootElementHttpMessageConverter();
			initializeJAXBContexts(jaxbConverter);
			messageConverters.add(jaxbConverter);
		} 
		return messageConverters;
	} 
 
	private static void initializeJAXBContexts(AbstractJaxb2HttpMessageConverter<?> c) {
 
		// Ugliest hack ever to workaround https://jira.springsource.org/browse/SPR-10262 
		Field f = ReflectionUtils.findField(AbstractJaxb2HttpMessageConverter.class, "jaxbContexts");
		ReflectionUtils.makeAccessible(f);
		@SuppressWarnings("unchecked") 
		Map<Class<?>, JAXBContext> contexts = (Map<Class<?>, JAXBContext>) ReflectionUtils.getField(f, c);
		try { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        converters.add(new ByteArrayHttpMessageConverter()); 
        converters.add(stringConverter); 
        converters.add(new ResourceHttpMessageConverter()); 
 
        if (isJaxb2Present()) { 
            converters.add(new Jaxb2RootElementHttpMessageConverter()); 
        } 
        if (isJackson2Present()) { 
            converters.add(new MappingJackson2HttpMessageConverter()); 
 
        } else if (isJacksonPresent()) { 
            converters.add(new MappingJacksonHttpMessageConverter()); 
        } 
        return converters; 
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java