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.transport.Connector;
10  import org.mule.transport.AbstractConnectorTestCase;
11  
12  import org.junit.Test;
13  
14  import static org.junit.Assert.assertEquals;
15  
16  public class TcpConnectorTestCase extends AbstractConnectorTestCase
17  {
18      public Connector createConnector() throws Exception
19      {
20          TcpConnector c = new TcpConnector(muleContext);
21          c.setName("TcpConnector");
22          return c;
23      }
24  
25      public String getTestEndpointURI()
26      {
27          return "tcp://localhost:56801";
28      }
29  
30      public Object getValidMessage() throws Exception
31      {
32          return "Hello".getBytes();
33      }
34  
35      @Test
36      public void testProperties() throws Exception
37      {
38          TcpConnector c = (TcpConnector) getConnector();
39  
40          c.setSendBufferSize(1024);
41          assertEquals(1024, c.getSendBufferSize());
42          c.setSendBufferSize(0);
43          assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
44  
45          // timeouts
46          c.setServerSoTimeout(-1);
47          assertEquals(TcpConnector.DEFAULT_SOCKET_TIMEOUT, c.getServerSoTimeout());
48          c.setClientSoTimeout(-1);
49          assertEquals(TcpConnector.DEFAULT_SOCKET_TIMEOUT, c.getClientSoTimeout());
50          c.setClientSoTimeout(1000);
51          c.setServerSoTimeout(1000);
52          assertEquals(1000, c.getServerSoTimeout());
53          assertEquals(1000, c.getClientSoTimeout());
54      }
55  }