1
2
3
4
5
6
7 package org.mule.test.integration.routing.nested;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.module.client.MuleClient;
11 import org.mule.tck.junit4.FunctionalTestCase;
12 import org.mule.transport.NullPayload;
13
14 import java.util.Date;
15
16 import org.junit.Test;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21
22 public class ComponentBindingTestCase extends FunctionalTestCase
23 {
24 private static final int number = 0xC0DE;
25
26 @Override
27 protected String getConfigResources()
28 {
29 return "org/mule/test/integration/routing/nested/interface-binding-test.xml";
30 }
31
32 private void internalTest(String prefix) throws Exception
33 {
34 MuleClient client = new MuleClient(muleContext);
35 String message = "Mule";
36 client.dispatch(prefix + "invoker.in", message, null);
37 MuleMessage reply = client.request(prefix + "invoker.out", RECEIVE_TIMEOUT);
38 assertNotNull(reply);
39 assertNull(reply.getExceptionPayload());
40 assertEquals("Received: Hello " + message + " " + number, reply.getPayload());
41 }
42
43 private void internalNullTest(String prefix) throws Exception
44 {
45 MuleClient client = new MuleClient(muleContext);
46 Date message = new Date();
47 client.dispatch(prefix + "invoker.in", message, null);
48 MuleMessage reply = client.request(prefix + "invoker.out", RECEIVE_TIMEOUT);
49 assertNotNull(reply);
50 assertNull(reply.getExceptionPayload());
51 assertEquals(NullPayload.getInstance(), reply.getPayload());
52 }
53
54 @Test
55 public void testVmBinding() throws Exception
56 {
57 internalTest("vm://");
58 }
59
60 @Test
61 public void testJmsQueueBinding() throws Exception
62 {
63 internalTest("jms://");
64 }
65
66 @Test
67 public void testJmsTopicBinding() throws Exception
68 {
69 internalTest("jms://topic:t");
70 }
71
72 @Test
73 public void testVmBindingReturnNull() throws Exception
74 {
75 internalNullTest("vm://");
76 }
77
78 @Test
79 public void testJmsQueueBindingReturnNull() throws Exception
80 {
81 internalNullTest("jms://");
82 }
83
84 @Test
85 public void testJmsTopicBindingReturnNull() throws Exception
86 {
87 internalNullTest("jms://topic:t");
88 }
89 }