Search in sources :

Example 1 with JdbcOutboundGateway

use of org.springframework.integration.jdbc.JdbcOutboundGateway in project spring-integration by spring-projects.

the class JdbcOutboundGatewayParserTests method testOutboundGatewayInsideChain.

// INT-1029
@Test
public void testOutboundGatewayInsideChain() {
    setUp("handlingMapPayloadJdbcOutboundGatewayTest.xml", getClass());
    String beanName = "org.springframework.integration.handler.MessageHandlerChain#" + "0$child.jdbc-outbound-gateway-within-chain.handler";
    JdbcOutboundGateway jdbcMessageHandler = this.context.getBean(beanName, JdbcOutboundGateway.class);
    MessageChannel channel = this.context.getBean("jdbcOutboundGatewayInsideChain", MessageChannel.class);
    assertFalse(TestUtils.getPropertyValue(jdbcMessageHandler, "requiresReply", Boolean.class));
    channel.send(MessageBuilder.withPayload(Collections.singletonMap("foo", "bar")).build());
    PollableChannel outbound = this.context.getBean("replyChannel", PollableChannel.class);
    Message<?> reply = outbound.receive(10000);
    assertNotNull(reply);
    @SuppressWarnings("unchecked") Map<String, ?> payload = (Map<String, ?>) reply.getPayload();
    assertEquals("bar", payload.get("name"));
}
Also used : JdbcOutboundGateway(org.springframework.integration.jdbc.JdbcOutboundGateway) MessageChannel(org.springframework.messaging.MessageChannel) PollableChannel(org.springframework.messaging.PollableChannel) Map(java.util.Map) Test(org.junit.Test)

Example 2 with JdbcOutboundGateway

use of org.springframework.integration.jdbc.JdbcOutboundGateway in project spring-integration by spring-projects.

the class JdbcOutboundGatewayParserTests method testMapPayloadMapReply.

@Test
public void testMapPayloadMapReply() {
    setUp("handlingMapPayloadJdbcOutboundGatewayTest.xml", getClass());
    assertTrue(this.context.containsBean("jdbcGateway"));
    Message<?> message = MessageBuilder.withPayload(Collections.singletonMap("foo", "bar")).build();
    this.channel.send(message);
    Message<?> reply = this.messagingTemplate.receive();
    assertNotNull(reply);
    @SuppressWarnings("unchecked") Map<String, ?> payload = (Map<String, ?>) reply.getPayload();
    assertEquals("bar", payload.get("name"));
    Map<String, Object> map = this.jdbcTemplate.queryForMap("SELECT * from FOOS");
    assertEquals("Wrong id", message.getHeaders().getId().toString(), map.get("ID"));
    assertEquals("Wrong name", "bar", map.get("name"));
    JdbcOutboundGateway gateway = context.getBean("jdbcGateway.handler", JdbcOutboundGateway.class);
    assertEquals(23, TestUtils.getPropertyValue(gateway, "order"));
    Assert.assertTrue(TestUtils.getPropertyValue(gateway, "requiresReply", Boolean.class));
    assertEquals(1, adviceCalled);
}
Also used : JdbcOutboundGateway(org.springframework.integration.jdbc.JdbcOutboundGateway) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Map (java.util.Map)2 Test (org.junit.Test)2 JdbcOutboundGateway (org.springframework.integration.jdbc.JdbcOutboundGateway)2 MessageChannel (org.springframework.messaging.MessageChannel)1 PollableChannel (org.springframework.messaging.PollableChannel)1