View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.jms;
8   
9   import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
10  import org.junit.Test;
11  
12  import static org.junit.Assert.assertEquals;
13  import static org.junit.Assert.assertTrue;
14  
15  public class JmsRedeliveryTestCase extends AbstractJmsRedeliveryTestCase
16  {
17  
18      private static final int MAX_REDELIVERY = 3;
19  
20      public JmsRedeliveryTestCase(ConfigVariant variant, String configResources)
21      {
22          super(variant, configResources);
23      }
24  
25      @Override
26      protected int getMaxRedelivery()
27      {
28          return MAX_REDELIVERY;
29      }
30  
31      @Test
32      public void testRedelivery() throws Exception
33      {
34          client.dispatch(JMS_INPUT_QUEUE, TEST_MESSAGE, null);
35  
36          assertTrue(messageRedeliveryExceptionFired.await(timeout, TimeUnit.MILLISECONDS));
37          assertEquals("MessageRedeliveredException never fired.", 0, messageRedeliveryExceptionFired.getCount());
38          assertEquals("Wrong number of delivery attempts", MAX_REDELIVERY + 1, callback.getCallbackCount());
39  
40          assertMessageInDlq();
41      }
42  }