Increase timeouts for JMS tests

The `ExtractRequestReplyPayloadTests` uses `3000` for `reply-timeout`.
This value might not be enough on high-loaded environment such a CI Server:
https://build.spring.io/browse/INT-B41-450

* Increase the timeouts for adapters to the `10000` to have more chances to pass on the CI.
* Some simple code polishing for the `ExtractRequestReplyPayloadTests`
This commit is contained in:
Artem Bilan
2015-10-21 16:11:04 -04:00
parent 152f46719a
commit 8637f86d74
2 changed files with 43 additions and 46 deletions

View File

@@ -1,39 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
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/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:task="http://www.springframework.org/schema/task">
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
<int:channel id="outboundChannel"/>
<int:channel id="replyChannel">
<int:queue/>
</int:channel>
<int-jms:outbound-gateway id="outboundGateway"
request-channel="outboundChannel"
request-destination="extractRecRepQueue"
reply-channel="replyChannel"
receive-timeout="3000"
reply-timeout="3000"/>
<int-jms:inbound-gateway id="inboundGateway"
request-destination="extractRecRepQueue"
request-channel="jmsInputChannel"
request-timeout="3000"
reply-timeout="3000"/>
request-channel="outboundChannel"
request-destination="extractRecRepQueue"
reply-channel="replyChannel"
receive-timeout="10000"
reply-timeout="10000"/>
<int-jms:inbound-gateway id="inboundGateway"
request-destination="extractRecRepQueue"
request-channel="jmsInputChannel"
request-timeout="10000"
reply-timeout="10000"/>
<int:channel id="jmsInputChannel"/>
<bean id="extractRecRepQueue" class="org.apache.activemq.command.ActiveMQQueue">
<bean id="extractRecRepQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="request.queue.req.rep"/>
</bean>
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">

View File

@@ -10,6 +10,7 @@
* 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.jms.config;
import static org.hamcrest.Matchers.instanceOf;
@@ -48,17 +49,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author ozhurakousky
* @author Gunnar Hillert
* @author Gary Russell
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public class ExtractRequestReplyPayloadTests {
@Rule
public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration",
"org.springframework.jms");
@Rule
public TestName testName = new TestName();
@@ -81,7 +77,7 @@ public class ExtractRequestReplyPayloadTests {
ChannelPublishingJmsMessageListener inboundGateway;
@Test
public void testOutboundInboundDefault(){
public void testOutboundInboundDefault() {
this.outboundGateway.setExtractRequestPayload(true);
this.outboundGateway.setExtractReplyPayload(true);
@@ -98,7 +94,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundInboundDefaultIsTx(){
public void testOutboundInboundDefaultIsTx() {
this.outboundGateway.setExtractRequestPayload(true);
this.outboundGateway.setExtractReplyPayload(true);
@@ -107,6 +103,7 @@ public class ExtractRequestReplyPayloadTests {
final AtomicBoolean failOnce = new AtomicBoolean();
MessageHandler handler = new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
assertTrue(message.getPayload() instanceof String);
@@ -117,6 +114,7 @@ public class ExtractRequestReplyPayloadTests {
template.setDefaultDestination((MessageChannel) message.getHeaders().getReplyChannel());
template.send(message);
}
};
this.jmsInputChannel.subscribe(handler);
this.outboundChannel.send(new GenericMessage<String>("Hello " + this.testName.getMethodName()));
@@ -127,7 +125,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundBothFalseInboundDefault(){
public void testOutboundBothFalseInboundDefault() {
this.outboundGateway.setExtractRequestPayload(false);
this.outboundGateway.setExtractReplyPayload(false);
@@ -144,7 +142,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundDefaultInboundBothFalse() throws Exception{
public void testOutboundDefaultInboundBothFalse() throws Exception {
this.outboundGateway.setExtractRequestPayload(true);
this.outboundGateway.setExtractReplyPayload(true);
@@ -160,7 +158,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundDefaultInboundReplyTrueRequestFalse(){
public void testOutboundDefaultInboundReplyTrueRequestFalse() {
this.outboundGateway.setExtractRequestPayload(true);
this.outboundGateway.setExtractReplyPayload(true);
@@ -176,7 +174,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundDefaultInboundReplyFalseRequestTrue(){
public void testOutboundDefaultInboundReplyFalseRequestTrue() {
this.outboundGateway.setExtractRequestPayload(true);
this.outboundGateway.setExtractReplyPayload(true);
@@ -192,7 +190,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundRequestTrueReplyFalseInboundDefault(){
public void testOutboundRequestTrueReplyFalseInboundDefault() {
this.outboundGateway.setExtractRequestPayload(true);
this.outboundGateway.setExtractReplyPayload(false);
@@ -208,7 +206,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testOutboundRequestFalseReplyTrueInboundDefault(){
public void testOutboundRequestFalseReplyTrueInboundDefault() {
this.outboundGateway.setExtractRequestPayload(false);
this.outboundGateway.setExtractReplyPayload(true);
@@ -224,7 +222,7 @@ public class ExtractRequestReplyPayloadTests {
}
@Test
public void testAllFalse() throws Exception{
public void testAllFalse() throws Exception {
this.outboundGateway.setExtractRequestPayload(false);
this.outboundGateway.setExtractReplyPayload(false);
@@ -240,7 +238,8 @@ public class ExtractRequestReplyPayloadTests {
}
private MessageHandler echoInboundStringHandler() {
MessageHandler handler = new MessageHandler() {
return new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
assertTrue(message.getPayload() instanceof String);
@@ -248,12 +247,13 @@ public class ExtractRequestReplyPayloadTests {
template.setDefaultDestination((MessageChannel) message.getHeaders().getReplyChannel());
template.send(message);
}
};
return handler;
}
private MessageHandler unwrapObjectMessageAndEchoHandler() {
MessageHandler handler = new MessageHandler() {
return new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
assertThat(message.getPayload(), instanceOf(javax.jms.ObjectMessage.class));
@@ -268,12 +268,13 @@ public class ExtractRequestReplyPayloadTests {
}
template.send(origMessage);
}
};
return handler;
}
private MessageHandler unwrapTextMessageAndEchoHandler() {
MessageHandler handler = new MessageHandler() {
return new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
assertThat(message.getPayload(), instanceOf(javax.jms.TextMessage.class));
@@ -288,8 +289,8 @@ public class ExtractRequestReplyPayloadTests {
}
template.send(new GenericMessage<String>(payload));
}
};
return handler;
}
}