1
2
3
4
5
6
7
8
9
10
11 package org.mule.issues;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleEventContext;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.FunctionalTestCase;
17 import org.mule.tck.functional.EventCallback;
18 import org.mule.tck.functional.FunctionalTestComponent;
19
20 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
21
22 public class MulticastRouterMule2112TestCase extends FunctionalTestCase
23 {
24
25 protected String getConfigResources()
26 {
27 return "issues/multicast-router-mule-2112-test.xml";
28 }
29
30 public void testMulticastRoutingOverTwoEndpoints() throws Exception
31 {
32 Object hop1 = getComponent("hop1");
33 assertTrue("FunctionalTestComponent expected", hop1 instanceof FunctionalTestComponent);
34 Object hop2 = getComponent("hop2");
35 assertTrue("FunctionalTestComponent expected", hop2 instanceof FunctionalTestComponent);
36 assertNotNull(hop1);
37 assertNotNull(hop2);
38
39 final AtomicBoolean hop1made = new AtomicBoolean(false);
40 EventCallback callback1 = new EventCallback()
41 {
42 public void eventReceived(final MuleEventContext context, final Object component) throws Exception
43 {
44 assertTrue(hop1made.compareAndSet(false, true));
45 }
46 };
47
48 final AtomicBoolean hop2made = new AtomicBoolean(false);
49 EventCallback callback2 = new EventCallback()
50 {
51 public void eventReceived(final MuleEventContext context, final Object component) throws Exception
52 {
53 assertTrue(hop2made.compareAndSet(false, true));
54 }
55 };
56
57 ((FunctionalTestComponent) hop1).setEventCallback(callback1);
58 ((FunctionalTestComponent) hop2).setEventCallback(callback2);
59
60 MuleClient client = new MuleClient();
61 DefaultMuleMessage request = new DefaultMuleMessage("payload");
62 client.dispatch("vm://inbound", request);
63 Thread.sleep(1000);
64
65 assertTrue("First callback never fired", hop1made.get());
66 assertTrue("Second callback never fired", hop2made.get());
67 }
68
69 }