View Javadoc

1   /*
2    * $Id: TcpLengthFunctionalTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
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.module.client.MuleClient;
15  import org.mule.tck.DynamicPortTestCase;
16  
17  public class TcpLengthFunctionalTestCase extends DynamicPortTestCase
18  {
19      protected static String TEST_MESSAGE = "Test TCP Request";
20      private int timeout = 60 * 1000 / 20;
21  
22      public TcpLengthFunctionalTestCase()
23      {
24          setDisposeManagerPerSuite(true);
25      }
26  
27      protected String getConfigResources()
28      {
29          return "tcp-length-functional-test.xml";
30      }
31  
32      public void testSend() throws Exception
33      {
34          MuleClient client = new MuleClient(muleContext);
35          MuleMessage result = client.send("clientEndpoint", TEST_MESSAGE, null);
36          assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
37      }
38  
39      public void testDispatchAndReplyViaStream() throws Exception
40      {
41          MuleClient client = new MuleClient(muleContext);
42          client.dispatch("asyncClientEndpoint1", TEST_MESSAGE, null);
43          // MULE-2754
44          Thread.sleep(200);
45          MuleMessage result =  client.request("asyncClientEndpoint1", timeout);
46          // expect failure - streaming not supported
47          assertNull(result);
48      }
49  
50      public void testDispatchAndReply() throws Exception
51      {
52          MuleClient client = new MuleClient(muleContext);
53          client.dispatch("asyncClientEndpoint2", TEST_MESSAGE, null);
54          // MULE-2754
55          Thread.sleep(200);
56          MuleMessage result =  client.request("asyncClientEndpoint2", timeout);
57          // expect failure - TCP simply can't work like this
58          assertNull(result);
59      }
60  
61      @Override
62      protected int getNumPortsToFind()
63      {
64          return 3;
65      }
66  }