From 0008dbaeefa1a389bf3ad931ca50424e83f79f19 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 20 Aug 2018 17:35:48 -0400 Subject: [PATCH] JMS Test Polishing * Add `@SuppressWarnings("serial")` for the `RequestMessageHolder` * Use non-caching JMS CF for the Inbound endpoints in the `JmsTests` * Make `AsyncGatewayTests extends ActiveMQMultiContextTests` to keep embedded broker opened in between test methods --- .../springframework/integration/jms/dsl/JmsTests.java | 10 +++++----- .../jms/request_reply/AsyncGatewayTests.java | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java index 67cdfe2dd2..e394ead624 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java @@ -176,7 +176,7 @@ public class JmsTests extends ActiveMQMultiContextTests { JmsTemplate jmsTemplate = TestUtils.getPropertyValue(this.jmsDestinationPollingSource, "jmsTemplate", JmsTemplate.class); - assertEquals(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT, jmsTemplate.getReceiveTimeout()); + assertEquals(1000, jmsTemplate.getReceiveTimeout()); this.jmsOutboundInboundChannel.send(MessageBuilder.withPayload("hello THROUGH the JMS") .setHeader(SimpMessageHeaderAccessor.DESTINATION_HEADER, "jmsInbound") @@ -307,7 +307,7 @@ public class JmsTests extends ActiveMQMultiContextTests { return f -> f .fixedSubscriberChannel("integerChannel") .transform("payload.toString()") - .channel(Jms.pollableChannel("flow1QueueChannel", cachingConnectionFactory()) + .channel(Jms.pollableChannel("flow1QueueChannel", jmsConnectionFactory()) .destination("flow1QueueChannel")); } @@ -327,7 +327,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsInboundFlow() { return IntegrationFlows - .from(Jms.inboundAdapter(cachingConnectionFactory()).destination("jmsInbound")) + .from(Jms.inboundAdapter(jmsConnectionFactory()).destination("jmsInbound")) .transform(String::toUpperCase) .channel(this.jmsOutboundInboundReplyChannel()) .get(); @@ -336,7 +336,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow pubSubFlow() { return IntegrationFlows - .from(Jms.publishSubscribeChannel(cachingConnectionFactory()) + .from(Jms.publishSubscribeChannel(jmsConnectionFactory()) .destination("pubsub")) .channel(c -> c.queue("jmsPubSubBridgeChannel")) .get(); @@ -430,7 +430,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsMessageDrivenRedeliveryFlow() { return IntegrationFlows - .from(Jms.messageDrivenChannelAdapter(cachingConnectionFactory()) + .from(Jms.messageDrivenChannelAdapter(jmsConnectionFactory()) .errorChannel(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME) .destination("jmsMessageDrivenRedelivery") .configureListenerContainer(c -> c diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java index e902343e7e..b48e81bda0 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/AsyncGatewayTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. @@ -34,6 +34,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; +import org.springframework.integration.jms.ActiveMQMultiContextTests; import org.springframework.integration.jms.JmsOutboundGateway; import org.springframework.integration.jms.JmsTimeoutException; import org.springframework.jms.connection.CachingConnectionFactory; @@ -49,13 +50,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Gary Russell + * @author Artem Bilan + * * @since 4.3 * */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @DirtiesContext -public class AsyncGatewayTests { +public class AsyncGatewayTests extends ActiveMQMultiContextTests { @Autowired private CachingConnectionFactory ccf;