View Javadoc

1   /*
2    * $Id: InboundMessageLossFlowTestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.jms.reliability;
12  
13  import java.util.concurrent.TimeUnit;
14  
15  import static org.junit.Assert.assertFalse;
16  
17  
18  /**
19   * Verify that no inbound messages are lost when exceptions occur.
20   * The message must either make it all the way to the SEDA queue (in the case of
21   * an asynchronous inbound endpoint), or be restored/rolled back at the source.
22   *
23   * In the case of JMS, this will cause the failed message to be redelivered if
24   * JMSRedelivery is configured.
25   */
26  public class InboundMessageLossFlowTestCase extends InboundMessageLossTestCase
27  {
28      @Override
29      protected String getConfigResources()
30      {
31          return "reliability/activemq-config.xml, reliability/inbound-message-loss-flow.xml";
32      }
33  
34      @Override
35      public void testTransformerException() throws Exception
36      {
37          putMessageOnQueue("transformerException");
38  
39          // Exception occurs after the SEDA queue for an asynchronous request, so from the client's
40          // perspective, the message has been delivered successfully.
41          // Note that this behavior is different from services because the exception occurs before
42          // the SEDA queue for services.
43          assertFalse("Message should not have been redelivered",
44              messageRedelivered.await(latchTimeout, TimeUnit.MILLISECONDS));
45      }
46  
47      @Override
48      public void testRouterException() throws Exception
49      {
50          putMessageOnQueue("routerException");
51  
52          // Exception occurs after the SEDA queue for an asynchronous request, so from the client's
53          // perspective, the message has been delivered successfully.
54          // Note that this behavior is different from services because the exception occurs before
55          // the SEDA queue for services.
56          assertFalse("Message should not have been redelivered",
57              messageRedelivered.await(latchTimeout, TimeUnit.MILLISECONDS));
58      }
59  }