directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r154063 [3/3] - in incubator/directory/asn1/branches/ber-decoder/modules: ber/ ber/xdocs/ codec/ codec/src/docbook/ codec/src/images/ compiler/ der/ runtime/ runtime/src/java/org/apache/snickers/encoding/ runtime/src/java/org/apache/snickers/encoding/ber/ runtime/src/java/org/apache/snickers/runtime/ runtime/src/test/com/acme/spnego/ runtime/src/test/com/acme/spnego/ber/ runtime/src/test/org/apache/snickers/encoding/ber/
Date Wed, 16 Feb 2005 18:57:34 GMT
Modified: incubator/directory/asn1/branches/ber-decoder/modules/runtime/src/test/org/apache/snickers/encoding/ber/TupleTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/asn1/branches/ber-decoder/modules/runtime/src/test/org/apache/snickers/encoding/ber/TupleTest.java?view=diff&r1=154062&r2=154063
==============================================================================
--- incubator/directory/asn1/branches/ber-decoder/modules/runtime/src/test/org/apache/snickers/encoding/ber/TupleTest.java (original)
+++ incubator/directory/asn1/branches/ber-decoder/modules/runtime/src/test/org/apache/snickers/encoding/ber/TupleTest.java Wed Feb 16 10:57:26 2005
@@ -21,7 +21,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 
-import org.apache.snickers.codec.binary.Binary;
+import org.apache.commons.codec.binary.BinaryCodec;
 
 
 /**
@@ -31,8 +31,7 @@
  *         Apache Directory Project</a>
  * @version $Rev$
  */
-public class TupleTest extends AbstractDecoderTestCase
-{
+public class TupleTest extends AbstractDecoderTestCase {
     /**
      * precalculated left shift of 1 by 14 places
      */
@@ -54,24 +53,21 @@
      */
     private static final int BIT_27 = 1 << 28;
 
-    public static void main( String[] args )
-    {
-        junit.textui.TestRunner.run( TupleTest.class );
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(TupleTest.class);
     }
 
     /*
      * @see TestCase#setUp()
      */
-    protected void setUp() throws Exception
-    {
+    protected void setUp() throws Exception {
         super.setUp();
     }
 
     /*
      * @see TestCase#tearDown()
      */
-    protected void tearDown() throws Exception
-    {
+    protected void tearDown() throws Exception {
         super.tearDown();
     }
 
@@ -80,997 +76,954 @@
      *
      * @param arg0
      */
-    public TupleTest( String arg0 )
-    {
-        super( arg0 );
+    public TupleTest(String arg0) {
+        super(arg0);
     }
 
     /*
      * Class to test for void Tuple()
      */
-    public void testTuple()
-    {
-        assertNotNull( new Tuple() );
+    public void testTuple() {
+        assertNotNull(new Tuple());
     }
 
     /*
      * Class to test for void Tuple(int)
      */
-    public void testTupleint()
-    {
-        Tuple t0 = new Tuple( 0, 0 );
-        assertEquals( 0, t0.getId() );
-        Tuple t1 = new Tuple( 1, 0 );
-        assertEquals( 1, t1.getId() );
-        assertFalse( t0.equals( t1 ) );
+    public void testTupleint() {
+        Tuple t0 = new Tuple(0, 0);
+        assertEquals(0, t0.getId());
+        Tuple t1 = new Tuple(1, 0);
+        assertEquals(1, t1.getId());
+        assertFalse(t0.equals(t1));
     }
 
     /*
      * Class to test for void Tuple(int, int)
      */
-    public void testTupleintint()
-    {
-        Tuple t0 = new Tuple( 0, 0 );
-        assertEquals( 0, t0.getId() );
-        assertEquals( 0, t0.getLength() );
-        Tuple t1 = new Tuple( 0, 1 );
-        assertEquals( 0, t1.getId() );
-        assertEquals( 1, t1.getLength() );
-        assertFalse( t0.equals( t1 ) );
+    public void testTupleintint() {
+        Tuple t0 = new Tuple(0, 0);
+        assertEquals(0, t0.getId());
+        assertEquals(0, t0.getLength());
+        Tuple t1 = new Tuple(0, 1);
+        assertEquals(0, t1.getId());
+        assertEquals(1, t1.getLength());
+        assertFalse(t0.equals(t1));
     }
 
     /*
      * Class to test for void Tuple(int, int, TypeClass)
      */
-    public void testTupleintintTypeClass()
-    {
-        Tuple t0 = new Tuple( 0, 0, TypeClass.PRIVATE );
-        assertEquals( 0, t0.getId() );
-        assertEquals( 0, t0.getLength() );
-        assertEquals( TypeClass.PRIVATE, t0.getTypeClass() );
-        Tuple t1 = new Tuple( 0, 1, null );
-        assertEquals( 0, t1.getId() );
-        assertEquals( 1, t1.getLength() );
-        assertFalse( t0.equals( t1 ) );
-        assertEquals( TypeClass.APPLICATION, t1.getTypeClass() );
+    public void testTupleintintTypeClass() {
+        Tuple t0 = new Tuple(0, 0, TypeClass.PRIVATE);
+        assertEquals(0, t0.getId());
+        assertEquals(0, t0.getLength());
+        assertEquals(TypeClass.PRIVATE, t0.getTypeClass());
+        Tuple t1 = new Tuple(0, 1, null);
+        assertEquals(0, t1.getId());
+        assertEquals(1, t1.getLength());
+        assertFalse(t0.equals(t1));
+        assertEquals(TypeClass.APPLICATION, t1.getTypeClass());
     }
 
     /*
      * Class to test for void Tuple(int, int, TypeClass, boolean, byte[])
      */
-    public void testTupleintTypeClass()
-    {
-        Tuple t = new Tuple( 2, TypeClass.PRIVATE );
-        assertEquals( 2, t.getId() );
-        assertEquals( TypeClass.PRIVATE, t.getTypeClass() );
-        assertEquals( false, t.isPrimitive() );
-        assertEquals( Length.INDEFINITE, t.getLength() );
-
-        t = new Tuple( 2, (TypeClass) null );
-        assertEquals( 2, t.getId() );
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() );
-        assertEquals( false, t.isPrimitive() );
-        assertEquals( Length.INDEFINITE, t.getLength() );
+    public void testTupleintTypeClass() {
+        Tuple t = new Tuple(2, TypeClass.PRIVATE);
+        assertEquals(2, t.getId());
+        assertEquals(TypeClass.PRIVATE, t.getTypeClass());
+        assertEquals(false, t.isPrimitive());
+        assertEquals(Length.INDEFINITE, t.getLength());
+
+        t = new Tuple(2, (TypeClass) null);
+        assertEquals(2, t.getId());
+        assertEquals(TypeClass.APPLICATION, t.getTypeClass());
+        assertEquals(false, t.isPrimitive());
+        assertEquals(Length.INDEFINITE, t.getLength());
     }
 
-    public void testGetId()
-    {
+    public void testGetId() {
         Tuple t = new Tuple();
-        assertEquals( 0, t.getId() );
-        t = new Tuple( 2, 0 );
-        assertEquals( 2, t.getId() );
-        t.setId( 21 );
-        assertEquals( 21, t.getId() );
+        assertEquals(0, t.getId());
+        t = new Tuple(2, 0);
+        assertEquals(2, t.getId());
+        t.setId(21);
+        assertEquals(21, t.getId());
     }
 
 
-    public void testSize()
-    {
-        Tuple t = new Tuple( 1, TypeClass.APPLICATION );
-        assertEquals( 2, t.size() );
-        t.setId( 32 );
-        assertEquals( 3, t.size() );
-        t.setId( 127 );
-        assertEquals( 4, t.size() );
-        t.setId( 128 );
-        assertEquals( 4, t.size() );
-        t.setId( 1 << 14 );
-        assertEquals( 5, t.size() );
-        t.setId( 1 << 21 );
-        assertEquals( 6, t.size() );
-
-        t.setLength( 127 );
-        assertEquals( 6 + 127, t.size() );
-        t.setLength( 128 );
-        assertEquals( 7 + 128, t.size() );
-        t.setLength( 255 );
-        assertEquals( 7 + 255, t.size() );
-        t.setLength( 256 );
-        assertEquals( 8 + 256, t.size() );
+    public void testSize() {
+        Tuple t = new Tuple(1, TypeClass.APPLICATION);
+        assertEquals(2, t.size());
+        t.setId(32);
+        assertEquals(3, t.size());
+        t.setId(127);
+        assertEquals(4, t.size());
+        t.setId(128);
+        assertEquals(4, t.size());
+        t.setId(1 << 14);
+        assertEquals(5, t.size());
+        t.setId(1 << 21);
+        assertEquals(6, t.size());
+
+        t.setLength(127);
+        assertEquals(6 + 127, t.size());
+        t.setLength(128);
+        assertEquals(7 + 128, t.size());
+        t.setLength(255);
+        assertEquals(7 + 255, t.size());
+        t.setLength(256);
+        assertEquals(8 + 256, t.size());
     }
 
 
-    public void testIsIndefinate()
-    {
+    public void testIsIndefinate() {
         Tuple t = new Tuple();
-        assertFalse( t.isIndefinite() );
-        t.setLength( Length.INDEFINITE );
-        assertTrue( t.isIndefinite() );
+        assertFalse(t.isIndefinite());
+        t.setLength(Length.INDEFINITE);
+        assertTrue(t.isIndefinite());
     }
 
 
-    public void testIsIndefinateTerminator()
-    {
+    public void testIsIndefinateTerminator() {
         Tuple t = new Tuple();
-        assertFalse( t.isIndefiniteTerminator() );
-        t.setId( 0 );
-        t.setLength( 0 );
-        t.setPrimitive( true );
-        t.setTypeClass( TypeClass.UNIVERSAL );
-        assertTrue( t.isIndefiniteTerminator() );
+        assertFalse(t.isIndefiniteTerminator());
+        t.setId(0);
+        t.setLength(0);
+        t.setPrimitive(true);
+        t.setTypeClass(TypeClass.UNIVERSAL);
+        assertTrue(t.isIndefiniteTerminator());
     }
 
 
-    public void testIsPrimitive()
-    {
+    public void testIsPrimitive() {
         Tuple t = new Tuple();
-        assertTrue( t.isPrimitive() );
-        t.setPrimitive( false );
-        assertFalse( t.isPrimitive() );
+        assertTrue(t.isPrimitive());
+        t.setPrimitive(false);
+        assertFalse(t.isPrimitive());
     }
 
-    public void testGetLength()
-    {
+    public void testGetLength() {
         Tuple t = new Tuple();
-        assertEquals( 0, t.getLength() );
-        t = new Tuple( 1, 2 );
-        assertEquals( 2, t.getLength() );
-        t.setLength( 21 );
-        assertEquals( 21, t.getLength() );
+        assertEquals(0, t.getLength());
+        t = new Tuple(1, 2);
+        assertEquals(2, t.getLength());
+        t.setLength(21);
+        assertEquals(21, t.getLength());
     }
 
-    public void testGetTypeClass()
-    {
+    public void testGetTypeClass() {
         Tuple t = new Tuple();
-        assertEquals( t.getTypeClass(), TypeClass.APPLICATION );
-        t = new Tuple( 0, 0 );
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() );
-        t.setTypeClass( TypeClass.PRIVATE );
-        assertEquals( TypeClass.PRIVATE, t.getTypeClass() );
+        assertEquals(t.getTypeClass(), TypeClass.APPLICATION);
+        t = new Tuple(0, 0);
+        assertEquals(TypeClass.APPLICATION, t.getTypeClass());
+        t.setTypeClass(TypeClass.PRIVATE);
+        assertEquals(TypeClass.PRIVATE, t.getTypeClass());
     }
 
-    public void testClear()
-    {
+    public void testClear() {
         Tuple t = new Tuple();
-        t.setId( 12 );
-        assertEquals( 12, t.getId() );
+        t.setId(12);
+        assertEquals(12, t.getId());
         t.clear();
-        assertEquals( 0, t.getId() );
+        assertEquals(0, t.getId());
 
-        t.setLength( 12 );
-        assertEquals( 12, t.getLength() );
+        t.setLength(12);
+        assertEquals(12, t.getLength());
         t.clear();
-        assertEquals( Length.UNDEFINED, t.getLength() );
+        assertEquals(Length.UNDEFINED, t.getLength());
 
-        t.setIndex( 12 );
-        assertEquals( 12, t.getIndex() );
+        t.setIndex(12);
+        assertEquals(12, t.getIndex());
         t.clear();
-        assertEquals( 0, t.getIndex() );
+        assertEquals(0, t.getIndex());
 
-        t.setPrimitive( false );
-        assertEquals( false, t.isPrimitive() );
+        t.setPrimitive(false);
+        assertEquals(false, t.isPrimitive());
         t.clear();
-        assertEquals( true, t.isPrimitive() );
+        assertEquals(true, t.isPrimitive());
 
-        t.setTypeClass( TypeClass.CONTEXT_SPECIFIC );
-        assertEquals( TypeClass.CONTEXT_SPECIFIC, t.getTypeClass() );
+        t.setTypeClass(TypeClass.CONTEXT_SPECIFIC);
+        assertEquals(TypeClass.CONTEXT_SPECIFIC, t.getTypeClass());
         t.clear();
-        assertEquals( TypeClass.APPLICATION, t.getTypeClass() );
+        assertEquals(TypeClass.APPLICATION, t.getTypeClass());
 
     }
 
     /*
      * Class to test for boolean equals(Object)
      */
-    public void testEqualsObject()
-    {
+    public void testEqualsObject() {
         Tuple tnull0 = new Tuple();
         Tuple tnull1 = new Tuple();
-        tnull0.equals( tnull1 );
+        tnull0.equals(tnull1);
 
-        tnull1.equals( tnull1 );
-        tnull0.equals( tnull0 );
+        tnull1.equals(tnull1);
+        tnull0.equals(tnull0);
     }
 
-    public void testToEncodedBufferConstructed()
-    {
+    public void testToEncodedBufferConstructed() {
         Tuple t = null;
         ByteBuffer encoded;
         String binary;
 
-        t = new Tuple( 0, 0 );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(0, 0);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "01100000"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 2, 0 );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(2, 0);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "01100010"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 30, 0 );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(30, 0);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "01111110"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 31, 0 );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(31, 0);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "00011111" +
                 "01111111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 128, 0 );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(128, 0);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "00000000" +
                 "10000001" +
                 "01111111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 128, 127 );
+        t = new Tuple(128, 127);
         ArrayList list = new ArrayList();
-        list.add( ByteBuffer.allocate( 127 ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( "01111111" +
+        list.add(ByteBuffer.allocate(127));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals("01111111" +
                 "00000000" +
                 "10000001" +
                 "01111111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 128, 128 );
+        t = new Tuple(128, 128);
         list.clear();
-        list.add( ByteBuffer.allocate( 128 ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( "10000000" +
+        list.add(ByteBuffer.allocate(128));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals("10000000" +
                 "10000001" +
                 "00000000" +
                 "10000001" +
                 "01111111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 128, 255 );
+        t = new Tuple(128, 255);
         list.clear();
-        list.add( ByteBuffer.allocate( 255 ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( "11111111" +
+        list.add(ByteBuffer.allocate(255));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals("11111111" +
                 "10000001" +
                 "00000000" +
                 "10000001" +
                 "01111111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 128, 256 );
+        t = new Tuple(128, 256);
         list.clear();
-        list.add( ByteBuffer.allocate( 256 ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000001" +
+        list.add(ByteBuffer.allocate(256));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals("00000001" +
                 "00000000" +
                 "10000010" +
                 "00000000" +
                 "10000001" +
                 "01111111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
     }
 
-    public void testToEncodedBufferPrimitive()
-    {
+    public void testToEncodedBufferPrimitive() {
         Tuple t = null;
         ByteBuffer encoded;
         byte[] data;
         String binary;
 
-        t = new Tuple( 0, 0, true, TypeClass.APPLICATION );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(0, 0, true, TypeClass.APPLICATION);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "01000000"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 2, 0, true, TypeClass.APPLICATION );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(2, 0, true, TypeClass.APPLICATION);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "01000010"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 30, 0, true, TypeClass.APPLICATION );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(30, 0, true, TypeClass.APPLICATION);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "01011110"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 31, 0, true, TypeClass.APPLICATION );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(31, 0, true, TypeClass.APPLICATION);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "00011111" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
-        t = new Tuple( 128, 0, true, TypeClass.APPLICATION );
-        encoded = t.toEncodedBuffer( Collections.EMPTY_LIST );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        t = new Tuple(128, 0, true, TypeClass.APPLICATION);
+        encoded = t.toEncodedBuffer(Collections.EMPTY_LIST);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "00000000" +
                 "10000001" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
         data = new byte[1];
-        t = new Tuple( 128, 1, true, TypeClass.APPLICATION );
+        t = new Tuple(128, 1, true, TypeClass.APPLICATION);
         ArrayList list = new ArrayList();
-        list.add( ByteBuffer.wrap( data ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( "00000000" +
+        list.add(ByteBuffer.wrap(data));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals("00000000" +
                 "00000001" +
                 "00000000" +
                 "10000001" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
         data = new byte[127];
-        t = new Tuple( 128, 127, true, TypeClass.APPLICATION );
+        t = new Tuple(128, 127, true, TypeClass.APPLICATION);
         list.clear();
-        list.add( ByteBuffer.wrap( data ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( Binary.toAsciiString( data ) +
+        list.add(ByteBuffer.wrap(data));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals(BinaryCodec.toAsciiString(data) +
                 "01111111" +
                 "00000000" +
                 "10000001" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
         data = new byte[128];
-        t = new Tuple( 128, 128, true, TypeClass.APPLICATION );
+        t = new Tuple(128, 128, true, TypeClass.APPLICATION);
         list.clear();
-        list.add( ByteBuffer.wrap( data ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( Binary.toAsciiString( data ) +
+        list.add(ByteBuffer.wrap(data));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals(BinaryCodec.toAsciiString(data) +
                 "10000000" +
                 "10000001" +
                 "00000000" +
                 "10000001" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
         data = new byte[255];
-        t = new Tuple( 128, 255, true, TypeClass.APPLICATION );
+        t = new Tuple(128, 255, true, TypeClass.APPLICATION);
         list.clear();
-        list.add( ByteBuffer.wrap( data ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( Binary.toAsciiString( data ) +
+        list.add(ByteBuffer.wrap(data));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals(BinaryCodec.toAsciiString(data) +
                 "11111111" +
                 "10000001" +
                 "00000000" +
                 "10000001" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
 
         data = new byte[256];
-        t = new Tuple( 128, 256, true, TypeClass.APPLICATION );
+        t = new Tuple(128, 256, true, TypeClass.APPLICATION);
         list.clear();
-        list.add( ByteBuffer.wrap( data ) );
-        encoded = t.toEncodedBuffer( list );
-        binary = toAsciiString( encoded );
-        assertEquals( Binary.toAsciiString( data ) +
+        list.add(ByteBuffer.wrap(data));
+        encoded = t.toEncodedBuffer(list);
+        binary = toAsciiString(encoded);
+        assertEquals(BinaryCodec.toAsciiString(data) +
                 "00000001" +
                 "00000000" +
                 "10000010" +
                 "00000000" +
                 "10000001" +
                 "01011111"
-                , toAsciiString( encoded ) );
+                , toAsciiString(encoded));
     }
 
 
-    public String toAsciiString( ByteBuffer buf )
-    {
-        return Binary.toAsciiString( buf.array() );
+    public String toAsciiString(ByteBuffer buf) {
+        return BinaryCodec.toAsciiString(buf.array());
     }
 
 
-    public void testSetTagBufferint()
-    {
-        ByteBuffer bites = ByteBuffer.allocate( 1 );
-        Tuple t = new Tuple( 0, 0 );
-        t.setTag( bites, 1 );
-        String binary = toAsciiString( bites );
-        assertEquals( "01100000", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 0 );
-        t.setTag( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111110", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 0 );
-        t.setPrimitive( true );
-        t.setTag( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "01011110", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 31, 0 );
-        t.setTag( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "00011111" + "01111111", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 127, 0 );
-        t.setTag( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" + "01111111", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( 128, 0 );
-        t.setTag( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000000" + "10000001" + "01111111", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( BIT_13 - 1, 0 );
-        t.setTag( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" +
+    public void testSetTagBufferint() {
+        ByteBuffer bites = ByteBuffer.allocate(1);
+        Tuple t = new Tuple(0, 0);
+        t.setTag(bites, 1);
+        String binary = toAsciiString(bites);
+        assertEquals("01100000", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 0);
+        t.setTag(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("01111110", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 0);
+        t.setPrimitive(true);
+        t.setTag(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("01011110", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(31, 0);
+        t.setTag(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("00011111" + "01111111", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(127, 0);
+        t.setTag(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" + "01111111", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(128, 0);
+        t.setTag(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("00000000" + "10000001" + "01111111", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(BIT_13 - 1, 0);
+        t.setTag(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" +
                 "11111111" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( BIT_13, 0 );
-        t.setTag( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000000" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(BIT_13, 0);
+        t.setTag(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000000" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( BIT_13 + 1, 0 );
-        t.setTag( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(BIT_13 + 1, 0);
+        t.setTag(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( BIT_20 - 1, 0 );
-        t.setTag( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(BIT_20 - 1, 0);
+        t.setTag(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" +
                 "11111111" +
                 "11111111" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( BIT_20, 0 );
-        t.setTag( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000000" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(BIT_20, 0);
+        t.setTag(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000000" +
                 "10000000" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( BIT_20 + 1, 0 );
-        t.setTag( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(BIT_20 + 1, 0);
+        t.setTag(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "10000000" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( BIT_27 - 1, 0 );
-        t.setTag( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(BIT_27 - 1, 0);
+        t.setTag(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" +
                 "11111111" +
                 "11111111" +
                 "11111111" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 6 );
-        t = new Tuple( BIT_27, 0 );
+        bites = ByteBuffer.allocate(6);
+        t = new Tuple(BIT_27, 0);
 
-        try
-        {
-            t.setTag( bites, 6 );
-            fail( "should never reach this point due to thrown exception" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
+        try {
+            t.setTag(bites, 6);
+            fail("should never reach this point due to thrown exception");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e);
         }
     }
 
-    public void testSetTagbyteArrayint()
-    {
-        ByteBuffer bites = ByteBuffer.allocate( 1 );
-        Tuple t = new Tuple( 0, 0 );
-        t.setTag( bites, 1 );
-        String binary = toAsciiString( bites );
-        assertEquals( "01100000", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 0 );
-        t.setTag( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111110", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 0 );
-        t.setPrimitive( true );
-        t.setTag( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "01011110", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 31, 0 );
-        t.setTag( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "00011111" + "01111111", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 127, 0 );
-        t.setTag( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" + "01111111", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( 128, 0 );
-        t.setTag( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000000" + "10000001" + "01111111", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( BIT_13 - 1, 0 );
-        t.setTag( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" +
+    public void testSetTagbyteArrayint() {
+        ByteBuffer bites = ByteBuffer.allocate(1);
+        Tuple t = new Tuple(0, 0);
+        t.setTag(bites, 1);
+        String binary = toAsciiString(bites);
+        assertEquals("01100000", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 0);
+        t.setTag(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("01111110", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 0);
+        t.setPrimitive(true);
+        t.setTag(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("01011110", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(31, 0);
+        t.setTag(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("00011111" + "01111111", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(127, 0);
+        t.setTag(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" + "01111111", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(128, 0);
+        t.setTag(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("00000000" + "10000001" + "01111111", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(BIT_13 - 1, 0);
+        t.setTag(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" +
                 "11111111" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( BIT_13, 0 );
-        t.setTag( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000000" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(BIT_13, 0);
+        t.setTag(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000000" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( BIT_13 + 1, 0 );
-        t.setTag( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(BIT_13 + 1, 0);
+        t.setTag(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( BIT_20 - 1, 0 );
-        t.setTag( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(BIT_20 - 1, 0);
+        t.setTag(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" +
                 "11111111" +
                 "11111111" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( BIT_20, 0 );
-        t.setTag( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000000" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(BIT_20, 0);
+        t.setTag(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000000" +
                 "10000000" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( BIT_20 + 1, 0 );
-        t.setTag( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(BIT_20 + 1, 0);
+        t.setTag(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "10000000" +
                 "10000000" +
                 "10000001" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( BIT_27 - 1, 0 );
-        t.setTag( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(BIT_27 - 1, 0);
+        t.setTag(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("01111111" +
                 "11111111" +
                 "11111111" +
                 "11111111" +
-                "01111111", binary );
+                "01111111", binary);
 
-        bites = ByteBuffer.allocate( 6 );
-        t = new Tuple( BIT_27, 0 );
+        bites = ByteBuffer.allocate(6);
+        t = new Tuple(BIT_27, 0);
 
-        try
-        {
-            t.setTag( bites, 6 );
-            fail( "should never reach this point due to thrown exception" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
+        try {
+            t.setTag(bites, 6);
+            fail("should never reach this point due to thrown exception");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e);
         }
     }
 
 
-    String toAsciiString( int raw )
-    {
+    String toAsciiString(int raw) {
         byte[] intBytes = new byte[4];
-        intBytes[0] = (byte) ( (int) 0x000000ff & raw );
-        intBytes[1] = (byte) ( (int) ( 0x0000ff00 & raw ) >> 8 );
-        intBytes[2] = (byte) ( (int) ( 0x00ff0000 & raw ) >> 16 );
-        intBytes[3] = (byte) ( (int) ( 0xff000000 & raw ) >> 24 );
-
-        return Binary.toAsciiString( intBytes );
-    }
-
-
-    public void testSetLengthBuffer()
-    {
-        ByteBuffer bites = ByteBuffer.allocate( 1 );
-        Tuple t = new Tuple( 0, 0 );
-        t.setLength( bites, 1 );
-        String binary = toAsciiString( bites );
-        assertEquals( "00000000", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 15 );
-        t.setLength( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "00001111", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 127 );
-        t.setLength( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 30, 128 );
-        t.setLength( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "10000000" +
-                "10000001", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 30, 255 );
-        t.setLength( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "11111111" +
-                "10000001", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( 30, 256 );
-        t.setLength( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
-                "00000000" +
-                "10000010", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( 30, BIT_15 - 1 );
-        t.setLength( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "11111111" +
-                "11111111" +
-                "10000010", binary );
-
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( 30, BIT_15 );
-        t.setLength( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
-                "00000000" +
-                "00000000" +
-                "10000011", binary );
-
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( 30, BIT_15 + 1 );
-        t.setLength( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        intBytes[0] = (byte) ((int) 0x000000ff & raw);
+        intBytes[1] = (byte) ((int) (0x0000ff00 & raw) >> 8);
+        intBytes[2] = (byte) ((int) (0x00ff0000 & raw) >> 16);
+        intBytes[3] = (byte) ((int) (0xff000000 & raw) >> 24);
+
+        return BinaryCodec.toAsciiString(intBytes);
+    }
+
+
+    public void testSetLengthBuffer() {
+        ByteBuffer bites = ByteBuffer.allocate(1);
+        Tuple t = new Tuple(0, 0);
+        t.setLength(bites, 1);
+        String binary = toAsciiString(bites);
+        assertEquals("00000000", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 15);
+        t.setLength(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("00001111", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 127);
+        t.setLength(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("01111111", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(30, 128);
+        t.setLength(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("10000000" +
+                "10000001", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(30, 255);
+        t.setLength(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("11111111" +
+                "10000001", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(30, 256);
+        t.setLength(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
+                "00000000" +
+                "10000010", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(30, BIT_15 - 1);
+        t.setLength(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("11111111" +
+                "11111111" +
+                "10000010", binary);
+
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(30, BIT_15);
+        t.setLength(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
+                "00000000" +
+                "00000000" +
+                "10000011", binary);
+
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(30, BIT_15 + 1);
+        t.setLength(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "00000000" +
                 "00000001" +
-                "10000011", binary );
+                "10000011", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( 30, BIT_23 - 1 );
-        t.setLength( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "11111111" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(30, BIT_23 - 1);
+        t.setLength(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("11111111" +
                 "11111111" +
                 "11111111" +
-                "10000011", binary );
+                "10000011", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( 30, BIT_23 );
-        t.setLength( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(30, BIT_23);
+        t.setLength(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "00000000" +
                 "00000000" +
                 "00000000" +
-                "10000100", binary );
+                "10000100", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( 30, BIT_23 + 1 );
-        t.setLength( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(30, BIT_23 + 1);
+        t.setLength(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "00000000" +
                 "00000000" +
                 "00000001" +
-                "10000100", binary );
-
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( 30, Integer.MAX_VALUE );
-        t.setLength( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( toAsciiString( Integer.MAX_VALUE ) +
-                "10000100", binary );
-
-
-        bites = ByteBuffer.allocate( 6 );
-        t = new Tuple( 30, Integer.MAX_VALUE + 1 );
-
-        try
-        {
-            t.setLength( bites, 6 );
-            fail( "should never get here due to thrown exception" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
-        }
-    }
+                "10000100", binary);
 
-    public void testSetLengthbyteArrayintint()
-    {
-        ByteBuffer bites = ByteBuffer.allocate( 1 );
-        Tuple t = new Tuple( 0, 0 );
-        t.setLength( bites, 1 );
-        String binary = toAsciiString( bites );
-        assertEquals( "00000000", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 15 );
-        t.setLength( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "00001111", binary );
-
-        bites = ByteBuffer.allocate( 1 );
-        t = new Tuple( 30, 127 );
-        t.setLength( bites, 1 );
-        binary = toAsciiString( bites );
-        assertEquals( "01111111", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 30, 128 );
-        t.setLength( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "10000000" +
-                "10000001", binary );
-
-        bites = ByteBuffer.allocate( 2 );
-        t = new Tuple( 30, 255 );
-        t.setLength( bites, 2 );
-        binary = toAsciiString( bites );
-        assertEquals( "11111111" +
-                "10000001", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( 30, 256 );
-        t.setLength( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
-                "00000000" +
-                "10000010", binary );
-
-        bites = ByteBuffer.allocate( 3 );
-        t = new Tuple( 30, BIT_15 - 1 );
-        t.setLength( bites, 3 );
-        binary = toAsciiString( bites );
-        assertEquals( "11111111" +
-                "11111111" +
-                "10000010", binary );
-
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( 30, BIT_15 );
-        t.setLength( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
-                "00000000" +
-                "00000000" +
-                "10000011", binary );
-
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( 30, BIT_15 + 1 );
-        t.setLength( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(30, Integer.MAX_VALUE);
+        t.setLength(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals(toAsciiString(Integer.MAX_VALUE) +
+                "10000100", binary);
+
+
+        bites = ByteBuffer.allocate(6);
+        t = new Tuple(30, Integer.MAX_VALUE + 1);
+
+        try {
+            t.setLength(bites, 6);
+            fail("should never get here due to thrown exception");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e);
+        }
+    }
+
+    public void testSetLengthbyteArrayintint() {
+        ByteBuffer bites = ByteBuffer.allocate(1);
+        Tuple t = new Tuple(0, 0);
+        t.setLength(bites, 1);
+        String binary = toAsciiString(bites);
+        assertEquals("00000000", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 15);
+        t.setLength(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("00001111", binary);
+
+        bites = ByteBuffer.allocate(1);
+        t = new Tuple(30, 127);
+        t.setLength(bites, 1);
+        binary = toAsciiString(bites);
+        assertEquals("01111111", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(30, 128);
+        t.setLength(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("10000000" +
+                "10000001", binary);
+
+        bites = ByteBuffer.allocate(2);
+        t = new Tuple(30, 255);
+        t.setLength(bites, 2);
+        binary = toAsciiString(bites);
+        assertEquals("11111111" +
+                "10000001", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(30, 256);
+        t.setLength(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
+                "00000000" +
+                "10000010", binary);
+
+        bites = ByteBuffer.allocate(3);
+        t = new Tuple(30, BIT_15 - 1);
+        t.setLength(bites, 3);
+        binary = toAsciiString(bites);
+        assertEquals("11111111" +
+                "11111111" +
+                "10000010", binary);
+
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(30, BIT_15);
+        t.setLength(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
+                "00000000" +
+                "00000000" +
+                "10000011", binary);
+
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(30, BIT_15 + 1);
+        t.setLength(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "00000000" +
                 "00000001" +
-                "10000011", binary );
+                "10000011", binary);
 
-        bites = ByteBuffer.allocate( 4 );
-        t = new Tuple( 30, BIT_23 - 1 );
-        t.setLength( bites, 4 );
-        binary = toAsciiString( bites );
-        assertEquals( "11111111" +
+        bites = ByteBuffer.allocate(4);
+        t = new Tuple(30, BIT_23 - 1);
+        t.setLength(bites, 4);
+        binary = toAsciiString(bites);
+        assertEquals("11111111" +
                 "11111111" +
                 "11111111" +
-                "10000011", binary );
+                "10000011", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( 30, BIT_23 );
-        t.setLength( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(30, BIT_23);
+        t.setLength(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "00000000" +
                 "00000000" +
                 "00000000" +
-                "10000100", binary );
+                "10000100", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( 30, BIT_23 + 1 );
-        t.setLength( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( "00000001" +
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(30, BIT_23 + 1);
+        t.setLength(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals("00000001" +
                 "00000000" +
                 "00000000" +
                 "00000001" +
-                "10000100", binary );
+                "10000100", binary);
 
-        bites = ByteBuffer.allocate( 5 );
-        t = new Tuple( 30, Integer.MAX_VALUE );
-        t.setLength( bites, 5 );
-        binary = toAsciiString( bites );
-        assertEquals( toAsciiString( Integer.MAX_VALUE ) +
-                "10000100", binary );
-
-
-        bites = ByteBuffer.allocate( 6 );
-        t = new Tuple( 30, Integer.MAX_VALUE + 1 );
-
-        try
-        {
-            t.setLength( bites, 6 );
-            fail( "should never get here due to thrown exception" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
+        bites = ByteBuffer.allocate(5);
+        t = new Tuple(30, Integer.MAX_VALUE);
+        t.setLength(bites, 5);
+        binary = toAsciiString(bites);
+        assertEquals(toAsciiString(Integer.MAX_VALUE) +
+                "10000100", binary);
+
+
+        bites = ByteBuffer.allocate(6);
+        t = new Tuple(30, Integer.MAX_VALUE + 1);
+
+        try {
+            t.setLength(bites, 6);
+            fail("should never get here due to thrown exception");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e);
         }
     }
 
-    public void testGetTagLength()
-    {
+    public void testGetTagLength() {
         Tuple t = new Tuple();
-        assertEquals( 1, t.getTagLength() );
-        t.setId( 30 );
-        assertEquals( 1, t.getTagLength() );
-        t.setId( 31 );
-        assertEquals( 2, t.getTagLength() );
-        t.setId( 100 );
-        assertEquals( 3, t.getTagLength() );
-        t.setId( 127 );
-        assertEquals( 3, t.getTagLength() );
-        t.setId( 128 );
-        assertEquals( 3, t.getTagLength() );
-        t.setId( 129 );
-        assertEquals( 3, t.getTagLength() );
-
-        t.setId( BIT_13 - 1 );
-        assertEquals( 3, t.getTagLength() );
-        t.setId( BIT_13 );
-        assertEquals( 4, t.getTagLength() );
-        t.setId( BIT_13 + 100 );
-        assertEquals( 4, t.getTagLength() );
-
-        t.setId( BIT_20 - 1 );
-        assertEquals( 4, t.getTagLength() );
-        t.setId( BIT_20 );
-        assertEquals( 5, t.getTagLength() );
-        t.setId( BIT_20 + 100 );
-        assertEquals( 5, t.getTagLength() );
-
-        t.setId( BIT_27 - 1 );
-        assertEquals( 5, t.getTagLength() );
-
-        t.setId( BIT_27 );
-
-        try
-        {
-            assertEquals( 6, t.getTagLength() );
-            fail( "should throw an exception before getting here" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
+        assertEquals(1, t.getTagLength());
+        t.setId(30);
+        assertEquals(1, t.getTagLength());
+        t.setId(31);
+        assertEquals(2, t.getTagLength());
+        t.setId(100);
+        assertEquals(3, t.getTagLength());
+        t.setId(127);
+        assertEquals(3, t.getTagLength());
+        t.setId(128);
+        assertEquals(3, t.getTagLength());
+        t.setId(129);
+        assertEquals(3, t.getTagLength());
+
+        t.setId(BIT_13 - 1);
+        assertEquals(3, t.getTagLength());
+        t.setId(BIT_13);
+        assertEquals(4, t.getTagLength());
+        t.setId(BIT_13 + 100);
+        assertEquals(4, t.getTagLength());
+
+        t.setId(BIT_20 - 1);
+        assertEquals(4, t.getTagLength());
+        t.setId(BIT_20);
+        assertEquals(5, t.getTagLength());
+        t.setId(BIT_20 + 100);
+        assertEquals(5, t.getTagLength());
+
+        t.setId(BIT_27 - 1);
+        assertEquals(5, t.getTagLength());
+
+        t.setId(BIT_27);
+
+        try {
+            assertEquals(6, t.getTagLength());
+            fail("should throw an exception before getting here");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e);
         }
     }
 
-    public void testGetLengthLength()
-    {
+    public void testGetLengthLength() {
         Tuple t = new Tuple();
-        assertEquals( 1, t.getLengthLength() );
-        t.setLength( 127 );
-        assertEquals( 1, t.getLengthLength() );
-        t.setLength( 128 );
-        assertEquals( 2, t.getLengthLength() );
-        t.setLength( 255 );
-        assertEquals( 2, t.getLengthLength() );
-        t.setLength( 256 );
-        assertEquals( 3, t.getLengthLength() );
-
-        t.setLength( BIT_15 - 1 );
-        assertEquals( 3, t.getLengthLength() );
-        t.setLength( BIT_15 );
-        assertEquals( 4, t.getLengthLength() );
-        t.setLength( BIT_15 + 100 );
-        assertEquals( 4, t.getLengthLength() );
-
-        t.setLength( BIT_23 - 1 );
-        assertEquals( 4, t.getLengthLength() );
-        t.setLength( BIT_23 );
-        assertEquals( 5, t.getLengthLength() );
-        t.setLength( BIT_23 + 100 );
-        assertEquals( 5, t.getLengthLength() );
-
-        t.setLength( Integer.MAX_VALUE );
-        assertEquals( 5, t.getLengthLength() );
-
-
-        t.setLength( Integer.MAX_VALUE + 1 );
-        try
-        {
-            assertEquals( 6, t.getLengthLength() );
-            fail( "should throw an exception before getting here" );
-        }
-        catch ( IllegalArgumentException e )
-        {
-            assertNotNull( e );
+        assertEquals(1, t.getLengthLength());
+        t.setLength(127);
+        assertEquals(1, t.getLengthLength());
+        t.setLength(128);
+        assertEquals(2, t.getLengthLength());
+        t.setLength(255);
+        assertEquals(2, t.getLengthLength());
+        t.setLength(256);
+        assertEquals(3, t.getLengthLength());
+
+        t.setLength(BIT_15 - 1);
+        assertEquals(3, t.getLengthLength());
+        t.setLength(BIT_15);
+        assertEquals(4, t.getLengthLength());
+        t.setLength(BIT_15 + 100);
+        assertEquals(4, t.getLengthLength());
+
+        t.setLength(BIT_23 - 1);
+        assertEquals(4, t.getLengthLength());
+        t.setLength(BIT_23);
+        assertEquals(5, t.getLengthLength());
+        t.setLength(BIT_23 + 100);
+        assertEquals(5, t.getLengthLength());
+
+        t.setLength(Integer.MAX_VALUE);
+        assertEquals(5, t.getLengthLength());
+
+
+        t.setLength(Integer.MAX_VALUE + 1);
+        try {
+            assertEquals(6, t.getLengthLength());
+            fail("should throw an exception before getting here");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e);
         }
 
     }



Mime
View raw message