1
2
3
4
5
6
7
8
9
10 package org.mule.test.integration.providers.jms.functional;
11
12 import org.mule.MuleManager;
13 import org.mule.extras.client.MuleClient;
14 import org.mule.tck.functional.EventCallback;
15 import org.mule.tck.functional.FunctionalTestComponent;
16 import org.mule.transaction.TransactionCoordination;
17 import org.mule.umo.UMOEventContext;
18 import org.mule.umo.UMOMessage;
19 import org.mule.umo.UMOTransaction;
20
21
22
23
24 public class JmsXATransactionComponentTestCase extends AbstractJmsFunctionalTestCase
25 {
26 public static final String MODEL_NAME = "TEST";
27 public static final String COMPONENT_NAME = "Part";
28
29
30
31 private UMOTransaction umoTransaction = null;
32
33 protected String getConfigResources()
34 {
35 return "providers/activemq/jms-xa-tx-component.xml";
36 }
37
38 public void testOneGlobalTx() throws Exception
39 {
40 EventCallback callback = new EventCallback()
41 {
42 public void eventReceived(UMOEventContext context, Object component) throws Exception
43 {
44 if (umoTransaction == null)
45 {
46 umoTransaction = TransactionCoordination.getInstance().getTransaction();
47 }
48 else
49 {
50 logger.error("Transactiuon: " + TransactionCoordination.getInstance().getTransaction());
51 assertTrue(TransactionCoordination.getInstance().getTransaction().equals(umoTransaction));
52 }
53 }
54 };
55
56 for (int i = 1; i < 5; i++)
57 {
58 ((FunctionalTestComponent) MuleManager.getInstance().lookupModel(MODEL_NAME).getComponent(COMPONENT_NAME + i).getDescriptor().getImplementation()).
59 setEventCallback(callback);
60 }
61
62 MuleClient client = new MuleClient();
63 client.dispatch("vm://in", DEFAULT_INPUT_MESSAGE, null);
64 UMOMessage result = client.receive("vm://out", TIMEOUT);
65 assertNotNull(result);
66 client.dispose();
67 }
68
69 }