View Javadoc

1   /*
2    * $Id: DefaultProtocolTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.protocols;
12  
13  import org.mule.tck.AbstractMuleTestCase;
14  import org.mule.transport.tcp.TcpProtocol;
15  import org.mule.transport.tcp.protocols.DirectProtocol;
16  
17  public class DefaultProtocolTestCase extends AbstractMuleTestCase
18  {
19  
20      private TcpProtocol protocol;
21      private int expectedLength;
22  
23      public DefaultProtocolTestCase()
24      {
25          // for old (full buffer) condition in DefaultProtocol
26  //        this(new DefaultProtocol(), 1);
27  
28          this(new DirectProtocol(), SlowInputStream.FULL_LENGTH);
29      }
30  
31      public DefaultProtocolTestCase(TcpProtocol protocol, int expectedLength)
32      {
33          this.protocol = protocol;
34          this.expectedLength = expectedLength;
35      }
36  
37  
38      public void testRead() throws Exception
39      {
40          byte[] result = (byte[]) protocol.read(new SlowInputStream());
41          assertEquals(expectedLength, result.length);
42      }
43  
44      protected TcpProtocol getProtocol()
45      {
46          return protocol;
47      }
48  
49  }