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