Search in sources :

Example 26 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomSourceExtractor.

@Test
public void simpleGatewayWithCustomSourceExtractor() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomSourceExtractor", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    SourceExtractor<?> sourceExtractor = (SourceExtractor<?>) context.getBean("sourceExtractor");
    assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SourceExtractor(org.springframework.ws.client.core.SourceExtractor) Test(org.junit.Test)

Example 27 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method marshallingGatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory.

@Test
public void marshallingGatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
    AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory");
    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));
    WebServiceMessageFactory messageFactory = context.getBean("messageFactory", WebServiceMessageFactory.class);
    assertEquals(messageFactory, TestUtils.getPropertyValue(gateway, "webServiceTemplate.messageFactory"));
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) Marshaller(org.springframework.oxm.Marshaller) WebServiceMessageFactory(org.springframework.ws.WebServiceMessageFactory) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Unmarshaller(org.springframework.oxm.Unmarshaller) Test(org.junit.Test)

Example 28 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomInterceptorList.

@Test
public void simpleGatewayWithCustomInterceptorList() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomInterceptorList", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
    ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class);
    assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
    assertEquals("Wrong number of interceptors ", 2, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ClientInterceptor(org.springframework.ws.client.support.interceptor.ClientInterceptor) Test(org.junit.Test)

Example 29 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithIgnoreEmptyResponseTrueByDefault.

@Test
public void simpleGatewayWithIgnoreEmptyResponseTrueByDefault() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithReplyChannel", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    assertEquals(Boolean.TRUE, accessor.getPropertyValue("ignoreEmptyResponses"));
    Assert.assertEquals(Boolean.FALSE, accessor.getPropertyValue("requiresReply"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 30 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method marshallingGatewayWithAllInOneMarshaller.

@Test
public void marshallingGatewayWithAllInOneMarshaller() {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
    AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithAllInOneMarshaller");
    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));
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) Marshaller(org.springframework.oxm.Marshaller) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Unmarshaller(org.springframework.oxm.Unmarshaller) Test(org.junit.Test)

Aggregations

AbstractEndpoint (org.springframework.integration.endpoint.AbstractEndpoint)34 Test (org.junit.Test)28 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)19 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)7 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)6 MessageHandler (org.springframework.messaging.MessageHandler)5 Marshaller (org.springframework.oxm.Marshaller)4 Unmarshaller (org.springframework.oxm.Unmarshaller)4 WebServiceMessageFactory (org.springframework.ws.WebServiceMessageFactory)4 PollingConsumer (org.springframework.integration.endpoint.PollingConsumer)3 WebServiceMessageCallback (org.springframework.ws.client.core.WebServiceMessageCallback)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)2 DirectChannel (org.springframework.integration.channel.DirectChannel)2 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)2 ReactiveStreamsConsumer (org.springframework.integration.endpoint.ReactiveStreamsConsumer)2 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)2 PollableChannel (org.springframework.messaging.PollableChannel)2 SubscribableChannel (org.springframework.messaging.SubscribableChannel)2 SourceExtractor (org.springframework.ws.client.core.SourceExtractor)2