INT-1029: Support for outbound-gateways in chain
XSD refactoring: remove use="required" from 'request-channel' attribute of all 'outbound-gateways' Tests for all 'outbound-gateways' inside the <chain>
This commit is contained in:
committed by
Oleg Zhurakousky
parent
c3860e14b7
commit
5bc41bc60b
@@ -28,16 +28,21 @@
|
||||
<int:method name="getAllStudents" request-channel="getAllStudentsChannel" />
|
||||
<int:method name="persistStudent" request-channel="persistStudentChannel" />
|
||||
<int:method name="persistStudentUsingMerge" request-channel="persistStudentUsingMergeChannel" />
|
||||
<int:method name="getStudent2" request-channel="retrievingGatewayInsideChain" />
|
||||
<int:method name="persistStudent2" request-channel="updatingGatewayInsideChain" />
|
||||
</int:gateway>
|
||||
|
||||
<int:channel id="studentReplyChannel"/>
|
||||
|
||||
<int:channel id="deleteStudentChannel"/>
|
||||
<int:channel id="getStudentChannel"/>
|
||||
<int:channel id="getStudentWithParametersChannel"/>
|
||||
<int:channel id="getAllStudentsChannel"/>
|
||||
<int:channel id="persistStudentChannel"/>
|
||||
<int:channel id="persistStudentUsingMergeChannel"/>
|
||||
<int:channel id="studentReplyChannel"/>
|
||||
<int:channel id="getStudentEndpointWithExceptionChannel"/>
|
||||
<int:channel id="retrievingGatewayInsideChain"/>
|
||||
<int:channel id="updatingGatewayInsideChain"/>
|
||||
|
||||
<bean id="deleteStudentEndpoint"
|
||||
class="org.springframework.integration.endpoint.EventDrivenConsumer">
|
||||
@@ -192,4 +197,21 @@
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<int:chain input-channel="retrievingGatewayInsideChain" output-channel="studentReplyChannel">
|
||||
<jpa:retrieving-outbound-gateway entity-manager="entityManager"
|
||||
expect-single-result="true"
|
||||
entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
|
||||
jpa-query="from Student s where s.id = :id">
|
||||
<jpa:parameter name="id" expression="payload"/>
|
||||
</jpa:retrieving-outbound-gateway>
|
||||
</int:chain>
|
||||
|
||||
<int:chain input-channel="updatingGatewayInsideChain" output-channel="studentReplyChannel">
|
||||
<!--TODO JPA outbound-gateway must have 'id' inside the chain because
|
||||
'org.springframework.integration.jpa.outbound.JpaOutboundGatewayFactoryBean#0' isn't registered as bean-->
|
||||
<jpa:updating-outbound-gateway id="gatewayInsideChain" entity-manager="entityManager"
|
||||
entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"/>
|
||||
</int:chain>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -16,12 +16,14 @@ import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.jpa.test.JpaTestUtils;
|
||||
import org.springframework.integration.jpa.test.entity.StudentDomain;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -31,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
/**
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
* @since 2.2
|
||||
*
|
||||
*/
|
||||
@@ -42,15 +45,22 @@ public class JpaOutboundGatewayTests {
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
|
||||
@Autowired
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
this.jdbcTemplate.execute("delete from Student where rollNumber > 1003");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void getStudent() {
|
||||
final StudentDomain student = studentService.getStudent(1001L);
|
||||
Assert.assertNotNull(student);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
@Transactional
|
||||
public void deleteNonExistingStudent() {
|
||||
|
||||
@@ -67,7 +77,6 @@ public class JpaOutboundGatewayTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void getStudentWithException() {
|
||||
try {
|
||||
studentService.getStudentWithException(1001L);
|
||||
@@ -82,7 +91,6 @@ public class JpaOutboundGatewayTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void getStudentStudentWithPositionalParameters() {
|
||||
|
||||
StudentDomain student = studentService.getStudentWithParameters("First Two");
|
||||
@@ -92,7 +100,6 @@ public class JpaOutboundGatewayTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
public void getAllStudents() {
|
||||
|
||||
final List<StudentDomain> students = studentService.getAllStudents();
|
||||
@@ -102,7 +109,6 @@ public class JpaOutboundGatewayTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
@Transactional
|
||||
public void persistStudent() {
|
||||
|
||||
@@ -116,7 +122,6 @@ public class JpaOutboundGatewayTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
@Transactional
|
||||
public void persistStudentUsingMerge() {
|
||||
|
||||
@@ -129,4 +134,23 @@ public class JpaOutboundGatewayTests {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetrievingGatewayInsideChain() {
|
||||
final StudentDomain student = studentService.getStudent2(1001L);
|
||||
Assert.assertNotNull(student);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void testUpdatingGatewayInsideChain() {
|
||||
|
||||
final StudentDomain studentToPersist = JpaTestUtils.getTestStudent();
|
||||
Assert.assertNull(studentToPersist.getRollNumber());
|
||||
|
||||
final StudentDomain persistedStudent = studentService.persistStudent2(studentToPersist);
|
||||
Assert.assertNotNull(persistedStudent);
|
||||
Assert.assertNotNull(persistedStudent.getRollNumber());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,7 @@ public interface StudentService {
|
||||
|
||||
StudentDomain getStudentWithParameters(String firstName);
|
||||
|
||||
StudentDomain getStudent2(Long id);
|
||||
|
||||
StudentDomain persistStudent2(StudentDomain studentToPersist);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user