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;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.api.endpoint.InboundEndpoint;
11  import org.mule.module.client.MuleClient;
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 TcpEchoDirectProtocolTestCase extends FunctionalTestCase
22  {
23  
24      protected static String TEST_MESSAGE = "Test TCP Request";
25  
26      @Rule
27      public DynamicPort dynamicPort = new DynamicPort("port1");
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "tcp-echo-test.xml";
33      }
34  
35      @Test
36      public void testSend() throws Exception
37      {
38          MuleClient client = new MuleClient(muleContext);
39          
40          MuleMessage response = client.send(((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inBounceTcpMMP")).getAddress(), 
41              TEST_MESSAGE, null);
42          
43          assertNotNull(response);
44          assertEquals(TEST_MESSAGE, response.getPayload());
45      }
46  
47  }