container.stop();
}
@Test
public void testSimpleMessageListenerContainerStoppedWithoutWarn() throws Exception {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setHost("localhost");
connectionFactory.setPort(BrokerTestUtils.getPort());
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
Log log = spy(TestUtils.getPropertyValue(container, "logger", Log.class));
final CountDownLatch latch = new CountDownLatch(1);
when(log.isDebugEnabled()).thenReturn(true);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
latch.countDown();
invocation.callRealMethod();
return null;
}
}).when(log).debug(
Mockito.contains("Consumer received Shutdown Signal, processing stopped"));
DirectFieldAccessor dfa = new DirectFieldAccessor(container);
dfa.setPropertyValue("logger", log);
container.setQueues(queue);
container.setMessageListener(new MessageListenerAdapter());
container.afterPropertiesSet();
container.start();
try {
connectionFactory.destroy();
assertTrue(latch.await(10, TimeUnit.SECONDS));
Mockito.verify(log).debug(
Mockito.contains("Consumer received Shutdown Signal, processing stopped"));
Mockito.verify(log, Mockito.never()).warn(Mockito.anyString(), Mockito.any(Throwable.class));