View Javadoc

1   /*
2    * $Id: LaxAsyncInterceptingMessageProcessorTestCase.java 22597 2011-08-05 20:40:24Z 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 LaxAsyncInterceptingMessageProcessorTestCase extends AsyncInterceptingMessageProcessorTestCase
23  {
24      @Test
25      public void testProcessOneWay() throws Exception
26      {
27          MuleEvent event = getTestEvent(TEST_MESSAGE, getTestInboundEndpoint(MessageExchangePattern.ONE_WAY));
28  
29          assertAsync(messageProcessor, event);
30      }
31  
32      @Test
33      public void testProcessRequestResponse() throws Exception
34      {
35          MuleEvent event = getTestEvent(TEST_MESSAGE,
36              getTestInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE));
37  
38          assertSync(messageProcessor, event);
39      }
40  
41      @Test
42      public void testProcessOneWayWithTx() throws Exception
43      {
44          MuleEvent event = getTestEvent(TEST_MESSAGE,
45              getTestTransactedInboundEndpoint(MessageExchangePattern.ONE_WAY));
46          Transaction transaction = new TestTransaction(muleContext);
47          TransactionCoordination.getInstance().bindTransaction(transaction);
48  
49          try
50          {
51              assertSync(messageProcessor, event);
52          }
53          finally
54          {
55              TransactionCoordination.getInstance().unbindTransaction(transaction);
56          }
57      }
58  
59      @Test
60      public void testProcessRequestResponseWithTx() throws Exception
61      {
62          MuleEvent event = getTestEvent(TEST_MESSAGE,
63              getTestTransactedInboundEndpoint(MessageExchangePattern.REQUEST_RESPONSE));
64          Transaction transaction = new TestTransaction(muleContext);
65          TransactionCoordination.getInstance().bindTransaction(transaction);
66  
67          try
68          {
69              assertSync(messageProcessor, event);
70          }
71          finally
72          {
73              TransactionCoordination.getInstance().unbindTransaction(transaction);
74          }
75      }
76  
77      protected AsyncInterceptingMessageProcessor createAsyncInterceptingMessageProcessor(MessageProcessor listener)
78          throws Exception
79      {
80          LaxAsyncInterceptingMessageProcessor mp = new LaxAsyncInterceptingMessageProcessor(
81              new TestWorkManagerSource());
82          mp.setListener(listener);
83          return mp;
84      }
85  
86  }