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