1
2
3
4
5
6
7 package org.mule.transport.vm.functional;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.module.client.MuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12 import org.mule.transaction.TransactionCoordination;
13
14 import org.apache.commons.logging.Log;
15 import org.apache.commons.logging.LogFactory;
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertTrue;
20
21 public class VmTransactionTestCase extends FunctionalTestCase
22 {
23 protected static volatile boolean serviceComponentAck = false;
24 protected static final Log logger = LogFactory.getLog(VmTransactionTestCase.class);
25
26 @Override
27 protected String getConfigResources()
28 {
29 return "vm/vm-transaction.xml";
30 }
31
32 @Test
33 public void testDispatch() throws Exception
34 {
35 serviceComponentAck = false;
36 MuleClient client = new MuleClient(muleContext);
37 client.dispatch("vm://dispatchIn", "TEST", null);
38 MuleMessage message = client.request("vm://out", 10000);
39 assertNotNull("Message", message);
40 }
41
42 @Test
43 public void testSend() throws Exception
44 {
45 serviceComponentAck = false;
46 MuleClient client = new MuleClient(muleContext);
47 MuleMessage message = client.send("vm://sendRequestIn", "TEST", null);
48 assertNotNull("Message", message);
49 assertTrue("Service component acknowledgement", serviceComponentAck);
50 }
51
52 public static class TestComponent
53 {
54
55 public Object process(Object message) throws Exception
56 {
57 if (TransactionCoordination.getInstance().getTransaction() != null)
58 {
59 serviceComponentAck = true;
60 }
61 return message;
62 }
63
64 }
65
66 }