cvs commit: spice/sandbox/packet/src/test/org/realityforge/packet/encoder BasicEncoderTestCase.java

Peter Donald <[email protected]> Tue, 11 Nov 2003 03:39:30 -0800
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
donaldp     03/11/11 03:39:30

  Modified:    sandbox/packet/src/test/org/realityforge/packet/encoder
                        BasicEncoderTestCase.java
  Log:
  Start to test decoding
  
  Revision  Changes    Path
  1.3       +35 -2     spice/sandbox/packet/src/test/org/realityforge/packet/encoder/BasicEncoderTestCase.java
  
  Index: BasicEncoderTestCase.java
  ===================================================================
  RCS file: /cvsroot/spice/spice/sandbox/packet/src/test/org/realityforge/packet/encoder/BasicEncoderTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicEncoderTestCase.java	11 Nov 2003 11:29:51 -0000	1.2
  +++ BasicEncoderTestCase.java	11 Nov 2003 11:39:30 -0000	1.3
  @@ -14,7 +14,7 @@
   /**
    *
    * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2003/11/11 11:29:51 $
  + * @version $Revision: 1.3 $ $Date: 2003/11/11 11:39:30 $
    */
   public class BasicEncoderTestCase
       extends TestCase
  @@ -56,7 +56,7 @@
           throws Exception
       {
           final int sequence = 2;
  -        
  +
           final ByteBuffer data = ByteBuffer.allocate( 5 );
           data.clear();
           data.put( (byte)'B' );
  @@ -73,5 +73,38 @@
           output.position( 48 );
           final boolean result = encoder.encode( packet, output );
           assertEquals( "encoded?", false, result );
  +    }
  +
  +    public void testDecodePacketThatHeaderNoPresent()
  +        throws Exception
  +    {
  +        final ByteBuffer input = ByteBuffer.allocate( 40 );
  +        input.clear();
  +        input.limit( 3 );
  +        input.position( 2 );
  +
  +        final BasicEncoder encoder = new BasicEncoder();
  +        final Packet packet = encoder.decode( input );
  +        assertEquals( "packet?", null, packet );
  +        assertEquals( "input.position()", 2, input.position() );
  +        assertEquals( "input.limit()", 3, input.limit() );
  +    }
  +
  +    public void testDecodePacketThatDataNoPresent()
  +        throws Exception
  +    {
  +        final ByteBuffer input = ByteBuffer.allocate( 40 );
  +        input.clear();
  +        input.limit( 10 );
  +        input.position( 0 );
  +        input.putShort( (short)7 );
  +        input.putShort( (short)23 );
  +        input.position( 2 );
  +
  +        final BasicEncoder encoder = new BasicEncoder();
  +        final Packet packet = encoder.decode( input );
  +        assertEquals( "packet", null, packet );
  +        assertEquals( "input.position()", 2, input.position() );
  +        assertEquals( "input.limit()", 10, input.limit() );
       }
   }
  
  
  


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/