directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r209017 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/LdapDecoderTest.java
Date Mon, 04 Jul 2005 06:35:58 GMT
Author: elecharny
Date: Sun Jul  3 23:35:56 2005
New Revision: 209017

URL: http://svn.apache.org/viewcvs?rev=209017&view=rev
Log:
Formatting and adding some javadoc

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/LdapDecoderTest.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/LdapDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/LdapDecoderTest.java?rev=209017&r1=209016&r2=209017&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/LdapDecoderTest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/LdapDecoderTest.java
Sun Jul  3 23:35:56 2005
@@ -16,7 +16,8 @@
  */
 package org.apache.asn1.ldap.codec;
 
-import java.nio.ByteBuffer;
+import junit.framework.Assert;
+import junit.framework.TestCase;
 
 import org.apache.asn1.DecoderException;
 import org.apache.asn1.ber.Asn1Decoder;
@@ -24,17 +25,23 @@
 import org.apache.asn1.ldap.pojo.BindRequest;
 import org.apache.asn1.ldap.pojo.LdapMessage;
 import org.apache.asn1.ldap.pojo.SimpleAuthentication;
+
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import java.nio.ByteBuffer;
+
 
 /**
+ * A global Ldap Decoder test
+ * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapDecoderTest extends TestCase {
-	
+public class LdapDecoderTest extends TestCase
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
     /** Logger */
     protected static Logger log = Logger.getLogger( LdapDecoderTest.class );
 
@@ -43,11 +50,14 @@
         PropertyConfigurator.configure( "conf/log4j.conf" );
     }
 
+    //~ Methods ------------------------------------------------------------------------------------
+
     /**
      * Test the decoding of a full PDU
      */
     public void testDecodeFull()
     {
+
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
         ByteBuffer  stream      = ByteBuffer.allocate( 0x35 );
@@ -55,16 +65,16 @@
             new byte[]
             {
                 0x30, 0x33, 		// LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	//         messageID MessageID
-				0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
+                0x02, 0x01, 0x01, 	//         messageID MessageID
+                0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
                         			// BindRequest ::= APPLICATION[0] SEQUENCE {
-				0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
-				0x04, 0x1F, 		//        name LDAPDN,
-				'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
+                0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
+                0x04, 0x1F, 		//        name LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd',
'c', '=',
                 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-				( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
+                ( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
                                      // AuthenticationChoice ::= CHOICE { simple [0] OCTET
STRING, ...
-				'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
+                'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
             } );
 
         stream.flip();
@@ -81,7 +91,7 @@
             de.printStackTrace();
             Assert.fail( de.getMessage() );
         }
-    	
+
         LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
         BindRequest br      = ( BindRequest ) ( message.getProtocolOp() );
 
@@ -89,7 +99,8 @@
         Assert.assertEquals( 3, br.getVersion() );
         Assert.assertEquals( "uid=akarasulu,dc=example,dc=com", br.getName() );
         Assert.assertEquals( true, ( br.getAuthentication() instanceof SimpleAuthentication
) );
-        Assert.assertEquals( "[70][61][73][73][77][6F][72][64]", ( ( SimpleAuthentication
) br.getAuthentication() ).getSimple().toString() );
+        Assert.assertEquals( "[70][61][73][73][77][6F][72][64]",
+            ( ( SimpleAuthentication ) br.getAuthentication() ).getSimple().toString() );
     }
 
     /**
@@ -97,6 +108,7 @@
      */
     public void testDecodePartial()
     {
+
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
         ByteBuffer  stream      = ByteBuffer.allocate( 16 );
@@ -104,12 +116,12 @@
             new byte[]
             {
                 0x30, 0x33, 		// LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	//         messageID MessageID
-				0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
+                0x02, 0x01, 0x01, 	//         messageID MessageID
+                0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
                         			// BindRequest ::= APPLICATION[0] SEQUENCE {
-				0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
-				0x04, 0x1F, 		//        name LDAPDN,
-				'u', 'i', 'd', '=' 
+                0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
+                0x04, 0x1F, 		//        name LDAPDN,
+                'u', 'i', 'd', '='
             } );
 
         stream.flip();
@@ -126,7 +138,7 @@
             de.printStackTrace();
             Assert.fail( de.getMessage() );
         }
-    	
+
         LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
         BindRequest br      = ( BindRequest ) ( message.getProtocolOp() );
 
@@ -141,6 +153,7 @@
      */
     public void testDecodeSplittedPDU()
     {
+
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
         ByteBuffer  stream      = ByteBuffer.allocate( 16 );
@@ -148,12 +161,12 @@
             new byte[]
             {
                 0x30, 0x33, 		// LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	//         messageID MessageID
-				0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
+                0x02, 0x01, 0x01, 	//         messageID MessageID
+                0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
                         			// BindRequest ::= APPLICATION[0] SEQUENCE {
-				0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
-				0x04, 0x1F, 		//        name LDAPDN,
-				'u', 'i', 'd', '=' 
+                0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
+                0x04, 0x1F, 		//        name LDAPDN,
+                'u', 'i', 'd', '='
             } );
 
         stream.flip();
@@ -171,17 +184,16 @@
             de.printStackTrace();
             Assert.fail( de.getMessage() );
         }
-    	
+
         // Second block of data
-        stream      = ByteBuffer.allocate( 37 );
+        stream = ByteBuffer.allocate( 37 );
         stream.put(
             new byte[]
             {
-    				'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
-	                'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-					( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
-	                                     // AuthenticationChoice ::= CHOICE { simple [0] OCTET
STRING, ...
-					'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
+                'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x',
'a',
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', ( byte ) 0x80, 0x08,
//        authentication AuthenticationChoice
+                                                                                        
   // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING, ...
+                'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
             } );
 
         stream.flip();
@@ -203,7 +215,8 @@
         Assert.assertEquals( 3, br.getVersion() );
         Assert.assertEquals( "uid=akarasulu,dc=example,dc=com", br.getName() );
         Assert.assertEquals( true, ( br.getAuthentication() instanceof SimpleAuthentication
) );
-        Assert.assertEquals( "[70][61][73][73][77][6F][72][64]", ( ( SimpleAuthentication
) br.getAuthentication() ).getSimple().toString() );
+        Assert.assertEquals( "[70][61][73][73][77][6F][72][64]",
+            ( ( SimpleAuthentication ) br.getAuthentication() ).getSimple().toString() );
     }
 
     /**
@@ -212,24 +225,25 @@
      */
     public void testDecodeBadLengthTooSmall()
     {
+
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
         ByteBuffer  stream      = ByteBuffer.allocate( 0x35 );
         stream.put(
             new byte[]
             {
-            	// Length should be 0x33...
+                    				// Length should be 0x33...
                 0x30, 0x32, 		// LDAPMessage ::=SEQUENCE {
-				0x02, 0x01, 0x01, 	//         messageID MessageID
-				0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
+                0x02, 0x01, 0x01, 	//         messageID MessageID
+                0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
                         			// BindRequest ::= APPLICATION[0] SEQUENCE {
-				0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
-				0x04, 0x1F, 		//        name LDAPDN,
-				'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
+                0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
+                0x04, 0x1F, 		//        name LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd',
'c', '=',
                 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-				( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
+                ( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
                                      // AuthenticationChoice ::= CHOICE { simple [0] OCTET
STRING, ...
-				'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
+                'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
             } );
 
         stream.flip();
@@ -243,11 +257,12 @@
         }
         catch ( DecoderException de )
         {
-            Assert.assertEquals( "The current Value length is above the expected length",
de.getMessage() );
+            Assert.assertEquals( "The current Value length is above the expected length",
+                de.getMessage() );
             return;
         }
-    	
-        Assert.fail("Should never reach this point..");
+
+        Assert.fail( "Should never reach this point.." );
     }
 
     /**
@@ -256,6 +271,7 @@
      */
     public void testDecodeBadPrimitiveLengthTooBig()
     {
+
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
         ByteBuffer  stream      = ByteBuffer.allocate( 0x35 );
@@ -263,17 +279,17 @@
             new byte[]
             {
                 0x30, 0x33, 		// LDAPMessage ::=SEQUENCE {
-            	// Length should be 0x01...
-				0x02, 0x02, 0x01, 	//         messageID MessageID
-				0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
+                					// Length should be 0x01...
+                0x02, 0x02, 0x01, 	//         messageID MessageID
+                0x60, 0x2E, 		//        CHOICE { ..., bindRequest BindRequest, ...
                         			// BindRequest ::= APPLICATION[0] SEQUENCE {
-				0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
-				0x04, 0x1F, 		//        name LDAPDN,
-				'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
+                0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
+                0x04, 0x1F, 		//        name LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd',
'c', '=',
                 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-				( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
+                ( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
                                      // AuthenticationChoice ::= CHOICE { simple [0] OCTET
STRING, ...
-				'p', 'a', 's', 's', 'w', 'o', 'r'
+                'p', 'a', 's', 's', 'w', 'o', 'r'
             } );
 
         stream.flip();
@@ -290,8 +306,8 @@
             Assert.assertEquals( "Universal tag 14 is reserved", de.getMessage() );
             return;
         }
-    	
-        Assert.fail("Should never reach this point.");
+
+        Assert.fail( "Should never reach this point." );
     }
 
     /**
@@ -300,6 +316,7 @@
      */
     public void testDecodeBadTagTransition()
     {
+
         Asn1Decoder ldapDecoder = new LdapDecoder();
 
         ByteBuffer  stream      = ByteBuffer.allocate( 0x35 );
@@ -307,17 +324,17 @@
             new byte[]
             {
                 0x30, 0x33, 		// LDAPMessage ::=SEQUENCE {
-            	// Length should be 0x01...
-				0x02, 0x01, 0x01, 	//         messageID MessageID
-				0x2D, 0x2D, 		//        CHOICE { ..., bindRequest BindRequest, ...
+                					// Length should be 0x01...
+                0x02, 0x01, 0x01, 	//         messageID MessageID
+                0x2D, 0x2D, 		//        CHOICE { ..., bindRequest BindRequest, ...
                         			// BindRequest ::= APPLICATION[0] SEQUENCE {
-				0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
-				0x04, 0x1F, 		//        name LDAPDN,
-				'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=',
+                0x02, 0x01, 0x03, 	//        version INTEGER (1..127),
+                0x04, 0x1F, 		//        name LDAPDN,
+                'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd',
'c', '=',
                 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
-				( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
+                ( byte ) 0x80, 0x08, //        authentication AuthenticationChoice
                                      // AuthenticationChoice ::= CHOICE { simple [0] OCTET
STRING, ...
-				'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
+                'p', 'a', 's', 's', 'w', 'o', 'r', 'd'
             } );
 
         stream.flip();
@@ -331,10 +348,11 @@
         }
         catch ( DecoderException de )
         {
-            Assert.assertEquals( "Bad transition from state PROTOCOL_OP_TAG, tag [2D]", de.getMessage()
);
+            Assert.assertEquals( "Bad transition from state PROTOCOL_OP_TAG, tag [2D]",
+                de.getMessage() );
             return;
         }
-    	
-        Assert.fail("Should never reach this point.");
+
+        Assert.fail( "Should never reach this point." );
     }
 }



Mime
View raw message