QueueManager implements CommandLineRunner { @Override public void run(String... arg0) throws Exception { for (final String queue : incomingQueues) { registerIncomingQueue(queue); } for (final String queue : outgoingQueues) { registerOutgoingQueue(queue); } }  @Override void run(String... arg0); List<String> getOutgoingQueues(); @PreDestroy void shutdown(); Map<String, Boolean> getListenerStatus(); void stopListener(String queue); void startListener(String queue);  }
@Test(expected = NameNotFoundException.class) public void lookupIncomingQueueWithWrongNameThrowsException() throws Exception { sut.incomingQueues = Arrays.asList("java:comp/env/wrongName"); sut.run(""); }
@Test public void emptyIncomingQueuesList() throws Exception { sut.incomingQueues = Collections.emptyList(); sut.run(""); testModule.verifyAllQueueSessionsClosed(); }
@Test public void incomingMessageShouldBeAddedToStorage() throws Exception { sut.incomingQueues = Arrays.asList("java:comp/env/q1", "java:comp/env/q2"); sut.run(""); testModule.verifyQueueConnectionStarted(); q1.addMessage(new MockTextMessage("bla")); ArgumentCaptor<SimpleMessage> argument = ArgumentCaptor.forClass(SimpleMessage.class); verify(storage, timeout(5000)).addMessage(argument.capture()); assertEquals("java:comp/env/q1", argument.getValue().getQueue()); assertEquals("bla", argument.getValue().getText()); q2.addMessage(new MockTextMessage("blup")); verify(storage, timeout(5000).times(2)).addMessage(argument.capture()); assertEquals("java:comp/env/q2", argument.getValue().getQueue()); assertEquals("blup", argument.getValue().getText()); }
@Test public void lookupOutgoingQueues() throws Exception { sut.outgoingQueues = Arrays.asList("java:comp/env/q1", "java:comp/env/q1"); sut.run(""); }
@Test(expected = NameNotFoundException.class) public void lookupOutgoingQueuesWithWrongNameThrowsException() throws Exception { sut.outgoingQueues = Arrays.asList("java:comp/env/q1", "java:comp/env/wrong"); sut.run(""); }