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