You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/01/24 17:15:29 UTC

svn commit: r1235326 [21/28] - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partitio...

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeBodyDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeBodyDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeBodyDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeBodyDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.kerberos.codec;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -38,6 +39,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 
+
 /**
  * Test cases for KrbSafeBody codec.
  *
@@ -49,55 +51,104 @@ public class KrbSafeBodyDecoderTest
     public void testDecodeKrbSafeBody() throws Exception
     {
         Asn1Decoder decoder = new Asn1Decoder();
-        
+
         int streamLen = 0x47;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
-        {
-            0x30, 0x45,
-              (byte)0xA0, 0x4,        // user-data
-                     0x04, 0x02, 0x00, 0x01,
-              (byte)0xA1, 0x11,       // timestamp
-                     0x18, 0xF, '2', '0', '1', '0', '1', '1', '1', '9', '0', '8', '0', '0', '4', '3', 'Z',
-              (byte)0xA2, 0x03,       // usec
-                     0x02, 0x01, 0x01,
-              (byte)0xA3, 0x03,       // seq-number
-                     0x02, 0x01, 0x01,
-              (byte)0xA4, 0xF,        // s-address
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1,
-              (byte)0xA5, 0xF,        // r-adress
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1
+            {
+                0x30, 0x45,
+                ( byte ) 0xA0, 0x4, // user-data
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                ( byte ) 0xA1,
+                0x11, // timestamp
+                0x18,
+                0xF,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '1',
+                '1',
+                '9',
+                '0',
+                '8',
+                '0',
+                '0',
+                '4',
+                '3',
+                'Z',
+                ( byte ) 0xA2,
+                0x03, // usec
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA3,
+                0x03, // seq-number
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA4,
+                0xF, // s-address
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+                ( byte ) 0xA5,
+                0xF, // r-adress
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1
         } );
 
-        String decoded = Strings.dumpBytes(stream.array());
+        String decoded = Strings.dumpBytes( stream.array() );
         stream.flip();
-        
+
         KrbSafeBodyContainer container = new KrbSafeBodyContainer();
         container.setStream( stream );
-        
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             fail();
         }
-        
+
         KrbSafeBody body = container.getKrbSafeBody();
-        
+
         String time = "20101119080043Z";
         HostAddress ad = new HostAddress( InetAddress.getByName( "127.0.0.1" ) );
-        
-        assertTrue( Arrays.equals( new byte[]{0,1}, body.getUserData() ) );
+
+        assertTrue( Arrays.equals( new byte[]
+            { 0, 1 }, body.getUserData() ) );
         assertEquals( time, body.getTimestamp().getDate() );
         assertEquals( 1, body.getUsec() );
         assertEquals( 1, body.getSeqNumber() );
@@ -105,76 +156,108 @@ public class KrbSafeBodyDecoderTest
         assertEquals( ad, body.getRecipientAddress() );
 
         int computedLen = body.computeLength();
-        
+
         assertEquals( streamLen, computedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( computedLen );
-            
+
             body.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }
     }
-    
-    
+
+
     @Test
     public void testDecodeKrbSafeBodyWithoutTimestamp() throws Exception
     {
         Asn1Decoder decoder = new Asn1Decoder();
-        
+
         int streamLen = 0x34;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
-        {
-            0x30, 0x32,
-              (byte)0xA0, 0x4,        // user-data
-                     0x04, 0x02, 0x00, 0x01,
-                     // NO timestamp
-              (byte)0xA2, 0x03,       // usec
-                     0x02, 0x01, 0x01,
-              (byte)0xA3, 0x03,       // seq-number
-                     0x02, 0x01, 0x01,
-              (byte)0xA4, 0xF,        // s-address
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1,
-              (byte)0xA5, 0xF,        // r-adress
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1
+            {
+                0x30, 0x32,
+                ( byte ) 0xA0, 0x4, // user-data
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                // NO timestamp
+                ( byte ) 0xA2,
+                0x03, // usec
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA3,
+                0x03, // seq-number
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA4,
+                0xF, // s-address
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+                ( byte ) 0xA5,
+                0xF, // r-adress
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1
         } );
 
-        String decoded = Strings.dumpBytes(stream.array());
+        String decoded = Strings.dumpBytes( stream.array() );
         stream.flip();
-        
+
         KrbSafeBodyContainer container = new KrbSafeBodyContainer();
         container.setStream( stream );
-        
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             fail();
         }
-        
+
         KrbSafeBody body = container.getKrbSafeBody();
-        
+
         HostAddress ad = new HostAddress( InetAddress.getByName( "127.0.0.1" ) );
-        
-        assertTrue( Arrays.equals( new byte[]{0,1}, body.getUserData() ) );
+
+        assertTrue( Arrays.equals( new byte[]
+            { 0, 1 }, body.getUserData() ) );
         assertNull( body.getTimestamp() );
         assertEquals( 1, body.getUsec() );
         assertEquals( 1, body.getSeqNumber() );
@@ -182,74 +265,103 @@ public class KrbSafeBodyDecoderTest
         assertEquals( ad, body.getRecipientAddress() );
 
         int computedLen = body.computeLength();
-        
+
         assertEquals( streamLen, computedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( computedLen );
-            
+
             body.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }
     }
 
-    
+
     @Test
     public void testDecodeKrbSafeBodyWithoutTimestampAndUsec() throws Exception
     {
         Asn1Decoder decoder = new Asn1Decoder();
-        
+
         int streamLen = 0x2F;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
-        {
-            0x30, 0x2D,
-              (byte)0xA0, 0x4,        // user-data
-                     0x04, 0x02, 0x00, 0x01,
-                     // NO timestamp and usec
-              (byte)0xA3, 0x03,       // seq-number
-                     0x02, 0x01, 0x01,
-              (byte)0xA4, 0xF,        // s-address
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1,
-              (byte)0xA5, 0xF,        // r-adress
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1
+            {
+                0x30, 0x2D,
+                ( byte ) 0xA0, 0x4, // user-data
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                // NO timestamp and usec
+                ( byte ) 0xA3,
+                0x03, // seq-number
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA4,
+                0xF, // s-address
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+                ( byte ) 0xA5,
+                0xF, // r-adress
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1
         } );
 
-        String decoded = Strings.dumpBytes(stream.array());
+        String decoded = Strings.dumpBytes( stream.array() );
         stream.flip();
-        
+
         KrbSafeBodyContainer container = new KrbSafeBodyContainer();
         container.setStream( stream );
-        
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             fail();
         }
-        
+
         KrbSafeBody body = container.getKrbSafeBody();
-        
+
         HostAddress ad = new HostAddress( InetAddress.getByName( "127.0.0.1" ) );
-        
-        assertTrue( Arrays.equals( new byte[]{0,1}, body.getUserData() ) );
+
+        assertTrue( Arrays.equals( new byte[]
+            { 0, 1 }, body.getUserData() ) );
         assertNull( body.getTimestamp() );
         assertEquals( 0, body.getUsec() );
         assertEquals( 1, body.getSeqNumber() );
@@ -257,73 +369,99 @@ public class KrbSafeBodyDecoderTest
         assertEquals( ad, body.getRecipientAddress() );
 
         int computedLen = body.computeLength();
-        
+
         assertEquals( streamLen, computedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( computedLen );
-            
+
             body.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }
     }
 
-    
+
     @Test
     public void testDecodeKrbSafeBodyWithoutTimestampUsecAndSeqNumber() throws Exception
     {
         Asn1Decoder decoder = new Asn1Decoder();
-        
+
         int streamLen = 0x2A;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
-        {
-            0x30, 0x28,
-              (byte)0xA0, 0x4,        // user-data
-                     0x04, 0x02, 0x00, 0x01,
-                     // NO timestamp, usec and seq-number
-              (byte)0xA4, 0xF,        // s-address
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1,
-              (byte)0xA5, 0xF,        // r-adress
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1
+            {
+                0x30, 0x28,
+                ( byte ) 0xA0, 0x4, // user-data
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                // NO timestamp, usec and seq-number
+                ( byte ) 0xA4,
+                0xF, // s-address
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+                ( byte ) 0xA5,
+                0xF, // r-adress
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1
         } );
 
-        String decoded = Strings.dumpBytes(stream.array());
+        String decoded = Strings.dumpBytes( stream.array() );
         stream.flip();
-        
+
         KrbSafeBodyContainer container = new KrbSafeBodyContainer();
         container.setStream( stream );
-        
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             e.printStackTrace();
             fail();
         }
-        
+
         KrbSafeBody body = container.getKrbSafeBody();
-        
+
         HostAddress ad = new HostAddress( InetAddress.getByName( "127.0.0.1" ) );
-        
-        assertTrue( Arrays.equals( new byte[]{0,1}, body.getUserData() ) );
+
+        assertTrue( Arrays.equals( new byte[]
+            { 0, 1 }, body.getUserData() ) );
         assertNull( body.getTimestamp() );
         assertEquals( 0, body.getUsec() );
         assertEquals( 0, body.getSeqNumber() );
@@ -331,77 +469,123 @@ public class KrbSafeBodyDecoderTest
         assertEquals( ad, body.getRecipientAddress() );
 
         int computedLen = body.computeLength();
-        
+
         assertEquals( streamLen, computedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( computedLen );
-            
+
             body.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }
     }
 
-    
+
     @Test
     public void testDecodeKrbSafeBodyWithoutSequenceNumber() throws Exception
     {
         Asn1Decoder decoder = new Asn1Decoder();
-        
+
         int streamLen = 0x42;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
-        {
-            0x30, 0x40,
-              (byte)0xA0, 0x4,        // user-data
-                     0x04, 0x02, 0x00, 0x01,
-              (byte)0xA1, 0x11,       // timestamp
-                     0x18, 0xF, '2', '0', '1', '0', '1', '1', '1', '9', '0', '8', '0', '0', '4', '3', 'Z',
-              (byte)0xA2, 0x03,       // usec
-                     0x02, 0x01, 0x01,
-                     // NO seq-number
-              (byte)0xA4, 0xF,        // s-address
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1,
-              (byte)0xA5, 0xF,        // r-adress
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1
+            {
+                0x30, 0x40,
+                ( byte ) 0xA0, 0x4, // user-data
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                ( byte ) 0xA1,
+                0x11, // timestamp
+                0x18,
+                0xF,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '1',
+                '1',
+                '9',
+                '0',
+                '8',
+                '0',
+                '0',
+                '4',
+                '3',
+                'Z',
+                ( byte ) 0xA2,
+                0x03, // usec
+                0x02,
+                0x01,
+                0x01,
+                // NO seq-number
+                ( byte ) 0xA4,
+                0xF, // s-address
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+                ( byte ) 0xA5,
+                0xF, // r-adress
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1
         } );
 
-        String decoded = Strings.dumpBytes(stream.array());
+        String decoded = Strings.dumpBytes( stream.array() );
         stream.flip();
-        
+
         KrbSafeBodyContainer container = new KrbSafeBodyContainer();
         container.setStream( stream );
-        
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             fail();
         }
-        
+
         KrbSafeBody body = container.getKrbSafeBody();
-        
+
         String time = "20101119080043Z";
         HostAddress ad = new HostAddress( InetAddress.getByName( "127.0.0.1" ) );
-        
-        assertTrue( Arrays.equals( new byte[]{0,1}, body.getUserData() ) );
+
+        assertTrue( Arrays.equals( new byte[]
+            { 0, 1 }, body.getUserData() ) );
         assertEquals( time, body.getTimestamp().getDate() );
         assertEquals( 1, body.getUsec() );
         assertEquals( 0, body.getSeqNumber() );
@@ -409,68 +593,83 @@ public class KrbSafeBodyDecoderTest
         assertEquals( ad, body.getRecipientAddress() );
 
         int computedLen = body.computeLength();
-        
+
         assertEquals( streamLen, computedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( computedLen );
-            
+
             body.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }
     }
 
-    
+
     @Test
     public void testDecodeKrbSafeBodyWithoutOptionalValues() throws Exception
     {
         Asn1Decoder decoder = new Asn1Decoder();
-        
+
         int streamLen = 0x19;
         ByteBuffer stream = ByteBuffer.allocate( streamLen );
         stream.put( new byte[]
-        {
-            0x30, 0x17,
-              (byte)0xA0, 0x4,        // user-data
-                     0x04, 0x02, 0x00, 0x01,
-                     // NO timestamp, usec and seq-number
-              (byte)0xA4, 0xF,        // s-address
-                     0x30, 0x0D,
-                      (byte)0xA0, 0x03,
-                             0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                              0x04, 0x04, 127, 0, 0, 1,
-                    // NO r-address
+            {
+                0x30, 0x17,
+                ( byte ) 0xA0, 0x4, // user-data
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                // NO timestamp, usec and seq-number
+                ( byte ) 0xA4,
+                0xF, // s-address
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+            // NO r-address
         } );
 
-        String decoded = Strings.dumpBytes(stream.array());
+        String decoded = Strings.dumpBytes( stream.array() );
         stream.flip();
-        
+
         KrbSafeBodyContainer container = new KrbSafeBodyContainer();
         container.setStream( stream );
-        
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             e.printStackTrace();
             fail();
         }
-        
+
         KrbSafeBody body = container.getKrbSafeBody();
-        
+
         HostAddress ad = new HostAddress( InetAddress.getByName( "127.0.0.1" ) );
-        
-        assertTrue( Arrays.equals( new byte[]{0,1}, body.getUserData() ) );
+
+        assertTrue( Arrays.equals( new byte[]
+            { 0, 1 }, body.getUserData() ) );
         assertNull( body.getTimestamp() );
         assertEquals( 0, body.getUsec() );
         assertEquals( 0, body.getSeqNumber() );
@@ -478,19 +677,19 @@ public class KrbSafeBodyDecoderTest
         assertNull( body.getRecipientAddress() );
 
         int computedLen = body.computeLength();
-        
+
         assertEquals( streamLen, computedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( computedLen );
-            
+
             body.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbSafeDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -36,6 +36,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 
+
 /**
  * Test cases for KrbSafe codec
  *
@@ -47,92 +48,130 @@ public class KrbSafeDecoderTest
     @Test
     public void testDecodeKrbSafe()
     {
-        byte[] data = new byte[]{
-            0x74, 0x36,
-              0x30, 0x34,
-               (byte)0xA0, 0x03,        // pvno
-                 0x02, 0x01, 0x05,
-               (byte)0xA1, 0x03,        // msg-type
-                 0x02, 0x01, 0x14,
-               (byte)0xA2, 0x19,        // safe-body
-                 0x30, 0x17,
-                   (byte)0xA0, 0x04,
-                     0x04, 0x02, 0x00, 0x01,
-                   (byte)0xA4, 0x0F,
-                     0x30, 0x0D,
-                       (byte)0xA0, 0x03, 
-                         0x02, 0x01, 0x02,
-                       (byte)0xA1, 0x06,
-                         0x04, 0x04, 127, 0, 0, 1, 
-               (byte)0xA3, 0x0D,        // cksum
-                 0x30, 0x0B,
-                   (byte)0xA0, 0x03,
-                     0x02, 0x01, 0x01,
-                   (byte)0xA1, 0x04,
-                     0x04, 0x02, 0x00, 0x01 
+        byte[] data = new byte[]
+            {
+                0x74, 0x36,
+                0x30, 0x34,
+                ( byte ) 0xA0, 0x03, // pvno
+                0x02,
+                0x01,
+                0x05,
+                ( byte ) 0xA1,
+                0x03, // msg-type
+                0x02,
+                0x01,
+                0x14,
+                ( byte ) 0xA2,
+                0x19, // safe-body
+                0x30,
+                0x17,
+                ( byte ) 0xA0,
+                0x04,
+                0x04,
+                0x02,
+                0x00,
+                0x01,
+                ( byte ) 0xA4,
+                0x0F,
+                0x30,
+                0x0D,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x06,
+                0x04,
+                0x04,
+                127,
+                0,
+                0,
+                1,
+                ( byte ) 0xA3,
+                0x0D, // cksum
+                0x30,
+                0x0B,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA1,
+                0x04,
+                0x04,
+                0x02,
+                0x00,
+                0x01
         };
-        
-        String decoded = Strings.dumpBytes(data);
+
+        String decoded = Strings.dumpBytes( data );
         int streamLen = data.length;
         ByteBuffer stream = ByteBuffer.wrap( data );
-        
+
         Asn1Decoder decoder = new Asn1Decoder();
-        
-        KrbSafeContainer container = new  KrbSafeContainer( stream );
-        
+
+        KrbSafeContainer container = new KrbSafeContainer( stream );
+
         try
         {
             decoder.decode( stream, container );
         }
-        catch( DecoderException e )
+        catch ( DecoderException e )
         {
             e.printStackTrace();
             fail();
         }
-        
+
         KrbSafe krbSafe = container.getKrbSafe();
-        
+
         assertEquals( 5, krbSafe.getProtocolVersionNumber() );
         assertEquals( KerberosMessageType.KRB_SAFE, krbSafe.getMessageType() );
         assertNotNull( krbSafe.getChecksum() );
         assertNotNull( krbSafe.getSafeBody() );
-        
+
         int encodedLen = krbSafe.computeLength();
         assertEquals( streamLen, encodedLen );
-        
+
         try
         {
             ByteBuffer bb = ByteBuffer.allocate( encodedLen );
             krbSafe.encode( bb );
-            
-            String encoded = Strings.dumpBytes(bb.array());
+
+            String encoded = Strings.dumpBytes( bb.array() );
             assertEquals( decoded, encoded );
         }
-        catch( EncoderException e )
+        catch ( EncoderException e )
         {
             fail();
         }
     }
-    
-    
-    @Test( expected = DecoderException.class)
+
+
+    @Test(expected = DecoderException.class)
     public void testDecodeKrbSafeWithIncorrectPdu() throws DecoderException
     {
-        byte[] data = new byte[]{
-            0x74, 0xC,
-              0x30, 0xA,
-               (byte)0xA0, 0x03,        // pvno
-                 0x02, 0x01, 0x05,
-               (byte)0xA1, 0x03,        // msg-type
-                 0x02, 0x01, 0x14,
+        byte[] data = new byte[]
+            {
+                0x74, 0xC,
+                0x30, 0xA,
+                ( byte ) 0xA0, 0x03, // pvno
+                0x02,
+                0x01,
+                0x05,
+                ( byte ) 0xA1,
+                0x03, // msg-type
+                0x02,
+                0x01,
+                0x14,
         };
-        
+
         ByteBuffer stream = ByteBuffer.wrap( data );
-        
+
         Asn1Decoder decoder = new Asn1Decoder();
-        
-        KrbSafeContainer container = new  KrbSafeContainer( stream );
-        
+
+        KrbSafeContainer container = new KrbSafeContainer( stream );
+
         decoder.decode( stream, container );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/LastReqDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.kerberos.codec;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
@@ -36,6 +37,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 
+
 /**
  * Test cases for LastReq decoder.
  *
@@ -50,27 +52,67 @@ public class LastReqDecoderTest
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x36 );
-        
+
         stream.put( new byte[]
-            { 
-              0x30, 0x34,
-                0x30, 0x18,
-                  (byte)0xA0, 0x03,                 // lr-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA1, 0x11,                 // lr-value
-                    0x18, 0x0F, '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z', 
+            {
+                0x30, 0x34,
                 0x30, 0x18,
-                  (byte)0xA0, 0x03,                 // lr-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA1, 0x11,                 // lr-value
-                    0x18, 0x0F, '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '6', 'Z'
-            } );
+                ( byte ) 0xA0, 0x03, // lr-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x11, // lr-value
+                0x18,
+                0x0F,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '1',
+                '1',
+                '0',
+                '1',
+                '5',
+                '4',
+                '5',
+                '2',
+                '5',
+                'Z',
+                0x30,
+                0x18,
+                ( byte ) 0xA0,
+                0x03, // lr-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x11, // lr-value
+                0x18,
+                0x0F,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '1',
+                '1',
+                '0',
+                '1',
+                '5',
+                '4',
+                '5',
+                '2',
+                '6',
+                'Z'
+        } );
 
-        String decodedPdu = Strings.dumpBytes(stream.array());
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         LastReqContainer lastReqContainer = new LastReqContainer();
-        
+
         // Decode the LastReq PDU
         try
         {
@@ -82,32 +124,33 @@ public class LastReqDecoderTest
         }
 
         LastReq lastReq = lastReqContainer.getLastReq();
-        
+
         assertNotNull( lastReq.getLastReqs().size() );
         assertEquals( 2, lastReq.getLastReqs().size() );
-        
-        String[] expected = new String[]{ "20101110154525Z", "20101110154526Z" };
+
+        String[] expected = new String[]
+            { "20101110154525Z", "20101110154526Z" };
         int i = 0;
-        
+
         for ( LastReqEntry lre : lastReq.getLastReqs() )
         {
             assertEquals( LastReqType.TIME_OF_INITIAL_REQ, lre.getLrType() );
             assertEquals( expected[i++], lre.getLrValue().toString() );
-            
+
         }
 
         // Check the encoding
         ByteBuffer bb = ByteBuffer.allocate( lastReq.computeLength() );
-        
+
         try
         {
             bb = lastReq.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x36, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
@@ -115,117 +158,157 @@ public class LastReqDecoderTest
             fail();
         }
     }
-    
-    
-    @Test( expected = DecoderException.class)
+
+
+    @Test(expected = DecoderException.class)
     public void testLastReqWithoutType() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x15 );
-        
+
         stream.put( new byte[]
-            { 
-              0x30, 0x13,
-                (byte)0xA1, 0x11,                 // lr-value
-                  0x18, 0x0F, '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '6', 'Z'
-            } );
+            {
+                0x30, 0x13,
+                ( byte ) 0xA1, 0x11, // lr-value
+                0x18,
+                0x0F,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '1',
+                '1',
+                '0',
+                '1',
+                '5',
+                '4',
+                '5',
+                '2',
+                '6',
+                'Z'
+        } );
 
         stream.flip();
 
         LastReqContainer lastReqContainer = new LastReqContainer();
-        
+
         kerberosDecoder.decode( stream, lastReqContainer );
         fail();
     }
-    
-    
-    @Test( expected = DecoderException.class)
+
+
+    @Test(expected = DecoderException.class)
     public void testLastReqWithoutValue() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x05,
-                (byte)0xA0, 0x03,                 // lr-type
-                  0x02, 0x01, 0x02
-            } );
+                ( byte ) 0xA0, 0x03, // lr-type
+                0x02,
+                0x01,
+                0x02
+        } );
 
         stream.flip();
 
         LastReqContainer lastReqContainer = new LastReqContainer();
-        
+
         kerberosDecoder.decode( stream, lastReqContainer );
         fail();
     }
 
-    
-    @Test( expected = DecoderException.class)
+
+    @Test(expected = DecoderException.class)
     public void testLastReqWithIncorrectPdu() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x00 } );
 
         stream.flip();
 
         LastReqContainer lastReqContainer = new LastReqContainer();
-        
+
         kerberosDecoder.decode( stream, lastReqContainer );
         fail();
     }
 
-    
-    @Test( expected = DecoderException.class)
+
+    @Test(expected = DecoderException.class)
     public void testLastReqWithEmptyValue() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0xB );
-        
+
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x09,
-                  (byte)0xA0, 0x03,                 // lr-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA1, 0x02,                 // lr-value
-                    0x18, 0x00
-            } );
+                ( byte ) 0xA0, 0x03, // lr-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA1,
+                0x02, // lr-value
+                0x18,
+                0x00
+        } );
 
         stream.flip();
 
         LastReqContainer lastReqContainer = new LastReqContainer();
-        
+
         kerberosDecoder.decode( stream, lastReqContainer );
         fail();
     }
 
-    
-    @Test( expected = DecoderException.class)
+
+    @Test(expected = DecoderException.class)
     public void testLastReqWithEmptyType() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x19 );
-        
+
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x17,
-                  (byte)0xA0, 0x02,                 // lr-type
-                    0x02, 0x00,
-                  (byte)0xA1, 0x11,                 // lr-value
-                    0x18, 0x0F, '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '6', 'Z'
-            } );
+                ( byte ) 0xA0, 0x02, // lr-type
+                0x02,
+                0x00,
+                ( byte ) 0xA1,
+                0x11, // lr-value
+                0x18,
+                0x0F,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '1',
+                '1',
+                '0',
+                '1',
+                '5',
+                '4',
+                '5',
+                '2',
+                '6',
+                'Z'
+        } );
 
         stream.flip();
 
         LastReqContainer lastReqContainer = new LastReqContainer();
-        
+
         kerberosDecoder.decode( stream, lastReqContainer );
         fail();
     }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/MethodDataDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/MethodDataDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/MethodDataDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/MethodDataDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -60,23 +60,45 @@ public class MethodDataDecoderTest
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x24 );
-        
+
         stream.put( new byte[]
-            { 
-              0x30, 0x22,
-                0x30, 0x0F,
-                  (byte)0xA1, 0x03,                 // padata-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA2, 0x08,                 // padata-value
-                    0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f',
+            {
+                0x30, 0x22,
                 0x30, 0x0F,
-                  (byte)0xA1, 0x03,                 // padata-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA2, 0x08,                 // padata-value
-                    0x04, 0x06, 'g', 'h', 'i', 'j', 'k', 'l'
-            } );
+                ( byte ) 0xA1, 0x03, // padata-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA2,
+                0x08, // padata-value
+                0x04,
+                0x06,
+                'a',
+                'b',
+                'c',
+                'd',
+                'e',
+                'f',
+                0x30,
+                0x0F,
+                ( byte ) 0xA1,
+                0x03, // padata-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA2,
+                0x08, // padata-value
+                0x04,
+                0x06,
+                'g',
+                'h',
+                'i',
+                'j',
+                'k',
+                'l'
+        } );
 
-        String decodedPdu = Strings.dumpBytes(stream.array());
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a METHOD-DATA Container
@@ -97,29 +119,30 @@ public class MethodDataDecoderTest
         MethodData methodData = ( ( MethodDataContainer ) methodDataContainer ).getMethodData();
 
         assertEquals( 2, methodData.getPaDatas().length );
-        
-        String[] expected = new String[]{ "abcdef", "ghijkl" };
+
+        String[] expected = new String[]
+            { "abcdef", "ghijkl" };
         int i = 0;
-        
+
         for ( PaData paData : methodData.getPaDatas() )
         {
             assertEquals( PaDataType.PA_ENC_TIMESTAMP, paData.getPaDataType() );
-            assertTrue( Arrays.equals( Strings.getBytesUtf8(expected[i]), paData.getPaDataValue() ) );
+            assertTrue( Arrays.equals( Strings.getBytesUtf8( expected[i] ), paData.getPaDataValue() ) );
             i++;
         }
 
         // Check the encoding
         ByteBuffer bb = ByteBuffer.allocate( methodData.computeLength() );
-        
+
         try
         {
             bb = methodData.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x24, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
@@ -127,18 +150,18 @@ public class MethodDataDecoderTest
             fail();
         }
     }
-    
-    
+
+
     /**
      * Test the decoding of a METHOD-DATA with nothing in it
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testETypeInfoEmpty() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x00 } );
 
@@ -151,23 +174,23 @@ public class MethodDataDecoderTest
         kerberosDecoder.decode( stream, methodDataContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a METHOD-DATA with empty PA-DATA in it
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testETypeInfoNoETypeInfoEntry() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-        
+
         stream.put( new byte[]
-            { 
-              0x30, 0x02,
-                (byte)0x30, 0x00                  // empty PA-DATA
-            } );
+            {
+                0x30, 0x02,
+                ( byte ) 0x30, 0x00 // empty PA-DATA
+        } );
 
         stream.flip();
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaDataDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaDataDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaDataDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaDataDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.kerberos.codec;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -36,6 +37,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 
+
 /**
  * Test cases for PaData codec.
  *
@@ -47,23 +49,33 @@ public class PaDataDecoderTest
     public void testDecodePaData()
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0x11 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x0F,
-                  (byte)0xA1, 0x03,                 // padata-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA2, 0x08,                 // padata-value
-                    0x04, 0x06, 'p', 'a', 'd', 'a', 't', 'a'
-            } );
-        
-        String decodedPdu = Strings.dumpBytes(stream.array());
+                ( byte ) 0xA1, 0x03, // padata-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA2,
+                0x08, // padata-value
+                0x04,
+                0x06,
+                'p',
+                'a',
+                'd',
+                'a',
+                't',
+                'a'
+        } );
+
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         PaDataContainer container = new PaDataContainer();
-        
+
         try
         {
             krbDecoder.decode( stream, container );
@@ -71,26 +83,26 @@ public class PaDataDecoderTest
         catch ( DecoderException de )
         {
             de.printStackTrace();
-            
+
             fail( de.getMessage() );
         }
 
         PaData checksum = container.getPaData();
-        
+
         assertEquals( PaDataType.getTypeByValue( 2 ), checksum.getPaDataType() );
-        assertTrue( Arrays.equals( Strings.getBytesUtf8("padata"), checksum.getPaDataValue() ) );
-        
+        assertTrue( Arrays.equals( Strings.getBytesUtf8( "padata" ), checksum.getPaDataValue() ) );
+
         ByteBuffer bb = ByteBuffer.allocate( checksum.computeLength() );
-        
+
         try
         {
             bb = checksum.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x11, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
@@ -98,73 +110,87 @@ public class PaDataDecoderTest
             fail();
         }
     }
-    
-    
-    @Test( expected = DecoderException.class )
+
+
+    @Test(expected = DecoderException.class)
     public void testDecodePaDataWithoutType() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0xC );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0xA,
-                  (byte)0xA2, 0x08,                 // padata-value
-                      0x04, 0x06, 'p', 'a', 'd', 'a', 't', 'a'
-            } );
-        
+                ( byte ) 0xA2, 0x08, // padata-value
+                0x04,
+                0x06,
+                'p',
+                'a',
+                'd',
+                'a',
+                't',
+                'a'
+        } );
+
         stream.flip();
 
         PaDataContainer chkContainer = new PaDataContainer();
-        
+
         krbDecoder.decode( stream, chkContainer );
         fail();
     }
-    
-    
-    @Test( expected = DecoderException.class )
+
+
+    @Test(expected = DecoderException.class)
     public void testDecodeChecksumWithoutPaDataValue() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x05,
-                  (byte)0xA1, 0x03,                 // padata-type
-                    0x02, 0x01, 0x02
-            } );
-        
+                ( byte ) 0xA1, 0x03, // padata-type
+                0x02,
+                0x01,
+                0x02
+        } );
+
         stream.flip();
 
         PaDataContainer container = new PaDataContainer();
-        
+
         krbDecoder.decode( stream, container );
         fail();
     }
-    
+
+
     @Test
     public void testDecodePaDataWithEmptySeq() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0x11 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x09,
-                  (byte)0xA1, 0x03,                 // padata-type
-                    0x02, 0x01, 0x02,
-                  (byte)0xA2, 0x02,                 // padata-value
-                    0x04, 0x00
-            } );
-        
+                ( byte ) 0xA1, 0x03, // padata-type
+                0x02,
+                0x01,
+                0x02,
+                ( byte ) 0xA2,
+                0x02, // padata-value
+                0x04,
+                0x00
+        } );
+
         stream.flip();
 
         PaDataContainer container = new PaDataContainer();
-        
+
         krbDecoder.decode( stream, container );
     }
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTimestampDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTimestampDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTimestampDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTimestampDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -59,19 +59,32 @@ public class PaEncTimestampDecoderTest
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x16 );
-        
+
         stream.put( new byte[]
-            { 
-              0x30, 0x14,
-                (byte)0xA0, 0x03,                 // etype
-                  0x02, 0x01, 0x12,               //
-                (byte)0xA1, 0x03,                 // kvno
-                  0x02, 0x01, 0x05,               //
-                (byte)0xA2, 0x08,                 // cipher
-                  0x04, 0x06, 'a', 'b', 'c', 'd', 'e', 'f'
-            } );
+            {
+                0x30, 0x14,
+                ( byte ) 0xA0, 0x03, // etype
+                0x02,
+                0x01,
+                0x12, //
+                ( byte ) 0xA1,
+                0x03, // kvno
+                0x02,
+                0x01,
+                0x05, //
+                ( byte ) 0xA2,
+                0x08, // cipher
+                0x04,
+                0x06,
+                'a',
+                'b',
+                'c',
+                'd',
+                'e',
+                'f'
+        } );
 
-        String decodedPdu = Strings.dumpBytes(stream.array());
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a PaEncTimestamp Container
@@ -92,20 +105,20 @@ public class PaEncTimestampDecoderTest
 
         assertEquals( EncryptionType.AES256_CTS_HMAC_SHA1_96, paEncTimestamp.getEType() );
         assertEquals( 5, paEncTimestamp.getKvno() );
-        assertTrue( Arrays.equals( Strings.getBytesUtf8("abcdef"), paEncTimestamp.getCipher() ) );
+        assertTrue( Arrays.equals( Strings.getBytesUtf8( "abcdef" ), paEncTimestamp.getCipher() ) );
 
         // Check the encoding
         ByteBuffer bb = ByteBuffer.allocate( paEncTimestamp.computeLength() );
-        
+
         try
         {
             bb = paEncTimestamp.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x16, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTsEncDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTsEncDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTsEncDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PaEncTsEncDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.kerberos.codec;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -33,6 +34,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 
+
 /**
  * Test cases for PaEncTsEnc codec.
  *
@@ -44,24 +46,42 @@ public class PaEncTsEncDecoderTest
     public void testDecodeFullPaEncTsEnc()
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0x1A );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x18,
-                  (byte)0xA0, 0x11,                 // PaTimestamp
-                    0x18, 0x0F, 
-                      '2', '0', '1', '0', '1', '0', '1', '0', '2', '3', '4', '5', '4', '5', 'Z',
-                  (byte)0xA1, 0x03,                 // PaUsec
-                    0x02, 0x01, 0x01
-            } );
-        
-        String decodedPdu = Strings.dumpBytes(stream.array());
+                ( byte ) 0xA0, 0x11, // PaTimestamp
+                0x18,
+                0x0F,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '0',
+                '1',
+                '0',
+                '2',
+                '3',
+                '4',
+                '5',
+                '4',
+                '5',
+                'Z',
+                ( byte ) 0xA1,
+                0x03, // PaUsec
+                0x02,
+                0x01,
+                0x01
+        } );
+
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         PaEncTsEncContainer paEncTsEncContainer = new PaEncTsEncContainer();
-        
+
         try
         {
             krbDecoder.decode( stream, paEncTsEncContainer );
@@ -72,21 +92,21 @@ public class PaEncTsEncDecoderTest
         }
 
         PaEncTsEnc paEncTsEnc = paEncTsEncContainer.getPaEncTsEnc();
-        
+
         assertEquals( "20101010234545Z", paEncTsEnc.getPaTimestamp().toString() );
         assertEquals( 1, paEncTsEnc.getPausec() );
-        
+
         ByteBuffer bb = ByteBuffer.allocate( paEncTsEnc.computeLength() );
-        
+
         try
         {
             bb = paEncTsEnc.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x1A, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
@@ -95,19 +115,19 @@ public class PaEncTsEncDecoderTest
         }
     }
 
-    
-    @Test( expected = DecoderException.class )
+
+    @Test(expected = DecoderException.class)
     public void testDecodePaEncTsEncWithEmptySeq() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 2 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x0
-            } );
-        
+        } );
+
         stream.flip();
 
         PaEncTsEncContainer paEncTsEncContainer = new PaEncTsEncContainer();
@@ -116,20 +136,20 @@ public class PaEncTsEncDecoderTest
         fail();
     }
 
-    
-    @Test( expected = DecoderException.class )
+
+    @Test(expected = DecoderException.class)
     public void testDecodePaEncTsEncEmptyPaTimestamp() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 4 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x02,
-                  (byte)0xA0, 0x00
-            } );
-        
+                ( byte ) 0xA0, 0x00
+        } );
+
         stream.flip();
 
         PaEncTsEncContainer paEncTsEncContainer = new PaEncTsEncContainer();
@@ -138,21 +158,21 @@ public class PaEncTsEncDecoderTest
         fail();
     }
 
-    
-    @Test( expected = DecoderException.class )
+
+    @Test(expected = DecoderException.class)
     public void testDecodeAdAndOrNullPaTimestamp() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 6 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x04,
-                  (byte)0xA0, 0x02,
-                    0x18, 0x00
-            } );
-        
+                ( byte ) 0xA0, 0x02,
+                0x18, 0x00
+        } );
+
         stream.flip();
 
         PaEncTsEncContainer paEncTsEncContainer = new PaEncTsEncContainer();
@@ -161,21 +181,23 @@ public class PaEncTsEncDecoderTest
         fail();
     }
 
-    
-    @Test( expected = DecoderException.class )
+
+    @Test(expected = DecoderException.class)
     public void testDecodeAdAndOrNoPaTimestamp() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
 
         stream.put( new byte[]
-             { 
-                 0x30, 0x05,
-                   (byte)0xA1, 0x03,                 // PaUsec
-                     0x02, 0x01, 0x01
-             } );
-         
+            {
+                0x30, 0x05,
+                ( byte ) 0xA1, 0x03, // PaUsec
+                0x02,
+                0x01,
+                0x01
+        } );
+
         stream.flip();
 
         PaEncTsEncContainer paEncTsEncContainer = new PaEncTsEncContainer();
@@ -189,22 +211,37 @@ public class PaEncTsEncDecoderTest
     public void testDecodePaEncTsEncNoPaUsec()
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
-        
+
         ByteBuffer stream = ByteBuffer.allocate( 0x15 );
 
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x13,
-                  (byte)0xA0, 0x11,                 // PaTimestamp
-                    0x18, 0x0F, 
-                      '2', '0', '1', '0', '1', '0', '1', '0', '2', '3', '4', '5', '4', '5', 'Z',
-            } );
-        
-        String decodedPdu = Strings.dumpBytes(stream.array());
+                ( byte ) 0xA0, 0x11, // PaTimestamp
+                0x18,
+                0x0F,
+                '2',
+                '0',
+                '1',
+                '0',
+                '1',
+                '0',
+                '1',
+                '0',
+                '2',
+                '3',
+                '4',
+                '5',
+                '4',
+                '5',
+                'Z',
+        } );
+
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         PaEncTsEncContainer paEncTsEncContainer = new PaEncTsEncContainer();
-        
+
         try
         {
             krbDecoder.decode( stream, paEncTsEncContainer );
@@ -215,21 +252,21 @@ public class PaEncTsEncDecoderTest
         }
 
         PaEncTsEnc paEncTsEnc = paEncTsEncContainer.getPaEncTsEnc();
-        
+
         assertEquals( "20101010234545Z", paEncTsEnc.getPaTimestamp().toString() );
         assertEquals( -1, paEncTsEnc.getPausec() );
-        
+
         ByteBuffer bb = ByteBuffer.allocate( paEncTsEnc.computeLength() );
-        
+
         try
         {
             bb = paEncTsEnc.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x15, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -57,19 +57,50 @@ public class PrincipalNameDecoderTest
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x29 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x27,
-                (byte)0xA0, 0x03,                 // name-type
-                  0x02, 0x01, 0x01,               // NT-PRINCIPAL
-                (byte)0xA1, 0x20,                 // name-string
-                  0x30, 0x1E,
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '2',
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '3',
-            } );
+                ( byte ) 0xA0, 0x03, // name-type
+                0x02,
+                0x01,
+                0x01, // NT-PRINCIPAL
+                ( byte ) 0xA1,
+                0x20, // name-string
+                0x30,
+                0x1E,
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '1',
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '2',
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '3',
+        } );
 
-        String decodedPdu = Strings.dumpBytes(stream.array());
+        String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
 
         // Allocate a PrincipalName Container
@@ -95,16 +126,16 @@ public class PrincipalNameDecoderTest
 
         // Check the encoding
         ByteBuffer bb = ByteBuffer.allocate( principalName.computeLength() );
-        
+
         try
         {
             bb = principalName.encode( bb );
-    
+
             // Check the length
             assertEquals( 0x29, bb.limit() );
-    
-            String encodedPdu = Strings.dumpBytes(bb.array());
-    
+
+            String encodedPdu = Strings.dumpBytes( bb.array() );
+
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
@@ -112,18 +143,18 @@ public class PrincipalNameDecoderTest
             fail();
         }
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with nothing in it
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameEmpty() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x00 } );
 
@@ -136,22 +167,22 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with no type
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameNoType() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x02,
-                (byte)0xA0, 0x00                  // name-type
-            } );
+                ( byte ) 0xA0, 0x00 // name-type
+        } );
 
         stream.flip();
 
@@ -162,23 +193,24 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with an empty type
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameEmptyType() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x04,
-                (byte)0xA0, 0x02,                 // name-type
-                  0x02, 0x00                      // NT-PRINCIPAL
-            } );
+                ( byte ) 0xA0, 0x02, // name-type
+                0x02,
+                0x00 // NT-PRINCIPAL
+        } );
 
         stream.flip();
 
@@ -189,25 +221,29 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with a wrong type
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameBadType() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0B );
-        
+
         stream.put( new byte[]
             { 0x30, 0x09,
-                (byte)0xA0, 0x03,                 // name-type
-                  0x02, 0x01, 0x7F,               // NT-PRINCIPAL
-                (byte)0xA1, 0x02,                 // name-string
-                  0x30, 0x00
-            } );
+                ( byte ) 0xA0, 0x03, // name-type
+                0x02,
+                0x01,
+                0x7F, // NT-PRINCIPAL
+                ( byte ) 0xA1,
+                0x02, // name-string
+                0x30,
+                0x00
+        } );
 
         stream.flip();
 
@@ -218,24 +254,27 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with an empty name
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameEmptyName() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x09 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x07,
-                (byte)0xA0, 0x03,                 // name-type
-                  0x02, 0x01, 0x01,               // NT-PRINCIPAL
-                (byte)0xA1, 0x00                  // name-string
-            } );
+                ( byte ) 0xA0, 0x03, // name-type
+                0x02,
+                0x01,
+                0x01, // NT-PRINCIPAL
+                ( byte ) 0xA1,
+                0x00 // name-string
+        } );
 
         stream.flip();
 
@@ -246,25 +285,29 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with no name
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameNoName() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0B );
-        
+
         stream.put( new byte[]
             { 0x30, 0x09,
-                (byte)0xA0, 0x03,                 // name-type
-                  0x02, 0x01, 0x01,               // NT-PRINCIPAL
-                (byte)0xA1, 0x02,                 // name-string
-                  0x30, 0x00
-            } );
+                ( byte ) 0xA0, 0x03, // name-type
+                0x02,
+                0x01,
+                0x01, // NT-PRINCIPAL
+                ( byte ) 0xA1,
+                0x02, // name-string
+                0x30,
+                0x00
+        } );
 
         stream.flip();
 
@@ -275,26 +318,31 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName
      */
-    @Test( expected = DecoderException.class )
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameBadName() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0D );
-        
+
         stream.put( new byte[]
             { 0x30, 0x0B,
-                (byte)0xA0, 0x03,                 // name-type
-                  0x02, 0x01, 0x01,               // NT-PRINCIPAL
-                (byte)0xA1, 0x04,                 // name-string
-                  0x30, 0x02,
-                    0x1B, 0x00
-            } );
+                ( byte ) 0xA0, 0x03, // name-type
+                0x02,
+                0x01,
+                0x01, // NT-PRINCIPAL
+                ( byte ) 0xA1,
+                0x04, // name-string
+                0x30,
+                0x02,
+                0x1B,
+                0x00
+        } );
 
         stream.flip();
 
@@ -305,28 +353,59 @@ public class PrincipalNameDecoderTest
         kerberosDecoder.decode( stream, principalNameContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName
      */
-    @Test( expected = DecoderException.class )
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameBadName2() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x29 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x27,
-                (byte)0xA0, 0x03,                 // name-type
-                  0x02, 0x01, 0x01,               // NT-PRINCIPAL
-                (byte)0xA1, 0x20,                 // name-string
-                  0x30, 0x1E,
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
-                    0x1B, 0x08, 'h', 'n', 'e', '\r', 's', 'o', 'n', '2',
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '3',
-            } );
+                ( byte ) 0xA0, 0x03, // name-type
+                0x02,
+                0x01,
+                0x01, // NT-PRINCIPAL
+                ( byte ) 0xA1,
+                0x20, // name-string
+                0x30,
+                0x1E,
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '1',
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                '\r',
+                's',
+                'o',
+                'n',
+                '2',
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '3',
+        } );
 
         stream.flip();
 
@@ -336,26 +415,54 @@ public class PrincipalNameDecoderTest
         // Decode the PrincipalName PDU
         kerberosDecoder.decode( stream, principalNameContainer );
     }
-    
-    
+
+
     /**
      * Test the decoding of a PrincipalName with no name-type
      */
-    @Test( expected = DecoderException.class )
+    @Test(expected = DecoderException.class)
     public void testPrincipalNameNoNameType() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x24 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x22,
-                (byte)0xA1, 0x20,                 // name-string
-                  0x30, 0x1E,
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
-                    0x1B, 0x08, 'h', 'n', 'e', '\r', 's', 'o', 'n', '2',
-                    0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '3',
-            } );
+                ( byte ) 0xA1, 0x20, // name-string
+                0x30,
+                0x1E,
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '1',
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                '\r',
+                's',
+                'o',
+                'n',
+                '2',
+                0x1B,
+                0x08,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                '3',
+        } );
 
         stream.flip();
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsRepDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsRepDecoderTest.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsRepDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TgsRepDecoderTest.java Tue Jan 24 16:15:05 2012
@@ -54,73 +54,183 @@ public class TgsRepDecoderTest
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0xAC );
-        
+
         stream.put( new byte[]
-        {
-          0x6D, (byte)0x81, (byte)0xA9,
-            0x30, (byte)0x81, (byte)0xA6,
-              (byte)0xA0, 0x03,                         // PVNO
-                0x02, 0x01, 0x05,
-              (byte)0xA1, 0x03,                         // msg-type
-                0x02, 0x01, 0x0D,
-              (byte)0xA2, 0x20,                         // PA-DATA
-                0x30, 0x1E,
-                  0x30, 0x0D,
-                    (byte)0xA1,0x03,
-                      0x02, 0x01, 01,
-                    (byte)0xA2, 0x06,
-                      0x04, 0x04, 'a', 'b', 'c', 'd',
-                  0x30, 0x0D,
-                    (byte)0xA1,0x03,
-                      0x02, 0x01, 01,
-                    (byte)0xA2, 0x06,
-                      0x04, 0x04, 'e', 'f', 'g', 'h',
-              (byte)0xA3, 0x0D,                         // crealm
-                0x1B, 0x0B, 'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M',
-              (byte)0xA4, 0x14,                         // cname
-                0x30, 0x12,
-                  (byte)0xA0, 0x03,                     // name-type
-                    0x02, 0x01, 0x01,
-                  (byte)0xA1, 0x0B,                     // name-string
-                    0x30, 0x09,
-                      0x1B, 0x07, 'h', 'n', 'e', 'l', 's', 'o', 'n',
-              (byte)0xA5, 0x40,                         // Ticket
-                0x61, 0x3E, 
-                  0x30, 0x3C, 
-                    (byte)0xA0, 0x03, 
-                      0x02, 0x01, 0x05, 
-                    (byte)0xA1, 0x0D, 
-                      0x1B, 0x0B, 
-                        'E', 'X', 'A', 'M', 'P', 'L', 'E', '.', 'C', 'O', 'M', 
-                    (byte)0xA2, 0x13, 
-                      0x30, 0x11, 
-                        (byte)0xA0, 0x03, 
-                          0x02, 0x01, 0x01, 
-                        (byte)0xA1, 0x0A, 
-                          0x30, 0x08, 
-                            0x1B, 0x06, 
-                              'c', 'l', 'i', 'e', 'n', 't', 
-                    (byte)0xA3, 0x11, 
-                      0x30, 0x0F, 
-                        (byte)0xA0, 0x03, 
-                          0x02, 0x01, 0x11, 
-                        (byte)0xA2, 0x08, 
-                          0x04, 0x06, 
-                            'a', 'b', 'c', 'd', 'e', 'f', 
-              (byte)0xA6, 0x11,                         // enc-part
-                0x30, 0x0F, 
-                  (byte)0xA0, 0x03, 
-                    0x02, 0x01, 0x11, 
-                  (byte)0xA2, 0x08, 
-                    0x04, 0x06, 
-                      'a', 'b', 'c', 'd', 'e', 'f', 
-        });
+            {
+                0x6D, ( byte ) 0x81, ( byte ) 0xA9,
+                0x30, ( byte ) 0x81, ( byte ) 0xA6,
+                ( byte ) 0xA0, 0x03, // PVNO
+                0x02,
+                0x01,
+                0x05,
+                ( byte ) 0xA1,
+                0x03, // msg-type
+                0x02,
+                0x01,
+                0x0D,
+                ( byte ) 0xA2,
+                0x20, // PA-DATA
+                0x30,
+                0x1E,
+                0x30,
+                0x0D,
+                ( byte ) 0xA1,
+                0x03,
+                0x02,
+                0x01,
+                01,
+                ( byte ) 0xA2,
+                0x06,
+                0x04,
+                0x04,
+                'a',
+                'b',
+                'c',
+                'd',
+                0x30,
+                0x0D,
+                ( byte ) 0xA1,
+                0x03,
+                0x02,
+                0x01,
+                01,
+                ( byte ) 0xA2,
+                0x06,
+                0x04,
+                0x04,
+                'e',
+                'f',
+                'g',
+                'h',
+                ( byte ) 0xA3,
+                0x0D, // crealm
+                0x1B,
+                0x0B,
+                'E',
+                'X',
+                'A',
+                'M',
+                'P',
+                'L',
+                'E',
+                '.',
+                'C',
+                'O',
+                'M',
+                ( byte ) 0xA4,
+                0x14, // cname
+                0x30,
+                0x12,
+                ( byte ) 0xA0,
+                0x03, // name-type
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA1,
+                0x0B, // name-string
+                0x30,
+                0x09,
+                0x1B,
+                0x07,
+                'h',
+                'n',
+                'e',
+                'l',
+                's',
+                'o',
+                'n',
+                ( byte ) 0xA5,
+                0x40, // Ticket
+                0x61,
+                0x3E,
+                0x30,
+                0x3C,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x05,
+                ( byte ) 0xA1,
+                0x0D,
+                0x1B,
+                0x0B,
+                'E',
+                'X',
+                'A',
+                'M',
+                'P',
+                'L',
+                'E',
+                '.',
+                'C',
+                'O',
+                'M',
+                ( byte ) 0xA2,
+                0x13,
+                0x30,
+                0x11,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x01,
+                ( byte ) 0xA1,
+                0x0A,
+                0x30,
+                0x08,
+                0x1B,
+                0x06,
+                'c',
+                'l',
+                'i',
+                'e',
+                'n',
+                't',
+                ( byte ) 0xA3,
+                0x11,
+                0x30,
+                0x0F,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x11,
+                ( byte ) 0xA2,
+                0x08,
+                0x04,
+                0x06,
+                'a',
+                'b',
+                'c',
+                'd',
+                'e',
+                'f',
+                ( byte ) 0xA6,
+                0x11, // enc-part
+                0x30,
+                0x0F,
+                ( byte ) 0xA0,
+                0x03,
+                0x02,
+                0x01,
+                0x11,
+                ( byte ) 0xA2,
+                0x08,
+                0x04,
+                0x06,
+                'a',
+                'b',
+                'c',
+                'd',
+                'e',
+                'f',
+        } );
 
         stream.flip();
 
         // Allocate a TgsRep Container
         TgsRepContainer tgsRepContainer = new TgsRepContainer( stream );
-        
+
         // Decode the TgsRep PDU
         try
         {
@@ -132,20 +242,20 @@ public class TgsRepDecoderTest
         }
 
         TgsRep tgsRep = tgsRepContainer.getTgsRep();
-        
+
         // Check the encoding
         int length = tgsRep.computeLength();
 
         // Check the length
         assertEquals( 0xAC, length );
-        
+
         // Check the encoding
         ByteBuffer encodedPdu = ByteBuffer.allocate( length );
-        
+
         try
         {
             encodedPdu = tgsRep.encode( encodedPdu );
-            
+
             // Check the length
             assertEquals( 0xAC, encodedPdu.limit() );
         }
@@ -154,18 +264,18 @@ public class TgsRepDecoderTest
             fail();
         }
     }
-    
-    
+
+
     /**
      * Test the decoding of a TGS-REP with nothing in it
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testTgsRepEmpty() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x02 );
-        
+
         stream.put( new byte[]
             { 0x30, 0x00 } );
 
@@ -178,23 +288,23 @@ public class TgsRepDecoderTest
         kerberosDecoder.decode( stream, tgsRepContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a TGS-REP with empty Pvno tag
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testTgsRepEmptyPvnoTag() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x04 );
-        
+
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x02,
-                  (byte)0xA0, 0x00
-            } );
+                ( byte ) 0xA0, 0x00
+        } );
 
         stream.flip();
 
@@ -205,24 +315,24 @@ public class TgsRepDecoderTest
         kerberosDecoder.decode( stream, tgsRepContainer );
         fail();
     }
-    
-    
+
+
     /**
      * Test the decoding of a TGS-REP with empty Pvno value
      */
-    @Test( expected = DecoderException.class)
+    @Test(expected = DecoderException.class)
     public void testTgsRepEmptyPvnoValue() throws DecoderException
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x06 );
-        
+
         stream.put( new byte[]
-            { 
+            {
                 0x30, 0x04,
-                  (byte)0xA0, 0x02,
-                    0x02, 0x00
-            } );
+                ( byte ) 0xA0, 0x02,
+                0x02, 0x00
+        } );
 
         stream.flip();