Search in sources :

Example 11 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomMessageFactory.

@Test
public void simpleGatewayWithCustomMessageFactory() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomMessageFactory", 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"));
    WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory");
    assertEquals(factory, accessor.getPropertyValue("messageFactory"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) WebServiceMessageFactory(org.springframework.ws.WebServiceMessageFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 12 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithDefaultSourceExtractor.

@Test
public void simpleGatewayWithDefaultSourceExtractor() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithDefaultSourceExtractor", 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("DefaultSourceExtractor", accessor.getPropertyValue("sourceExtractor").getClass().getSimpleName());
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 13 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomMessageSenderList.

@Test
public void simpleGatewayWithCustomMessageSenderList() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomMessageSenderList", 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"));
    WebServiceMessageSender messageSender = (WebServiceMessageSender) context.getBean("messageSender");
    assertEquals(messageSender, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders"))[0]);
    assertEquals("Wrong number of message senders ", 2, ((WebServiceMessageSender[]) accessor.getPropertyValue("messageSenders")).length);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) WebServiceMessageSender(org.springframework.ws.transport.WebServiceMessageSender) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 14 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint 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();
}
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 15 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method advised.

@Test
public void advised() {
    adviceCalled = 0;
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithAdvice", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
    handler.handleMessage(new GenericMessage<String>("foo"));
    assertEquals(1, adviceCalled);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) MessageHandler(org.springframework.messaging.MessageHandler) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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