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

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

  Modified:    sandbox/packet/src/test/org/realityforge/packet/encoder
                        BasicEncoderTestCase.java
  Log:
  Test no encode
  
  Revision  Changes    Path
  1.2       +24 -1     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicEncoderTestCase.java	11 Nov 2003 11:24:33 -0000	1.1
  +++ BasicEncoderTestCase.java	11 Nov 2003 11:29:51 -0000	1.2
  @@ -14,7 +14,7 @@
   /**
    *
    * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2003/11/11 11:24:33 $
  + * @version $Revision: 1.2 $ $Date: 2003/11/11 11:29:51 $
    */
   public class BasicEncoderTestCase
       extends TestCase
  @@ -50,5 +50,28 @@
           assertEquals( "output.getShort( 28 )", 'i', output.get( 28 ) );
           assertEquals( "output.getShort( 29 )", 'n', output.get( 29 ) );
           assertEquals( "output.getShort( 30 )", 'g', output.get( 30 ) );
  +    }
  +
  +    public void testEncodePacketThatNoFit()
  +        throws Exception
  +    {
  +        final int sequence = 2;
  +        
  +        final ByteBuffer data = ByteBuffer.allocate( 5 );
  +        data.clear();
  +        data.put( (byte)'B' );
  +        data.put( (byte)'i' );
  +        data.put( (byte)'n' );
  +        data.put( (byte)'g' );
  +        data.flip();
  +        data.position( sequence );
  +
  +        final Packet packet = new Packet( (short)sequence, 0, data );
  +        final BasicEncoder encoder = new BasicEncoder();
  +
  +        final ByteBuffer output = ByteBuffer.allocate( 50 );
  +        output.position( 48 );
  +        final boolean result = encoder.encode( packet, output );
  +        assertEquals( "encoded?", false, result );
       }
   }
  
  
  


-------------------------------------------------------
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/