Search in sources :

Example 6 with GatewayProxyFactoryBean

use of org.springframework.integration.gateway.GatewayProxyFactoryBean in project spring-integration by spring-projects.

the class AsyncHandlerTests method testGatewayWithException.

@Test
public void testGatewayWithException() throws Exception {
    this.whichTest = 0;
    GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class);
    gpfb.setBeanFactory(mock(BeanFactory.class));
    DirectChannel input = new DirectChannel();
    gpfb.setDefaultRequestChannel(input);
    gpfb.setDefaultReplyTimeout(10000L);
    gpfb.afterPropertiesSet();
    Foo foo = (Foo) gpfb.getObject();
    this.handler.setOutputChannel(null);
    EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler);
    consumer.afterPropertiesSet();
    consumer.start();
    this.latch.countDown();
    try {
        foo.exchange("foo");
    } catch (MessagingException e) {
        assertThat(e.getClass().getSimpleName(), equalTo("RuntimeException"));
        assertThat(e.getMessage(), equalTo("foo"));
    }
}
Also used : GatewayProxyFactoryBean(org.springframework.integration.gateway.GatewayProxyFactoryBean) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) DirectChannel(org.springframework.integration.channel.DirectChannel) MessagingException(org.springframework.messaging.MessagingException) BeanFactory(org.springframework.beans.factory.BeanFactory) Test(org.junit.Test)

Example 7 with GatewayProxyFactoryBean

use of org.springframework.integration.gateway.GatewayProxyFactoryBean in project spring-integration by spring-projects.

the class AsyncHandlerTests method testGateway.

@Test
public void testGateway() throws Exception {
    this.whichTest = 0;
    GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class);
    gpfb.setBeanFactory(mock(BeanFactory.class));
    DirectChannel input = new DirectChannel();
    gpfb.setDefaultRequestChannel(input);
    gpfb.setDefaultReplyTimeout(10000L);
    gpfb.afterPropertiesSet();
    Foo foo = (Foo) gpfb.getObject();
    this.handler.setOutputChannel(null);
    EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler);
    consumer.afterPropertiesSet();
    consumer.start();
    this.latch.countDown();
    String result = foo.exchange("foo");
    assertEquals("reply", result);
}
Also used : GatewayProxyFactoryBean(org.springframework.integration.gateway.GatewayProxyFactoryBean) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) DirectChannel(org.springframework.integration.channel.DirectChannel) BeanFactory(org.springframework.beans.factory.BeanFactory) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

GatewayProxyFactoryBean (org.springframework.integration.gateway.GatewayProxyFactoryBean)7 Test (org.junit.Test)5 BeanFactory (org.springframework.beans.factory.BeanFactory)3 DirectChannel (org.springframework.integration.channel.DirectChannel)3 Method (java.lang.reflect.Method)2 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)1 AnnotationGatewayProxyFactoryBean (org.springframework.integration.gateway.AnnotationGatewayProxyFactoryBean)1 GatewayMethodMetadata (org.springframework.integration.gateway.GatewayMethodMetadata)1 MessagingGatewaySupport (org.springframework.integration.gateway.MessagingGatewaySupport)1 TestService (org.springframework.integration.gateway.TestService)1 MessageHandlerChain (org.springframework.integration.handler.MessageHandlerChain)1 ServiceActivatingHandler (org.springframework.integration.handler.ServiceActivatingHandler)1 MessagingMethodInvokerHelper (org.springframework.integration.handler.support.MessagingMethodInvokerHelper)1 JsonObjectMapper (org.springframework.integration.support.json.JsonObjectMapper)1 MessageTransformingHandler (org.springframework.integration.transformer.MessageTransformingHandler)1 ObjectToMapTransformer (org.springframework.integration.transformer.ObjectToMapTransformer)1 MessagingException (org.springframework.messaging.MessagingException)1