1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jms.integration;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.module.client.MuleClient;
15 import org.mule.transport.NullPayload;
16 import org.mule.transport.jms.JmsConstants;
17 import org.mule.util.StringUtils;
18
19 import org.junit.Test;
20
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.assertTrue;
24
25
26
27
28
29 public class JmsSynchronousResponseTestCase extends AbstractJmsFunctionalTestCase
30 {
31
32 @Override
33 protected String getConfigResources()
34 {
35 return "integration/jms-synchronous-response.xml";
36 }
37
38 @Test
39 public void testResponseWithoutReplyTo() throws Exception
40 {
41 MuleClient client = new MuleClient(muleContext);
42
43 MuleMessage response = client.send("out1", "TEST_MESSAGE", null);
44 assertNotNull(response);
45 assertTrue("Response is not a JMS Message", response.getPayload() instanceof javax.jms.Message);
46 assertJmsMessageIdPresent(response);
47 }
48
49 @Test
50 public void testResponseWithoutReplyToEndpointProperties() throws Exception
51 {
52 MuleClient client = new MuleClient(muleContext);
53
54 MuleMessage response = client.send("out2", "TEST_MESSAGE", null);
55 assertNotNull(response);
56 assertTrue("Response is not a JMS Message", response.getPayload() instanceof javax.jms.Message);
57 assertJmsMessageIdPresent(response);
58 }
59
60 @Test
61 public void testResponseWithReplyTo() throws Exception
62 {
63 MuleClient client = new MuleClient(muleContext);
64
65 MuleMessage response = client.send("out3", "TEST_MESSAGE", null);
66 assertNotNull(response);
67 assertFalse("Response should not be NullPayload", response.getPayload() instanceof NullPayload);
68 }
69
70 private void assertJmsMessageIdPresent(MuleMessage message)
71 {
72 String messageId = message.getInboundProperty(JmsConstants.JMS_MESSAGE_ID);
73 assertTrue("JMSMessageID is missing", StringUtils.isNotBlank(messageId));
74 }
75 }