use of org.springframework.oxm.Marshaller in project spring-integration by spring-projects.
the class WebServiceOutboundGatewayParserTests method marshallingGatewayWithAllInOneMarshallerAndMessageFactory.
@Test
public void marshallingGatewayWithAllInOneMarshallerAndMessageFactory() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAllInOneMarshallerAndMessageFactory");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object gateway = TestUtils.getPropertyValue(endpoint, "handler");
Marshaller marshaller = context.getBean("marshallerAndUnmarshaller", Marshaller.class);
assertSame(marshaller, TestUtils.getPropertyValue(gateway, "webServiceTemplate.marshaller", Marshaller.class));
assertSame(marshaller, TestUtils.getPropertyValue(gateway, "webServiceTemplate.unmarshaller", Unmarshaller.class));
WebServiceMessageFactory messageFactory = (WebServiceMessageFactory) context.getBean("messageFactory");
assertEquals(messageFactory, TestUtils.getPropertyValue(gateway, "webServiceTemplate.messageFactory"));
context.close();
}
use of org.springframework.oxm.Marshaller in project spring-integration by spring-projects.
the class WebServiceOutboundGatewayParserTests method marshallingGatewayWithSeparateMarshallerAndUnmarshaller.
@Test
public void marshallingGatewayWithSeparateMarshallerAndUnmarshaller() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshaller");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object gateway = TestUtils.getPropertyValue(endpoint, "handler");
Marshaller marshaller = context.getBean("marshaller", Marshaller.class);
Unmarshaller unmarshaller = context.getBean("unmarshaller", Unmarshaller.class);
assertSame(marshaller, TestUtils.getPropertyValue(gateway, "webServiceTemplate.marshaller", Marshaller.class));
assertSame(unmarshaller, TestUtils.getPropertyValue(gateway, "webServiceTemplate.unmarshaller", Unmarshaller.class));
context.close();
}
use of org.springframework.oxm.Marshaller in project spring-framework by spring-projects.
the class MarshallingHttpMessageConverterTests method readWithTypeMismatchException.
@Test
public void readWithTypeMismatchException() throws Exception {
MockHttpInputMessage inputMessage = new MockHttpInputMessage(new byte[0]);
Marshaller marshaller = mock(Marshaller.class);
Unmarshaller unmarshaller = mock(Unmarshaller.class);
given(unmarshaller.unmarshal(isA(StreamSource.class))).willReturn(3);
MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller, unmarshaller);
assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() -> converter.read(String.class, inputMessage)).withCauseInstanceOf(TypeMismatchException.class);
}
use of org.springframework.oxm.Marshaller in project spring-framework by spring-projects.
the class MarshallingHttpMessageConverterTests method write.
@Test
public void write() throws Exception {
String body = "<root>Hello World</root>";
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
Marshaller marshaller = mock(Marshaller.class);
willDoNothing().given(marshaller).marshal(eq(body), isA(Result.class));
MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller);
converter.write(body, null, outputMessage);
assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "xml"));
}
use of org.springframework.oxm.Marshaller in project spring-boot by spring-projects.
the class WebServiceTemplateBuilderTests method setMarshaller.
@Test
void setMarshaller() {
Marshaller marshaller = mock(Marshaller.class);
WebServiceTemplate template = this.builder.setMarshaller(marshaller).build();
assertThat(template.getMarshaller()).isEqualTo(marshaller);
}
Aggregations