adding JMS Channel history test with full config
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/test/java/org/springframework/integration/jms/config/GlobalChannelInterceptorTests-context.xml</config>
|
||||
<config>src/test/java/org/springframework/integration/jms/config/JmsChannelHistoryTests-context.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
</configSets>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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-jms="http://www.springframework.org/schema/integration/jms"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<int:message-history/>
|
||||
|
||||
<int-jms:channel id="jmsChannel" queue="requestQueue"/>
|
||||
|
||||
<int:bridge input-channel="jmsChannel" output-channel="resultChannel"/>
|
||||
|
||||
<int:channel id="resultChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
|
||||
<constructor-arg value="request.queue."/>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
|
||||
<property name="targetConnectionFactory">
|
||||
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="vm://localhost"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="sessionCacheSize" value="10"/>
|
||||
<property name="cacheProducers" value="false"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -26,7 +26,11 @@ import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.jms.SubscribableJmsChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
@@ -61,4 +65,16 @@ public class JmsChannelHistoryTests {
|
||||
channel.send(message);
|
||||
verify(template, times(1)).convertAndSend(Mockito.any(Message.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFullConfig() throws Exception{
|
||||
ActiveMqTestUtils.prepare();
|
||||
ApplicationContext ac = new ClassPathXmlApplicationContext("JmsChannelHistoryTests-context.xml", this.getClass());
|
||||
SubscribableChannel channel = ac.getBean("jmsChannel", SubscribableChannel.class);
|
||||
PollableChannel resultChannel = ac.getBean("resultChannel", PollableChannel.class);
|
||||
channel.send(new GenericMessage<String>("hello"));
|
||||
Message<?> resultMessage = resultChannel.receive(5000);
|
||||
MessageHistory history = MessageHistory.read(resultMessage);
|
||||
assertTrue(history.get(0).contains("jmsChannel"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,14 +160,11 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport {
|
||||
return "mail:imap-idle-channel-adapter";
|
||||
}
|
||||
|
||||
private void waitToReconnect() {
|
||||
private void waitToReconnect() throws InterruptedException{
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
try {
|
||||
logger.warn("Waiting " + reconnectDelay + " seconds before attemptong to reconnect to host");
|
||||
latch.await(this.reconnectDelay, TimeUnit.SECONDS);
|
||||
reconnecting = true;
|
||||
logger.warn("Will attempt to reconnect to host now");
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
logger.warn("Waiting " + reconnectDelay + " seconds before attemptong to reconnect to host");
|
||||
latch.await(this.reconnectDelay, TimeUnit.SECONDS);
|
||||
reconnecting = true;
|
||||
logger.warn("Will attempt to reconnect to host now");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user