/**
* Tests that all containers are subscribed at start-up to the
* correct JMS queues (by sending message to expected subscribed).
* @throws InterruptedException
* @throws JMSException
*/
@Test
@Ignore("This test is broken")
public void testInitAtStartUp() throws InterruptedException, JMSException {
ArrayList<Long> keys = new ArrayList<Long>();
keys.add(0, 1L);
keys.add(1, 2L);
Process mockProcess1 = EasyMock.createMock(Process.class);
Process mockProcess2 = EasyMock.createMock(Process.class);
EasyMock.expect(mockProcessCache.getKeys()).andReturn(keys);
EasyMock.expect(mockProcessCache.get(1L)).andReturn(mockProcess1);
EasyMock.expect(mockProcessCache.get(2L)).andReturn(mockProcess2);
long millis = System.currentTimeMillis();
EasyMock.expect(mockProcess1.getName()).andReturn("Process-1-" + millis).times(2);
EasyMock.expect(mockProcess2.getName()).andReturn("Process-2-" + millis).times(2);
EasyMock.expect(mockProcess1.getId()).andReturn(1L);
EasyMock.expect(mockProcess2.getId()).andReturn(2L);
final CountDownLatch latch = new CountDownLatch(2);
//expect one message from each
mockListener.onMessage(EasyMock.isA(TextMessage.class), EasyMock.isA(Session.class));
EasyMock.expectLastCall().andAnswer(() -> {
latch.countDown();
return null;
});
mockListener.onMessage(EasyMock.isA(TextMessage.class), EasyMock.isA(Session.class));
EasyMock.expectLastCall().andAnswer(() -> {
latch.countDown();
return null;
});
//run test
EasyMock.replay(mockProcessCache);
EasyMock.replay(mockProcess1);
EasyMock.replay(mockProcess2);
EasyMock.replay(mockListener);
//init subscriptions
((JmsContainerManagerImpl) jmsContainerManager).init();
((SmartLifecycle) jmsContainerManager).start();
//check messages are picked up
jmsSender.sendToQueue("test message from process 1", testTrunkName + ".Process-1-" + millis);
jmsSender.sendToQueue("test message from process 2", testTrunkName + ".Process-2-" + millis);
// wait for the listeners to fire
latch.await();
EasyMock.verify(mockProcessCache);
EasyMock.verify(mockProcess1);
EasyMock.verify(mockProcess2);
EasyMock.verify(mockListener);
}
JmsContainerManagerTest.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:c2mon
作者:
评论列表
文章目录