directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r520867 - in /directory/shared/trunk/asn1/src: main/java/org/apache/directory/shared/asn1/primitives/OID.java test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
Date Wed, 21 Mar 2007 12:52:29 GMT
Author: elecharny
Date: Wed Mar 21 05:52:29 2007
New Revision: 520867

URL: http://svn.apache.org/viewvc?view=rev&rev=520867
Log:
Fixed DIRSERVER-875. The OID migh be sometime seen as correct, due to incorrectly handling
a final '.'. 
Fixed the tests whcich were not detecting such a bug...

Modified:
    directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java
    directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java

Modified: directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java?view=diff&rev=520867&r1=520866&r2=520867
==============================================================================
--- directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java
(original)
+++ directory/shared/trunk/asn1/src/main/java/org/apache/directory/shared/asn1/primitives/OID.java
Wed Mar 21 05:52:29 2007
@@ -583,7 +583,7 @@
         }
 
         // We must have a dot
-        if ( bytes[pos++] != '.' )
+        if ( ( pos + 1 >= bytes.length ) || ( bytes[++pos] != '.' ) )
         {
             return false;
         }
@@ -630,6 +630,6 @@
             }
         }
 
-        return true;
+        return !dotSeen;
     }
 }

Modified: directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java?view=diff&rev=520867&r1=520866&r2=520867
==============================================================================
--- directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
(original)
+++ directory/shared/trunk/asn1/src/test/java/org/apache/directory/shared/asn1/primitives/OIDTest.java
Wed Mar 21 05:52:29 2007
@@ -262,99 +262,16 @@
      */
     public void testOidStringBad()
     {
-
-        OID oid = new OID();
-
-        try
-        {
-            oid.setOID( "0" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "0." );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "." );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "0.1.2." );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "3.1" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "0..1" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "0..12" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "0.a.2" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "0.123456" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
-        try
-        {
-            oid.setOID( "1.123456" );
-        }
-        catch ( DecoderException de )
-        {
-            Assert.assertTrue( true );
-        }
-
+        assertFalse( OID.isOID( "0" ) );
+        assertFalse( OID.isOID( "0." ) );
+        assertFalse( OID.isOID( "." ) );
+        assertFalse( OID.isOID( "0.1.2." ) );
+        assertFalse( OID.isOID( "3.1" ) );
+        assertFalse( OID.isOID( "0..1" ) );
+        assertFalse( OID.isOID( "0..12" ) );
+        assertFalse( OID.isOID( "0.a.2" ) );
+        assertFalse( OID.isOID( "0.123456" ) );
+        assertFalse( OID.isOID( "1.123456" ) );
     }
 
 



Mime
View raw message