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.api.config.MuleProperties;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
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 InOutAsyncTestCase 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-Out-Async.xml";
31      }
32  
33      @Test
34      public void testExchange() throws Exception
35      {
36          MuleClient client = new MuleClient(muleContext);
37          Map props = new HashMap();
38          //Almost any endpoint can be used here
39          props.put(MuleProperties.MULE_REPLY_TO_PROPERTY, "jms://client-reply");
40  
41          MuleMessage result = client.send("inboundEndpoint", "some data", props);
42          assertNotNull(result);
43          assertEquals("got it!", result.getPayloadAsString());
44  
45          final Object foo = result.getInboundProperty("foo");
46          assertNotNull(foo);
47          assertEquals("bar", foo);
48      }
49  }