View Javadoc

1   /*
2    * $Id: JmsTemporaryReplyToTestCase.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.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.transport.NullPayload;
17  
18  import org.junit.Test;
19  
20  /**
21   * TODO this test does not use the Test scenarios, I think it would need a new Method
22   * sendAndReceive It might make sense to leave this test as is because it tests that
23   * the client also works with ReplyTo correctly
24   */
25  public class JmsTemporaryReplyToTestCase extends AbstractJmsFunctionalTestCase
26  {
27  
28      protected String getConfigResources()
29      {
30          return "integration/jms-temporary-replyTo.xml";
31      }
32  
33      @Test
34      public void testTemporaryReplyEnabledAsync() throws MuleException
35      {
36          MuleClient muleClient = new MuleClient(muleContext);
37          MuleMessage response = muleClient.send("vm://in1", TEST_MESSAGE, null);
38          assertEquals(TEST_MESSAGE, response.getPayload());
39      }
40      
41      @Test
42      public void testTemporaryReplyEnabledSync() throws MuleException
43      {
44          MuleClient muleClient = new MuleClient(muleContext);
45          MuleMessage response = muleClient.send("vm://in1Sync", TEST_MESSAGE, null);
46          assertEquals(TEST_MESSAGE + " TestService1", response.getPayload());
47      }
48  
49      @Test
50      public void testTemporaryReplyDisabledAsync() throws MuleException
51      {
52          MuleClient muleClient = new MuleClient(muleContext);
53          MuleMessage response = muleClient.send("vm://in2", TEST_MESSAGE, null);
54          assertEquals(TEST_MESSAGE, response.getPayload());
55      }
56  
57      @Test
58      public void testTemporaryReplyDisabledSync() throws MuleException
59      {
60          MuleClient muleClient = new MuleClient(muleContext);
61          MuleMessage response = muleClient.send("vm://in2Sync", TEST_MESSAGE, null);
62          assertEquals(TEST_MESSAGE, response.getPayload());
63      }    
64      
65      @Test
66      public void testDisableTemporaryReplyOnTheConnector() throws MuleException
67      {
68          MuleClient muleClient = new MuleClient(muleContext);
69          MuleMessage response = muleClient.send("vm://in3", TEST_MESSAGE, null);
70          
71          assertEquals(NullPayload.getInstance(), response.getPayload());
72      }
73  
74      @Test
75      public void testExplicitReplyToAsyncSet() throws MuleException
76      {
77          MuleClient muleClient = new MuleClient(muleContext);
78          MuleMessage response = muleClient.send("vm://in4", TEST_MESSAGE, null);
79          // We get the original message back, not the result from the remote component
80          assertEquals(TEST_MESSAGE + " TestService1", response.getPayload());
81      }
82  }