@Test public void testRequeueDefaultNot() throws Exception { testRequeueOrNotDefaultNo(new RuntimeException(), false); }
@Test public void testRequeue() throws Exception { Exception ex = new RuntimeException(); testRequeueOrNotDefaultYes(ex, true); }
private void testRequeueOrNotDefaultYes(Exception ex, boolean expectedRequeue) throws Exception { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); Channel channel = mock(Channel.class); BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory, new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeMode.AUTO, true, 1, "testQ"); testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer); }
private void testRequeueOrNotDefaultNo(Exception ex, boolean expectedRequeue) throws Exception { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); Channel channel = mock(Channel.class); BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory, new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeMode.AUTO, true, 1, false, "testQ"); testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer); }
@Test public void testRequeueNullExceptionDefaultNot() throws Exception { testRequeueOrNotDefaultNo(null, false); }
@Test public void testRequeueNullException() throws Exception { testRequeueOrNotDefaultYes(null, true); }
/** * We should always requeue if the exception is a * {@link MessageRejectedWhileStoppingException}. */ @Test public void testDoRequeueStoppingDefaultNot() throws Exception { testRequeueOrNotDefaultNo(new MessageRejectedWhileStoppingException(), true); }
@Test public void testDontRequeue() throws Exception { testRequeueOrNotDefaultYes(new AmqpRejectAndDontRequeueException("fail"), false); }
@Test public void testDontRequeueDefaultNot() throws Exception { testRequeueOrNotDefaultNo(new AmqpRejectAndDontRequeueException("fail"), false); }
@Test public void testDontRequeueNested() throws Exception { Exception ex = new RuntimeException(new RuntimeException(new AmqpRejectAndDontRequeueException("fail"))); testRequeueOrNotDefaultYes(ex, false); }
@Test public void testDontRequeueNestedDefaultNot() throws Exception { Exception ex = new RuntimeException(new RuntimeException(new AmqpRejectAndDontRequeueException("fail"))); testRequeueOrNotDefaultNo(ex, false); }