INT-1788 added support for 'ID' to JDBC outbound gateway and adapter

This commit is contained in:
Oleg Zhurakousky
2011-02-08 09:18:25 -05:00
parent d43a19221b
commit a69c27b4cf
5 changed files with 10 additions and 3 deletions

View File

@@ -268,6 +268,7 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="id" type="xsd:ID" use="optional"/>
<xsd:attribute name="channel" type="xsd:string" use="required">
<xsd:annotation>
<xsd:appinfo>
@@ -339,6 +340,7 @@
</xsd:element>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" use="optional"/>
<xsd:attribute name="update" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>

View File

@@ -1,5 +1,6 @@
package org.springframework.integration.jdbc.config;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import java.util.Collections;
@@ -50,6 +51,8 @@ public class JdbcMessageHandlerParserTests {
@Test
public void testMapPayloadOutboundChannelAdapter(){
setUp("handlingMapPayloadJdbcOutboundChannelAdapterTest.xml", getClass());
assertTrue(context.containsBean("jdbcAdapter"));
System.out.println(context.getBean("jdbcAdapter").getClass().getName());
Message<?> message = MessageBuilder.withPayload(Collections.singletonMap("foo", "bar")).build();
channel.send(message);
Map<String, Object> map = this.jdbcTemplate.queryForMap("SELECT * from FOOS");

View File

@@ -1,5 +1,6 @@
package org.springframework.integration.jdbc.config;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -35,8 +36,9 @@ public class JdbcOutboundGatewayParserTests {
@Test
public void testMapPayloadMapReply() {
setUp("handlingMapPayloadJdbcOutboundGatewayTest.xml", getClass());
assertTrue(context.containsBean("jdbcGateway"));
Message<?> message = MessageBuilder.withPayload(Collections.singletonMap("foo", "bar")).build();
channel.send(message);
channel.send(message);
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"));

View File

@@ -9,7 +9,7 @@
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
<outbound-channel-adapter query="insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])"
<outbound-channel-adapter id="jdbcAdapter" query="insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])"
channel="target" data-source="dataSource"/>
<beans:import resource="jdbcOutboundChannelAdapterCommonConfig.xml" />

View File

@@ -13,7 +13,7 @@
<si:queue />
</si:channel>
<outbound-gateway query="select * from foos where id=:headers[id]" update="insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])"
<outbound-gateway id="jdbcGateway" query="select * from foos where id=:headers[id]" update="insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])"
request-channel="target" reply-channel="output" data-source="dataSource" />
<beans:import resource="jdbcOutboundChannelAdapterCommonConfig.xml" />