Search in sources :

Example 1 with GatewayMethodMetadata

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

the class GatewayParserTests method testOneWayOverride.

@Test
public void testOneWayOverride() {
    TestService service = (TestService) context.getBean("methodOverride");
    service.oneWay("foo");
    PollableChannel channel = (PollableChannel) context.getBean("otherRequestChannel");
    Message<?> result = channel.receive(10000);
    assertNotNull(result);
    assertEquals("fiz", result.getPayload());
    assertEquals("bar", result.getHeaders().get("foo"));
    assertEquals("qux", result.getHeaders().get("baz"));
    GatewayProxyFactoryBean fb = context.getBean("&methodOverride", GatewayProxyFactoryBean.class);
    assertEquals(1000L, TestUtils.getPropertyValue(fb, "defaultRequestTimeout", Expression.class).getValue());
    assertEquals(2000L, TestUtils.getPropertyValue(fb, "defaultReplyTimeout", Expression.class).getValue());
    Map<?, ?> methods = TestUtils.getPropertyValue(fb, "methodMetadataMap", Map.class);
    GatewayMethodMetadata meta = (GatewayMethodMetadata) methods.get("oneWay");
    assertNotNull(meta);
    assertEquals("456", meta.getRequestTimeout());
    assertEquals("123", meta.getReplyTimeout());
    assertEquals("foo", meta.getReplyChannelName());
    meta = (GatewayMethodMetadata) methods.get("oneWayWithTimeouts");
    assertNotNull(meta);
    assertEquals("#args[1]", meta.getRequestTimeout());
    assertEquals("#args[2]", meta.getReplyTimeout());
    service.oneWayWithTimeouts("foo", 100L, 200L);
    result = channel.receive(10000);
    assertNotNull(result);
}
Also used : GatewayProxyFactoryBean(org.springframework.integration.gateway.GatewayProxyFactoryBean) TestService(org.springframework.integration.gateway.TestService) PollableChannel(org.springframework.messaging.PollableChannel) GatewayMethodMetadata(org.springframework.integration.gateway.GatewayMethodMetadata) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 GatewayMethodMetadata (org.springframework.integration.gateway.GatewayMethodMetadata)1 GatewayProxyFactoryBean (org.springframework.integration.gateway.GatewayProxyFactoryBean)1 TestService (org.springframework.integration.gateway.TestService)1 PollableChannel (org.springframework.messaging.PollableChannel)1