1
2
3
4
5
6
7 package org.mule.transport.jms.integration;
8
9 import org.mule.api.MuleMessage;
10 import org.mule.module.client.MuleClient;
11
12 import org.junit.Test;
13
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertNull;
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 public class JmsConnectorJndiTestCase extends AbstractJmsFunctionalTestCase
36 {
37
38 @Override
39 protected String getConfigResources()
40 {
41 return "integration/jms-jndi-config.xml";
42 }
43
44 @Test
45 public void testConnectionFactoryFromJndi() throws Exception
46 {
47
48
49 }
50
51 @Test
52 public void testQueueFromJndi() throws Exception
53 {
54 MuleClient client = new MuleClient(muleContext);
55
56 client.dispatch("ep_jndi-queue", DEFAULT_INPUT_MESSAGE, null);
57
58 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
59 assertNotNull(result);
60 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
61 }
62
63 @Test
64 public void testTopicFromJndi() throws Exception
65 {
66 MuleClient client = new MuleClient(muleContext);
67
68 client.dispatch("ep_jndi-topic", DEFAULT_INPUT_MESSAGE, null);
69
70 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
71 assertNotNull(result);
72 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
73 }
74
75
76
77
78 @Test
79 public void testNonJndiDestination() throws Exception
80 {
81 MuleClient client = new MuleClient(muleContext);
82
83 client.dispatch("ep_non-jndi-queue", DEFAULT_INPUT_MESSAGE, null);
84
85 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
86 assertNotNull(result);
87 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
88 }
89
90
91
92
93 @Test
94 public void testNonJndiDestinationOptional() throws Exception
95 {
96 MuleClient client = new MuleClient(muleContext);
97
98 client.dispatch("ep_non-jndi-queue-optional-jndi", DEFAULT_INPUT_MESSAGE, null);
99
100 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
101 assertNotNull(result);
102 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
103 }
104
105
106
107
108 @Test
109 public void testNonJndiDestinationForce() throws Exception
110 {
111 MuleClient client = new MuleClient(muleContext);
112
113 client.dispatch("ep_non-jndi-queue-force-jndi", DEFAULT_INPUT_MESSAGE, null);
114
115 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
116 assertNull("Attempt to look up a non-existant JNDI Destination should have failed", result);
117 }
118
119 @Test
120 public void testQueueFromJndiWithJndiNameResolver() throws Exception
121 {
122 MuleClient client = new MuleClient(muleContext);
123
124 client.dispatch("ep_jndi-queue-with-jndi-name-resolver", DEFAULT_INPUT_MESSAGE, null);
125
126 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
127 assertNotNull(result);
128 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
129 }
130
131 @Test
132 public void testTopicFromJndiWithJndiNameResolver() throws Exception
133 {
134 MuleClient client = new MuleClient(muleContext);
135
136 client.dispatch("ep_jndi-topic-with-jndi-name-resolver", DEFAULT_INPUT_MESSAGE, null);
137
138 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
139 assertNotNull(result);
140 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
141 }
142
143
144
145
146 @Test
147 public void testNonJndiDestinationWithJndiNameResolver() throws Exception
148 {
149 MuleClient client = new MuleClient(muleContext);
150
151 client.dispatch("ep_non-jndi-queue-with-jndi-name-resolver", DEFAULT_INPUT_MESSAGE, null);
152
153 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
154 assertNotNull(result);
155 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
156 }
157
158
159
160
161 @Test
162 public void testNonJndiDestinationOptionalWithJndiNameResolver() throws Exception
163 {
164 MuleClient client = new MuleClient(muleContext);
165
166 client.dispatch("ep_non-jndi-queue-optional-jndi-with-jndi-name-resolver", DEFAULT_INPUT_MESSAGE, null);
167
168 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
169 assertNotNull(result);
170 assertEquals(DEFAULT_INPUT_MESSAGE, result.getPayloadAsString());
171 }
172
173
174
175
176 @Test
177 public void testNonJndiDestinationForceWithJndiNameResolver() throws Exception
178 {
179 MuleClient client = new MuleClient(muleContext);
180
181 client.dispatch("ep_non-jndi-queue-force-jndi-with-jndi-name-resolver", DEFAULT_INPUT_MESSAGE, null);
182
183 MuleMessage result = client.request("vm://out", RECEIVE_TIMEOUT);
184 assertNull("Attempt to look up a non-existant JNDI Destination should have failed", result);
185 }
186 }