1
2
3
4
5
6
7
8
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 }