View Javadoc

1   /*
2    * $Id: TcpEchoDirectProtocolTestCase.java 19840 2010-10-05 18:32:45Z dzapata $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.tcp;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.DynamicPortTestCase;
17  
18  public class TcpEchoDirectProtocolTestCase extends DynamicPortTestCase 
19  {
20  
21      protected static String TEST_MESSAGE = "Test TCP Request";
22  
23      protected String getConfigResources()
24      {
25          return "tcp-echo-test.xml";
26      }
27  
28      public void testSend() throws Exception
29      {
30          MuleClient client = new MuleClient(muleContext);
31          
32          MuleMessage response = client.send(((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inBounceTcpMMP")).getAddress(), 
33              TEST_MESSAGE, null);
34          
35          assertNotNull(response);
36          assertEquals(TEST_MESSAGE, response.getPayload());
37      }
38  
39      @Override
40      protected int getNumPortsToFind()
41      {
42          return 1;
43      }
44  
45  }