1   /*
2    * $Id: TcpConnectorTestCase.java 11311 2008-03-10 20:15:57Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  public class TcpConnectorTestCase extends AbstractConnectorTestCase
17  {
18  
19      // @Override
20      public Connector createConnector() throws Exception
21      {
22          TcpConnector c = new TcpConnector();
23          c.setName("TcpConnector");
24          return c;
25      }
26  
27      public String getTestEndpointURI()
28      {
29          return "tcp://localhost:56801";
30      }
31  
32      public Object getValidMessage() throws Exception
33      {
34          return "Hello".getBytes();
35      }
36  
37      public void testValidListener() throws Exception
38      {
39          // TODO Implement
40      }
41  
42      public void testProperties() throws Exception
43      {
44          TcpConnector c = (TcpConnector)getConnector();
45  
46          c.setSendBufferSize(1024);
47          assertEquals(1024, c.getSendBufferSize());
48          c.setSendBufferSize(0);
49          assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());
50  
51          // timeouts
52          c.setServerSoTimeout(-1);
53          assertEquals(TcpConnector.DEFAULT_SOCKET_TIMEOUT, c.getServerSoTimeout());
54          c.setClientSoTimeout(-1);
55          assertEquals(TcpConnector.DEFAULT_SOCKET_TIMEOUT, c.getClientSoTimeout());
56          c.setClientSoTimeout(1000);
57          c.setServerSoTimeout(1000);
58          assertEquals(1000, c.getServerSoTimeout());
59          assertEquals(1000, c.getClientSoTimeout());
60      }
61  }