View Javadoc

1   /*
2    * $Id: LaxSedaStageInterceptingMessageProcessorTestCase.java 22864 2011-09-05 17:18:46Z dfeist $
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.processor;
12  
13  import org.mule.MessageExchangePattern;
14  import org.mule.api.MuleEvent;
15  import org.mule.api.processor.MessageProcessor;
16  import org.mule.api.transaction.Transaction;
17  import org.mule.tck.testmodels.mule.TestTransaction;
18  import org.mule.transaction.TransactionCoordination;
19  
20  import org.junit.Test;
21  
22  public class LaxSedaStageInterceptingMessageProcessorTestCase extends
23      SedaStageInterceptingMessageProcessorTestCase
24  {
25  
26      @Test
27      public void testProcessOneWay() throws Exception
28      {
29          MuleEvent event = getTestEvent(TEST_MESSAGE, getTestInboundEndpoint(MessageExchangePattern.ONE_WAY));
30  
31          assertAsync(messageProcessor, event);
32      }
33  
34      @Test
35      public void testProcessRequestResponse() throws Exception
36      {
37          MuleEvent event = getTestEvent(TEST_MESSAGE,
38              getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE));
39  
40          assertSync(messageProcessor, event);
41      }
42  
43      @Test
44      public void testProcessOneWayWithTx() throws Exception
45      {
46          MuleEvent event = getTestEvent(TEST_MESSAGE,
47              getTestTransactedInboundEndpoint(MessageExchangePattern.ONE_WAY));
48          Transaction transaction = new TestTransaction(muleContext);
49          TransactionCoordination.getInstance().bindTransaction(transaction);
50  
51          try
52          {
53              assertSync(messageProcessor, event);
54          }
55          finally
56          {
57              TransactionCoordination.getInstance().unbindTransaction(transaction);
58          }
59      }
60  
61      @Test
62      public void testProcessRequestResponseWithTx() throws Exception
63      {
64          MuleEvent event = getTestEvent(TEST_MESSAGE,
65              getTestTransactedInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE));
66          Transaction transaction = new TestTransaction(muleContext);
67          TransactionCoordination.getInstance().bindTransaction(transaction);
68  
69          try
70          {
71              assertSync(messageProcessor, event);
72          }
73          finally
74          {
75              TransactionCoordination.getInstance().unbindTransaction(transaction);
76          }
77      }
78  
79      @Override
80      protected AsyncInterceptingMessageProcessor createAsyncInterceptingMessageProcessor(MessageProcessor listener)
81          throws Exception
82      {
83          LaxSedaStageInterceptingMessageProcessor mp = new LaxSedaStageInterceptingMessageProcessor("name",
84              "name", queueProfile, queueTimeout, muleContext.getDefaultThreadingProfile(), queueStatistics,
85              muleContext);
86          mp.setListener(listener);
87          return mp;
88      }
89  
90  }