View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.jms.integration;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.transport.NullPayload;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  
18  /**
19   * TODO this test does not use the Test scenarios, I think it would need a new Method
20   * sendAndReceive It might make sense to leave this test as is because it tests that
21   * the client also works with ReplyTo correctly
22   */
23  public class JmsTemporaryReplyToTestCase extends AbstractJmsFunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "integration/jms-temporary-replyTo.xml";
30      }
31  
32      @Test
33      public void testTemporaryReplyEnabledAsync() throws MuleException
34      {
35          MuleClient muleClient = new MuleClient(muleContext);
36          MuleMessage response = muleClient.send("vm://in1", TEST_MESSAGE, null);
37          assertEquals(TEST_MESSAGE, response.getPayload());
38      }
39      
40      @Test
41      public void testTemporaryReplyEnabledSync() throws MuleException
42      {
43          MuleClient muleClient = new MuleClient(muleContext);
44          MuleMessage response = muleClient.send("vm://in1Sync", TEST_MESSAGE, null);
45          assertEquals(TEST_MESSAGE + " TestService1", response.getPayload());
46      }
47  
48      @Test
49      public void testTemporaryReplyDisabledAsync() throws MuleException
50      {
51          MuleClient muleClient = new MuleClient(muleContext);
52          MuleMessage response = muleClient.send("vm://in2", TEST_MESSAGE, null);
53          assertEquals(TEST_MESSAGE, response.getPayload());
54      }
55  
56      @Test
57      public void testTemporaryReplyDisabledSync() throws MuleException
58      {
59          MuleClient muleClient = new MuleClient(muleContext);
60          MuleMessage response = muleClient.send("vm://in2Sync", TEST_MESSAGE, null);
61          assertEquals(TEST_MESSAGE, response.getPayload());
62      }    
63      
64      @Test
65      public void testDisableTemporaryReplyOnTheConnector() throws MuleException
66      {
67          MuleClient muleClient = new MuleClient(muleContext);
68          MuleMessage response = muleClient.send("vm://in3", TEST_MESSAGE, null);
69          
70          assertEquals(NullPayload.getInstance(), response.getPayload());
71      }
72  
73      @Test
74      public void testExplicitReplyToAsyncSet() throws MuleException
75      {
76          MuleClient muleClient = new MuleClient(muleContext);
77          MuleMessage response = muleClient.send("vm://in4", TEST_MESSAGE, null);
78          // We get the original message back, not the result from the remote component
79          assertEquals(TEST_MESSAGE + " TestService1", response.getPayload());
80      }
81  }