View Javadoc

1   /*
2    * $Id: ChainingRouterRemoteSyncTestCase.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.test.integration.routing.outbound;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.config.MuleProperties;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.FunctionalTestCase;
18  import org.mule.transport.NullPayload;
19  
20  /**
21   */
22  public class ChainingRouterRemoteSyncTestCase extends FunctionalTestCase
23  {
24      protected String getConfigResources()
25      {
26          return "org/mule/test/integration/routing/outbound/chaining-router-remote-sync.xml";
27      }
28  
29      public void testRemoteSync() throws Exception
30      {
31  
32          MuleClient muleClient = new MuleClient(muleContext);
33          MuleMessage result = muleClient.send("vm://in", new DefaultMuleMessage("test", muleContext));
34  
35          assertNull("Shouldn't have any exceptions", result.getExceptionPayload());
36          assertEquals("test [REMOTESYNC RESPONSE] [REMOTESYNC RESPONSE 2]", result.getPayloadAsString());
37      }
38  
39      /**
40       * MULE-4619 ChainingRouter sets MULE_REMOTE_SYNC_PROPERTY true on message when dispatching to last endpoint
41       * @throws Exception
42       */
43      public void testRemoteSyncLastEndpointDispatch() throws Exception
44      {
45  
46          MuleClient muleClient = new MuleClient(muleContext);
47          MuleMessage result = muleClient.send("vm://in2", new DefaultMuleMessage("test", muleContext));
48  
49          assertNull("Shouldn't have any exceptions", result.getExceptionPayload());
50          // When last endpoint on chaining router is async the outbound phase behaves as out-only and null is returned
51          assertEquals(NullPayload.getInstance(), result.getPayload());
52  
53          MuleMessage jmsMessage = muleClient.request("jms://out2", FunctionalTestCase.RECEIVE_TIMEOUT);
54          assertEquals("test [REMOTESYNC RESPONSE] [REMOTESYNC RESPONSE 2]", jmsMessage.getPayloadAsString());
55          assertFalse(jmsMessage.getOutboundProperty(MuleProperties.MULE_REMOTE_SYNC_PROPERTY, false));
56      }
57  
58  }