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