Search in sources :

Example 6 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method jmsUri.

@Test
@SuppressWarnings("unchecked")
public void jmsUri() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithJmsUri", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
    assertNull(TestUtils.getPropertyValue(handler, "destinationProvider"));
    assertFalse(TestUtils.getPropertyValue(handler, "encodeUri", Boolean.class));
    WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(handler, "webServiceTemplate", WebServiceTemplate.class);
    webServiceTemplate = spy(webServiceTemplate);
    doReturn(null).when(webServiceTemplate).sendAndReceive(anyString(), any(WebServiceMessageCallback.class), ArgumentMatchers.<WebServiceMessageExtractor<Object>>any());
    new DirectFieldAccessor(handler).setPropertyValue("webServiceTemplate", webServiceTemplate);
    handler.handleMessage(new GenericMessage<String>("foo"));
    verify(webServiceTemplate).sendAndReceive(eq("jms:wsQueue"), any(WebServiceMessageCallback.class), ArgumentMatchers.<WebServiceMessageExtractor<Object>>any());
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) WebServiceMessageCallback(org.springframework.ws.client.core.WebServiceMessageCallback) MessageHandler(org.springframework.messaging.MessageHandler) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) Test(org.junit.Test)

Example 7 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithStartupFalse.

@Test
public void simpleGatewayWithStartupFalse() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithOrderAndAutoStartupFalse", AbstractEndpoint.class);
    assertEquals(Boolean.FALSE, new DirectFieldAccessor(endpoint).getPropertyValue("autoStartup"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 8 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithPoller.

@Test
public void simpleGatewayWithPoller() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithPoller", AbstractEndpoint.class);
    assertEquals(PollingConsumer.class, endpoint.getClass());
    Object triggerObject = new DirectFieldAccessor(endpoint).getPropertyValue("trigger");
    assertEquals(PeriodicTrigger.class, triggerObject.getClass());
    PeriodicTrigger trigger = (PeriodicTrigger) triggerObject;
    DirectFieldAccessor accessor = new DirectFieldAccessor(trigger);
    assertEquals("PeriodicTrigger had wrong period", 5000, ((Long) accessor.getPropertyValue("period")).longValue());
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) PeriodicTrigger(org.springframework.scheduling.support.PeriodicTrigger) Test(org.junit.Test)

Example 9 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomMessageSender.

@Test
public void simpleGatewayWithCustomMessageSender() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomMessageSender", 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]);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) WebServiceMessageSender(org.springframework.ws.transport.WebServiceMessageSender) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 10 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithReplyChannel.

@Test
public void simpleGatewayWithReplyChannel() {
    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);
    Object expected = this.context.getBean("outputChannel");
    assertEquals(expected, accessor.getPropertyValue("outputChannel"));
    Assert.assertEquals(Boolean.FALSE, accessor.getPropertyValue("requiresReply"));
    AbstractHeaderMapper.HeaderMatcher requestHeaderMatcher = TestUtils.getPropertyValue(endpoint, "handler.headerMapper.requestHeaderMatcher", AbstractHeaderMapper.HeaderMatcher.class);
    assertTrue(requestHeaderMatcher.matchHeader("testRequest"));
    assertFalse(requestHeaderMatcher.matchHeader("testReply"));
    AbstractHeaderMapper.HeaderMatcher replyHeaderMatcher = TestUtils.getPropertyValue(endpoint, "handler.headerMapper.replyHeaderMatcher", AbstractHeaderMapper.HeaderMatcher.class);
    assertFalse(replyHeaderMatcher.matchHeader("testRequest"));
    assertTrue(replyHeaderMatcher.matchHeader("testReply"));
    Long sendTimeout = TestUtils.getPropertyValue(gateway, "messagingTemplate.sendTimeout", Long.class);
    assertEquals(Long.valueOf(777), sendTimeout);
    assertSame(this.context.getBean("webServiceTemplate"), TestUtils.getPropertyValue(gateway, "webServiceTemplate"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) AbstractHeaderMapper(org.springframework.integration.mapping.AbstractHeaderMapper) 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