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.transport.tcp.issues;
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.tck.junit4.rule.DynamicPort;
13  
14  import java.util.HashMap;
15  import java.util.Map;
16  
17  import org.junit.Rule;
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertNotNull;
22  
23  public class AsynchMule1869TestCase extends FunctionalTestCase
24  {
25  
26      protected static String TEST_MESSAGE = "Test TCP Request";
27  
28      @Rule
29      public DynamicPort dynamicPort1 = new DynamicPort("port1");
30  
31      @Rule
32      public DynamicPort dynamicPort2 = new DynamicPort("port2");
33  
34      @Override
35      protected String getConfigResources()
36      {
37          return "tcp-functional-test.xml";
38      }
39  
40      @Test
41      public void testDispatchAndReply() throws Exception
42      {
43          MuleClient client = new MuleClient(muleContext);
44          Map props = new HashMap();
45          client.dispatch("asyncClientEndpoint", TEST_MESSAGE, props);
46          // MULE-2754
47          Thread.sleep(100);
48          MuleMessage result =  client.request("asyncClientEndpoint", 10000);
49          assertNotNull("No message received", result);
50          assertEquals(TEST_MESSAGE + " Received Async", result.getPayloadAsString());
51      }
52  
53  }