View Javadoc

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