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 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 }