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 static org.junit.Assert.assertEquals;
10  import static org.junit.Assert.assertNotNull;
11  import org.mule.api.MuleMessage;
12  import org.mule.api.client.MuleClient;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  import org.mule.tck.junit4.rule.DynamicPort;
15  
16  import java.util.HashMap;
17  import java.util.Map;
18  
19  import org.junit.Rule;
20  import org.junit.Test;
21  
22  public class InOutTestCase extends FunctionalTestCase
23  {
24  
25      public static final long TIMEOUT = 3000;
26  
27      @Rule
28      public DynamicPort httpPort = new DynamicPort("port1");
29  
30      @Override
31      protected String getConfigResources()
32      {
33          return "org/mule/test/integration/messaging/meps/pattern_In-Out.xml";
34      }
35  
36      @Test
37      public void testExchange() throws Exception
38      {
39          MuleClient client = muleContext.getClient();
40  
41          MuleMessage result = client.send("inboundEndpoint", "some data", null);
42          assertNotNull(result);
43          assertEquals("foo header not received", result.getPayloadAsString());
44  
45          Map props = new HashMap();
46          props.put("foo", "bar");
47          result = client.send("inboundEndpoint", "some data", props);
48          assertNotNull(result);
49          assertEquals("foo header received", result.getPayloadAsString());
50      }
51  }