directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1085789 [3/4] - in /directory/shared/trunk: dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ dsml/parser/src/test/java/org/apache/directory/shared/d...
Date Sat, 26 Mar 2011 19:17:42 GMT
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueTest.java Sat Mar 26 19:17:40 2011
@@ -34,10 +34,16 @@ import java.io.ObjectOutputStream;
 import java.util.Arrays;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.model.schema.MatchingRule;
 import org.apache.directory.shared.ldap.model.schema.Normalizer;
 import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.model.schema.comparators.ByteArrayComparator;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
 import org.apache.directory.shared.util.StringConstants;
 import org.apache.directory.shared.util.Strings;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -59,34 +65,57 @@ public class BinaryValueTest
     private static final byte[] BYTES2 = new byte[]{(byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84};
     private static final byte[] INVALID_BYTES = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05};
     private static final byte[] BYTES_MOD = new byte[]{0x11, 0x02, 0x03, 0x04};
+    private LdapSyntax s;
+    private AttributeType at;
+    private MatchingRule mr;
     
-    private static final Normalizer BINARY_NORMALIZER = new Normalizer( "1.1.1" )
+    /**
+     * Initialize an AttributeType and the associated MatchingRule 
+     * and Syntax
+     */
+    @Before public void initAT()
     {
-        public Value<?> normalize( Value<?> value ) throws LdapException
+        s = EntryUtils.syntaxFactory( "1.1.1.1", false );
+        s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+        mr = EntryUtils.matchingRuleFactory( "1.1.2.1" );
+        mr.setSyntax( s );
+        
+        mr.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
+        mr.setNormalizer( new Normalizer( "1.1.1" )
         {
-            if ( value.isBinary() )
+            public Value<?> normalize( Value<?> value ) throws LdapException
             {
-                byte[] val = value.getBytes();
-                // each byte will be changed to be > 0, and spaces will be trimmed
-                byte[] newVal = new byte[ val.length ];
-                int i = 0;
-                
-                for ( byte b:val )
+                if ( !value.isHR() )
                 {
-                    newVal[i++] = (byte)(b & 0x007F); 
+                    byte[] val = value.getBytes();
+                    // each byte will be changed to be > 0, and spaces will be trimmed
+                    byte[] newVal = new byte[ val.length ];
+                    int i = 0;
+                    
+                    for ( byte b:val )
+                    {
+                        newVal[i++] = (byte)(b & 0x007F); 
+                    }
+                    
+                    return new BinaryValue( Strings.trim(newVal) );
                 }
-                
-                return new BinaryValue( Strings.trim(newVal) );
-            }
 
-            throw new IllegalStateException( "expected byte[] to normalize" );
-        }
+                throw new IllegalStateException( "expected byte[] to normalize" );
+            }
 
-        public String normalize( String value ) throws LdapException
-        {
-            throw new IllegalStateException( "expected byte[] to normalize" );
-        }
-};
+        
+            public String normalize( String value ) throws LdapException
+            {
+                throw new IllegalStateException( "expected byte[] to normalize" );
+            }
+        });
+        
+        at = new AttributeType( "1.1.3.1" );
+        at.setEquality( mr );
+        at.setOrdering( mr );
+        at.setSubstring( mr );
+        at.setSyntax( s );
+    }
 
     
     /**
@@ -96,7 +125,7 @@ public class BinaryValueTest
     {
         public Value<?> normalize( Value<?> value ) throws LdapException
         {
-            if ( value.isBinary() )
+            if ( !value.isHR() )
             {
                 return new BinaryValue( StringConstants.EMPTY_BYTES );
             }
@@ -165,7 +194,7 @@ public class BinaryValueTest
     /**
      * Deserialize a BinaryValue
      */
-    private BinaryValue deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    private BinaryValue deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
     {
         ObjectInputStream oIn = null;
         ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
@@ -174,7 +203,7 @@ public class BinaryValueTest
         {
             oIn = new ObjectInputStream( in );
 
-            BinaryValue value = new BinaryValue();
+            BinaryValue value = new BinaryValue( at );
             value.readExternal( oIn );
             
             return value;
@@ -222,10 +251,10 @@ public class BinaryValueTest
         BinaryValue cbv = new BinaryValue( (byte[])null );
         
         assertNull( cbv.get() );
-        assertFalse( cbv.isNormalized() );
+        assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertTrue( cbv.isNull() );
-        assertNull( cbv.getNormalizedValue() );
+        assertNull( cbv.getNormValue() );
     }
 
 
@@ -237,12 +266,12 @@ public class BinaryValueTest
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getBytes() ) );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.get() ) );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getReference() ) );
-        assertFalse( cbv.isNormalized() );
+        assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
-        assertNotNull( cbv.getNormalizedValue() );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormalizedValue() ) );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormalizedValueReference() ) );
+        assertNotNull( cbv.getNormValue() );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormValue() ) );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormReference() ) );
     }
 
 
@@ -254,11 +283,11 @@ public class BinaryValueTest
         assertTrue( Arrays.equals( BYTES1, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.get() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getReference() ) );
-        assertFalse( cbv.isNormalized() );
+        assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
-        assertNotNull( cbv.getNormalizedValue() );
-        assertTrue( Arrays.equals( BYTES1, cbv.getNormalizedValue() ) );
+        assertNotNull( cbv.getNormValue() );
+        assertTrue( Arrays.equals( BYTES1, cbv.getNormValue() ) );
     }
 
 
@@ -272,11 +301,11 @@ public class BinaryValueTest
         assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, bv.get() ) );
         assertTrue( Arrays.equals( BYTES1, bv.getReference() ) );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertFalse( bv.isNull() );
-        assertNotNull( bv.getNormalizedValue() );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormalizedValue() ) );
+        assertNotNull( bv.getNormValue() );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
     }
 
 
@@ -288,16 +317,16 @@ public class BinaryValueTest
         assertTrue( Arrays.equals( BYTES2, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES2, cbv.get() ) );
         assertTrue( Arrays.equals( BYTES2, cbv.getReference() ) );
-        assertFalse( cbv.isNormalized() );
+        assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
-        assertNotNull( cbv.getNormalizedValue() );
-        assertTrue( Arrays.equals( BYTES2, cbv.getNormalizedValue() ) );
+        assertNotNull( cbv.getNormValue() );
+        assertTrue( Arrays.equals( BYTES2, cbv.getNormValue() ) );
         
-        cbv.normalize( BINARY_NORMALIZER );
-        byte[] copy = cbv.getNormalizedValue();
+        cbv.apply( at );
+        byte[] copy = cbv.getNormValue();
         assertTrue( Arrays.equals( BYTES1, copy ) );
-        cbv.getNormalizedValueReference()[0]=0x11;
+        cbv.getNormReference()[0]=0x11;
         assertTrue( Arrays.equals( BYTES1, copy ) );
     }
 
@@ -307,27 +336,27 @@ public class BinaryValueTest
     {
         BinaryValue bv = new BinaryValue();
         
-        bv.normalize( BINARY_NORMALIZER );
-        assertTrue( bv.isNormalized() );
-        assertEquals( null, bv.getNormalizedValue() );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
+        assertEquals( null, bv.getNormValue() );
         
         bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        bv.normalize( BINARY_NORMALIZER );
-        assertTrue( bv.isNormalized() );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormalizedValue() ) );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
         
         bv = new BinaryValue( BYTES1 );
-        bv.normalize( BINARY_NORMALIZER );
-        assertTrue( bv.isNormalized() );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
         assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormalizedValue() ) );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
 
         bv = new BinaryValue( BYTES2 );
-        bv.normalize( BINARY_NORMALIZER );
-        assertTrue( bv.isNormalized() );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
         assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormalizedValue() ) );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
     }
 
 
@@ -345,7 +374,7 @@ public class BinaryValueTest
         bv2 = new BinaryValue( BYTES2 );
         assertEquals( 1, bv1.compareTo( bv2 ) );
         
-        bv2.normalize( BINARY_NORMALIZER );
+        bv2.apply( at );
         assertEquals( 0, bv1.compareTo( bv2 ) );
         
         bv1 = new BinaryValue( BYTES2 );
@@ -367,7 +396,7 @@ public class BinaryValueTest
         bv2 = new BinaryValue( BYTES2 );
         assertNotSame( bv1, bv2 );
         
-        bv2.normalize( BINARY_NORMALIZER );
+        bv2.apply( at );
         assertEquals( bv1, bv2 );
         
         bv1 = new BinaryValue( BYTES2 );
@@ -436,7 +465,7 @@ public class BinaryValueTest
         // Now check that the equals method works on normalized values.
         bv1 = new BinaryValue( BYTES2 );
         bv2 = new BinaryValue( BYTES1 );
-        bv1.normalize( BINARY_NORMALIZER );
+        bv1.apply( at );
         assertEquals( 0, bv1.compareTo( bv2 ) );
         
         bv1 = new BinaryValue( BYTES1 );
@@ -513,18 +542,18 @@ public class BinaryValueTest
     {
         BinaryValue bv = new BinaryValue();
         
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
 
-        bv.normalize( BINARY_NORMALIZER );
-        byte[] value = bv.getNormalizedValue();
+        bv.apply( at );
+        byte[] value = bv.getNormValue();
         assertNull( value );
-        assertTrue( bv.isNormalized() );
+        assertTrue( bv.isSchemaAware() );
         
         bv = new BinaryValue( BYTES2 );
-        bv.normalize( BINARY_NORMALIZER );
-        value = bv.getNormalizedValue();
+        bv.apply( at );
+        value = bv.getNormValue();
         assertTrue( Arrays.equals( BYTES1, value ) );
-        bv.getNormalizedValueReference()[0]=0x11;
+        bv.getNormReference()[0]=0x11;
         assertFalse( Arrays.equals( BYTES_MOD, value ) );
     }
 
@@ -534,18 +563,18 @@ public class BinaryValueTest
     {
         BinaryValue bv = new BinaryValue();
         
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
 
-        bv.normalize( BINARY_NORMALIZER );
-        byte[] value = bv.getNormalizedValueReference();
+        bv.apply( at );
+        byte[] value = bv.getNormReference();
         assertNull( value );
-        assertTrue( bv.isNormalized() );
+        assertTrue( bv.isSchemaAware() );
         
         bv = new BinaryValue( BYTES2 );
-        bv.normalize( BINARY_NORMALIZER );
-        value = bv.getNormalizedValueReference();
+        bv.apply( at );
+        value = bv.getNormReference();
         assertTrue( Arrays.equals( BYTES1, value ) );
-        bv.getNormalizedValueReference()[0]=0x11;
+        bv.getNormReference()[0]=0x11;
         assertTrue( Arrays.equals( BYTES_MOD, value ) );
     }
 
@@ -570,24 +599,18 @@ public class BinaryValueTest
     {
         BinaryValue bv = new BinaryValue();
         
-        assertFalse( bv.isValid() );
-        bv.isValid( BINARY_CHECKER );
-        assertTrue( bv.isValid() );
+        assertTrue( bv.isValid( BINARY_CHECKER ) );
         
         bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        assertFalse( bv.isValid() );
-        bv.isValid( BINARY_CHECKER );
-        assertTrue( bv.isValid() );
+        assertTrue( bv.isValid( BINARY_CHECKER ) );
         
         bv = new BinaryValue( BYTES1 );
         assertFalse( bv.isNull() );
-        bv.isValid( BINARY_CHECKER );
-        assertTrue( bv.isValid() );
+        assertTrue( bv.isValid( BINARY_CHECKER ) );
 
         bv = new BinaryValue( INVALID_BYTES );
         assertFalse( bv.isNull() );
-        bv.isValid( BINARY_CHECKER );
-        assertFalse( bv.isValid() );
+        assertFalse( bv.isValid( BINARY_CHECKER ) );
     }
 
 
@@ -614,19 +637,20 @@ public class BinaryValueTest
     {
         BinaryValue bv = new BinaryValue();
         
-        bv.normalize();
-        assertTrue( bv.isNormalized() );
-        assertEquals( null, bv.getNormalizedValue() );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
+        assertEquals( null, bv.getNormValue() );
         
         bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        bv.normalize();
-        assertTrue( bv.isNormalized() );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormalizedValue() ) );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
         
         bv = new BinaryValue( BYTES2 );
-        bv.normalize();
-        assertTrue( bv.isNormalized() );
-        assertTrue( Arrays.equals( BYTES2, bv.getNormalizedValue() ) );
+        bv.apply( at );
+        assertTrue( bv.isSchemaAware() );
+        assertTrue( Arrays.equals( BYTES2, bv.get() ) );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
     }
 
 
@@ -636,21 +660,21 @@ public class BinaryValueTest
         BinaryValue bv = new BinaryValue( (byte[])null );
         
         assertNull( bv.get() );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertTrue( bv.isNull() );
 
         bv = new BinaryValue( StringConstants.EMPTY_BYTES );
         assertNotNull( bv.get() );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertFalse( bv.isNull() );
 
         bv = new BinaryValue( BYTES1 );
         assertNotNull( bv.get() );
         assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertFalse( bv.isNull() );
     }
@@ -660,21 +684,21 @@ public class BinaryValueTest
     public void testIsNormalized() throws LdapException
     {
         BinaryValue bv = new BinaryValue();
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         
         bv = new BinaryValue( BYTES2 );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         
-        bv.normalize( BINARY_NORMALIZER );
+        bv.apply( at );
         
-        assertTrue( Arrays.equals( BYTES1, bv.getNormalizedValue() ) );
-        assertTrue( bv.isNormalized() );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
+        assertTrue( bv.isSchemaAware() );
         
         bv = new BinaryValue( BYTES2 );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
 
         bv = new BinaryValue( BYTES_MOD );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
     }
 
 
@@ -683,24 +707,17 @@ public class BinaryValueTest
     {
         BinaryValue bv = new BinaryValue();
         
-        assertFalse( bv.isNormalized() );
-        
-        bv.setNormalized( true );
-        assertTrue( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         
         bv = new BinaryValue( BYTES2 );
-        assertFalse( bv.isNormalized() );
+        assertFalse( bv.isSchemaAware() );
         
-        bv.normalize( BINARY_NORMALIZER );
+        bv.apply( at );
         
-        assertTrue( Arrays.equals( BYTES1, bv.getNormalizedValue() ) );
-        assertTrue( bv.isNormalized() );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
+        assertTrue( bv.isSchemaAware() );
         
-        bv.setNormalized( false );
-        assertTrue( Arrays.equals( BYTES2, bv.getNormalizedValue() ) );
-        assertTrue( bv.isNormalized() );
-
-        bv.normalize( BINARY_NORMALIZER );
+        assertTrue( Arrays.equals( BYTES2, bv.get() ) );
     }
     
     
@@ -711,17 +728,15 @@ public class BinaryValueTest
     public void testSerializeStandard() throws LdapException, IOException, ClassNotFoundException
     {
         BinaryValue bv = new BinaryValue();
-        bv.setNormalized( true );
         bv = new BinaryValue( BYTES2 );
-        bv.normalize( BINARY_NORMALIZER );
-        bv.isValid( BINARY_CHECKER );
+        bv.apply( at );
+        assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        BinaryValue cbvSer = deserializeValue( serializeValue( bv ) );
+        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
         assertNotSame( bv, cbvSer );
         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
-        assertTrue( Arrays.equals( bv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
-        assertTrue( cbvSer.isNormalized() );
-        assertFalse( cbvSer.isValid() );
+        assertTrue( Arrays.equals( bv.getNormReference(), cbvSer.getNormReference() ) );
+        assertTrue( cbvSer.isSchemaAware() );
     }
     
     
@@ -732,16 +747,14 @@ public class BinaryValueTest
     public void testSerializeNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
         BinaryValue bv = new BinaryValue();
-        bv.setNormalized( false );
         bv = new BinaryValue( BYTES2 );
         bv.isValid( BINARY_CHECKER );
 
-        BinaryValue cbvSer = deserializeValue( serializeValue( bv ) );
-         assertNotSame( bv, cbvSer );
-         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
-         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getNormalizedValueReference() ) );
-         assertTrue( cbvSer.isNormalized() );
-         assertFalse( cbvSer.isValid() );
+        BinaryValue cbvSer = deserializeValue( null, serializeValue( bv ) );
+        assertNotSame( bv, cbvSer );
+        assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
+        assertTrue( Arrays.equals( bv.getReference(), cbvSer.getNormReference() ) );
+        assertFalse( cbvSer.isSchemaAware() );
     }
     
     
@@ -752,17 +765,15 @@ public class BinaryValueTest
     public void testSerializeEmptyNormalized() throws LdapException, IOException, ClassNotFoundException
     {
         BinaryValue bv = new BinaryValue();
-        bv.setNormalized( true );
         bv = new BinaryValue( BYTES2 );
         bv.isValid( BINARY_CHECKER );
-        bv.normalize( BINARY_NORMALIZER_EMPTY );
+        bv.apply( at );
 
-        BinaryValue cbvSer = deserializeValue( serializeValue( bv ) );
-         assertNotSame( bv, cbvSer );
-         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
-         assertTrue( Arrays.equals( bv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
-         assertTrue( cbvSer.isNormalized() );
-         assertFalse( cbvSer.isValid() );
+        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        assertNotSame( bv, cbvSer );
+        assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
+        assertTrue( Arrays.equals( bv.getNormReference(), cbvSer.getNormReference() ) );
+        assertTrue( cbvSer.isSchemaAware() );
     }
     
     
@@ -773,17 +784,15 @@ public class BinaryValueTest
     public void testSerializeNullValue() throws LdapException, IOException, ClassNotFoundException
     {
         BinaryValue bv = new BinaryValue();
-        bv.setNormalized( true );
         bv = new BinaryValue( (byte[])null );
         bv.isValid( BINARY_CHECKER );
-        bv.normalize( BINARY_NORMALIZER );
+        bv.apply( at );
 
-        BinaryValue cbvSer = deserializeValue( serializeValue( bv ) );
-         assertNotSame( bv, cbvSer );
-         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
-         assertTrue( Arrays.equals( bv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
-         assertTrue( cbvSer.isNormalized() );
-         assertFalse( cbvSer.isValid() );
+        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        assertNotSame( bv, cbvSer );
+        assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
+        assertTrue( Arrays.equals( bv.getNormReference(), cbvSer.getNormReference() ) );
+        assertTrue( cbvSer.isSchemaAware() );
     }
     
     
@@ -794,17 +803,15 @@ public class BinaryValueTest
     public void testSerializeEmptyValue() throws LdapException, IOException, ClassNotFoundException
     {
         BinaryValue bv = new BinaryValue();
-        bv.setNormalized( true );
         bv = new BinaryValue( StringConstants.EMPTY_BYTES );
         bv.isValid( BINARY_CHECKER );
-        bv.normalize( BINARY_NORMALIZER );
+        bv.apply( at );
 
-        BinaryValue cbvSer = deserializeValue( serializeValue( bv ) );
-         assertNotSame( bv, cbvSer );
-         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
-         assertTrue( Arrays.equals( bv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
-         assertTrue( cbvSer.isNormalized() );
-         assertFalse( cbvSer.isValid() );
+        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        assertNotSame( bv, cbvSer );
+        assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
+        assertTrue( Arrays.equals( bv.getNormReference(), cbvSer.getNormReference() ) );
+        assertTrue( cbvSer.isSchemaAware() );
     }
     
     
@@ -815,15 +822,13 @@ public class BinaryValueTest
     public void testSerializeEmptyValueNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
         BinaryValue bv = new BinaryValue();
-        bv.setNormalized( false );
         bv = new BinaryValue( StringConstants.EMPTY_BYTES );
         bv.isValid( BINARY_CHECKER );
 
-        BinaryValue cbvSer = deserializeValue( serializeValue( bv ) );
-         assertNotSame( bv, cbvSer );
-         assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
-         assertTrue( Arrays.equals( bv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
-         assertTrue( cbvSer.isNormalized() );
-         assertFalse( cbvSer.isValid() );
+        BinaryValue cbvSer = deserializeValue( null, serializeValue( bv ) );
+        assertNotSame( bv, cbvSer );
+        assertTrue( Arrays.equals( bv.getReference(), cbvSer.getReference() ) );
+        assertTrue( Arrays.equals( bv.getNormReference(), cbvSer.getNormReference() ) );
+        assertFalse( cbvSer.isSchemaAware() );
     }
 }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttributeTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttributeTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttributeTest.java Sat Mar 26 19:17:40 2011
@@ -454,7 +454,7 @@ public class DefaultEntryAttributeTest
      * Test method iterator()
      */
     @Test
-    public void testIterator()
+    public void testIterator() throws LdapException
     {
         EntryAttribute attr = new DefaultEntryAttribute();
         attr.add(  "a", "b", "c" );
@@ -916,7 +916,7 @@ public class DefaultEntryAttributeTest
      * Test method getAll()
      */
     @Test
-    public void testGetAll()
+    public void testGetAll() throws LdapException
     {
         EntryAttribute attr = new DefaultEntryAttribute( "test" );
         
@@ -1397,7 +1397,7 @@ public class DefaultEntryAttributeTest
      * Test method testEquals()
      */
     @Test
-    public void testEquals()
+    public void testEquals() throws LdapException
     {
         EntryAttribute attr1 = new DefaultEntryAttribute( "test" );
         
@@ -1459,7 +1459,7 @@ public class DefaultEntryAttributeTest
      * Test method testClone()
      */
     @Test
-    public void testClone()
+    public void testClone() throws LdapException
     {
         EntryAttribute attr = new DefaultEntryAttribute( "test" );
         
@@ -1502,7 +1502,6 @@ public class DefaultEntryAttributeTest
         assertEquals( "test1", dcaSer.getString() );
         assertTrue( dcaSer.contains( "test2", "test1" ) );
         assertTrue( dcaSer.isHR() );
-        assertFalse( dcaSer.isValid() );
     }
     
     
@@ -1545,7 +1544,6 @@ public class DefaultEntryAttributeTest
         assertEquals( 1, dcaSer.size() );
         assertTrue( dcaSer.contains( (String)null ) );
         assertTrue( dcaSer.isHR() );
-        assertFalse( dcaSer.isValid() );
     }
     
     
@@ -1568,6 +1566,5 @@ public class DefaultEntryAttributeTest
         assertEquals( 1, dcaSer.size() );
         assertTrue( dcaSer.contains( password ) );
         assertFalse( dcaSer.isHR() );
-        assertFalse( dcaSer.isValid() );
     }
 }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java Sat Mar 26 19:17:40 2011
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -121,7 +122,7 @@ public class ModificationTest
     
     
     @Test 
-    public void testCreateServerModification()
+    public void testCreateServerModification() throws LdapException
     {
         EntryAttribute attribute = new DefaultEntryAttribute( "cn" );
         attribute.add( "test1", "test2" );
@@ -143,7 +144,7 @@ public class ModificationTest
     
     
     @Test
-    public void testSerializationModificationADD() throws ClassNotFoundException, IOException
+    public void testSerializationModificationADD() throws ClassNotFoundException, IOException, LdapException
     {
         EntryAttribute attribute = new DefaultEntryAttribute( "cn" );
         attribute.add( "test1", "test2" );
@@ -157,7 +158,7 @@ public class ModificationTest
     
     
     @Test
-    public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException
+    public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException, LdapException
     {
         EntryAttribute attribute = new DefaultEntryAttribute( "cn" );
         attribute.add( "test1", "test2" );
@@ -171,7 +172,7 @@ public class ModificationTest
     
     
     @Test
-    public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException
+    public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException, LdapException
     {
         EntryAttribute attribute = new DefaultEntryAttribute( "cn" );
         attribute.add( "test1", "test2" );

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java Sat Mar 26 19:17:40 2011
@@ -39,6 +39,7 @@ import java.util.HashSet;
 import java.util.List;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.LdapComparator;
 import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
@@ -79,7 +80,8 @@ public class StringValueAttributeTypeTes
      * Initialize an AttributeType and the associated MatchingRule 
      * and Syntax
      */
-    @Before public void initAT()
+    @Before
+    public void initAT()
     {
         s = new EntryUtils.S( "1.1.1.1", false );
         s.setSyntaxChecker( new OctetStringSyntaxChecker() );
@@ -175,7 +177,7 @@ public class StringValueAttributeTypeTes
      * Test the constructor with a null value
      */
     @Test 
-    public void testClientStringValueNullValue()
+    public void testClientStringValueNullValue() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
         
@@ -187,27 +189,27 @@ public class StringValueAttributeTypeTes
     
     
     /**
-     * Test the getNormalizedValue method
+     * Test the getNormValue method
      */
-    @Test public void testGetNormalizedValue()
+    @Test 
+    public void testGetNormalizedValue() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
         
         StringValue sv = new StringValue( attribute, null );
         
-        assertFalse( sv.isNormalized() );
-        assertNull( sv.getNormalizedValue() );
-        assertTrue( sv.isNormalized() );
+        assertTrue( sv.isSchemaAware() );
+        assertNull( sv.getNormValue() );
+        assertTrue( sv.isSchemaAware() );
 
         sv = new StringValue( attribute, "" );
-        assertFalse( sv.isNormalized() );
-        assertEquals( "", sv.getNormalizedValue() );
-        assertTrue( sv.isNormalized() );
+        assertTrue( sv.isSchemaAware() );
+        assertEquals( "", sv.getNormValue() );
+        assertTrue( sv.isSchemaAware() );
 
         sv = new StringValue( attribute, "TEST" );
-        assertFalse( sv.isNormalized() );
-        assertEquals( "test", sv.getNormalizedValue() );
-        assertTrue( sv.isNormalized() );
+        assertTrue( sv.isSchemaAware() );
+        assertEquals( "test", sv.getNormValue() );
     }
     
 
@@ -216,21 +218,24 @@ public class StringValueAttributeTypeTes
      * 
      * The SyntaxChecker does not accept values longer than 5 chars.
      */
-    @Test public void testIsValid()
+    @Test 
+    public void testIsValid() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
         
-        StringValue sv = new StringValue( attribute, null );
-        assertTrue( sv.isValid() );
-
-        sv = new StringValue( attribute, "" );
-        assertTrue( sv.isValid() );
-
-        sv = new StringValue( attribute, "TEST" );
-        assertTrue( sv.isValid() );
+        new StringValue( attribute, null );
+        new StringValue( attribute, "" );
+        new StringValue( attribute, "TEST" );
 
-        sv = new StringValue( attribute, "testlong" );
-        assertFalse( sv.isValid() );
+        try
+        {
+            new StringValue( attribute, "testlong" );
+            fail();
+        }
+        catch ( LdapInvalidAttributeValueException liave )
+        {
+            assertTrue( true );
+        }
     }
     
     
@@ -238,21 +243,20 @@ public class StringValueAttributeTypeTes
      * Test the normalize method
      */
     @Test
-    public void testNormalize() throws LdapException
+    public void testApply() throws LdapException
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
         StringValue sv = new StringValue( attribute );
 
-        sv.normalize();
-        assertEquals( null, sv.getNormalizedValue() );
+        sv.apply( at );
+        assertEquals( null, sv.getNormValue() );
         
         sv = new StringValue( attribute, "" );
-        sv.normalize();
-        assertEquals( "", sv.getNormalizedValue() );
+        sv.apply( at );
+        assertEquals( "", sv.getNormValue() );
 
-        sv = new StringValue( attribute, "  This is    a   TEST  " );
-        sv.normalize();
-        assertEquals( "this is a test", sv.getNormalizedValue() );
+        sv = new StringValue( attribute, "  A   TEST  " );
+        assertEquals( "a test", sv.getNormValue() );
     }
     
 
@@ -289,7 +293,8 @@ public class StringValueAttributeTypeTes
     /**
      * Test the equals method
      */
-    @Test public void testEquals()
+    @Test 
+    public void testEquals() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getIA5StringAttributeType();
         AttributeType at2 = EntryUtils.getBytesAttributeType();
@@ -318,7 +323,8 @@ public class StringValueAttributeTypeTes
     /**
      * Test the constructor with bad AttributeType
      */
-    @Test public void testBadConstructor()
+    @Test 
+    public void testBadConstructor()
     {
         // create a AT without any syntax
         AttributeType attribute = new EntryUtils.AT( "1.1.3.1" );
@@ -339,7 +345,8 @@ public class StringValueAttributeTypeTes
      * Tests to make sure the hashCode method is working properly.
      * @throws Exception on errors
      */
-    @Test public void testHashCode()
+    @Test 
+    public void testHashCode() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
         StringValue v0 = new StringValue( at1, "Alex" );
@@ -354,13 +361,8 @@ public class StringValueAttributeTypeTes
         assertEquals( v0, v2 );
         assertEquals( v1, v2 );
         
-        assertTrue( v0.isValid() );
-        assertTrue( v1.isValid() );
-        assertTrue( v2.isValid() );
-
         StringValue v3 = new StringValue( at1, "Timber" );
         
-        assertTrue( v3.isValid() );
         assertNotSame( v0.hashCode(), v3.hashCode() );
 
         StringValue v4 = new StringValue( at, "Alex" );
@@ -373,7 +375,7 @@ public class StringValueAttributeTypeTes
      * Test the compareTo method
      */
     @Test
-    public void testCompareTo()
+    public void testCompareTo() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
         StringValue v0 = new StringValue( at1, "Alex" );
@@ -411,9 +413,6 @@ public class StringValueAttributeTypeTes
         sv1 = sv.clone();
         
         assertEquals( sv, sv1 );
-        
-        sv.normalize();
-        
         assertEquals( sv, sv1 );
     }
     
@@ -425,7 +424,8 @@ public class StringValueAttributeTypeTes
      *
      * @throws Exception on errors
      */
-    @Test public void testConstrainedString()
+    @Test 
+    public void testConstrainedString() throws LdapInvalidAttributeValueException
     {
         s.setSyntaxChecker( new SyntaxChecker( "1.1.1.1" ) {
             public boolean isValidSyntax( Object value )
@@ -486,33 +486,28 @@ public class StringValueAttributeTypeTes
         // check that normalization and syntax checks work as expected
         StringValue value = new StringValue( at, "HIGH" );
         assertEquals( value.get(), value.get() );
-        assertTrue( value.isValid() );
-        value = new StringValue( at, "high" );
-        assertFalse( value.isValid() );
+        
+        try
+        {  
+            new StringValue( at, "high" );
+            fail();
+        }
+        catch ( LdapInvalidAttributeValueException liave )
+        {
+            // expected
+        }
 
         // create a bunch to best tested for equals and in containers
         StringValue v0 = new StringValue( at, "LOW" );
-        assertTrue( v0.isValid() );
         StringValue v1 = new StringValue( at, "LOW" );
-        assertTrue( v1.isValid() );
         StringValue v2 = new StringValue( at, "MEDIUM" );
-        assertTrue( v2.isValid() );
         StringValue v3 = new StringValue( at, "HIGH" );
-        assertTrue( v3.isValid() );
-        StringValue v4 = new StringValue( at );
-        assertFalse( v4.isValid() );
-        StringValue v5 = new StringValue( at );
-        assertFalse( v5.isValid() );
 
         // check equals
         assertTrue( v0.equals( v1 ) );
         assertTrue( v1.equals( v0 ) );
         assertEquals( 0, v0.compareTo( v1 ) );
 
-        assertTrue( v4.equals( v5 ) );
-        assertTrue( v5.equals( v4 ) );
-        assertEquals( 0, v4.compareTo( v5 ) );
-
         assertFalse( v2.equals( v3 ) );
         assertFalse( v3.equals( v2 ) );
         assertTrue( v2.compareTo( v3 ) < 0 );
@@ -523,40 +518,28 @@ public class StringValueAttributeTypeTes
         set.add( v0 );
         set.add( v2 );
         set.add( v3 );
-        set.add( v4 );
 
         // check contains method
         assertTrue( "since v1.equals( v0 ) and v0 was added then this should be true", set.contains( v1 ) );
-        assertTrue( "since v4.equals( v5 ) and v4 was added then this should be true", set.contains( v5 ) );
 
         // check ordering based on the comparator
         List<Value<String>> list = new ArrayList<Value<String>>();
         list.add( v1 );
         list.add( v3 );
-        list.add( v5 );
         list.add( v0 );
         list.add( v2 );
-        list.add( v4 );
 
         Collections.sort( list );
 
-        // null ones are at first 2 indices
-        assertTrue( "since v4 equals v5 and has no value either could be at index 0 & 1", list.get( 0 ).equals( v4 ) );
-        assertTrue( "since v4 equals v5 and has no value either could be at index 0 & 1", list.get( 0 ).equals( v5 ) );
-        assertTrue( "since v4 equals v5 and has no value either could be at index 0 & 1", list.get( 1 ).equals( v4 ) );
-        assertTrue( "since v4 equals v5 and has no value either could be at index 0 & 1", list.get( 1 ).equals( v5 ) );
-
         // low ones are at the 3rd and 4th indices
-        assertTrue( "since v0 equals v1 either could be at index 2 & 3", list.get( 2 ).equals( v0 ) );
-        assertTrue( "since v0 equals v1 either could be at index 2 & 3", list.get( 2 ).equals( v1 ) );
-        assertTrue( "since v0 equals v1 either could be at index 2 & 3", list.get( 3 ).equals( v0 ) );
-        assertTrue( "since v0 equals v1 either could be at index 2 & 3", list.get( 3 ).equals( v1 ) );
+        assertTrue( "since v0 equals v1 either could be at index 0 & 1", list.get( 0 ).equals( v0 ) );
+        assertTrue( "since v0 equals v1 either could be at index 0 & 1", list.get( 1 ).equals( v1 ) );
 
         // medium then high next
-        assertTrue( "since v2 \"MEDIUM\" should be at index 4", list.get( 4 ).equals( v2 ) );
-        assertTrue( "since v3 \"HIGH\" should be at index 5", list.get( 5 ).equals( v3 ) );
+        assertTrue( "since v2 \"MEDIUM\" should be at index 2", list.get( 2 ).equals( v2 ) );
+        assertTrue( "since v3 \"HIGH\" should be at index 3", list.get( 3 ).equals( v3 ) );
 
-        assertEquals( 6, list.size() );
+        assertEquals( 4, list.size() );
     }
 
 
@@ -568,12 +551,12 @@ public class StringValueAttributeTypeTes
      * is still OK.
      * @throws Exception on errors
      */
-    @Test public void testAcceptAllNoNormalization()
+    @Test 
+    public void testAcceptAllNoNormalization() throws LdapInvalidAttributeValueException
     {
         // check that normalization and syntax checks work as expected
         StringValue value = new StringValue( at, "hello" );
         assertEquals( value.get(), value.get() );
-        assertTrue( value.isValid() );
 
         // create a bunch to best tested for equals and in containers
         StringValue v0 = new StringValue( at, "hello" );
@@ -663,13 +646,13 @@ public class StringValueAttributeTypeTes
     /**
      * Test serialization of a StringValue which has a normalized value
      */
-    @Test public void testNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
+    @Test 
+    public void testNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
         StringValue ssv = new StringValue( at, "  Test   Test  " );
         
-        ssv.normalize();
-        String normalized = ssv.getNormalizedValue();
+        String normalized = ssv.getNormValue();
         
         assertEquals( "test test", normalized );
         assertEquals( "  Test   Test  ", ssv.getString() );
@@ -683,13 +666,13 @@ public class StringValueAttributeTypeTes
     /**
      * Test serialization of a StringValue which does not have a normalized value
      */
-    @Test public void testNoNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
+    @Test 
+    public void testNoNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
         StringValue ssv = new StringValue( at, "test" );
         
-        ssv.normalize();
-        String normalized = ssv.getNormalizedValue();
+        String normalized = ssv.getNormValue();
         
         assertEquals( "test", normalized );
         assertEquals( "test", ssv.getString() );
@@ -703,13 +686,13 @@ public class StringValueAttributeTypeTes
     /**
      * Test serialization of a null StringValue
      */
-    @Test public void testNullStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
+    @Test 
+    public void testNullStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
         StringValue ssv = new StringValue( at );
         
-        ssv.normalize();
-        String normalized = ssv.getNormalizedValue();
+        String normalized = ssv.getNormValue();
         
         assertNull( normalized );
         assertNull( ssv.get() );
@@ -723,13 +706,13 @@ public class StringValueAttributeTypeTes
     /**
      * Test serialization of an empty StringValue
      */
-    @Test public void testEmptyStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
+    @Test 
+    public void testEmptyStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
         StringValue ssv = new StringValue( at, "" );
         
-        ssv.normalize();
-        String normalized = ssv.getNormalizedValue();
+        String normalized = ssv.getNormValue();
         
         assertEquals( "", normalized );
         assertEquals( "", ssv.getString() );
@@ -743,7 +726,8 @@ public class StringValueAttributeTypeTes
     /**
      * Test serialization of an empty StringValue
      */
-    @Test public void testStringValueEmptyNormalizedSerialization() throws LdapException, IOException, ClassNotFoundException
+    @Test 
+    public void testStringValueEmptyNormalizedSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
         StringValue ssv = new StringValue( "  " );

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java Sat Mar 26 19:17:40 2011
@@ -19,11 +19,11 @@
 package org.apache.directory.shared.ldap.model.entry;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -31,14 +31,19 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.comparators.StringComparator;
 import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.Ia5StringSyntaxChecker;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 /**
  * 
  * Test the StringValue class
@@ -49,6 +54,32 @@ import org.junit.runner.RunWith;
 @Concurrency()
 public class StringValueTest
 {
+    private static EntryUtils.S s;
+    private static EntryUtils.AT at;
+    private static EntryUtils.MR mr;
+
+
+    /**
+     * Initialize an AttributeType and the associated MatchingRule 
+     * and Syntax
+     */
+    @BeforeClass 
+    public static void initAT()
+    {
+        s = new EntryUtils.S( "1.1.1.1", false );
+        s.setSyntaxChecker( new OctetStringSyntaxChecker() );
+        mr = new EntryUtils.MR( "1.1.2.1" );
+        mr.setSyntax( s );
+        mr.setLdapComparator( new StringComparator( "1.1.2.1" ) );
+        mr.setNormalizer( new DeepTrimToLowerNormalizer( "1.1.2.1" ) );
+        at = new EntryUtils.AT( "1.1.3.1" );
+        at.setEquality( mr );
+        at.setOrdering( mr );
+        at.setSubstring( mr );
+        at.setSyntax( s );
+    }
+    
+    
     //----------------------------------------------------------------------------------
     // Helper method
     //----------------------------------------------------------------------------------
@@ -60,30 +91,8 @@ public class StringValueTest
         ObjectOutputStream oOut = null;
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        try
-        {
-            oOut = new ObjectOutputStream( out );
-            oOut.writeObject( value );
-        }
-        catch ( IOException ioe )
-        {
-            throw ioe;
-        }
-        finally
-        {
-            try
-            {
-                if ( oOut != null )
-                {
-                    oOut.flush();
-                    oOut.close();
-                }
-            }
-            catch ( IOException ioe )
-            {
-                throw ioe;
-            }
-        }
+        oOut = new ObjectOutputStream( out );
+        value.writeExternal( oOut );
         
         return out;
     }
@@ -92,7 +101,7 @@ public class StringValueTest
     /**
      * Deserialize a StringValue
      */
-    private StringValue deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    private StringValue deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
     {
         ObjectInputStream oIn = null;
         ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
@@ -101,7 +110,8 @@ public class StringValueTest
         {
             oIn = new ObjectInputStream( in );
 
-            StringValue value = ( StringValue ) oIn.readObject();
+            StringValue value = new StringValue( at );
+            value.readExternal( oIn );
 
             return value;
         }
@@ -124,8 +134,8 @@ public class StringValueTest
             }
         }
     }
-
-
+    
+    
     //----------------------------------------------------------------------------------
     // Test the clone() method
     //----------------------------------------------------------------------------------
@@ -164,13 +174,13 @@ public class StringValueTest
         assertEquals( sv, sv1 );
         assertEquals( "  This is    a   TEST  ", sv.getString() );
 
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv.apply( at );
         
         assertNotSame( sv, sv1 );
         assertEquals( "  This is    a   TEST  ", sv1.getString() );
-        assertEquals( "  This is    a   TEST  ", sv1.getNormalizedValue() );
+        assertEquals( "  This is    a   TEST  ", sv1.getNormValue() );
         assertEquals( "  This is    a   TEST  ", sv.getString() );
-        assertEquals( "this is a test", sv.getNormalizedValue() );
+        assertEquals( "this is a test", sv.getNormValue() );
     }
 
 
@@ -200,10 +210,10 @@ public class StringValueTest
         StringValue csv = new StringValue();
         
         assertNull( csv.get() );
-        assertFalse( csv.isNormalized() );
+        assertFalse( csv.isSchemaAware() );
         assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertTrue( csv.isNull() );
-        assertNull( csv.getNormalizedValue() );
+        assertNull( csv.getNormValue() );
     }
 
 
@@ -217,11 +227,11 @@ public class StringValueTest
         
         assertNotNull( csv.get() );
         assertEquals( "", csv.getString() );
-        assertFalse( csv.isNormalized() );
+        assertFalse( csv.isSchemaAware() );
         assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( csv.isNull() );
-        assertNotNull( csv.getNormalizedValue() );
-        assertEquals( "", csv.getNormalizedValue() );
+        assertNotNull( csv.getNormValue() );
+        assertEquals( "", csv.getNormValue() );
     }
 
 
@@ -234,11 +244,11 @@ public class StringValueTest
         StringValue csv = new StringValue( "test" );
         
         assertEquals( "test", csv.get() );
-        assertFalse( csv.isNormalized() );
+        assertFalse( csv.isSchemaAware() );
         assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( csv.isNull() );
-        assertNotNull( csv.getNormalizedValue() );
-        assertEquals( "test", csv.getNormalizedValue() );
+        assertNotNull( csv.getNormValue() );
+        assertEquals( "test", csv.getNormValue() );
     }
 
 
@@ -280,21 +290,21 @@ public class StringValueTest
         StringValue sv = new StringValue( (String)null );
         
         assertNull( sv.get() );
-        assertFalse( sv.isNormalized() );
+        assertFalse( sv.isSchemaAware() );
         assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
         assertTrue( sv.isNull() );
 
         sv = new StringValue( "" );
         assertNotNull( sv.get() );
         assertEquals( "", sv.get() );
-        assertFalse( sv.isNormalized() );
+        assertFalse( sv.isSchemaAware() );
         assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( sv.isNull() );
 
         sv = new StringValue( "Test" );
         assertNotNull( sv.get() );
         assertEquals( "Test", sv.get() );
-        assertFalse( sv.isNormalized() );
+        assertFalse( sv.isSchemaAware() );
         assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( sv.isNull() );
     }
@@ -315,22 +325,22 @@ public class StringValueTest
 
     
     /**
-     * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#isNormalized()}.
+     * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#isSchemaAware()}.
      */
     @Test
     public void testIsNormalized() throws LdapException
     {
         StringValue sv = new StringValue( "  This is    a   TEST  " );
         
-        assertFalse( sv.isNormalized() );
+        assertFalse( sv.isSchemaAware() );
         
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv.apply( at );
         
-        assertEquals( "this is a test", sv.getNormalizedValue() );
-        assertTrue( sv.isNormalized() );
+        assertEquals( "this is a test", sv.getNormValue() );
+        assertTrue( sv.isSchemaAware() );
         
         sv = new StringValue( "test" );
-        assertFalse( sv.isNormalized() );
+        assertFalse( sv.isSchemaAware() );
     }
 
 
@@ -342,62 +352,53 @@ public class StringValueTest
     {
         StringValue sv = new StringValue();
         
-        assertFalse( sv.isNormalized() );
-        
-        sv.setNormalized( true );
-        assertTrue( sv.isNormalized() );
+        assertFalse( sv.isSchemaAware() );
         
         sv = new StringValue( "  This is    a   TEST  " );
-        assertFalse( sv.isNormalized() );
-        
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        assertFalse( sv.isSchemaAware() );
         
-        assertEquals( "this is a test", sv.getNormalizedValue() );
-        assertTrue( sv.isNormalized() );
+        sv.apply( at );
         
-        sv.setNormalized( false );
-        assertEquals( "this is a test", sv.getNormalizedValue() );
-        assertFalse( sv.isNormalized() );
-
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        assertEquals( "this is a test", sv.getNormValue() );
+        assertTrue( sv.isSchemaAware() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#getNormalizedValue()}.
+     * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#getNormValue()}.
      */
     @Test
     public void testGetNormalizedValue() throws LdapException
     {
         StringValue sv = new StringValue();
         
-        assertEquals( null, sv.getNormalizedValue() );
+        assertEquals( null, sv.getNormValue() );
         
         sv = new StringValue( "  This is    a   TEST  " );
-        assertEquals( "  This is    a   TEST  ", sv.getNormalizedValue() );
+        assertEquals( "  This is    a   TEST  ", sv.getNormValue() );
         
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv.apply( at );
         
-        assertEquals( "this is a test", sv.getNormalizedValue() );
+        assertEquals( "this is a test", sv.getNormValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#getNormalizedValue()}.
+     * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#getNormValue()}.
      */
     @Test
-    public void getNormalizedValueCopy() throws LdapException
+    public void getNormValueCopy() throws LdapException
     {
         StringValue sv = new StringValue();
         
-        assertEquals( null, sv.getNormalizedValue() );
+        assertEquals( null, sv.getNormValue() );
         
         sv = new StringValue( "  This is    a   TEST  " );
-        assertEquals( "  This is    a   TEST  ", sv.getNormalizedValue() );
+        assertEquals( "  This is    a   TEST  ", sv.getNormValue() );
         
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv.apply( at );
         
-        assertEquals( "this is a test", sv.getNormalizedValue() );
+        assertEquals( "this is a test", sv.getNormValue() );
     }
 
     
@@ -409,19 +410,19 @@ public class StringValueTest
     {
         StringValue sv = new StringValue();
 
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
-        assertEquals( null, sv.getNormalizedValue() );
+        sv.apply( at );
+        assertEquals( null, sv.getNormValue() );
         
         sv = new StringValue( "" );
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
-        assertEquals( "", sv.getNormalizedValue() );
+        sv.apply( at );
+        assertEquals( "", sv.getNormValue() );
 
         sv = new StringValue(  "  This is    a   TEST  " );
-        assertEquals( "  This is    a   TEST  ", sv.getNormalizedValue() );
+        assertEquals( "  This is    a   TEST  ", sv.getNormValue() );
         
-        sv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv.apply( at );
         
-        assertEquals( "this is a test", sv.getNormalizedValue() );
+        assertEquals( "this is a test", sv.getNormValue() );
     }
 
 
@@ -461,7 +462,7 @@ public class StringValueTest
         // Now check that the equals method works on normalized values.
         sv1 = new StringValue(  "  This is    a TEST   " );
         sv2 = new StringValue( "this is a test" );
-        sv1.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv1.apply( at );
         assertEquals( 0, sv1.compareTo( sv2 ) );
         
         sv1 = new StringValue( "a" );
@@ -494,7 +495,7 @@ public class StringValueTest
         // Now check that the equals method works on normalized values.
         sv1 = new StringValue( "  This is    a TEST   " );
         sv2 = new StringValue( "this is a test" );
-        sv1.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        sv1.apply( at );
         assertEquals( sv1, sv2 );
     }
 
@@ -524,16 +525,14 @@ public class StringValueTest
     public void testSerializeStandard() throws LdapException, IOException, ClassNotFoundException
     {
         StringValue csv = new StringValue( "TEST");
-        csv.setNormalized( true );
-        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        csv.apply( at );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
-        StringValue csvSer = deserializeValue( serializeValue( csv ) );
+        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.get(), csvSer.get() );
-        assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
-        assertTrue( csvSer.isNormalized() );
-        assertFalse( csvSer.isValid() );
+        assertEquals( csv.getNormValue(), csvSer.getNormValue() );
+        assertTrue( csvSer.isSchemaAware() );
     }
     
     
@@ -544,15 +543,13 @@ public class StringValueTest
     public void testSerializeNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
         StringValue csv = new StringValue( "Test" );
-        csv.setNormalized( false );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
-        StringValue csvSer = deserializeValue( serializeValue( csv ) );
-         assertNotSame( csv, csvSer );
-         assertEquals( csv.get(), csvSer.get() );
-         assertEquals( csv.get(), csvSer.getNormalizedValue() );
-         assertFalse( csvSer.isNormalized() );
-         assertFalse( csvSer.isValid() );
+        StringValue csvSer = deserializeValue( null, serializeValue( csv ) );
+        assertNotSame( csv, csvSer );
+        assertEquals( csv.get(), csvSer.get() );
+        assertEquals( csv.get(), csvSer.getNormValue() );
+        assertFalse( csvSer.isSchemaAware() );
     }
     
     
@@ -563,16 +560,14 @@ public class StringValueTest
     public void testSerializeEmptyNormalized() throws LdapException, IOException, ClassNotFoundException
     {
         StringValue csv = new StringValue( "  " );
-        csv.setNormalized( true );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        csv.apply( at );
 
-        StringValue csvSer = deserializeValue( serializeValue( csv ) );
+        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
          assertNotSame( csv, csvSer );
          assertEquals( csv.get(), csvSer.get() );
-         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
-         assertTrue( csvSer.isNormalized() );
-         assertFalse( csvSer.isValid() );
+         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
+         assertTrue( csvSer.isSchemaAware() );
     }
     
     
@@ -583,16 +578,14 @@ public class StringValueTest
     public void testSerializeNullValue() throws LdapException, IOException, ClassNotFoundException
     {
         StringValue csv = new StringValue( (String)null );
-        csv.setNormalized( true );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        csv.apply( at );
 
-        StringValue csvSer = deserializeValue( serializeValue( csv ) );
+        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
          assertNotSame( csv, csvSer );
          assertEquals( csv.get(), csvSer.get() );
-         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
-         assertTrue( csvSer.isNormalized() );
-         assertFalse( csvSer.isValid() );
+         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
+         assertTrue( csvSer.isSchemaAware() );
     }
     
     
@@ -603,16 +596,14 @@ public class StringValueTest
     public void testSerializeEmptyValue() throws LdapException, IOException, ClassNotFoundException
     {
         StringValue csv = new StringValue( "" );
-        csv.setNormalized( true );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.normalize( new DeepTrimToLowerNormalizer( "1.1.1" ) );
+        csv.apply( at );
 
-        StringValue csvSer = deserializeValue( serializeValue( csv ) );
+        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
          assertNotSame( csv, csvSer );
          assertEquals( csv.get(), csvSer.get() );
-         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
-         assertTrue( csvSer.isNormalized() );
-         assertFalse( csvSer.isValid() );
+         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
+         assertTrue( csvSer.isSchemaAware() );
     }
     
     
@@ -623,14 +614,12 @@ public class StringValueTest
     public void testSerializeEmptyValueNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
         StringValue csv = new StringValue( "" );
-        csv.setNormalized( false );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
-        StringValue csvSer = deserializeValue( serializeValue( csv ) );
+        StringValue csvSer = deserializeValue( null, serializeValue( csv ) );
          assertNotSame( csv, csvSer );
          assertEquals( csv.get(), csvSer.get() );
-         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
-         assertFalse( csvSer.isNormalized() );
-         assertFalse( csvSer.isValid() );
+         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
+         assertFalse( csvSer.isSchemaAware() );
     }
 }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java Sat Mar 26 19:17:40 2011
@@ -29,7 +29,14 @@ import java.io.ObjectOutputStream;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.Normalizer;
+import org.apache.directory.shared.ldap.model.schema.comparators.ByteArrayComparator;
+import org.apache.directory.shared.ldap.model.schema.comparators.StringComparator;
+import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
+import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
 import org.apache.directory.shared.util.StringConstants;
+import org.apache.directory.shared.util.Strings;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -59,6 +66,75 @@ public class ValueSerializationTest
     StringValue sv2n = new StringValue( "" );
     StringValue sv3n = new StringValue();
     
+    private EntryUtils.S sb;
+    private EntryUtils.AT atb;
+    private EntryUtils.MR mrb;
+
+    private EntryUtils.S ss;
+    private EntryUtils.AT ats;
+    private EntryUtils.MR mrs;
+
+    /**
+     * Initialize an AttributeType and the associated MatchingRule 
+     * and Syntax
+     */
+    @Before
+    public void initAT()
+    {
+        sb = new EntryUtils.S( "1.1.1.1", false );
+        sb.setSyntaxChecker( new OctetStringSyntaxChecker() );
+        mrb = new EntryUtils.MR( "1.1.2.1" );
+        mrb.setSyntax( sb );
+        
+        mrb.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
+        mrb.setNormalizer( new Normalizer( "1.1.1" )
+        {
+            public Value<?> normalize( Value<?> value ) throws LdapException
+            {
+                if ( !value.isHR() )
+                {
+                    byte[] val = value.getBytes();
+                    // each byte will be changed to be > 0, and spaces will be trimmed
+                    byte[] newVal = new byte[ val.length ];
+                    int i = 0;
+                    
+                    for ( byte b:val )
+                    {
+                        newVal[i++] = (byte)(b & 0x007F); 
+                    }
+                    
+                    return new BinaryValue( Strings.trim(newVal) );
+                }
+
+                throw new IllegalStateException( "expected byte[] to normalize" );
+            }
+
+        
+            public String normalize( String value ) throws LdapException
+            {
+                throw new IllegalStateException( "expected byte[] to normalize" );
+            }
+        });
+        
+        atb = new EntryUtils.AT( "1.1.3.1" );
+        atb.setEquality( mrb );
+        atb.setOrdering( mrb );
+        atb.setSubstring( mrb );
+        atb.setSyntax( sb );
+        
+        ss = new EntryUtils.S( "1.1.1.1", false );
+        ss.setSyntaxChecker( new OctetStringSyntaxChecker() );
+        mrs = new EntryUtils.MR( "1.1.2.1" );
+        mrs.setSyntax( ss );
+        mrs.setLdapComparator( new StringComparator( "1.1.2.1" ) );
+        mrs.setNormalizer( new DeepTrimToLowerNormalizer( "1.1.2.1" ) );
+        ats = new EntryUtils.AT( "1.1.3.1" );
+        ats.setEquality( mrs );
+        ats.setOrdering( mrs );
+        ats.setSubstring( mrs );
+        ats.setSyntax( ss );
+    }
+
     
     @Test
     public void testBinaryValueWithDataSerialization() throws IOException, ClassNotFoundException
@@ -185,7 +261,7 @@ public class ValueSerializationTest
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
-        bv1n.normalize();
+        bv1n.apply( atb );
 
         bv1n.writeExternal( out );
         
@@ -206,7 +282,7 @@ public class ValueSerializationTest
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
-        bv2n.normalize();
+        bv2n.apply( atb );
 
         bv2n.writeExternal( out );
         
@@ -227,7 +303,7 @@ public class ValueSerializationTest
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
-        bv3n.normalize();
+        bv3n.apply( atb );
 
         bv3n.writeExternal( out );
         
@@ -248,7 +324,7 @@ public class ValueSerializationTest
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
-        sv1n.normalize();
+        sv1n.apply( ats );
 
         sv1n.writeExternal( out );
         
@@ -269,7 +345,7 @@ public class ValueSerializationTest
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
-        sv2n.normalize();
+        sv2n.apply( ats );
 
         sv2n.writeExternal( out );
         
@@ -290,7 +366,7 @@ public class ValueSerializationTest
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
-        sv3n.normalize();
+        sv3n.apply( ats );
 
         sv3n.writeExternal( out );
         

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java Sat Mar 26 19:17:40 2011
@@ -26,8 +26,6 @@ import static org.junit.Assert.assertTru
 import java.util.HashMap;
 import java.util.Map;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -38,6 +36,9 @@ import org.apache.directory.shared.ldap.
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * TestCase for the AddRequestImpl class.
@@ -58,7 +59,7 @@ public class AddRequestImplTest
      *            the id for the attribute
      * @return the AttributeImpl assembled for testing
      */
-    private EntryAttribute getAttribute( String id )
+    private EntryAttribute getAttribute( String id ) throws LdapException
     {
         EntryAttribute attr = new DefaultEntryAttribute( id );
         attr.add( "value0" );

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/ModifyRequestImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/ModifyRequestImplTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/ModifyRequestImplTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/ModifyRequestImplTest.java Sat Mar 26 19:17:40 2011
@@ -29,20 +29,21 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.model.exception.MessageException;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.DefaultModification;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.model.exception.MessageException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test case for the ModifyRequestImpl class.
@@ -61,7 +62,7 @@ public class ModifyRequestImplTest
      * 
      * @return the ModifyRequest to use for tests
      */
-    private ModifyRequestImpl getRequest()
+    private ModifyRequestImpl getRequest() throws LdapException
     {
         // Construct the Modify request to test
         ModifyRequestImpl req = new ModifyRequestImpl( 45 );
@@ -101,7 +102,7 @@ public class ModifyRequestImplTest
      * Tests the same object reference for equality.
      */
     @Test
-    public void testEqualsSameObj()
+    public void testEqualsSameObj() throws LdapException
     {
         ModifyRequestImpl req = getRequest();
         assertTrue( req.equals( req ) );
@@ -112,7 +113,7 @@ public class ModifyRequestImplTest
      * Tests for equality using exact copies.
      */
     @Test
-    public void testEqualsExactCopy()
+    public void testEqualsExactCopy() throws LdapException
     {
         ModifyRequestImpl req0 = getRequest();
         ModifyRequestImpl req1 = getRequest();
@@ -124,7 +125,7 @@ public class ModifyRequestImplTest
      * Tests the same object reference for equal hashCode.
      */
     @Test
-    public void testHashCodeSameObj()
+    public void testHashCodeSameObj() throws LdapException
     {
         ModifyRequestImpl req = getRequest();
         assertTrue( req.hashCode() == req.hashCode() );
@@ -135,7 +136,7 @@ public class ModifyRequestImplTest
      * Tests for equal hashCode using exact copies.
      */
     @Test
-    public void testHashCodeExactCopy()
+    public void testHashCodeExactCopy() throws LdapException
     {
         ModifyRequestImpl req0 = getRequest();
         ModifyRequestImpl req1 = getRequest();
@@ -181,7 +182,7 @@ public class ModifyRequestImplTest
      * Test for inequality when only the mods ops are different.
      */
     @Test
-    public void testNotEqualDiffModOps()
+    public void testNotEqualDiffModOps() throws LdapException
     {
         ModifyRequestImpl req0 = getRequest();
         EntryAttribute attr = new DefaultEntryAttribute( "attr3" );
@@ -208,7 +209,7 @@ public class ModifyRequestImplTest
      * Test for inequality when only the number of mods are different.
      */
     @Test
-    public void testNotEqualDiffModCount()
+    public void testNotEqualDiffModCount() throws LdapException
     {
         ModifyRequestImpl req0 = getRequest();
         EntryAttribute attr = new DefaultEntryAttribute( "attr3" );
@@ -229,7 +230,7 @@ public class ModifyRequestImplTest
      * Test for inequality when only the mods attribute Id's are different.
      */
     @Test
-    public void testNotEqualDiffModIds()
+    public void testNotEqualDiffModIds() throws LdapException
     {
         ModifyRequestImpl req0 = getRequest();
         EntryAttribute attr = new DefaultEntryAttribute( "attr3" );
@@ -256,7 +257,7 @@ public class ModifyRequestImplTest
      * Test for inequality when only the mods attribute values are different.
      */
     @Test
-    public void testNotEqualDiffModValues()
+    public void testNotEqualDiffModValues() throws LdapException
     {
         ModifyRequestImpl req0 = getRequest();
         EntryAttribute attr = new DefaultEntryAttribute( "attr3" );
@@ -284,30 +285,38 @@ public class ModifyRequestImplTest
      * Tests for equality even when another BindRequest implementation is used.
      */
     @Test
-    public void testEqualsDiffImpl()
+    public void testEqualsDiffImpl() throws LdapException
     {
         ModifyRequest req0 = new ModifyRequest()
         {
             public Collection<Modification> getModifications()
             {
                 List<Modification> list = new ArrayList<Modification>();
-                EntryAttribute attr = new DefaultEntryAttribute( "attr0" );
-                attr.add( "val0" );
-                attr.add( "val1" );
-                attr.add( "val2" );
-                Modification item = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
-                list.add( item );
-
-                attr = new DefaultEntryAttribute( "attr1" );
-                attr.add( "val3" );
-                item = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
-                list.add( item );
-
-                attr = new DefaultEntryAttribute( "attr2" );
-                attr.add( "val4" );
-                attr.add( "val5" );
-                item = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
-                list.add( item );
+                
+                try
+                { 
+                    EntryAttribute attr = new DefaultEntryAttribute( "attr0" );
+                    attr.add( "val0" );
+                    attr.add( "val1" );
+                    attr.add( "val2" );
+                    Modification item = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
+                    list.add( item );
+    
+                    attr = new DefaultEntryAttribute( "attr1" );
+                    attr.add( "val3" );
+                    item = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );
+                    list.add( item );
+    
+                    attr = new DefaultEntryAttribute( "attr2" );
+                    attr.add( "val4" );
+                    attr.add( "val5" );
+                    item = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attr );
+                    list.add( item );
+                }
+                catch ( LdapInvalidAttributeValueException liave )
+                {
+                    // Can't happen
+                }
 
                 return list;
             }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImplTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImplTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImplTest.java Sat Mar 26 19:17:40 2011
@@ -23,18 +23,18 @@ package org.apache.directory.shared.ldap
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.message.SearchResultEntryImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test cases for the methods of the SearchResponseEntryImpl class.
@@ -52,7 +52,7 @@ public class SearchResultEntryImplTest
      * @param id the id for the attribute
      * @return the EntryAttribute assembled for testing
      */
-    private EntryAttribute getEntry( String id )
+    private EntryAttribute getEntry( String id ) throws LdapException
     {
         EntryAttribute attr = new DefaultEntryAttribute( id );
         attr.add( "value0" );

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/AttributeClassLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/AttributeClassLoader.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/AttributeClassLoader.java (original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/AttributeClassLoader.java Sat Mar 26 19:17:40 2011
@@ -76,15 +76,13 @@ public class AttributeClassLoader extend
 
         Value<?> value = attribute.get();
 
-        if ( value.isBinary() )
-        {
-            classBytes = value.getBytes();
-
-            return defineClass( name, classBytes, 0, classBytes.length );
-        }
-        else
+        if ( value.isHR() )
         {
             throw new ClassNotFoundException( I18n.err( I18n.ERR_10002 ) );
         }
+        
+        classBytes = value.getBytes();
+
+        return defineClass( name, classBytes, 0, classBytes.length );
     }
 }

Modified: directory/shared/trunk/ldap/schema/data/src/main/resources/schema-all.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/resources/schema-all.ldif?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/resources/schema-all.ldif (original)
+++ directory/shared/trunk/ldap/schema/data/src/main/resources/schema-all.ldif Sat Mar 26 19:17:40 2011
@@ -12,6 +12,74 @@ m-dependencies: core
 creatorsname: uid=admin,ou=system
 
 
+dn: ou=syntaxes,cn=adsconfig,ou=schema
+objectclass: top
+objectclass: organizationalUnit
+ou: syntaxes
+entrycsn: 20090818052725.824000Z#000000#000#000000
+creatorsname: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+createtimestamp: 20100111145217Z
+
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.0.10,ou=syntaxes,cn=adsconfig,ou=schema
+objectclass: top
+objectclass: metaTop
+objectclass: metaSyntax
+m-oid: 1.3.6.1.4.1.18060.0.4.1.0.10
+m-description: a syntax for SearchScope
+x-humanreadable: TRUE
+m-obsolete: FALSE
+entrycsn: 20100111202214.878000Z#000000#000#000000
+creatorsname: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+createtimestamp: 20100111145217Z
+
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.0.11,ou=syntaxes,cn=adsconfig,ou=schema
+objectclass: top
+objectclass: metaTop
+objectclass: metaSyntax
+m-oid: 1.3.6.1.4.1.18060.0.4.1.0.11
+m-description: a syntax for DerefAlias
+x-humanreadable: TRUE
+m-obsolete: FALSE
+entrycsn: 20100111202214.878000Z#000000#000#000000
+creatorsname: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+createtimestamp: 20100111145217Z
+
+
+dn: ou=syntaxCheckers,cn=adsconfig,ou=schema
+objectclass: top
+objectclass: organizationalUnit
+ou: syntaxcheckers
+entrycsn: 20090818052725.824000Z#000000#000#000000
+creatorsname: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+createtimestamp: 20100111145217Z
+
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.0.10,ou=syntaxCheckers,cn=adsconfig,ou=schema
+objectclass: top
+objectclass: metaTop
+objectclass: metaSyntaxChecker
+m-oid: 1.3.6.1.4.1.18060.0.4.1.0.10
+m-fqcn: org.apache.directory.shared.ldap.model.schema.syntaxCheckers.SearchScop
+ eSyntaxChecker
+entrycsn: 20100111202214.878000Z#000000#000#000000
+creatorsname: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+createtimestamp: 20100111145217Z
+
+
+dn: m-oid=1.3.6.1.4.1.18060.0.4.1.0.11,ou=syntaxCheckers,cn=adsconfig,ou=schema
+objectclass: top
+objectclass: metaTop
+objectclass: metaSyntaxChecker
+m-oid: 1.3.6.1.4.1.18060.0.4.1.0.11
+m-fqcn: org.apache.directory.shared.ldap.model.schema.syntaxCheckers.DerefAlias
+ SyntaxChecker
+entrycsn: 20100111202214.878000Z#000000#000#000000
+creatorsname: 0.9.2342.19200300.100.1.1=admin,2.5.4.11=system
+createtimestamp: 20100111145217Z
+
+
 dn: ou=attributeTypes, cn=adsconfig, ou=schema
 createtimestamp: 20100111145214Z
 ou: attributetypes
@@ -1620,7 +1688,7 @@ m-name: ads-replAliasDerefMode
 m-description: the alias dereference mode of replication search
 m-equality: integerMatch
 m-ordering: integerOrderingMatch
-m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
+m-syntax: 1.3.6.1.4.1.18060.0.4.1.0.11
 m-length: 0
 m-singleValue: TRUE
 
@@ -1649,7 +1717,7 @@ m-name: ads-replSearchScope
 m-description: the search scope of the replication
 m-equality: integerMatch
 m-ordering: integerOrderingMatch
-m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
+m-syntax: 1.3.6.1.4.1.18060.0.4.1.0.10
 m-length: 0
 m-singleValue: TRUE
 



Mime
View raw message