INT-2275: any outbound-channel-adapter in <chain>
Add re-init logic for nested chains Add logic about nested element for AbstractChannelAdapterParser Refactor of DefaultOutboundChannelAdapterParser Test for non-last nested chain with some outbound-channel-adapter Improve XSD for chain-type Manual outbound-channel-adapter ability for chain Integration tests for all outbound-channel-adapter within <chain> Remove redundant 'return-value-required' attribute from <stored-proc-outbound-channel-adapter> Add support 'expectReply' for FileWritingMessageHandler INT-2275 polishing & refactor FileOutbound*Parser HttpRequestExecutingMessageHandlerTests polishing INT-2275: polishing JavaDoc
This commit is contained in:
committed by
Oleg Zhurakousky
parent
4d5b8d5be1
commit
45c429ee2b
@@ -705,17 +705,6 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="return-value-required" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Indicates whether this procedure's return value
|
||||
should be included.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="xsd:boolean xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
@@ -1313,4 +1302,4 @@
|
||||
<xsd:enumeration value="INOUT"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:schema>
|
||||
</xsd:schema>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="DERBY">
|
||||
<jdbc:script location="classpath:derby-stored-procedures.sql"/>
|
||||
</jdbc:embedded-database>
|
||||
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<constructor-arg ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<int:chain input-channel="jdbcStoredProcOutboundChannelAdapterWithinChain">
|
||||
<int-jdbc:stored-proc-outbound-channel-adapter stored-procedure-name="CREATE_USER" data-source="dataSource">
|
||||
<int-jdbc:parameter name="username" expression="payload.username"/>
|
||||
<int-jdbc:parameter name="password" expression="payload.password"/>
|
||||
<int-jdbc:parameter name="email" expression="payload.email"/>
|
||||
</int-jdbc:stored-proc-outbound-channel-adapter>
|
||||
</int:chain>
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.jdbc;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.jdbc.storedproc.User;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @since 2.2
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StoredProcOutboundChannelAdapterWithinChainTests {
|
||||
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private MessageChannel jdbcStoredProcOutboundChannelAdapterWithinChain;
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Message<User> message = MessageBuilder.withPayload(new User("username", "password", "email")).build();
|
||||
this.jdbcStoredProcOutboundChannelAdapterWithinChain.send(message);
|
||||
|
||||
Map<String, Object> map = this.jdbcTemplate.queryForMap("SELECT * FROM USERS WHERE USERNAME=?", "username");
|
||||
|
||||
assertEquals("Wrong username", "username", map.get("USERNAME"));
|
||||
assertEquals("Wrong password", "password", map.get("PASSWORD"));
|
||||
assertEquals("Wrong email", "email", map.get("EMAIL"));
|
||||
// embeddedDatabase can be in working state. So other tests with the same embeddedDatabase beanId, type and init scripts
|
||||
// may be failed with Exception like: object in the DB already exists
|
||||
this.context.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -38,6 +38,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
@@ -115,6 +116,16 @@ public class JdbcMessageHandlerParserTests {
|
||||
assertEquals("Wrong id", "foo", map.get("name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutboundChannelAdapterWithinChain(){
|
||||
setUp("handlingJdbcOutboundChannelAdapterWithinChainTest.xml", getClass());
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setHeader("business.key", "FOO").build();
|
||||
channel.send(message);
|
||||
Map<String, Object> map = this.jdbcTemplate.queryForMap("SELECT * from FOOS");
|
||||
assertEquals("Wrong id", "FOO", map.get("ID"));
|
||||
assertEquals("Wrong id", "foo", map.get("name"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown(){
|
||||
if(context != null){
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc
|
||||
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
|
||||
|
||||
<si:chain input-channel="target">
|
||||
<outbound-channel-adapter
|
||||
query="insert into foos (id, status, name) values (:headers[business.key], 0, :payload)"
|
||||
jdbc-operations="jdbcTemplate"/>
|
||||
</si:chain>
|
||||
|
||||
<beans:import resource="jdbcOutboundChannelAdapterCommonConfig.xml" />
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user