directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1736388 [5/6] - in /directory/shared/branches/shared-value: dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/ dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/ dsml/parser/src/main/java/org/apache/directory/api/ds...
Date Wed, 23 Mar 2016 23:28:29 GMT
Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java?rev=1736388&r1=1736387&r2=1736388&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/BinaryValueTest.java Wed Mar 23 23:28:28 2016
@@ -54,7 +54,7 @@ import com.mycila.junit.concurrent.Concu
 
 /**
  * 
- * Test the BinaryValue class
+ * Test the Value class
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -93,7 +93,7 @@ public class BinaryValueTest
             public static final long serialVersionUID = 1L;
 
 
-            public Value<?> normalize( Value<?> value ) throws LdapException
+            public Value normalize( Value value ) throws LdapException
             {
                 if ( !value.isHumanReadable() )
                 {
@@ -107,7 +107,7 @@ public class BinaryValueTest
                         newVal[i++] = ( byte ) ( b & 0x007F );
                     }
 
-                    return new BinaryValue( Strings.trim( newVal ) );
+                    return new Value( Strings.trim( newVal ) );
                 }
 
                 throw new IllegalStateException( "expected byte[] to normalize" );
@@ -145,9 +145,9 @@ public class BinaryValueTest
 
 
     /**
-     * Serialize a BinaryValue
+     * Serialize a Value
      */
-    private ByteArrayOutputStream serializeValue( BinaryValue value ) throws IOException
+    private ByteArrayOutputStream serializeValue( Value value ) throws IOException
     {
         ObjectOutputStream oOut = null;
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -182,9 +182,9 @@ public class BinaryValueTest
 
 
     /**
-     * Deserialize a BinaryValue
+     * Deserialize a Value
      */
-    private BinaryValue deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException,
+    private Value deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException,
         ClassNotFoundException
     {
         ObjectInputStream oIn = null;
@@ -194,7 +194,7 @@ public class BinaryValueTest
         {
             oIn = new ObjectInputStream( in );
 
-            BinaryValue value = new BinaryValue( at );
+            Value value = Value.createValue( at );
             value.readExternal( oIn );
 
             return value;
@@ -223,15 +223,15 @@ public class BinaryValueTest
     @Test
     public void testHashCode()
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
         assertEquals( 0, bv.hashCode() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         int h = Arrays.hashCode( StringConstants.EMPTY_BYTES );
         assertEquals( h, bv.hashCode() );
 
         h = Arrays.hashCode( BYTES1 );
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         assertEquals( h, bv.hashCode() );
     }
 
@@ -239,7 +239,7 @@ public class BinaryValueTest
     @Test
     public void testBinaryValueNull() throws LdapException
     {
-        BinaryValue cbv = new BinaryValue( ( byte[] ) null );
+        Value cbv = new Value( ( byte[] ) null );
 
         assertNull( cbv.getValue() );
         assertFalse( cbv.isSchemaAware() );
@@ -252,145 +252,124 @@ public class BinaryValueTest
     @Test
     public void testBinaryValueEmpty() throws LdapException
     {
-        BinaryValue cbv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        Value cbv = new Value( StringConstants.EMPTY_BYTES );
 
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getBytes() ) );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getValue() ) );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getReference() ) );
         assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
         assertNotNull( cbv.getNormValue() );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormValue() ) );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, cbv.getNormReference() ) );
     }
 
 
     @Test
     public void testBinaryValue() throws LdapException
     {
-        BinaryValue cbv = new BinaryValue( BYTES1 );
+        Value cbv = new Value( BYTES1 );
 
         assertTrue( Arrays.equals( BYTES1, cbv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES1, cbv.getValue() ) );
-        assertTrue( Arrays.equals( BYTES1, cbv.getReference() ) );
         assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
-        assertNotNull( cbv.getNormValue() );
-        assertTrue( Arrays.equals( BYTES1, cbv.getNormValue() ) );
     }
 
 
     @Test
     public void testSetByteArray() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
 
         assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getValue() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getReference() ) );
         assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertFalse( bv.isNull() );
-        assertNotNull( bv.getNormValue() );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
     }
 
 
     @Test
     public void testGetNormalizedValueCopy() throws LdapException
     {
-        BinaryValue cbv = new BinaryValue( BYTES2 );
+        Value cbv = new Value( BYTES2 );
 
         assertTrue( Arrays.equals( BYTES2, cbv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES2, cbv.getValue() ) );
-        assertTrue( Arrays.equals( BYTES2, cbv.getReference() ) );
         assertFalse( cbv.isSchemaAware() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
-        assertNotNull( cbv.getNormValue() );
-        assertTrue( Arrays.equals( BYTES2, cbv.getNormValue() ) );
 
-        cbv.apply( at );
-        byte[] copy = cbv.getNormValue();
-        assertTrue( Arrays.equals( BYTES1, copy ) );
-        cbv.getNormReference()[0] = 0x11;
-        assertTrue( Arrays.equals( BYTES1, copy ) );
+        cbv = new Value( at, cbv );
+        byte[] copy = cbv.getBytes();
+        assertTrue( Arrays.equals( BYTES2, copy ) );
     }
 
 
     @Test
     public void testNormalizeNormalizer() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
-        bv.apply( at );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
-        assertEquals( null, bv.getNormValue() );
+        assertNull( bv.getBytes() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        bv.apply( at );
+        bv = new Value( StringConstants.EMPTY_BYTES );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
 
-        bv = new BinaryValue( BYTES1 );
-        bv.apply( at );
+        bv = new Value( BYTES1 );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
         assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
 
-        bv = new BinaryValue( BYTES2 );
-        bv.apply( at );
+        bv = new Value( BYTES2 );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
         assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
     }
 
 
     @Test
     public void testCompareToValueOfbyte() throws LdapException
     {
-        BinaryValue bv1 = new BinaryValue( ( byte[] ) null );
-        BinaryValue bv2 = new BinaryValue( ( byte[] ) null );
+        Value bv1 = new Value( ( byte[] ) null );
+        Value bv2 = new Value( ( byte[] ) null );
 
         assertEquals( 0, bv1.compareTo( bv2 ) );
 
-        bv1 = new BinaryValue( BYTES1 );
+        bv1 = new Value( BYTES1 );
         assertEquals( 1, bv1.compareTo( bv2 ) );
 
-        bv2 = new BinaryValue( BYTES2 );
+        bv2 = new Value( BYTES2 );
         assertEquals( 1, bv1.compareTo( bv2 ) );
 
-        bv2.apply( at );
-        assertEquals( 0, bv1.compareTo( bv2 ) );
+        bv2 = new Value( at, bv2 );
+        assertEquals( 1, bv1.compareTo( bv2 ) );
 
-        bv1 = new BinaryValue( BYTES2 );
-        assertEquals( -1, bv1.compareTo( bv2 ) );
+        bv1 = new Value( BYTES2 );
+        assertEquals( 0, bv1.compareTo( bv2 ) );
     }
 
 
     @Test
     public void testEquals() throws LdapException
     {
-        BinaryValue bv1 = new BinaryValue( ( byte[] ) null );
-        BinaryValue bv2 = new BinaryValue( ( byte[] ) null );
+        Value bv1 = new Value( ( byte[] ) null );
+        Value bv2 = new Value( ( byte[] ) null );
 
         assertEquals( bv1, bv2 );
 
-        bv1 = new BinaryValue( BYTES1 );
+        bv1 = new Value( BYTES1 );
         assertNotSame( bv1, bv2 );
 
-        bv2 = new BinaryValue( BYTES2 );
+        bv2 = new Value( BYTES2 );
         assertNotSame( bv1, bv2 );
 
-        bv2.apply( at );
+        bv1 = new Value( at, bv2 );
         assertEquals( bv1, bv2 );
 
-        bv1 = new BinaryValue( BYTES2 );
+        bv1 = new Value( BYTES2 );
         assertNotSame( bv1, bv2 );
     }
 
@@ -398,20 +377,17 @@ public class BinaryValueTest
     @Test
     public void testClone()
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        BinaryValue copy = bv.clone();
+        Value bv = new Value( ( byte[] ) null );
+        Value copy = bv.clone();
 
         assertEquals( bv, copy );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         assertNotSame( bv, copy );
 
         copy = bv.clone();
         assertEquals( bv, copy );
 
-        bv.getReference()[0] = 0x11;
-
-        assertTrue( Arrays.equals( BYTES_MOD, bv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, copy.getBytes() ) );
     }
 
@@ -419,52 +395,50 @@ public class BinaryValueTest
     @Test
     public void testGetCopy()
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertNull( bv.getValue() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        assertNotNull( bv.getValue() );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getValue() ) );
+        bv = new Value( StringConstants.EMPTY_BYTES );
+        assertNotNull( bv.getBytes() );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
 
-        bv = new BinaryValue( BYTES1 );
-        byte[] copy = bv.getValue();
+        bv = new Value( BYTES1 );
+        byte[] copy = bv.getBytes();
 
         assertTrue( Arrays.equals( BYTES1, copy ) );
 
-        bv.getReference()[0] = 0x11;
         assertTrue( Arrays.equals( BYTES1, copy ) );
-        assertTrue( Arrays.equals( BYTES_MOD, bv.getBytes() ) );
     }
 
 
     @Test
     public void testCompareTo() throws LdapException
     {
-        BinaryValue bv1 = new BinaryValue( ( byte[] ) null );
-        BinaryValue bv2 = new BinaryValue( ( byte[] ) null );
+        Value bv1 = new Value( ( byte[] ) null );
+        Value bv2 = new Value( ( byte[] ) null );
 
         assertEquals( 0, bv1.compareTo( bv2 ) );
 
-        bv1 = new BinaryValue( BYTES1 );
+        bv1 = new Value( BYTES1 );
         assertEquals( 1, bv1.compareTo( bv2 ) );
         assertEquals( -1, bv2.compareTo( bv1 ) );
 
-        bv2 = new BinaryValue( BYTES1 );
+        bv2 = new Value( BYTES1 );
         assertEquals( 0, bv1.compareTo( bv2 ) );
 
         // Now check that the equals method works on normalized values.
-        bv1 = new BinaryValue( BYTES2 );
-        bv2 = new BinaryValue( BYTES1 );
-        bv1.apply( at );
-        assertEquals( 0, bv1.compareTo( bv2 ) );
+        bv1 = new Value( BYTES2 );
+        bv2 = new Value( BYTES1 );
+        bv1 = new Value( at, bv1 );
+        assertEquals( -1, bv1.compareTo( bv2 ) );
 
-        bv1 = new BinaryValue( BYTES1 );
-        bv2 = new BinaryValue( BYTES2 );
+        bv1 = new Value( BYTES1 );
+        bv2 = new Value( BYTES2 );
         assertEquals( 1, bv1.compareTo( bv2 ) );
 
-        bv1 = new BinaryValue( BYTES2 );
-        bv2 = new BinaryValue( BYTES1 );
+        bv1 = new Value( BYTES2 );
+        bv2 = new Value( BYTES1 );
         assertEquals( -1, bv1.compareTo( bv2 ) );
     }
 
@@ -472,115 +446,68 @@ public class BinaryValueTest
     @Test
     public void testToString()
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertEquals( "null", bv.toString() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         assertEquals( "", bv.toString() );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         assertEquals( "0x01 0x02 0x03 0x04 ", bv.toString() );
     }
 
 
     @Test
-    public void testGetReference()
-    {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-
-        assertNull( bv.getReference() );
-
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        assertNotNull( bv.getReference() );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getReference() ) );
-
-        bv = new BinaryValue( BYTES1 );
-        byte[] reference = bv.getReference();
-
-        assertTrue( Arrays.equals( BYTES1, reference ) );
-
-        bv.getReference()[0] = 0x11;
-        assertTrue( Arrays.equals( BYTES_MOD, reference ) );
-        assertTrue( Arrays.equals( BYTES_MOD, bv.getBytes() ) );
-    }
-
-
-    @Test
     public void testGet()
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertNull( bv.getValue() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        assertNotNull( bv.getValue() );
+        bv = new Value( StringConstants.EMPTY_BYTES );
+        assertNull( bv.getValue() );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         byte[] get = bv.getBytes();
 
         assertTrue( Arrays.equals( BYTES1, get ) );
 
-        bv.getReference()[0] = 0x11;
         assertTrue( Arrays.equals( BYTES1, get ) );
-        assertTrue( Arrays.equals( BYTES_MOD, bv.getBytes() ) );
     }
 
 
     @Test
     public void testGetNormalizedValue() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-
-        assertFalse( bv.isSchemaAware() );
-
-        bv.apply( at );
-        byte[] value = bv.getNormValue();
-        assertNull( value );
-        assertTrue( bv.isSchemaAware() );
-
-        bv = new BinaryValue( BYTES2 );
-        bv.apply( at );
-        value = bv.getNormValue();
-        assertTrue( Arrays.equals( BYTES1, value ) );
-        bv.getNormReference()[0] = 0x11;
-        assertFalse( Arrays.equals( BYTES_MOD, value ) );
-    }
-
-
-    @Test
-    public void testGetNormalizedValueReference() throws LdapException
-    {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertFalse( bv.isSchemaAware() );
 
-        bv.apply( at );
-        byte[] value = bv.getNormReference();
+        bv = new Value( at, bv );
+        byte[] value = bv.getBytes();
         assertNull( value );
         assertTrue( bv.isSchemaAware() );
 
-        bv = new BinaryValue( BYTES2 );
-        bv.apply( at );
-        value = bv.getNormReference();
-        assertTrue( Arrays.equals( BYTES1, value ) );
-        bv.getNormReference()[0] = 0x11;
-        assertTrue( Arrays.equals( BYTES_MOD, value ) );
+        bv = new Value( BYTES2 );
+        bv = new Value( at, bv );
+        value = bv.getBytes();
+        assertTrue( Arrays.equals( BYTES2, value ) );
     }
 
 
     @Test
     public void testIsNull()
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertTrue( bv.isNull() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         assertFalse( bv.isNull() );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         assertFalse( bv.isNull() );
     }
 
@@ -588,18 +515,18 @@ public class BinaryValueTest
     @Test
     public void testIsValid() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         assertFalse( bv.isNull() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        bv = new BinaryValue( INVALID_BYTES );
+        bv = new Value( INVALID_BYTES );
         assertFalse( bv.isNull() );
         assertFalse( bv.isValid( BINARY_CHECKER ) );
     }
@@ -608,17 +535,17 @@ public class BinaryValueTest
     @Test
     public void testIsValidSyntaxChecker() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        bv = new BinaryValue( BYTES1 );
+        bv = new Value( BYTES1 );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        bv = new BinaryValue( INVALID_BYTES );
+        bv = new Value( INVALID_BYTES );
         assertFalse( bv.isValid( BINARY_CHECKER ) );
     }
 
@@ -626,44 +553,43 @@ public class BinaryValueTest
     @Test
     public void testNormalize() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
-        bv.apply( at );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
         assertEquals( null, bv.getNormValue() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        bv.apply( at );
+        bv = new Value( StringConstants.EMPTY_BYTES );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
 
-        bv = new BinaryValue( BYTES2 );
-        bv.apply( at );
+        bv = new Value( BYTES2 );
+        bv = new Value( at, bv );
         assertTrue( bv.isSchemaAware() );
-        assertTrue( Arrays.equals( BYTES2, bv.getValue() ) );
-        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
+        assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) );
     }
 
 
     @Test
     public void testSet() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertNull( bv.getValue() );
         assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertTrue( bv.isNull() );
 
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
-        assertNotNull( bv.getValue() );
+        bv = new Value( StringConstants.EMPTY_BYTES );
+        assertNull( bv.getValue() );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getBytes() ) );
         assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
         assertFalse( bv.isNull() );
 
-        bv = new BinaryValue( BYTES1 );
-        assertNotNull( bv.getValue() );
+        bv = new Value( BYTES1 );
+        assertNotNull( bv.getBytes() );
         assertTrue( Arrays.equals( BYTES1, bv.getBytes() ) );
         assertFalse( bv.isSchemaAware() );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
@@ -674,21 +600,21 @@ public class BinaryValueTest
     @Test
     public void testIsNormalized() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
         assertFalse( bv.isSchemaAware() );
 
-        bv = new BinaryValue( BYTES2 );
+        bv = new Value( BYTES2 );
         assertFalse( bv.isSchemaAware() );
 
-        bv.apply( at );
+        bv = new Value( at, bv );
 
-        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
+        assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) );
         assertTrue( bv.isSchemaAware() );
 
-        bv = new BinaryValue( BYTES2 );
+        bv = new Value( BYTES2 );
         assertFalse( bv.isSchemaAware() );
 
-        bv = new BinaryValue( BYTES_MOD );
+        bv = new Value( BYTES_MOD );
         assertFalse( bv.isSchemaAware() );
     }
 
@@ -696,19 +622,19 @@ public class BinaryValueTest
     @Test
     public void testSetNormalized() throws LdapException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
 
         assertFalse( bv.isSchemaAware() );
 
-        bv = new BinaryValue( BYTES2 );
+        bv = new Value( BYTES2 );
         assertFalse( bv.isSchemaAware() );
 
-        bv.apply( at );
+        bv = new Value( at, bv );
 
-        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
+        assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) );
         assertTrue( bv.isSchemaAware() );
 
-        assertTrue( Arrays.equals( BYTES2, bv.getValue() ) );
+        assertTrue( Arrays.equals( BYTES2, bv.getBytes() ) );
     }
 
 
@@ -718,15 +644,13 @@ public class BinaryValueTest
     @Test
     public void testSerializeStandard() throws LdapException, IOException, ClassNotFoundException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        bv = new BinaryValue( BYTES2 );
-        bv.apply( at );
+        Value bv = new Value( ( byte[] ) null );
+        bv = new Value( BYTES2 );
+        bv = new Value( at, bv );
         assertTrue( bv.isValid( BINARY_CHECKER ) );
 
-        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        Value 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() );
     }
 
@@ -737,14 +661,12 @@ public class BinaryValueTest
     @Test
     public void testSerializeNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        bv = new BinaryValue( BYTES2 );
+        Value bv = new Value( ( byte[] ) null );
+        bv = new Value( BYTES2 );
         bv.isValid( BINARY_CHECKER );
 
-        BinaryValue cbvSer = deserializeValue( null, serializeValue( bv ) );
+        Value 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() );
     }
 
@@ -755,15 +677,13 @@ public class BinaryValueTest
     @Test
     public void testSerializeEmptyNormalized() throws LdapException, IOException, ClassNotFoundException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        bv = new BinaryValue( BYTES2 );
+        Value bv = new Value( ( byte[] ) null );
+        bv = new Value( BYTES2 );
         bv.isValid( BINARY_CHECKER );
-        bv.apply( at );
+        bv = new Value( at, bv );
 
-        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        Value 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() );
     }
 
@@ -774,15 +694,13 @@ public class BinaryValueTest
     @Test
     public void testSerializeNullValue() throws LdapException, IOException, ClassNotFoundException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        bv = new BinaryValue( ( byte[] ) null );
+        Value bv = new Value( ( byte[] ) null );
+        bv = new Value( ( byte[] ) null );
         bv.isValid( BINARY_CHECKER );
-        bv.apply( at );
+        bv = new Value( at, bv );
 
-        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        Value 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() );
     }
 
@@ -793,15 +711,13 @@ public class BinaryValueTest
     @Test
     public void testSerializeEmptyValue() throws LdapException, IOException, ClassNotFoundException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        Value bv = new Value( ( byte[] ) null );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         bv.isValid( BINARY_CHECKER );
-        bv.apply( at );
+        bv = new Value( at, bv );
 
-        BinaryValue cbvSer = deserializeValue( at, serializeValue( bv ) );
+        Value 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() );
     }
 
@@ -812,14 +728,12 @@ public class BinaryValueTest
     @Test
     public void testSerializeEmptyValueNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
-        BinaryValue bv = new BinaryValue( ( byte[] ) null );
-        bv = new BinaryValue( StringConstants.EMPTY_BYTES );
+        Value bv = new Value( ( byte[] ) null );
+        bv = new Value( StringConstants.EMPTY_BYTES );
         bv.isValid( BINARY_CHECKER );
 
-        BinaryValue cbvSer = deserializeValue( null, serializeValue( bv ) );
+        Value 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/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/EntryUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/EntryUtils.java?rev=1736388&r1=1736387&r2=1736388&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/EntryUtils.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/EntryUtils.java Wed Mar 23 23:28:28 2016
@@ -31,6 +31,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator;
 import org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
+import org.apache.directory.api.ldap.model.schema.normalizers.NoOpNormalizer;
 import org.apache.directory.api.util.Strings;
 
 
@@ -158,11 +159,11 @@ public class EntryUtils
             public static final long serialVersionUID = 1L;
 
 
-            public Value<?> normalize( Value<?> value ) throws LdapException
+            public Value normalize( Value value ) throws LdapException
             {
                 if ( value.isHumanReadable() )
                 {
-                    return new StringValue( Strings.toLowerCaseAscii( value.getString() ) );
+                    return new Value( Strings.toLowerCaseAscii( value.getString() ) );
                 }
 
                 throw new IllegalStateException( I18n.err( I18n.ERR_04474 ) );
@@ -247,39 +248,7 @@ public class EntryUtils
 
         matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );
 
-        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
-        {
-            public static final long serialVersionUID = 1L;
-
-
-            public Value<?> normalize( Value<?> value ) throws LdapException
-            {
-                if ( !value.isHumanReadable() )
-                {
-                    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( I18n.err( I18n.ERR_04475 ) );
-            }
-
-
-            public String normalize( String value ) throws LdapException
-            {
-                throw new IllegalStateException( I18n.err( I18n.ERR_04475 ) );
-            }
-        } );
+        matchingRule.setNormalizer( new NoOpNormalizer( "1.1.1" ) );
 
         attributeType.setEquality( matchingRule );
         attributeType.setSyntax( syntax );

Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java?rev=1736388&r1=1736387&r2=1736388&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueAttributeTypeTest.java Wed Mar 23 23:28:28 2016
@@ -56,7 +56,7 @@ import com.mycila.junit.concurrent.Concu
 
 
 /**
- * Tests that the StringValue class works properly as expected.
+ * Tests that the Value class works properly as expected.
  *
  * Some notes while conducting tests:
  *
@@ -98,9 +98,9 @@ public class StringValueAttributeTypeTes
 
 
     /**
-     * Serialize a StringValue
+     * Serialize a Value
      */
-    private ByteArrayOutputStream serializeValue( StringValue value ) throws IOException
+    private ByteArrayOutputStream serializeValue( Value value ) throws IOException
     {
         ObjectOutputStream oOut = null;
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -135,9 +135,9 @@ public class StringValueAttributeTypeTes
 
 
     /**
-     * Deserialize a StringValue
+     * Deserialize a Value
      */
-    private StringValue deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    private Value deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
     {
         ObjectInputStream oIn = null;
         ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
@@ -146,7 +146,7 @@ public class StringValueAttributeTypeTes
         {
             oIn = new ObjectInputStream( in );
 
-            StringValue value = new StringValue( at );
+            Value value = Value.createValue( at );
 
             value.readExternal( oIn );
 
@@ -181,7 +181,7 @@ public class StringValueAttributeTypeTes
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
 
-        StringValue value = new StringValue( attribute, null );
+        Value value = new Value( attribute, (String)null );
 
         assertNull( value.getValue() );
         assertTrue( value.isNull() );
@@ -196,18 +196,18 @@ public class StringValueAttributeTypeTes
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
 
-        StringValue sv = new StringValue( attribute, null );
+        Value sv = new Value( attribute, (String)null );
 
         assertTrue( sv.isSchemaAware() );
         assertNull( sv.getNormValue() );
         assertTrue( sv.isSchemaAware() );
 
-        sv = new StringValue( attribute, "" );
+        sv = new Value( attribute, "" );
         assertTrue( sv.isSchemaAware() );
         assertEquals( "", sv.getNormValue() );
         assertTrue( sv.isSchemaAware() );
 
-        sv = new StringValue( attribute, "TEST" );
+        sv = new Value( attribute, "TEST" );
         assertTrue( sv.isSchemaAware() );
         assertEquals( "test", sv.getNormValue() );
     }
@@ -223,13 +223,13 @@ public class StringValueAttributeTypeTes
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
 
-        new StringValue( attribute, null );
-        new StringValue( attribute, "" );
-        new StringValue( attribute, "TEST" );
+        new Value( attribute, (String)null );
+        new Value( attribute, "" );
+        new Value( attribute, "TEST" );
 
         try
         {
-            new StringValue( attribute, "testlong" );
+            new Value( attribute, "testlong" );
             fail();
         }
         catch ( LdapInvalidAttributeValueException liave )
@@ -246,16 +246,16 @@ public class StringValueAttributeTypeTes
     public void testApply() throws LdapException
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
-        StringValue sv = new StringValue( attribute );
+        Value sv = Value.createValue( attribute );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
         assertEquals( null, sv.getNormValue() );
 
-        sv = new StringValue( attribute, "" );
-        sv.apply( at );
+        sv = new Value( attribute, "" );
+        sv = new Value( at, sv );
         assertEquals( "", sv.getNormValue() );
 
-        sv = new StringValue( attribute, "  A   TEST  " );
+        sv = new Value( attribute, "  A   TEST  " );
         assertEquals( "a test", sv.getNormValue() );
     }
 
@@ -267,7 +267,7 @@ public class StringValueAttributeTypeTes
     public void testInstanceOf() throws LdapException
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
-        StringValue ssv = new StringValue( attribute );
+        Value ssv = Value.createValue( attribute );
 
         assertTrue( ssv.isInstanceOf( attribute ) );
 
@@ -284,7 +284,7 @@ public class StringValueAttributeTypeTes
     public void testgetAttributeType()
     {
         AttributeType attribute = EntryUtils.getIA5StringAttributeType();
-        StringValue ssv = new StringValue( attribute );
+        Value ssv = Value.createValue( attribute );
 
         assertEquals( attribute, ssv.getAttributeType() );
     }
@@ -299,14 +299,14 @@ public class StringValueAttributeTypeTes
         AttributeType at1 = EntryUtils.getIA5StringAttributeType();
         AttributeType at2 = EntryUtils.getBytesAttributeType();
 
-        StringValue value1 = new StringValue( at1, "test" );
-        StringValue value2 = new StringValue( at1, "test" );
-        StringValue value3 = new StringValue( at1, "TEST" );
-        StringValue value4 = new StringValue( at1, "tes" );
-        StringValue value5 = new StringValue( at1, null );
-        BinaryValue valueBytes = new BinaryValue( at2, new byte[]
+        Value value1 = new Value( at1, "test" );
+        Value value2 = new Value( at1, "test" );
+        Value value3 = new Value( at1, "TEST" );
+        Value value4 = new Value( at1, "tes" );
+        Value value5 = new Value( at1, (byte[])null );
+        Value valueBytes = new Value( at2, new byte[]
             { 0x01 } );
-        StringValue valueString = new StringValue( at, "test" );
+        Value valueString = new Value( at, "test" );
 
         assertTrue( value1.equals( value1 ) );
         assertTrue( value1.equals( value2 ) );
@@ -332,7 +332,7 @@ public class StringValueAttributeTypeTes
 
         try
         {
-            new StringValue( attribute );
+            Value.createValue( attribute );
             fail();
         }
         catch ( IllegalArgumentException iae )
@@ -350,9 +350,9 @@ public class StringValueAttributeTypeTes
     public void testHashCode() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
-        StringValue v0 = new StringValue( at1, "Alex" );
-        StringValue v1 = new StringValue( at1, "ALEX" );
-        StringValue v2 = new StringValue( at1, "alex" );
+        Value v0 = new Value( at1, "Alex" );
+        Value v1 = new Value( at1, "ALEX" );
+        Value v2 = new Value( at1, "alex" );
 
         assertEquals( v0.hashCode(), v1.hashCode() );
         assertEquals( v0.hashCode(), v2.hashCode() );
@@ -362,11 +362,11 @@ public class StringValueAttributeTypeTes
         assertEquals( v0, v2 );
         assertEquals( v1, v2 );
 
-        StringValue v3 = new StringValue( at1, "Timber" );
+        Value v3 = new Value( at1, "Timber" );
 
         assertNotSame( v0.hashCode(), v3.hashCode() );
 
-        StringValue v4 = new StringValue( at, "Alex" );
+        Value v4 = new Value( at, "Alex" );
 
         assertNotSame( v0.hashCode(), v4.hashCode() );
     }
@@ -379,13 +379,13 @@ public class StringValueAttributeTypeTes
     public void testCompareTo() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
-        StringValue v0 = new StringValue( at1, "Alex" );
-        StringValue v1 = new StringValue( at1, "ALEX" );
+        Value v0 = new Value( at1, "Alex" );
+        Value v1 = new Value( at1, "ALEX" );
 
         assertEquals( 0, v0.compareTo( v1 ) );
         assertEquals( 0, v1.compareTo( v0 ) );
 
-        StringValue v2 = new StringValue( at1, null );
+        Value v2 = new Value( at1, (String)null );
 
         assertEquals( 1, v0.compareTo( v2 ) );
         assertEquals( -1, v2.compareTo( v0 ) );
@@ -399,18 +399,18 @@ public class StringValueAttributeTypeTes
     public void testClone() throws LdapException
     {
         AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
-        StringValue sv = new StringValue( at1, "Test" );
+        Value sv = new Value( at1, "Test" );
 
-        StringValue sv1 = sv.clone();
+        Value sv1 = sv.clone();
 
         assertEquals( sv, sv1 );
 
-        sv = new StringValue( "" );
+        sv = new Value( "" );
 
         assertNotSame( sv, sv1 );
         assertEquals( "", sv.getString() );
 
-        sv = new StringValue( "  This is    a   TEST  " );
+        sv = new Value( "  This is    a   TEST  " );
         sv1 = sv.clone();
 
         assertEquals( sv, sv1 );
@@ -511,12 +511,12 @@ public class StringValueAttributeTypeTes
         at.setSyntax( s );
 
         // check that normalization and syntax checks work as expected
-        StringValue value = new StringValue( at, "HIGH" );
+        Value value = new Value( at, "HIGH" );
         assertEquals( value.getValue(), value.getValue() );
 
         try
         {
-            new StringValue( at, "high" );
+            new Value( at, "high" );
             fail();
         }
         catch ( LdapInvalidAttributeValueException liave )
@@ -525,10 +525,10 @@ public class StringValueAttributeTypeTes
         }
 
         // create a bunch to best tested for equals and in containers
-        StringValue v0 = new StringValue( at, "LOW" );
-        StringValue v1 = new StringValue( at, "LOW" );
-        StringValue v2 = new StringValue( at, "MEDIUM" );
-        StringValue v3 = new StringValue( at, "HIGH" );
+        Value v0 = new Value( at, "LOW" );
+        Value v1 = new Value( at, "LOW" );
+        Value v2 = new Value( at, "MEDIUM" );
+        Value v3 = new Value( at, "HIGH" );
 
         // check equals
         assertTrue( v0.equals( v1 ) );
@@ -541,7 +541,7 @@ public class StringValueAttributeTypeTes
         assertTrue( v3.compareTo( v2 ) > 0 );
 
         // add all except v1 and v5 to a set
-        HashSet<StringValue> set = new HashSet<StringValue>();
+        HashSet<Value> set = new HashSet<Value>();
         set.add( v0 );
         set.add( v2 );
         set.add( v3 );
@@ -550,7 +550,7 @@ public class StringValueAttributeTypeTes
         assertTrue( "since v1.equals( v0 ) and v0 was added then this should be true", set.contains( v1 ) );
 
         // check ordering based on the comparator
-        List<Value<String>> list = new ArrayList<Value<String>>();
+        List<Value> list = new ArrayList<Value>();
         list.add( v1 );
         list.add( v3 );
         list.add( v0 );
@@ -582,16 +582,16 @@ public class StringValueAttributeTypeTes
     public void testAcceptAllNoNormalization() throws LdapInvalidAttributeValueException
     {
         // check that normalization and syntax checks work as expected
-        StringValue value = new StringValue( at, "hello" );
+        Value value = new Value( at, "hello" );
         assertEquals( value.getValue(), value.getValue() );
 
         // create a bunch to best tested for equals and in containers
-        StringValue v0 = new StringValue( at, "hello" );
-        StringValue v1 = new StringValue( at, "hello" );
-        StringValue v2 = new StringValue( at, "next0" );
-        StringValue v3 = new StringValue( at, "next1" );
-        StringValue v4 = new StringValue( at );
-        StringValue v5 = new StringValue( at );
+        Value v0 = new Value( at, "hello" );
+        Value v1 = new Value( at, "hello" );
+        Value v2 = new Value( at, "next0" );
+        Value v3 = new Value( at, "next1" );
+        Value v4 = Value.createValue( at );
+        Value v5 = Value.createValue( at );
 
         // check equals
         assertTrue( v0.equals( v1 ) );
@@ -602,7 +602,7 @@ public class StringValueAttributeTypeTes
         assertFalse( v3.equals( v2 ) );
 
         // add all except v1 and v5 to a set
-        HashSet<StringValue> set = new HashSet<StringValue>();
+        HashSet<Value> set = new HashSet<Value>();
         set.add( v0 );
         set.add( v2 );
         set.add( v3 );
@@ -613,7 +613,7 @@ public class StringValueAttributeTypeTes
         assertTrue( "since v4.equals( v5 ) and v4 was added then this should be true", set.contains( v5 ) );
 
         // check ordering based on the comparator
-        ArrayList<StringValue> list = new ArrayList<StringValue>();
+        ArrayList<Value> list = new ArrayList<Value>();
         list.add( v1 );
         list.add( v3 );
         list.add( v5 );
@@ -621,9 +621,9 @@ public class StringValueAttributeTypeTes
         list.add( v2 );
         list.add( v4 );
 
-        Comparator<StringValue> c = new Comparator<StringValue>()
+        Comparator<Value> c = new Comparator<Value>()
         {
-            public int compare( StringValue o1, StringValue o2 )
+            public int compare( Value o1, Value o2 )
             {
                 String n1 = null;
                 String n2 = null;
@@ -671,97 +671,97 @@ public class StringValueAttributeTypeTes
 
 
     /**
-     * Test serialization of a StringValue which has a normalized value
+     * Test serialization of a Value which has a normalized value
      */
     @Test
     public void testNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        StringValue ssv = new StringValue( at, "  Test   Test  " );
+        Value ssv = new Value( at, "  Test   Test  " );
 
         String normalized = ssv.getNormValue();
 
         assertEquals( "test test", normalized );
         assertEquals( "  Test   Test  ", ssv.getString() );
 
-        StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
+        Value ssvSer = deserializeValue( serializeValue( ssv ) );
 
         assertEquals( ssv, ssvSer );
     }
 
 
     /**
-     * Test serialization of a StringValue which does not have a normalized value
+     * Test serialization of a Value which does not have a normalized value
      */
     @Test
     public void testNoNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        StringValue ssv = new StringValue( at, "test" );
+        Value ssv = new Value( at, "test" );
 
         String normalized = ssv.getNormValue();
 
         assertEquals( "test", normalized );
         assertEquals( "test", ssv.getString() );
 
-        StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
+        Value ssvSer = deserializeValue( serializeValue( ssv ) );
 
         assertEquals( ssv, ssvSer );
     }
 
 
     /**
-     * Test serialization of a null StringValue
+     * Test serialization of a null Value
      */
     @Test
     public void testNullStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        StringValue ssv = new StringValue( at );
+        Value ssv = Value.createValue( at );
 
         String normalized = ssv.getNormValue();
 
         assertNull( normalized );
         assertNull( ssv.getValue() );
 
-        StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
+        Value ssvSer = deserializeValue( serializeValue( ssv ) );
 
         assertEquals( ssv, ssvSer );
     }
 
 
     /**
-     * Test serialization of an empty StringValue
+     * Test serialization of an empty Value
      */
     @Test
     public void testEmptyStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        StringValue ssv = new StringValue( at, "" );
+        Value ssv = new Value( at, "" );
 
         String normalized = ssv.getNormValue();
 
         assertEquals( "", normalized );
         assertEquals( "", ssv.getString() );
 
-        StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
+        Value ssvSer = deserializeValue( serializeValue( ssv ) );
 
         assertEquals( ssv, ssvSer );
     }
 
 
     /**
-     * Test serialization of an empty StringValue
+     * Test serialization of an empty Value
      */
     @Test
     public void testStringValueEmptyNormalizedSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        StringValue ssv = new StringValue( "  " );
+        Value ssv = new Value( "  " );
 
         assertEquals( "  ", ssv.getString() );
 
-        StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
+        Value ssvSer = deserializeValue( serializeValue( ssv ) );
 
         assertEquals( ssv, ssvSer );
     }

Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java?rev=1736388&r1=1736387&r2=1736388&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/StringValueTest.java Wed Mar 23 23:28:28 2016
@@ -31,14 +31,16 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.util.Arrays;
 
-import org.apache.directory.api.ldap.model.entry.StringValue;
+import org.apache.directory.api.ldap.model.entry.Value;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.comparators.StringComparator;
 import org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.api.ldap.model.schema.syntaxCheckers.Ia5StringSyntaxChecker;
 import org.apache.directory.api.ldap.model.schema.syntaxCheckers.OctetStringSyntaxChecker;
+import org.apache.directory.api.util.Strings;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -49,7 +51,7 @@ import com.mycila.junit.concurrent.Concu
 
 /**
  * 
- * Test the StringValue class
+ * Test the Value class
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -87,9 +89,9 @@ public class StringValueTest
     // Helper method
     //----------------------------------------------------------------------------------
     /**
-     * Serialize a StringValue
+     * Serialize a Value
      */
-    private ByteArrayOutputStream serializeValue( StringValue value ) throws IOException
+    private ByteArrayOutputStream serializeValue( Value value ) throws IOException
     {
         ObjectOutputStream oOut = null;
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -102,9 +104,9 @@ public class StringValueTest
 
 
     /**
-     * Deserialize a StringValue
+     * Deserialize a Value
      */
-    private StringValue deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException,
+    private Value deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException,
         ClassNotFoundException
     {
         ObjectInputStream oIn = null;
@@ -114,7 +116,7 @@ public class StringValueTest
         {
             oIn = new ObjectInputStream( in );
 
-            StringValue value = new StringValue( at );
+            Value value = Value.createValue( at );
             value.readExternal( oIn );
 
             return value;
@@ -149,13 +151,13 @@ public class StringValueTest
     @Test
     public void testCloneEmptyValue() throws LdapException
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
-        StringValue sv1 = ( StringValue ) sv.clone();
+        Value sv1 = ( Value ) sv.clone();
 
         assertEquals( sv, sv1 );
 
-        StringValue sv2 = new StringValue( "" );
+        Value sv2 = new Value( "" );
 
         assertNotSame( sv2, sv1 );
         assertNull( sv1.getValue() );
@@ -169,16 +171,16 @@ public class StringValueTest
     @Test
     public void testCloneValue() throws LdapException
     {
-        StringValue sv = new StringValue( "  This is    a   TEST  " );
+        Value sv = new Value( "  This is    a   TEST  " );
 
-        StringValue sv1 = ( StringValue ) sv.clone();
+        Value sv1 = ( Value ) sv.clone();
 
         sv1 = sv.clone();
 
         assertEquals( sv, sv1 );
         assertEquals( "  This is    a   TEST  ", sv.getString() );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
 
         assertNotSame( sv, sv1 );
         assertEquals( "  This is    a   TEST  ", sv1.getString() );
@@ -189,45 +191,44 @@ public class StringValueTest
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#hashCode()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#hashCode()}.
      */
     @Test
     public void testHashCode()
     {
-        StringValue csv = new StringValue( "test" );
+        Value csv = new Value( "test" );
 
-        int hash = "test".hashCode();
+        int hash = Arrays.hashCode( Strings.getBytesUtf8( "test" ) );
         assertEquals( hash, csv.hashCode() );
 
-        csv = new StringValue( ( String ) null );
-        hash = "".hashCode();
-        assertEquals( hash, csv.hashCode() );
+        csv = new Value( ( String ) null );
+        assertEquals( 0, csv.hashCode() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#ClientStringValue()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#ClientStringValue()}.
      */
     @Test
     public void testClientStringValueNull() throws LdapException
     {
-        StringValue csv = new StringValue( ( String ) null );
+        Value csv = new Value( ( String ) null );
 
         assertNull( csv.getValue() );
         assertFalse( csv.isSchemaAware() );
         assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) );
         assertTrue( csv.isNull() );
-        assertNull( csv.getNormValue() );
+        assertEquals( null, csv.getNormValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#ClientStringValue(java.lang.String)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#ClientStringValue(java.lang.String)}.
      */
     @Test
     public void testClientStringValueEmpty() throws LdapException
     {
-        StringValue csv = new StringValue( "" );
+        Value csv = new Value( "" );
 
         assertNotNull( csv.getValue() );
         assertEquals( "", csv.getString() );
@@ -240,12 +241,12 @@ public class StringValueTest
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#ClientStringValue(java.lang.String)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#ClientStringValue(java.lang.String)}.
      */
     @Test
     public void testClientStringValueString() throws LdapException
     {
-        StringValue csv = new StringValue( "test" );
+        Value csv = new Value( "test" );
 
         assertEquals( "test", csv.getValue() );
         assertFalse( csv.isSchemaAware() );
@@ -257,55 +258,55 @@ public class StringValueTest
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#getValue()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#getValue()}.
      */
     @Test
     public void testGet()
     {
-        StringValue sv = new StringValue( "test" );
+        Value sv = new Value( "test" );
         assertEquals( "test", sv.getValue() );
 
-        StringValue sv2 = new StringValue( "" );
+        Value sv2 = new Value( "" );
         assertEquals( "", sv2.getValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#getCopy()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#getCopy()}.
      */
     @Test
     public void testGetCopy()
     {
-        StringValue sv = new StringValue( "test" );
+        Value sv = new Value( "test" );
 
         assertEquals( "test", sv.getValue() );
 
-        StringValue sv2 = new StringValue( "" );
+        Value sv2 = new Value( "" );
         assertEquals( "", sv2.getValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#set(java.lang.String)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#set(java.lang.String)}.
      */
     @Test
     public void testSet() throws LdapException
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
         assertNull( sv.getValue() );
         assertFalse( sv.isSchemaAware() );
         assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
         assertTrue( sv.isNull() );
 
-        sv = new StringValue( "" );
+        sv = new Value( "" );
         assertNotNull( sv.getValue() );
         assertEquals( "", sv.getValue() );
         assertFalse( sv.isSchemaAware() );
         assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
         assertFalse( sv.isNull() );
 
-        sv = new StringValue( "Test" );
+        sv = new Value( "Test" );
         assertNotNull( sv.getValue() );
         assertEquals( "Test", sv.getValue() );
         assertFalse( sv.isSchemaAware() );
@@ -315,53 +316,53 @@ public class StringValueTest
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#isNull()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#isNull()}.
      */
     @Test
     public void testIsNull()
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
         assertTrue( sv.isNull() );
 
-        sv = new StringValue( "test" );
+        sv = new Value( "test" );
         assertFalse( sv.isNull() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#isSchemaAware()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#isSchemaAware()}.
      */
     @Test
     public void testIsNormalized() throws LdapException
     {
-        StringValue sv = new StringValue( "  This is    a   TEST  " );
+        Value sv = new Value( "  This is    a   TEST  " );
 
         assertFalse( sv.isSchemaAware() );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
 
         assertEquals( "this is a test", sv.getNormValue() );
         assertTrue( sv.isSchemaAware() );
 
-        sv = new StringValue( "test" );
+        sv = new Value( "test" );
         assertFalse( sv.isSchemaAware() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#setNormalized(boolean)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#setNormalized(boolean)}.
      */
     @Test
     public void testSetNormalized() throws LdapException
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
         assertFalse( sv.isSchemaAware() );
 
-        sv = new StringValue( "  This is    a   TEST  " );
+        sv = new Value( "  This is    a   TEST  " );
         assertFalse( sv.isSchemaAware() );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
 
         assertEquals( "this is a test", sv.getNormValue() );
         assertTrue( sv.isSchemaAware() );
@@ -369,155 +370,154 @@ public class StringValueTest
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#getNormValue()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#getNormValue()}.
      */
     @Test
     public void testGetNormalizedValue() throws LdapException
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
         assertEquals( null, sv.getNormValue() );
 
-        sv = new StringValue( "  This is    a   TEST  " );
+        sv = new Value( "  This is    a   TEST  " );
         assertEquals( "  This is    a   TEST  ", sv.getNormValue() );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
 
         assertEquals( "this is a test", sv.getNormValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#getNormValue()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#getNormValue()}.
      */
     @Test
     public void getNormValueCopy() throws LdapException
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
         assertEquals( null, sv.getNormValue() );
 
-        sv = new StringValue( "  This is    a   TEST  " );
+        sv = new Value( "  This is    a   TEST  " );
         assertEquals( "  This is    a   TEST  ", sv.getNormValue() );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
 
         assertEquals( "this is a test", sv.getNormValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#normalize(org.apache.directory.api.ldap.model.schema.Normalizer)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#normalize(org.apache.directory.api.ldap.model.schema.Normalizer)}.
      */
     @Test
     public void testNormalize() throws LdapException
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
         assertEquals( null, sv.getNormValue() );
 
-        sv = new StringValue( "" );
-        sv.apply( at );
+        sv = new Value( "" );
+        sv = new Value( at, sv );
         assertEquals( "", sv.getNormValue() );
 
-        sv = new StringValue( "  This is    a   TEST  " );
+        sv = new Value( "  This is    a   TEST  " );
         assertEquals( "  This is    a   TEST  ", sv.getNormValue() );
 
-        sv.apply( at );
+        sv = new Value( at, sv );
 
         assertEquals( "this is a test", sv.getNormValue() );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#isValid(org.apache.directory.api.ldap.model.schema.SyntaxChecker)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#isValid(org.apache.directory.api.ldap.model.schema.SyntaxChecker)}.
      */
     @Test
     public void testIsValid() throws LdapException
     {
-        StringValue sv = new StringValue( "Test" );
+        Value sv = new Value( "Test" );
 
         assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) );
 
-        sv = new StringValue( "é" );
+        sv = new Value( "é" );
         assertFalse( sv.isValid( new Ia5StringSyntaxChecker() ) );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#compareTo(org.apache.directory.api.ldap.model.entry.Value)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#compareTo(org.apache.directory.api.ldap.model.entry.Value)}.
      */
     @Test
     public void testCompareTo() throws LdapException
     {
-        StringValue sv1 = new StringValue( ( String ) null );
-        StringValue sv2 = new StringValue( ( String ) null );
+        Value sv1 = new Value( ( String ) null );
+        Value sv2 = new Value( ( String ) null );
 
         assertEquals( 0, sv1.compareTo( sv2 ) );
 
-        sv1 = new StringValue( "Test" );
+        sv1 = new Value( "Test" );
         assertEquals( 1, sv1.compareTo( sv2 ) );
         assertEquals( -1, sv2.compareTo( sv1 ) );
 
-        sv2 = new StringValue( "Test" );
+        sv2 = new Value( "Test" );
         assertEquals( 0, sv1.compareTo( sv2 ) );
 
         // 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.apply( at );
+        sv1 = new Value( "  This is    a TEST   " );
+        sv2 = new Value( "this is a test" );
+        sv1 = new Value( at, sv1 );
         assertEquals( 0, sv1.compareTo( sv2 ) );
 
-        sv1 = new StringValue( "a" );
-        sv2 = new StringValue( "b" );
+        sv1 = new Value( "a" );
+        sv2 = new Value( "b" );
         assertEquals( -1, sv1.compareTo( sv2 ) );
 
-        sv1 = new StringValue( "b" );
-        sv2 = new StringValue( "a" );
+        sv1 = new Value( "b" );
+        sv2 = new Value( "a" );
         assertEquals( 1, sv1.compareTo( sv2 ) );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#equals(java.lang.Object)}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#equals(java.lang.Object)}.
      */
     @Test
     public void testEquals() throws LdapException
     {
-        StringValue sv1 = new StringValue( ( String ) null );
-        StringValue sv2 = new StringValue( ( String ) null );
+        Value sv1 = new Value( ( String ) null );
+        Value sv2 = new Value( ( String ) null );
 
         assertEquals( sv1, sv2 );
 
-        sv1 = new StringValue( "Test" );
+        sv1 = new Value( "Test" );
         assertNotSame( sv1, sv2 );
 
-        sv2 = new StringValue( "Test" );
+        sv2 = new Value( "Test" );
         assertEquals( sv1, sv2 );
 
         // 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.apply( at );
+        sv1 = new Value( at, "  This is    a TEST   " );
+        sv2 = new Value( at,  "this is a test" );
         assertEquals( sv1, sv2 );
     }
 
 
     /**
-     * Test method for {@link org.apache.directory.api.ldap.model.entry.StringValue#toString()}.
+     * Test method for {@link org.apache.directory.api.ldap.model.entry.Value#toString()}.
      */
     @Test
     public void testToString()
     {
-        StringValue sv = new StringValue( ( String ) null );
+        Value sv = new Value( ( String ) null );
 
         assertEquals( "null", sv.toString() );
 
-        sv = new StringValue( "" );
+        sv = new Value( "" );
         assertEquals( "", sv.toString() );
 
-        sv = new StringValue( "Test" );
+        sv = new Value( "Test" );
         assertEquals( "Test", sv.toString() );
     }
 
@@ -528,11 +528,11 @@ public class StringValueTest
     @Test
     public void testSerializeStandard() throws LdapException, IOException, ClassNotFoundException
     {
-        StringValue csv = new StringValue( "TEST" );
-        csv.apply( at );
+        Value csv = new Value( "TEST" );
+        csv = new Value( at, csv );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
-        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
+        Value csvSer = deserializeValue( at, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.getValue(), csvSer.getValue() );
         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
@@ -546,10 +546,10 @@ public class StringValueTest
     @Test
     public void testSerializeNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
-        StringValue csv = new StringValue( "Test" );
+        Value csv = new Value( "Test" );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
-        StringValue csvSer = deserializeValue( null, serializeValue( csv ) );
+        Value csvSer = deserializeValue( null, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.getValue(), csvSer.getValue() );
         assertEquals( csv.getValue(), csvSer.getNormValue() );
@@ -563,11 +563,11 @@ public class StringValueTest
     @Test
     public void testSerializeEmptyNormalized() throws LdapException, IOException, ClassNotFoundException
     {
-        StringValue csv = new StringValue( "  " );
+        Value csv = new Value( "  " );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.apply( at );
+        csv = new Value( at, csv );
 
-        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
+        Value csvSer = deserializeValue( at, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.getValue(), csvSer.getValue() );
         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
@@ -581,11 +581,11 @@ public class StringValueTest
     @Test
     public void testSerializeNullValue() throws LdapException, IOException, ClassNotFoundException
     {
-        StringValue csv = new StringValue( ( String ) null );
+        Value csv = new Value( ( String ) null );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.apply( at );
+        csv = new Value( at, csv );
 
-        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
+        Value csvSer = deserializeValue( at, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.getValue(), csvSer.getValue() );
         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
@@ -599,11 +599,11 @@ public class StringValueTest
     @Test
     public void testSerializeEmptyValue() throws LdapException, IOException, ClassNotFoundException
     {
-        StringValue csv = new StringValue( "" );
+        Value csv = new Value( "" );
         csv.isValid( new Ia5StringSyntaxChecker() );
-        csv.apply( at );
+        csv = new Value( at, csv );
 
-        StringValue csvSer = deserializeValue( at, serializeValue( csv ) );
+        Value csvSer = deserializeValue( at, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.getValue(), csvSer.getValue() );
         assertEquals( csv.getNormValue(), csvSer.getNormValue() );
@@ -617,10 +617,10 @@ public class StringValueTest
     @Test
     public void testSerializeEmptyValueNotNormalized() throws LdapException, IOException, ClassNotFoundException
     {
-        StringValue csv = new StringValue( "" );
+        Value csv = new Value( "" );
         csv.isValid( new Ia5StringSyntaxChecker() );
 
-        StringValue csvSer = deserializeValue( null, serializeValue( csv ) );
+        Value csvSer = deserializeValue( null, serializeValue( csv ) );
         assertNotSame( csv, csvSer );
         assertEquals( csv.getValue(), csvSer.getValue() );
         assertEquals( csv.getNormValue(), csvSer.getNormValue() );

Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java?rev=1736388&r1=1736387&r2=1736388&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/entry/ValueSerializationTest.java Wed Mar 23 23:28:28 2016
@@ -29,6 +29,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.Normalizer;
 import org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator;
@@ -57,18 +58,18 @@ public class ValueSerializationTest
 {
     private static byte[] data = new byte[]
         { 0x01, 0x02, 0x03, 0x04 };
-    BinaryValue bv1 = new BinaryValue( data );
-    BinaryValue bv2 = new BinaryValue( StringConstants.EMPTY_BYTES );
-    BinaryValue bv3 = new BinaryValue( ( byte[] ) null );
-    BinaryValue bv1n = new BinaryValue( data );
-    BinaryValue bv2n = new BinaryValue( StringConstants.EMPTY_BYTES );
-    BinaryValue bv3n = new BinaryValue( ( byte[] ) null );
-    StringValue sv1 = new StringValue( "test" );
-    StringValue sv2 = new StringValue( "" );
-    StringValue sv3 = new StringValue( ( String ) null );
-    StringValue sv1n = new StringValue( "test" );
-    StringValue sv2n = new StringValue( "" );
-    StringValue sv3n = new StringValue( ( String ) null );
+    Value bv1 = new Value( data );
+    Value bv2 = new Value( StringConstants.EMPTY_BYTES );
+    Value bv3 = new Value( ( byte[] ) null );
+    Value bv1n = new Value( data );
+    Value bv2n = new Value( StringConstants.EMPTY_BYTES );
+    Value bv3n = new Value( ( byte[] ) null );
+    Value sv1 = new Value( "test" );
+    Value sv2 = new Value( "" );
+    Value sv3 = new Value( ( String ) null );
+    Value sv1n = new Value( "test" );
+    Value sv2n = new Value( "" );
+    Value sv3n = new Value( ( String ) null );
 
     private EntryUtils.S sb;
     private EntryUtils.AT atb;
@@ -97,7 +98,7 @@ public class ValueSerializationTest
             public static final long serialVersionUID = 1L;
 
 
-            public Value<?> normalize( Value<?> value ) throws LdapException
+            public Value normalize( Value value ) throws LdapException
             {
                 if ( !value.isHumanReadable() )
                 {
@@ -111,7 +112,7 @@ public class ValueSerializationTest
                         newVal[i++] = ( byte ) ( b & 0x007F );
                     }
 
-                    return new BinaryValue( Strings.trim( newVal ) );
+                    return new Value( Strings.trim( newVal ) );
                 }
 
                 throw new IllegalStateException( "expected byte[] to normalize" );
@@ -157,7 +158,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null );
+        Value bvDeser = new Value( ( AttributeType ) null );
         bvDeser.readExternal( in );
 
         assertEquals( bv1, bvDeser );
@@ -177,7 +178,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null );
+        Value bvDeser = new Value( ( AttributeType ) null );
         bvDeser.readExternal( in );
 
         assertEquals( bv2, bvDeser );
@@ -197,7 +198,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null );
+        Value bvDeser = new Value( ( AttributeType ) null );
         bvDeser.readExternal( in );
 
         assertEquals( bv3, bvDeser );
@@ -217,7 +218,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = new StringValue( ( AttributeType ) null );
+        Value svDeser = new Value( ( AttributeType ) null );
         svDeser.readExternal( in );
 
         assertEquals( sv1, svDeser );
@@ -237,7 +238,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = new StringValue( ( AttributeType ) null );
+        Value svDeser = new Value( ( AttributeType ) null );
         svDeser.readExternal( in );
 
         assertEquals( sv2, svDeser );
@@ -257,7 +258,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = new StringValue( ( AttributeType ) null );
+        Value svDeser = new Value( ( AttributeType ) null );
         svDeser.readExternal( in );
 
         assertEquals( sv3, svDeser );
@@ -279,7 +280,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null );
+        Value bvDeser = new Value( ( AttributeType ) null );
         bvDeser.readExternal( in );
 
         assertEquals( bv1n, bvDeser );
@@ -301,7 +302,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null );
+        Value bvDeser = new Value( ( AttributeType ) null );
         bvDeser.readExternal( in );
 
         assertEquals( bv2n, bvDeser );
@@ -323,7 +324,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null );
+        Value bvDeser = new Value( ( AttributeType ) null );
         bvDeser.readExternal( in );
 
         assertEquals( bv3n, bvDeser );
@@ -345,7 +346,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
         svDeser.readExternal( in );
 
         assertEquals( sv1n, svDeser );
@@ -367,7 +368,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
         svDeser.readExternal( in );
 
         assertEquals( sv2n, svDeser );
@@ -389,7 +390,7 @@ public class ValueSerializationTest
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
         svDeser.readExternal( in );
 
         assertEquals( sv3n, svDeser );
@@ -405,7 +406,7 @@ public class ValueSerializationTest
 
         int pos = sv1n.serialize( buffer, 0 );
 
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
 
         int pos2 = svDeser.deserialize( buffer, 0 );
 
@@ -423,7 +424,7 @@ public class ValueSerializationTest
 
         int pos = sv2n.serialize( buffer, 0 );
 
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
 
         int pos2 = svDeser.deserialize( buffer, 0 );
 
@@ -441,7 +442,7 @@ public class ValueSerializationTest
 
         int pos = sv3n.serialize( buffer, 0 );
 
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
         int pos2 = svDeser.deserialize( buffer, 0 );
 
         assertEquals( pos, pos2 );
@@ -450,13 +451,13 @@ public class ValueSerializationTest
 
 
     @Test
-    public void testStringValueWithDataSerializationBytes() throws IOException, ClassNotFoundException
+    public void testStringValueWithDataSerializationBytes() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
     {
         byte[] buffer = new byte[128];
 
         int pos = sv1.serialize( buffer, 0 );
 
-        StringValue svDeser = new StringValue( ( AttributeType ) null );
+        Value svDeser = new Value( ( AttributeType ) null );
 
         int pos2 = svDeser.deserialize( buffer, 0 );
 
@@ -466,13 +467,13 @@ public class ValueSerializationTest
 
 
     @Test
-    public void testStringValueWithEmptyDataSerializationBytes() throws IOException, ClassNotFoundException
+    public void testStringValueWithEmptyDataSerializationBytes() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
     {
         byte[] buffer = new byte[128];
 
         int pos = sv2.serialize( buffer, 0 );
 
-        StringValue svDeser = new StringValue( ( AttributeType ) null );
+        Value svDeser = new Value( ( AttributeType ) null );
 
         int pos2 = svDeser.deserialize( buffer, 0 );
 
@@ -482,13 +483,13 @@ public class ValueSerializationTest
 
 
     @Test
-    public void testStringValueNoDataSerializationBytes() throws IOException, ClassNotFoundException
+    public void testStringValueNoDataSerializationBytes() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
     {
         byte[] buffer = new byte[128];
 
         int pos = sv3.serialize( buffer, 0 );
 
-        StringValue svDeser = new StringValue( ( AttributeType ) null );
+        Value svDeser = new Value( ( AttributeType ) null );
 
         int pos2 = svDeser.deserialize( buffer, 0 );
 
@@ -503,7 +504,7 @@ public class ValueSerializationTest
         ClassNotFoundException
     {
         sv1n.apply( ats );
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
 
         long t0 = System.currentTimeMillis();
 
@@ -531,7 +532,7 @@ public class ValueSerializationTest
         ClassNotFoundException
     {
         sv1n.apply( ats );
-        StringValue svDeser = new StringValue( ats );
+        Value svDeser = new Value( ats );
 
         long t0 = System.currentTimeMillis();
 

Modified: directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java?rev=1736388&r1=1736387&r2=1736388&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/test/java/org/apache/directory/api/ldap/model/filter/FilterNodeEqualityTest.java Wed Mar 23 23:28:28 2016
@@ -23,7 +23,7 @@ package org.apache.directory.api.ldap.mo
 import com.mycila.junit.concurrent.Concurrency;
 import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 
-import org.apache.directory.api.ldap.model.entry.StringValue;
+import org.apache.directory.api.ldap.model.entry.Value;
 import org.apache.directory.api.ldap.model.filter.ApproximateNode;
 import org.apache.directory.api.ldap.model.filter.EqualityNode;
 import org.apache.directory.api.ldap.model.filter.GreaterEqNode;
@@ -48,22 +48,22 @@ public class FilterNodeEqualityTest
     @Test
     public void testEqualityEquals()
     {
-        EqualityNode<String> eqNode1 = new EqualityNode<String>( "attr1", new StringValue( "test" ) );
-        EqualityNode<String> eqNode2 = new EqualityNode<String>( "attr1", new StringValue( "test" ) );
+        EqualityNode<String> eqNode1 = new EqualityNode<String>( "attr1", new Value( "test" ) );
+        EqualityNode<String> eqNode2 = new EqualityNode<String>( "attr1", new Value( "test" ) );
 
         assertEquals( "two exact nodes should be equal", eqNode1, eqNode2 );
 
-        eqNode2 = new EqualityNode<String>( "attr2", new StringValue( "test" ) );
+        eqNode2 = new EqualityNode<String>( "attr2", new Value( "test" ) );
         assertFalse( "different attribute in node should return false on equals()", eqNode1.equals( eqNode2 ) );
 
-        eqNode2 = new EqualityNode<String>( "attr2", new StringValue( "foobar" ) );
+        eqNode2 = new EqualityNode<String>( "attr2", new Value( "foobar" ) );
         assertFalse( "different value in node should return false on equals()", eqNode1.equals( eqNode2 ) );
 
         PresenceNode presenceNode = new PresenceNode( "attr1" );
         assertFalse( "two different leaf nodes should not be equal", eqNode1.equals( presenceNode ) );
         assertFalse( "two different leaf nodes should not be equal", presenceNode.equals( eqNode1 ) );
 
-        GreaterEqNode<String> greaterEqNode = new GreaterEqNode<String>( "attr1", new StringValue( "test" ) );
+        GreaterEqNode<String> greaterEqNode = new GreaterEqNode<String>( "attr1", new Value( "test" ) );
         assertFalse( "two different simple nodes should not be equal", eqNode1.equals( greaterEqNode ) );
         assertFalse( "two different simple nodes should not be equal", greaterEqNode.equals( eqNode1 ) );
     }
@@ -72,16 +72,16 @@ public class FilterNodeEqualityTest
     @Test
     public void testGreaterEqEquals()
     {
-        GreaterEqNode<String> greaterEqNode1 = new GreaterEqNode<String>( "attr1", new StringValue( "test" ) );
-        GreaterEqNode<String> greaterEqNode2 = new GreaterEqNode<String>( "attr1", new StringValue( "test" ) );
+        GreaterEqNode<String> greaterEqNode1 = new GreaterEqNode<String>( "attr1", new Value( "test" ) );
+        GreaterEqNode<String> greaterEqNode2 = new GreaterEqNode<String>( "attr1", new Value( "test" ) );
 
         assertEquals( "two exact nodes should be equal", greaterEqNode1, greaterEqNode2 );
 
-        greaterEqNode2 = new GreaterEqNode<String>( "attr2", new StringValue( "test" ) );
+        greaterEqNode2 = new GreaterEqNode<String>( "attr2", new Value( "test" ) );
         assertFalse( "different attribute in node should return false on equals()", greaterEqNode1
             .equals( greaterEqNode2 ) );
 
-        greaterEqNode2 = new GreaterEqNode<String>( "attr2", new StringValue( "foobar" ) );
+        greaterEqNode2 = new GreaterEqNode<String>( "attr2", new Value( "foobar" ) );
         assertFalse( "different value in node should return false on equals()", greaterEqNode1.equals( greaterEqNode2 ) );
     }
 
@@ -89,15 +89,15 @@ public class FilterNodeEqualityTest
     @Test
     public void testLessEqEquals()
     {
-        LessEqNode<String> lessEqNode1 = new LessEqNode<String>( "attr1", new StringValue( "test" ) );
-        LessEqNode<String> lessEqNode2 = new LessEqNode<String>( "attr1", new StringValue( "test" ) );
+        LessEqNode<String> lessEqNode1 = new LessEqNode<String>( "attr1", new Value( "test" ) );
+        LessEqNode<String> lessEqNode2 = new LessEqNode<String>( "attr1", new Value( "test" ) );
 
         assertEquals( "two exact nodes should be equal", lessEqNode1, lessEqNode2 );
 
-        lessEqNode2 = new LessEqNode<String>( "attr2", new StringValue( "test" ) );
+        lessEqNode2 = new LessEqNode<String>( "attr2", new Value( "test" ) );
         assertFalse( "different attribute in node should return false on equals()", lessEqNode1.equals( lessEqNode2 ) );
 
-        lessEqNode2 = new LessEqNode<String>( "attr2", new StringValue( "foobar" ) );
+        lessEqNode2 = new LessEqNode<String>( "attr2", new Value( "foobar" ) );
         assertFalse( "different value in node should return false on equals()", lessEqNode1.equals( lessEqNode2 ) );
     }
 
@@ -105,16 +105,16 @@ public class FilterNodeEqualityTest
     @Test
     public void testApproximateEqEquals()
     {
-        ApproximateNode<String> approximateNode1 = new ApproximateNode<String>( "attr1", new StringValue( "test" ) );
-        ApproximateNode<String> approximateNode2 = new ApproximateNode<String>( "attr1", new StringValue( "test" ) );
+        ApproximateNode<String> approximateNode1 = new ApproximateNode<String>( "attr1", new Value( "test" ) );
+        ApproximateNode<String> approximateNode2 = new ApproximateNode<String>( "attr1", new Value( "test" ) );
 
         assertEquals( "two exact nodes should be equal", approximateNode1, approximateNode2 );
 
-        approximateNode2 = new ApproximateNode<String>( "attr2", new StringValue( "test" ) );
+        approximateNode2 = new ApproximateNode<String>( "attr2", new Value( "test" ) );
         assertFalse( "different attribute in node should return false on equals()", approximateNode1
             .equals( approximateNode2 ) );
 
-        approximateNode2 = new ApproximateNode<String>( "attr2", new StringValue( "foobar" ) );
+        approximateNode2 = new ApproximateNode<String>( "attr2", new Value( "foobar" ) );
         assertFalse( "different value in node should return false on equals()", approximateNode1
             .equals( approximateNode2 ) );
     }




Mime
View raw message