Added tests for the "expect-reply" attribute on the <jms-gateway/> element.

This commit is contained in:
Mark Fisher
2008-05-14 15:13:32 +00:00
parent 18d03ae2d7
commit b2b2912b1e
2 changed files with 66 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -76,6 +77,33 @@ public class JmsGatewayParserTests {
context.stop();
}
@Test
public void testGatewayWithDefaultExpectReply() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewaysWithExpectReplyAttributes.xml", this.getClass());
JmsGateway gateway = (JmsGateway) context.getBean("defaultGateway");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(Boolean.FALSE, accessor.getPropertyValue("expectReply"));
}
@Test
public void testGatewayExpectingReply() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewaysWithExpectReplyAttributes.xml", this.getClass());
JmsGateway gateway = (JmsGateway) context.getBean("gatewayExpectingReply");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(Boolean.TRUE, accessor.getPropertyValue("expectReply"));
}
@Test
public void testGatewayNotExpectingReply() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewaysWithExpectReplyAttributes.xml", this.getClass());
JmsGateway gateway = (JmsGateway) context.getBean("gatewayNotExpectingReply");
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
assertEquals(Boolean.FALSE, accessor.getPropertyValue("expectReply"));
}
@Test(expected=BeanDefinitionStoreException.class)
public void testGatewayWithConnectionFactoryOnly() {
try {

View File

@@ -0,0 +1,38 @@
<?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:si="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
<si:message-bus/>
<si:channel id="requestChannel"/>
<si:jms-gateway id="defaultGateway"
destination="testDestination"
request-channel="requestChannel"/>
<si:jms-gateway id="gatewayNotExpectingReply"
destination="testDestination"
request-channel="requestChannel"
expect-reply="false"/>
<si:jms-gateway id="gatewayExpectingReply"
destination="testDestination"
request-channel="requestChannel"
expect-reply="true"/>
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
<constructor-arg>
<bean class="org.springframework.integration.adapter.jms.StubConnection">
<constructor-arg value="test-message"/>
</bean>
</constructor-arg>
</bean>
<bean id="testDestination" class="org.springframework.integration.adapter.jms.StubDestination"/>
</beans>