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.test.integration.messaging.meps;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.transport.NullPayload;
13  
14  import java.util.HashMap;
15  import java.util.Map;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  import static org.junit.Assert.assertNotNull;
21  
22  public class InOptionalOutOutOptionalInTestCase extends FunctionalTestCase
23  {
24  
25      public static final long TIMEOUT = 3000;
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "org/mule/test/integration/messaging/meps/pattern_In-Optional-Out_Out-Optional-In.xml";
31      }
32  
33      @Test
34      public void testExchange() throws Exception
35      {
36          MuleClient client = new MuleClient(muleContext);
37  
38          MuleMessage result = client.send("inboundEndpoint", "some data", null);
39          assertNotNull(result);
40          assertEquals(NullPayload.getInstance(), result.getPayload());
41          //TODO Even though the component returns a null the remoteSync is honoured.
42          // I don't think this is right for Out-Optional-In, but probably should be the behaviour for Out-In
43          assertEquals("Received", result.getInboundProperty("externalApp"));
44  
45          Map props = new HashMap();
46          props.put("foo", "bar");
47          result = client.send("inboundEndpoint", "some data", props);
48          assertNotNull(result);
49          assertEquals("bar header received", result.getPayload());
50          assertEquals("Received", result.getInboundProperty("externalApp"));
51      }
52  }