directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r165437 - /directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/primitives/OIDTest.java
Date Sat, 30 Apr 2005 23:17:10 GMT
Author: elecharny
Date: Sat Apr 30 16:17:10 2005
New Revision: 165437

URL: http://svn.apache.org/viewcvs?rev=165437&view=rev
Log:
Added much more tests on the OID class.

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/primitives/OIDTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/primitives/OIDTest.java?rev=165437&r1=165436&r2=165437&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/primitives/OIDTest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/primitives/OIDTest.java
Sat Apr 30 16:17:10 2005
@@ -16,31 +16,38 @@
  */
 package org.apache.asn1.primitives;
 
-import org.apache.asn1.DecoderException;
-
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import org.apache.asn1.DecoderException;
+
+
 /**
+ * DOCUMENT ME!
+ * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class OIDTest extends TestCase {
-    
+public class OIDTest extends TestCase
+{
+    //~ Methods ------------------------------------------------------------------------------------
+
     /**
      * Test a null OID
      */
     public void testOidNull()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            oid.setOID(null);
-            Assert.fail("Should not reach this point ...");
+            oid.setOID( null );
+            Assert.fail( "Should not reach this point ..." );
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
-            Assert.assertTrue(true);
+            Assert.assertTrue( true );
         }
     }
 
@@ -49,16 +56,17 @@
      */
     public void testOidEmpty()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            oid.setOID(new byte[]{});
-            Assert.fail("Should not reach this point ...");
+            oid.setOID( new byte[] {} );
+            Assert.fail( "Should not reach this point ..." );
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
-            Assert.assertTrue(true);
+            Assert.assertTrue( true );
         }
     }
 
@@ -67,45 +75,55 @@
      */
     public void testOidItuT()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            // itu-t(0), recommendation(0), series a-z (0..26) 
-            for ( int i = 1 ; i < 27 ; i ++ ) 
+
+            // itu-t(0), recommendation(0), series a-z (0..26)
+            for ( int i = 1; i < 27; i++ )
             {
-                oid.setOID(new byte[]{0x00, (byte)i});
-                Assert.assertEquals("0.0." + i, oid.getOID());
+                oid.setOID( new byte[] { 0x00, ( byte ) i } );
+                Assert.assertEquals( "0.0." + i, oid.getOID() );
             }
 
-            // itu-t(0), question(1) 
-            oid.setOID(new byte[]{0x01});
-            Assert.assertEquals("0.1", oid.getOID());
+            // itu-t(0), question(1)
+            oid.setOID( new byte[] { 0x01 } );
+            Assert.assertEquals( "0.1", oid.getOID() );
 
             // itu-t(0), administration(2), country(202 .. 748)
-            for ( int i = 202 ; i < 748 ; i ++ ) 
+            for ( int i = 202; i < 748; i++ )
             {
-                oid.setOID(new byte[]{0x02, (byte)((i / 128) | 0x0080), (byte)(i % 128)});
-                Assert.assertEquals("0.2." + i, oid.getOID());
+                oid.setOID(
+                    new byte[] { 0x02, ( byte ) ( ( i / 128 ) | 0x0080 ), ( byte ) ( i %
128 ) } );
+                Assert.assertEquals( "0.2." + i, oid.getOID() );
             }
 
             // itu-t(0), network-operator(3), operator(2023 .. 41363)
-            for ( int i = 2023 ; i < 41363 ; i ++ ) 
+            for ( int i = 2023; i < 41363; i++ )
             {
-                if (i < 128*128)
+
+                if ( i < ( 128 * 128 ) )
                 {
-                    oid.setOID(new byte[]{0x03, (byte)((i / 128) | 0x0080), (byte)(i % 128)});
-                    Assert.assertEquals("0.3." + i, oid.getOID());
+                    oid.setOID(
+                        new byte[] { 0x03, ( byte ) ( ( i / 128 ) | 0x0080 ), ( byte ) (
i % 128 ) } );
+                    Assert.assertEquals( "0.3." + i, oid.getOID() );
                 }
                 else
                 {
-                    oid.setOID(new byte[]{0x03, (byte)((i / (128*128)) | 0x0080), (byte)(((i
/ 128) % 128 ) | 0x0080), (byte)(i % 128)});
-                    Assert.assertEquals("0.3." + i, oid.getOID());
-                    
+                    oid.setOID(
+                        new byte[]
+                        {
+                            0x03, ( byte ) ( ( i / ( 128 * 128 ) ) | 0x0080 ),
+                            ( byte ) ( ( ( i / 128 ) % 128 ) | 0x0080 ), ( byte ) ( i % 128
)
+                        } );
+                    Assert.assertEquals( "0.3." + i, oid.getOID() );
+
                 }
             }
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
             Assert.fail();
         }
@@ -116,27 +134,29 @@
      */
     public void testOidIso()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            // iso(1), standard(0) 
-            oid.setOID(new byte[]{40 + 0});
-            Assert.assertEquals("1.0", oid.getOID());
-
-            // iso(1), registration-authority(1) 
-            oid.setOID(new byte[]{40 + 1});
-            Assert.assertEquals("1.1", oid.getOID());
+
+            // iso(1), standard(0)
+            oid.setOID( new byte[] { 40 + 0 } );
+            Assert.assertEquals( "1.0", oid.getOID() );
+
+            // iso(1), registration-authority(1)
+            oid.setOID( new byte[] { 40 + 1 } );
+            Assert.assertEquals( "1.1", oid.getOID() );
 
             // iso(1), member-body(2)
-            oid.setOID(new byte[]{40 + 2});
-            Assert.assertEquals("1.2", oid.getOID());
+            oid.setOID( new byte[] { 40 + 2 } );
+            Assert.assertEquals( "1.2", oid.getOID() );
 
-            // iso(1), identified-organization(3) | org(3) | organization(3) 
-            oid.setOID(new byte[]{40 + 3});
-            Assert.assertEquals("1.3", oid.getOID());
+            // iso(1), identified-organization(3) | org(3) | organization(3)
+            oid.setOID( new byte[] { 40 + 3 } );
+            Assert.assertEquals( "1.3", oid.getOID() );
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
             Assert.fail();
         }
@@ -147,32 +167,34 @@
      */
     public void testOidJointIsoItuT()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            // joint-iso-itu-t(2), presentation(0) 
-            oid.setOID(new byte[]{80 + 0});
-            Assert.assertEquals("2.0", oid.getOID());
-
-            // joint-iso-itu-t(2), asn1(1)   
-            oid.setOID(new byte[]{80 + 1});
-            Assert.assertEquals("2.1", oid.getOID());
+
+            // joint-iso-itu-t(2), presentation(0)
+            oid.setOID( new byte[] { 80 + 0 } );
+            Assert.assertEquals( "2.0", oid.getOID() );
+
+            // joint-iso-itu-t(2), asn1(1)
+            oid.setOID( new byte[] { 80 + 1 } );
+            Assert.assertEquals( "2.1", oid.getOID() );
 
             // joint-iso-itu-t(2), association-control(2)
-            oid.setOID(new byte[]{80 + 2});
-            Assert.assertEquals("2.2", oid.getOID());
+            oid.setOID( new byte[] { 80 + 2 } );
+            Assert.assertEquals( "2.2", oid.getOID() );
 
             // joint-iso-itu-t(2), reliable-transfer(3)
-            oid.setOID(new byte[]{80 + 3});
-            Assert.assertEquals("2.3", oid.getOID());
+            oid.setOID( new byte[] { 80 + 3 } );
+            Assert.assertEquals( "2.3", oid.getOID() );
 
             // ...
             // joint-iso-itu-t(2), upu(40)
-            oid.setOID(new byte[]{80 + 40});
-            Assert.assertEquals("2.40", oid.getOID());
+            oid.setOID( new byte[] { 80 + 40 } );
+            Assert.assertEquals( "2.40", oid.getOID() );
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
             Assert.fail();
         }
@@ -183,15 +205,16 @@
      */
     public void testOidSpnego()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            oid.setOID(new byte[]{0x2b, 0x06, 0x01, 0x05, 0x05, 0x02});
-            
-            Assert.assertEquals("1.3.6.1.5.5.2", oid.getOID());
+            oid.setOID( new byte[] { 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 } );
+
+            Assert.assertEquals( "1.3.6.1.5.5.2", oid.getOID() );
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
             Assert.fail();
         }
@@ -202,15 +225,21 @@
      */
     public void testOidKerberosV5()
     {
+
         OID oid = new OID();
-        
-        try 
+
+        try
         {
-            oid.setOID(new byte[]{0x2a, (byte)0x86, 0x48, (byte)0x86, (byte)0xf7, 0x12, 0x01,
0x02, 0x02});
-            
-            Assert.assertEquals("1.2.840.113554.1.2.2", oid.getOID());
+            oid.setOID(
+                new byte[]
+                {
+                    0x2a, ( byte ) 0x86, 0x48, ( byte ) 0x86, ( byte ) 0xf7, 0x12, 0x01,
0x02,
+                    0x02
+                } );
+
+            Assert.assertEquals( "1.2.840.113554.1.2.2", oid.getOID() );
         }
-        catch (DecoderException de)
+        catch ( DecoderException de )
         {
             Assert.fail();
         }



Mime
View raw message