1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.routing.nested;
12
13 import org.junit.Test;
14 import org.junit.runners.Parameterized;
15 import org.mule.api.MuleMessage;
16 import org.mule.module.client.MuleClient;
17 import org.mule.tck.AbstractServiceAndFlowTestCase;
18
19 import java.util.Arrays;
20 import java.util.Collection;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertNull;
25
26 public class ComponentBindingTestCase extends AbstractServiceAndFlowTestCase
27 {
28 private static final int number = 0xC0DE;
29
30
31 public ComponentBindingTestCase(AbstractServiceAndFlowTestCase.ConfigVariant variant, String configResources)
32 {
33 super(variant, configResources);
34 }
35
36 @Parameterized.Parameters
37 public static Collection<Object[]> parameters()
38 {
39 return Arrays.asList(new Object[][]{
40 {AbstractServiceAndFlowTestCase.ConfigVariant.SERVICE, "org/mule/test/integration/routing/nested/interface-binding-test.xml"},
41 {AbstractServiceAndFlowTestCase.ConfigVariant.FLOW, "org/mule/test/integration/routing/nested/interface-binding-test-flow.xml"}
42 });
43 }
44
45 @Test
46 public void testVmBinding() throws Exception
47 {
48 internalTest("vm://");
49 }
50
51 @Test
52 public void testJmsQueueBinding() throws Exception
53 {
54 internalTest("jms://");
55 }
56
57 @Test
58 public void testJmsTopicBinding() throws Exception
59 {
60 internalTest("jms://topic:t");
61 }
62
63 private void internalTest(String prefix) throws Exception
64 {
65 MuleClient client = new MuleClient(muleContext);
66 String message = "Mule";
67 client.dispatch(prefix + "invoker.in", message, null);
68 MuleMessage reply = client.request(prefix + "invoker.out", RECEIVE_TIMEOUT);
69 assertNotNull(reply);
70 assertNull(reply.getExceptionPayload());
71 assertEquals("Received: Hello " + message + " " + number, reply.getPayload());
72 }
73 }