View Javadoc

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