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.endpoints;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.client.DefaultLocalMuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  import org.mule.tck.junit4.rule.DynamicPort;
14  
15  import org.junit.Rule;
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  
21  public class DynamicEndpointWithAsyncResponseTestCase extends FunctionalTestCase
22  {
23      @Rule
24      public DynamicPort dynamicPort = new DynamicPort("port1");
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/integration/endpoints/dynamic-endpoint-with-async-response-config.xml";
30      }
31  
32      @Test
33      public void testDynamicEndpointWithAsyncResponse() throws Exception
34      {
35          DefaultMuleMessage message = new DefaultMuleMessage("hello", muleContext);
36          message.setOutboundProperty("host", "localhost");
37          message.setOutboundProperty("port", dynamicPort.getNumber());
38          message.setOutboundProperty("path", "/TEST");
39  
40          DefaultLocalMuleClient client = new DefaultLocalMuleClient(muleContext);
41          MuleMessage response = client.send("vm://vmProxy", message);
42          assertEquals("hello Received", response.getPayloadAsString());
43  
44          response = client.request("vm://vmOut", 5000);
45          assertNotNull(response);
46      }
47  }