View Javadoc

1   /*
2    * $Id: JmsSynchronousResponseTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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  
22  /**
23   * @see EE-1688/MULE-3059
24   */
25  public class JmsSynchronousResponseTestCase extends AbstractJmsFunctionalTestCase
26  {
27      
28      @Override
29      protected String getConfigResources()
30      {
31          return "integration/jms-synchronous-response.xml";
32      }
33  
34      @Test
35      public void testResponseWithoutReplyTo() throws Exception
36      {
37          MuleClient client = new MuleClient(muleContext);
38          
39          MuleMessage response = client.send("out1", "TEST_MESSAGE", null);
40          assertNotNull(response);
41          assertTrue("Response is not a JMS Message", response.getPayload() instanceof javax.jms.Message);
42          assertJmsMessageIdPresent(response);
43      }
44  
45      @Test
46      public void testResponseWithoutReplyToEndpointProperties() throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          
50          MuleMessage response = client.send("out2", "TEST_MESSAGE", null);
51          assertNotNull(response);
52          assertTrue("Response is not a JMS Message", response.getPayload() instanceof javax.jms.Message);
53          assertJmsMessageIdPresent(response);
54      }
55  
56      @Test
57      public void testResponseWithReplyTo() throws Exception
58      {
59          MuleClient client = new MuleClient(muleContext);
60          
61          MuleMessage response = client.send("out3", "TEST_MESSAGE", null);
62          assertNotNull(response);
63          assertTrue("Response should be NullPayload", response.getPayload() instanceof NullPayload);
64      }
65  
66      private void assertJmsMessageIdPresent(MuleMessage message)
67      {
68          String messageId = message.getInboundProperty(JmsConstants.JMS_MESSAGE_ID);
69          assertTrue("JMSMessageID is missing", StringUtils.isNotBlank(messageId));
70      }
71  }