directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r775478 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/schema/syntaxes/ test/java/org/apache/directory/shared/ldap/entry/client/ test/java/org/apache/directory/shared/ldap/schema/syntax/
Date Sat, 16 May 2009 14:41:28 GMT
Author: elecharny
Date: Sat May 16 14:41:27 2009
New Revision: 775478

URL: http://svn.apache.org/viewvc?rev=775478&view=rev
Log:
Updated Ia5String and OcteString Syntax checkers to allow empty values. Fixed the tests accordingly

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/Ia5StringSyntaxChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/OctetStringSyntaxChecker.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/Ia5StringSyntaxCheckerTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/OctetStringSyntaxCheckerTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/Ia5StringSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/Ia5StringSyntaxChecker.java?rev=775478&r1=775477&r2=775478&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/Ia5StringSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/Ia5StringSyntaxChecker.java
Sat May 16 14:41:27 2009
@@ -70,7 +70,7 @@
 
         if ( value == null )
         {
-            return false;
+            return true;
         }
         
         if ( value instanceof String )
@@ -86,11 +86,6 @@
             strValue = value.toString();
         }
 
-        if ( strValue.length() == 0 )
-        {
-            return false;
-        }
-        
         return StringTools.isIA5String( strValue );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/OctetStringSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/OctetStringSyntaxChecker.java?rev=775478&r1=775477&r2=775478&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/OctetStringSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/OctetStringSyntaxChecker.java
Sat May 16 14:41:27 2009
@@ -49,6 +49,7 @@
     {
         super( SC_OID );
     }
+
     
     /**
      * 
@@ -62,11 +63,14 @@
         super( oid );
     }
     
-    /* (non-Javadoc)
-     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+
+    
+    /**
+     * {@inheritDoc}
      */
     public boolean isValidSyntax( Object value )
     {
-        return ( value != null );
+        // It must be a byte[]
+        return value instanceof byte[];
     }
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java?rev=775478&r1=775477&r2=775478&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java
Sat May 16 14:41:27 2009
@@ -35,7 +35,6 @@
 
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.syntaxes.Ia5StringSyntaxChecker;
-import org.apache.directory.shared.ldap.schema.syntaxes.OctetStringSyntaxChecker;
 import org.junit.Test;
 
 /**
@@ -148,7 +147,7 @@
         
         assertNull( csv.get() );
         assertFalse( csv.isNormalized() );
-        assertFalse( csv.isValid( new Ia5StringSyntaxChecker() ) );
+        assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertTrue( csv.isNull() );
         assertNull( csv.getNormalizedValue() );
     }
@@ -165,7 +164,7 @@
         assertNotNull( csv.get() );
         assertEquals( "", csv.get() );
         assertFalse( csv.isNormalized() );
-        assertTrue( csv.isValid( new OctetStringSyntaxChecker() ) );
+        assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( csv.isNull() );
         assertNotNull( csv.getNormalizedValue() );
         assertEquals( "", csv.getNormalizedValue() );
@@ -236,14 +235,14 @@
         csv.set( null );
         assertNull( csv.get() );
         assertFalse( csv.isNormalized() );
-        assertFalse( csv.isValid( new Ia5StringSyntaxChecker() ) );
+        assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertTrue( csv.isNull() );
 
         csv.set( "" );
         assertNotNull( csv.get() );
         assertEquals( "", csv.get() );
         assertFalse( csv.isNormalized() );
-        assertTrue( csv.isValid( new OctetStringSyntaxChecker() ) );
+        assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( csv.isNull() );
 
         csv.set( "Test" );
@@ -289,7 +288,7 @@
         assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         csv.clear();
         assertTrue( csv.isNull() );
-        assertFalse( csv.isValid( new Ia5StringSyntaxChecker() ) );
+        assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( csv.isNormalized() );
     }
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/Ia5StringSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/Ia5StringSyntaxCheckerTest.java?rev=775478&r1=775477&r2=775478&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/Ia5StringSyntaxCheckerTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/Ia5StringSyntaxCheckerTest.java
Sat May 16 14:41:27 2009
@@ -39,14 +39,14 @@
     @Test
     public void testNullString()
     {
-        assertFalse( checker.isValidSyntax( null ) );
+        assertTrue( checker.isValidSyntax( null ) );
     }
 
 
     @Test
     public void testEmptyString()
     {
-        assertFalse( checker.isValidSyntax( "" ) );
+        assertTrue( checker.isValidSyntax( "" ) );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/OctetStringSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/OctetStringSyntaxCheckerTest.java?rev=775478&r1=775477&r2=775478&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/OctetStringSyntaxCheckerTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/OctetStringSyntaxCheckerTest.java
Sat May 16 14:41:27 2009
@@ -21,13 +21,14 @@
 
 
 import org.apache.directory.shared.ldap.schema.syntaxes.OctetStringSyntaxChecker;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.junit.Test;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 /**
- * Test cases for BitStringSyntaxChecker.
+ * Test cases for OctetStringSyntaxChecker.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
@@ -45,9 +46,16 @@
 
 
     @Test
-    public void testEmptyString()
+    public void testEmptyOctetString()
     {
-        assertTrue( checker.isValidSyntax( "" ) );
+        assertTrue( checker.isValidSyntax( StringTools.EMPTY_BYTES ) );
+    }
+
+
+    @Test
+    public void testStringOctetString()
+    {
+        assertFalse( checker.isValidSyntax( "" ) );
     }
 
 



Mime
View raw message