directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r686082 [6/7] - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/c...
Date Thu, 14 Aug 2008 23:12:13 GMT
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java Thu Aug 14 16:12:09 2008
@@ -25,19 +25,11 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.FileInputStream;
-import java.io.StringReader;
 import java.util.Enumeration;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.Properties;
 
-import javax.naming.directory.Attributes;
-import javax.naming.NamingException;
-
 import org.apache.directory.shared.ldap.NotImplementedException;
-import org.apache.directory.shared.ldap.ldif.LdifEntry;
-import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 
 
 /**
@@ -124,7 +116,7 @@
      *            a class to use for relative path references
      * @return the static properties
      */
-    public static Properties getStaticProperties( Class ref )
+    public static Properties getStaticProperties( Class<?> ref )
     {
         final Properties properties = new Properties();
         final String address = ref.toString().replace( '.', '/' );
@@ -156,7 +148,7 @@
      *            the relative path to the resoruce
      * @return the static properties
      */
-    public static Properties getStaticProperties( Class ref, String path )
+    public static Properties getStaticProperties( Class<?> ref, String path )
     {
         Properties properties = new Properties();
         InputStream input = ref.getResourceAsStream( path );
@@ -261,7 +253,7 @@
      *            the relative path to the resource
      * @return the loaded or new Properties
      */
-    public static Properties getProperties( Class clazz, String path )
+    public static Properties getProperties( Class<?> clazz, String path )
     {
         Properties properties = new Properties();
         InputStream input = clazz.getResourceAsStream( path );
@@ -316,7 +308,8 @@
             optionals = new Properties[0];
         }
 
-        Enumeration list = expanded.propertyNames();
+        Enumeration<?> list = expanded.propertyNames();
+        
         while ( list.hasMoreElements() )
         {
             String key = ( String ) list.nextElement();
@@ -423,15 +416,13 @@
         /*
          * H A N D L E S I N G L E V A L U E D K E Y S
          */
-        Iterator list = keys.keySet().iterator();
-        while ( list.hasNext() )
+        for ( Object key:keys.keySet() )
         {
-            String key = ( String ) list.next();
-            String value = discover( key, sources, haltOnDiscovery );
+            String value = discover( (String)key, sources, haltOnDiscovery );
 
             if ( value != null )
             {
-                keys.setProperty( key, value );
+                keys.setProperty( (String)key, value );
             }
         }
     }
@@ -481,7 +472,7 @@
      *            if the value cannot be represented as a primitive integer.
      * @return the primitive integer representation of a hashtable value
      */
-    public static int get( Hashtable ht, Object key, int defval )
+    public static int get( Hashtable<String, Object> ht, Object key, int defval )
     {
         if ( ht == null || !ht.containsKey( key ) || ht.get( key ) == null )
         {
@@ -554,43 +545,4 @@
 
         throw new NotImplementedException();
     }
-
-
-    /**
-     * Creates, fills and returns an Attributes instance using the LDIF encoded
-     * within the property value. The LDIF should use '*' (asterisk) characters
-     * as line delimiters within the property value. These are replaced with
-     * newlines and fed to the LDIF parser. Also note that the LdifParser
-     * deposites the DN as a property within the attributes object.
-     * 
-     * @param props
-     *            the properties to get the ldif property from
-     * @param key
-     *            the key for the LDIF property
-     * @return the attributes for the encoded LDIF entry
-     */
-    public static Attributes fillAttributes( Properties props, String key, Attributes values ) throws NamingException
-    {
-        if ( props == null || !props.containsKey( key ) || props.getProperty( key ) == null )
-        {
-            if ( values == null )
-            {
-                return new AttributesImpl();
-            }
-
-            return values;
-        }
-
-        String ldif = props.getProperty( key ).trim().replace( '*', '\n' );
-        
-        LdifReader ldifReader = new LdifReader( new StringReader( ldif ) );
-        
-        LdifEntry entry = ldifReader.next();
-        
-        if ( entry != null )
-        {
-            values = entry.getAttributes();
-        }
-        return values;
-    }
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java Thu Aug 14 16:12:09 2008
@@ -25,6 +25,11 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Arrays;
 
 import javax.naming.NamingException;
@@ -73,6 +78,26 @@
             throw new IllegalStateException( "expected byte[] to normalize" );
         }
     };
+
+    
+    /**
+     * A binary normalizer which set the normalized value to a empty byte array
+     */
+    private static final Normalizer BINARY_NORMALIZER_EMPTY = new Normalizer()
+    {
+        private static final long serialVersionUID = 1L;
+        
+        public Object normalize( Object value ) throws NamingException
+        {
+            if ( value instanceof byte[] )
+            {
+                return StringTools.EMPTY_BYTES;
+            }
+
+            throw new IllegalStateException( "expected byte[] to normalize" );
+        }
+    };
+
     
     private static final SyntaxChecker BINARY_CHECKER = new SyntaxChecker()
     {
@@ -98,7 +123,82 @@
             }
         }
     };
+    
+    
+    /**
+     * Serialize a ClientBinaryValue
+     */
+    private ByteArrayOutputStream serializeValue( ClientBinaryValue value ) throws IOException
+    {
+        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;
+            }
+        }
+        
+        return out;
+    }
+    
+    
+    /**
+     * Deserialize a ClientBinaryValue
+     */
+    private ClientBinaryValue deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    {
+        ObjectInputStream oIn = null;
+        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
 
+        try
+        {
+            oIn = new ObjectInputStream( in );
+
+            ClientBinaryValue value = ( ClientBinaryValue ) oIn.readObject();
+
+            return value;
+        }
+        catch ( IOException ioe )
+        {
+            throw ioe;
+        }
+        finally
+        {
+            try
+            {
+                if ( oIn != null )
+                {
+                    oIn.close();
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw ioe;
+            }
+        }
+    }
+    
+    
     @Test
     public void testHashCode()
     {
@@ -631,4 +731,128 @@
         cbv.clear();
         assertFalse( cbv.isNormalized() );
     }
+    
+    
+    /**
+     * Test the serialization of a CBV with a value and a normalized value
+     */
+    @Test
+    public void testSerializeStandard() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientBinaryValue cbv = new ClientBinaryValue();
+        cbv.setNormalized( true );
+        cbv.set( BYTES2 );
+        cbv.normalize( BINARY_NORMALIZER );
+        cbv.isValid( BINARY_CHECKER );
+
+        ClientBinaryValue cbvSer = deserializeValue( serializeValue( cbv ) );
+         assertNotSame( cbv, cbvSer );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getReference() ) );
+         assertTrue( Arrays.equals( cbv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
+         assertTrue( cbvSer.isNormalized() );
+         assertFalse( cbvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CBV with a value and no normalized value
+     */
+    @Test
+    public void testSerializeNotNormalized() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientBinaryValue cbv = new ClientBinaryValue();
+        cbv.setNormalized( false );
+        cbv.set( BYTES2 );
+        cbv.isValid( BINARY_CHECKER );
+
+        ClientBinaryValue cbvSer = deserializeValue( serializeValue( cbv ) );
+         assertNotSame( cbv, cbvSer );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getReference() ) );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getNormalizedValueReference() ) );
+         assertFalse( cbvSer.isNormalized() );
+         assertFalse( cbvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CBV with a value and an empty normalized value
+     */
+    @Test
+    public void testSerializeEmptyNormalized() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientBinaryValue cbv = new ClientBinaryValue();
+        cbv.setNormalized( true );
+        cbv.set( BYTES2 );
+        cbv.isValid( BINARY_CHECKER );
+        cbv.normalize( BINARY_NORMALIZER_EMPTY );
+
+        ClientBinaryValue cbvSer = deserializeValue( serializeValue( cbv ) );
+         assertNotSame( cbv, cbvSer );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getReference() ) );
+         assertTrue( Arrays.equals( cbv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
+         assertTrue( cbvSer.isNormalized() );
+         assertFalse( cbvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CBV with a null value
+     */
+    @Test
+    public void testSerializeNullValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientBinaryValue cbv = new ClientBinaryValue();
+        cbv.setNormalized( true );
+        cbv.set( null );
+        cbv.isValid( BINARY_CHECKER );
+        cbv.normalize( BINARY_NORMALIZER );
+
+        ClientBinaryValue cbvSer = deserializeValue( serializeValue( cbv ) );
+         assertNotSame( cbv, cbvSer );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getReference() ) );
+         assertTrue( Arrays.equals( cbv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
+         assertTrue( cbvSer.isNormalized() );
+         assertFalse( cbvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CBV with an empty value
+     */
+    @Test
+    public void testSerializeEmptyValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientBinaryValue cbv = new ClientBinaryValue();
+        cbv.setNormalized( true );
+        cbv.set( StringTools.EMPTY_BYTES );
+        cbv.isValid( BINARY_CHECKER );
+        cbv.normalize( BINARY_NORMALIZER );
+
+        ClientBinaryValue cbvSer = deserializeValue( serializeValue( cbv ) );
+         assertNotSame( cbv, cbvSer );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getReference() ) );
+         assertTrue( Arrays.equals( cbv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
+         assertTrue( cbvSer.isNormalized() );
+         assertFalse( cbvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CBV with an empty value not normalized
+     */
+    @Test
+    public void testSerializeEmptyValueNotNormalized() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientBinaryValue cbv = new ClientBinaryValue();
+        cbv.setNormalized( false );
+        cbv.set( StringTools.EMPTY_BYTES );
+        cbv.isValid( BINARY_CHECKER );
+
+        ClientBinaryValue cbvSer = deserializeValue( serializeValue( cbv ) );
+         assertNotSame( cbv, cbvSer );
+         assertTrue( Arrays.equals( cbv.getReference(), cbvSer.getReference() ) );
+         assertTrue( Arrays.equals( cbv.getNormalizedValueReference(), cbvSer.getNormalizedValueReference() ) );
+         assertFalse( cbvSer.isNormalized() );
+         assertFalse( cbvSer.isValid() );
+    }
 }

Added: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientModificationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientModificationTest.java?rev=686082&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientModificationTest.java (added)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientModificationTest.java Thu Aug 14 16:12:09 2008
@@ -0,0 +1,195 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.entry.client;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+
+/**
+ * Test the ClientModification class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ClientModificationTest
+{
+    /**
+     * Serialize a ClientModification
+     */
+    private ByteArrayOutputStream serializeValue( ClientModification value ) throws IOException
+    {
+        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;
+            }
+        }
+        
+        return out;
+    }
+    
+    
+    /**
+     * Deserialize a ClientModification
+     */
+    private ClientModification deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    {
+        ObjectInputStream oIn = null;
+        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
+
+        try
+        {
+            oIn = new ObjectInputStream( in );
+
+            ClientModification value = ( ClientModification ) oIn.readObject();
+
+            return value;
+        }
+        catch ( IOException ioe )
+        {
+            throw ioe;
+        }
+        finally
+        {
+            try
+            {
+                if ( oIn != null )
+                {
+                    oIn.close();
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw ioe;
+            }
+        }
+    }
+    
+    
+    @Test 
+    public void testCreateServerModification()
+    {
+        EntryAttribute attribute = new DefaultClientAttribute( "cn" );
+        attribute.add( "test1", "test2" );
+        
+        Modification mod = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
+        Modification clone = mod.clone();
+        
+        attribute.remove( "test2" );
+        
+        EntryAttribute clonedAttribute = (ClientAttribute)clone.getAttribute();
+        
+        assertEquals( 1, mod.getAttribute().size() );
+        assertTrue( mod.getAttribute().contains( "test1" ) );
+
+        assertEquals( 2, clonedAttribute.size() );
+        assertTrue( clone.getAttribute().contains( "test1" ) );
+        assertTrue( clone.getAttribute().contains( "test2" ) );
+    }
+    
+    
+    @Test
+    public void testSerializationModificationADD() throws ClassNotFoundException, IOException
+    {
+        EntryAttribute attribute = new DefaultClientAttribute( "cn" );
+        attribute.add( "test1", "test2" );
+        
+        ClientModification mod = new ClientModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
+        
+        Modification modSer = deserializeValue( serializeValue( mod ) );
+        
+        assertEquals( mod, modSer );
+    }
+    
+    
+    @Test
+    public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException
+    {
+        EntryAttribute attribute = new DefaultClientAttribute( "cn" );
+        attribute.add( "test1", "test2" );
+        
+        ClientModification mod = new ClientModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
+        
+        Modification modSer = deserializeValue( serializeValue( mod ) );
+        
+        assertEquals( mod, modSer );
+    }
+    
+    
+    @Test
+    public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException
+    {
+        EntryAttribute attribute = new DefaultClientAttribute( "cn" );
+        attribute.add( "test1", "test2" );
+        
+        ClientModification mod = new ClientModification( ModificationOperation.REMOVE_ATTRIBUTE, attribute );
+        
+        Modification modSer = deserializeValue( serializeValue( mod ) );
+        
+        assertEquals( mod, modSer );
+    }
+    
+    
+    @Test
+    public void testSerializationModificationNoAttribute() throws ClassNotFoundException, IOException
+    {
+        ClientModification mod = new ClientModification();
+        
+        mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
+        
+        Modification modSer = deserializeValue( serializeValue( mod ) );
+        
+        assertEquals( mod, modSer );
+    }
+}

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientStringValueTest.java Thu Aug 14 16:12:09 2008
@@ -25,6 +25,12 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
@@ -42,6 +48,80 @@
 public class ClientStringValueTest
 {
     /**
+     * Serialize a ClientStringValue
+     */
+    private ByteArrayOutputStream serializeValue( ClientStringValue value ) throws IOException
+    {
+        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;
+            }
+        }
+        
+        return out;
+    }
+    
+    
+    /**
+     * Deserialize a ClientStringValue
+     */
+    private ClientStringValue deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    {
+        ObjectInputStream oIn = null;
+        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
+
+        try
+        {
+            oIn = new ObjectInputStream( in );
+
+            ClientStringValue value = ( ClientStringValue ) oIn.readObject();
+
+            return value;
+        }
+        catch ( IOException ioe )
+        {
+            throw ioe;
+        }
+        finally
+        {
+            try
+            {
+                if ( oIn != null )
+                {
+                    oIn.close();
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw ioe;
+            }
+        }
+    }
+    
+    
+    /**
      * Test method for {@link org.apache.directory.shared.ldap.entry.client.ClientStringValue#hashCode()}.
      */
     @Test
@@ -460,4 +540,122 @@
         csv.clear();
         assertEquals( "null", csv.toString() );
     }
+    
+    
+    /**
+     * Test the serialization of a CSV with a value and a normalized value
+     */
+    @Test
+    public void testSerializeStandard() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientStringValue csv = new ClientStringValue( "TEST");
+        csv.setNormalized( true );
+        csv.normalize( new DeepTrimToLowerNormalizer() );
+        csv.isValid( new Ia5StringSyntaxChecker() );
+
+        ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
+         assertNotSame( csv, csvSer );
+         assertEquals( csv.get(), csvSer.get() );
+         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
+         assertTrue( csvSer.isNormalized() );
+         assertFalse( csvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CSV with a value and no normalized value
+     */
+    @Test
+    public void testSerializeNotNormalized() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientStringValue csv = new ClientStringValue( "Test" );
+        csv.setNormalized( false );
+        csv.isValid( new Ia5StringSyntaxChecker() );
+
+        ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
+         assertNotSame( csv, csvSer );
+         assertEquals( csv.get(), csvSer.get() );
+         assertEquals( csv.get(), csvSer.getNormalizedValue() );
+         assertFalse( csvSer.isNormalized() );
+         assertFalse( csvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CSV with a value and an empty normalized value
+     */
+    @Test
+    public void testSerializeEmptyNormalized() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientStringValue csv = new ClientStringValue( "  " );
+        csv.setNormalized( true );
+        csv.isValid( new Ia5StringSyntaxChecker() );
+        csv.normalize( new DeepTrimToLowerNormalizer() );
+
+        ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
+         assertNotSame( csv, csvSer );
+         assertEquals( csv.get(), csvSer.get() );
+         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
+         assertTrue( csvSer.isNormalized() );
+         assertFalse( csvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CSV with a null value
+     */
+    @Test
+    public void testSerializeNullValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientStringValue csv = new ClientStringValue( null );
+        csv.setNormalized( true );
+        csv.isValid( new Ia5StringSyntaxChecker() );
+        csv.normalize( new DeepTrimToLowerNormalizer() );
+
+        ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
+         assertNotSame( csv, csvSer );
+         assertEquals( csv.get(), csvSer.get() );
+         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
+         assertTrue( csvSer.isNormalized() );
+         assertFalse( csvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CSV with an empty value
+     */
+    @Test
+    public void testSerializeEmptyValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientStringValue csv = new ClientStringValue( "" );
+        csv.setNormalized( true );
+        csv.isValid( new Ia5StringSyntaxChecker() );
+        csv.normalize( new DeepTrimToLowerNormalizer() );
+
+        ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
+         assertNotSame( csv, csvSer );
+         assertEquals( csv.get(), csvSer.get() );
+         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
+         assertTrue( csvSer.isNormalized() );
+         assertFalse( csvSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a CSV with an empty value not normalized
+     */
+    @Test
+    public void testSerializeEmptyValueNotNormalized() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientStringValue csv = new ClientStringValue( "" );
+        csv.setNormalized( false );
+        csv.isValid( new Ia5StringSyntaxChecker() );
+
+        ClientStringValue csvSer = deserializeValue( serializeValue( csv ) );
+         assertNotSame( csv, csvSer );
+         assertEquals( csv.get(), csvSer.get() );
+         assertEquals( csv.getNormalizedValue(), csvSer.getNormalizedValue() );
+         assertFalse( csvSer.isNormalized() );
+         assertFalse( csvSer.isValid() );
+    }
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttributeTest.java Thu Aug 14 16:12:09 2008
@@ -25,6 +25,11 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -65,6 +70,82 @@
     private static final ClientBinaryValue BIN_VALUE3 = new ClientBinaryValue( BYTES3 );
     private static final ClientBinaryValue BIN_VALUE4 = new ClientBinaryValue( BYTES4 );
 
+    
+    
+    /**
+     * Serialize a DefaultClientAttribute
+     */
+    private ByteArrayOutputStream serializeValue( DefaultClientAttribute value ) throws IOException
+    {
+        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;
+            }
+        }
+        
+        return out;
+    }
+    
+    
+    /**
+     * Deserialize a DefaultClientAttribute
+     */
+    private DefaultClientAttribute deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    {
+        ObjectInputStream oIn = null;
+        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
+
+        try
+        {
+            oIn = new ObjectInputStream( in );
+
+            DefaultClientAttribute value = ( DefaultClientAttribute ) oIn.readObject();
+
+            return value;
+        }
+        catch ( IOException ioe )
+        {
+            throw ioe;
+        }
+        finally
+        {
+            try
+            {
+                if ( oIn != null )
+                {
+                    oIn.close();
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw ioe;
+            }
+        }
+    }
+
+    
     /**
      * @throws java.lang.Exception
      */
@@ -1462,4 +1543,92 @@
         attr.setHR( false );
         assertNotSame( attr, clone );
     }
+    
+    
+    /**
+     * Test the serialization of a complete client attribute
+     */
+    @Test
+    public void testSerializeCompleteAttribute() throws NamingException, IOException, ClassNotFoundException
+    {
+        DefaultClientAttribute dca = new DefaultClientAttribute( "CommonName" );
+        dca.setHR( true );
+        dca.setId( "cn" );
+        dca.add( "test1", "test2" );
+
+        DefaultClientAttribute dcaSer = deserializeValue( serializeValue( dca ) );
+        assertEquals( dca.toString(), dcaSer.toString() );
+        assertEquals( "commonname", dcaSer.getId() );
+        assertEquals( "CommonName", dcaSer.getUpId() );
+        assertEquals( "test1", dcaSer.getString() );
+        assertTrue( dcaSer.contains( "test2", "test1" ) );
+        assertTrue( dcaSer.isHR() );
+        assertFalse( dcaSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a client attribute with no value
+     */
+    @Test
+    public void testSerializeAttributeWithNoValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        DefaultClientAttribute dca = new DefaultClientAttribute( "CommonName" );
+        dca.setHR( true );
+        dca.setId( "cn" );
+
+        DefaultClientAttribute dcaSer = deserializeValue( serializeValue( dca ) );
+        assertEquals( dca.toString(), dcaSer.toString() );
+        assertEquals( "commonname", dcaSer.getId() );
+        assertEquals( "CommonName", dcaSer.getUpId() );
+        assertEquals( 0, dcaSer.size() );
+        assertTrue( dcaSer.isHR() );
+        assertTrue( dcaSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a client attribute with a null value
+     */
+    @Test
+    public void testSerializeAttributeNullValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        DefaultClientAttribute dca = new DefaultClientAttribute( "CommonName" );
+        dca.setHR( true );
+        dca.setId( "cn" );
+        dca.add( (String)null );
+
+        DefaultClientAttribute dcaSer = deserializeValue( serializeValue( dca ) );
+        assertEquals( dca.toString(), dcaSer.toString() );
+        assertEquals( "commonname", dcaSer.getId() );
+        assertEquals( "CommonName", dcaSer.getUpId() );
+        assertNull( dcaSer.getString() );
+        assertEquals( 1, dcaSer.size() );
+        assertTrue( dcaSer.contains( (String)null ) );
+        assertTrue( dcaSer.isHR() );
+        assertFalse( dcaSer.isValid() );
+    }
+    
+    
+    /**
+     * Test the serialization of a client attribute with a binary value
+     */
+    @Test
+    public void testSerializeAttributeBinaryValue() throws NamingException, IOException, ClassNotFoundException
+    {
+        DefaultClientAttribute dca = new DefaultClientAttribute( "UserPassword" );
+        dca.setHR( false );
+        byte[] password = StringTools.getBytesUtf8( "secret" );
+        dca.add( password );
+
+        DefaultClientAttribute dcaSer = deserializeValue( serializeValue( dca ) );
+        assertEquals( dca.toString(), dcaSer.toString() );
+        assertEquals( "userpassword", dcaSer.getId() );
+        assertEquals( "UserPassword", dcaSer.getUpId() );
+        assertTrue( Arrays.equals( dca.getBytes(), dcaSer.getBytes() ) );
+        assertEquals( 1, dcaSer.size() );
+        assertTrue( dcaSer.contains( password ) );
+        assertFalse( dcaSer.isHR() );
+        assertFalse( dcaSer.isValid() );
+    }
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java Thu Aug 14 16:12:09 2008
@@ -26,10 +26,17 @@
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.fail;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.naming.InvalidNameException;
@@ -39,6 +46,9 @@
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -54,6 +64,7 @@
     private static final byte[] BYTES1 = new byte[]{ 'a', 'b' };
     private static final byte[] BYTES2 = new byte[]{ 'b' };
     private static final byte[] BYTES3 = new byte[]{ 'c' };
+    private static Map<String, OidNormalizer> oids;
     
     
     /**
@@ -81,6 +92,81 @@
         }
     }
 
+
+    /**
+     * Serialize a ClientEntry
+     */
+    private ByteArrayOutputStream serializeValue( ClientEntry value ) throws IOException
+    {
+        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;
+            }
+        }
+        
+        return out;
+    }
+    
+    
+    /**
+     * Deserialize a ClientEntry
+     */
+    private ClientEntry deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+    {
+        ObjectInputStream oIn = null;
+        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
+
+        try
+        {
+            oIn = new ObjectInputStream( in );
+
+            ClientEntry value = ( ClientEntry ) oIn.readObject();
+
+            return value;
+        }
+        catch ( IOException ioe )
+        {
+            throw ioe;
+        }
+        finally
+        {
+            try
+            {
+                if ( oIn != null )
+                {
+                    oIn.close();
+                }
+            }
+            catch ( IOException ioe )
+            {
+                throw ioe;
+            }
+        }
+    }
+
+    
     /**
      * @throws java.lang.Exception
      */
@@ -88,6 +174,16 @@
     public static void setUpBeforeClass() throws Exception
     {
         EXAMPLE_DN = new LdapDN( "dc=example,dc=com" );
+
+        oids = new HashMap<String, OidNormalizer>();
+
+        oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
+
+        oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
+        oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
     }
 
 
@@ -100,7 +196,7 @@
         Entry entry = new DefaultClientEntry();
         
         assertNotNull( entry );
-        assertNull( entry.getDn() );
+        assertEquals( LdapDN.EMPTY_LDAPDN, entry.getDn() );
         assertEquals( 0, entry.size() );
     }
 
@@ -360,7 +456,7 @@
         assertEquals( entry1, entry2 );
         entry2.setDn( EXAMPLE_DN );
         
-        assertNull( entry1.getDn() );
+        assertEquals( LdapDN.EMPTY_LDAPDN, entry1.getDn() );
         
         entry1.setDn( EXAMPLE_DN );
         entry2 = entry1.clone();
@@ -1095,7 +1191,7 @@
     {
         Entry entry = new DefaultClientEntry();
         
-        assertNull( entry.getDn() );
+        assertEquals( LdapDN.EMPTY_LDAPDN, entry.getDn() );
         
         entry.setDn( EXAMPLE_DN );
         assertEquals( EXAMPLE_DN, entry.getDn() );
@@ -1155,4 +1251,78 @@
 
         assertEquals( expected, entry.toString() );
     }
+    
+    
+    /**
+     * Test the serialization of a complete entry
+     */
+    @Test
+    public void testSerializeCompleteEntry() throws NamingException, IOException, ClassNotFoundException
+    {
+        LdapDN dn = new LdapDN( "ou=system" );
+        
+        dn.normalize( oids );
+        
+        byte[] password = StringTools.getBytesUtf8( "secret" );
+        ClientEntry entry = new DefaultClientEntry( dn);
+        entry.add( "ObjectClass", "top", "person" );
+        entry.add( "cn", "test1" );
+        entry.add( "userPassword", password );
+
+        ClientEntry entrySer = deserializeValue( serializeValue( entry ) );
+        
+        assertEquals( entry, entrySer );
+    }
+    
+    
+    /**
+     * Test the serialization of an entry with no DN
+     */
+    @Test
+    public void testSerializeEntryWithNoDN() throws NamingException, IOException, ClassNotFoundException
+    {
+        byte[] password = StringTools.getBytesUtf8( "secret" );
+        ClientEntry entry = new DefaultClientEntry();
+        entry.add( "ObjectClass", "top", "person" );
+        entry.add( "cn", "test1" );
+        entry.add( "userPassword", password );
+
+        ClientEntry entrySer = deserializeValue( serializeValue( entry ) );
+        
+        assertEquals( entry, entrySer );
+    }
+    
+    
+    /**
+     * Test the serialization of an entry with no attribute and no DN
+     */
+    @Test
+    public void testSerializeEntryWithNoDNNoAttribute() throws NamingException, IOException, ClassNotFoundException
+    {
+        ClientEntry entry = new DefaultClientEntry();
+
+        ClientEntry entrySer = deserializeValue( serializeValue( entry ) );
+        
+        assertEquals( entry, entrySer );
+    }
+    
+    
+    /**
+     * Test the serialization of an entry with no attribute
+     */
+    @Test
+    public void testSerializeEntryWithNoAttribute() throws NamingException, IOException, ClassNotFoundException
+    {
+        LdapDN dn = new LdapDN( "ou=system" );
+        
+        dn.normalize( oids );
+        
+        ClientEntry entry = new DefaultClientEntry( dn );
+
+        ClientEntry entrySer = deserializeValue( serializeValue( entry ) );
+        
+        assertEquals( entry, entrySer );
+    }
+    
+    
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?rev=686082&r1=686081&r2=686082&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java Thu Aug 14 16:12:09 2008
@@ -29,13 +29,13 @@
 
 import junit.framework.TestCase;
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.DirContext;
 import javax.naming.ldap.Control;
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 /**
@@ -174,9 +174,9 @@
 
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "displayname" );
+        EntryAttribute attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
     }
 
@@ -227,9 +227,9 @@
 
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "displayname" );
+        EntryAttribute attr = entry.get( "displayname" );
         assertTrue( attr.contains( "app1" ) );
 
     }
@@ -271,13 +271,13 @@
 
         assertTrue( entry.isChangeModify() );
 
-        assertEquals( "dc=example,dc=com", entry.getDn() );
+        assertEquals( "dc=example,dc=com", entry.getDn().getUpName() );
 
-        List<ModificationItemImpl> mods = entry.getModificationItems( );
+        List<Modification> mods = entry.getModificationItems( );
         assertTrue( mods.size() == 1 );
-        Attribute attr = mods.get(0).getAttribute();
-        assertTrue( attr.getID().equals( "administrativeRole"));
-        assertEquals( attr.get(), "accessControlSpecificArea" );
+        EntryAttribute attr = mods.get(0).getAttribute();
+        assertTrue( attr.getId().equals( "administrativerole"));
+        assertEquals( attr.getString(), "accessControlSpecificArea" );
     }
 
     /**
@@ -450,9 +450,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1" ) );
 
         attr = entry.get( "objectclass" );
@@ -463,10 +463,10 @@
         assertTrue( attr.contains( "app1" ) );
 
         attr = entry.get( "dependencies" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
 
         attr = entry.get( "envvars" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
     }
 
     public void testLdifParserMuiltiLineComments() throws NamingException
@@ -493,9 +493,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1#another comment" ) );
 
         attr = entry.get( "objectclass" );
@@ -506,10 +506,10 @@
         assertTrue( attr.contains( "app1" ) );
 
         attr = entry.get( "dependencies" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
 
         attr = entry.get( "envvars" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
     }
 
     public void testLdifParserMultiLineEntries() throws NamingException
@@ -536,9 +536,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "app1#another comment" ) );
 
         attr = entry.get( "objectclass" );
@@ -549,10 +549,10 @@
         assertTrue( attr.contains( "app1" ) );
 
         attr = entry.get( "dependencies" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
 
         attr = entry.get( "envvars" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
     }
 
     public void testLdifParserBase64() throws NamingException, UnsupportedEncodingException
@@ -578,9 +578,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( "UTF-8" ) ) );
 
         attr = entry.get( "objectclass" );
@@ -591,10 +591,10 @@
         assertTrue( attr.contains( "app1" ) );
 
         attr = entry.get( "dependencies" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
 
         attr = entry.get( "envvars" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
     }
 
     public void testLdifParserBase64MultiLine() throws NamingException, UnsupportedEncodingException
@@ -621,9 +621,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
+        assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "cn" );
+        EntryAttribute attr = entry.get( "cn" );
         assertTrue( attr.contains( "Emmanuel L\u00e9charny  ".getBytes( "UTF-8" ) ) );
 
         attr = entry.get( "objectclass" );
@@ -634,10 +634,10 @@
         assertTrue( attr.contains( "app1" ) );
 
         attr = entry.get( "dependencies" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
 
         attr = entry.get( "envvars" );
-        assertNull( attr.get() );
+        assertNull( attr.get().get() );
     }
 
     public void testLdifParserRFC2849Sample1() throws NamingException
@@ -673,9 +673,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "person" ) );
         assertTrue( attr.contains( "organizationalPerson" ) );
@@ -702,7 +702,7 @@
         assertTrue( entry.isChangeAdd() );
 
         attr = entry.get( "dn" );
-        assertEquals( "cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com", entry.getDn().getUpName() );
 
         attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
@@ -746,9 +746,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "person" ) );
         assertTrue( attr.contains( "organizationalPerson" ) );
@@ -803,9 +803,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "person" ) );
         assertTrue( attr.contains( "organizationalPerson" ) );
@@ -856,9 +856,9 @@
         LdifEntry entry = (LdifEntry) entries.get( 0 );
         assertTrue( entry.isChangeAdd() );
 
-        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "person" ) );
         assertTrue( attr.contains( "organizationalPerson" ) );
@@ -995,11 +995,11 @@
             {
                 if ( "dn".equalsIgnoreCase( values[i][j][0] ) )
                 {
-                    assertEquals( values[i][j][1], entry.getDn() );
+                    assertEquals( values[i][j][1], entry.getDn().getUpName() );
                 }
                 else
                 {
-                    Attribute attr = entry.get( values[i][j][0] );
+                    EntryAttribute attr = entry.get( values[i][j][0] );
 
                     if ( attr.contains( values[i][j][1] ) )
                     {
@@ -1056,16 +1056,16 @@
         {
             if ( "dn".equalsIgnoreCase( values[i][0] ) )
             {
-                assertEquals( values[i][1], entry.getDn() );
+                assertEquals( values[i][1], entry.getDn().getUpName() );
             }
             else if ( "jpegphoto".equalsIgnoreCase( values[i][0] ) )
             {
-                Attribute attr = entry.get( values[i][0] );
-                assertEquals( StringTools.dumpBytes( data ), StringTools.dumpBytes( (byte[]) attr.get() ) );
+                EntryAttribute attr = entry.get( values[i][0] );
+                assertEquals( StringTools.dumpBytes( data ), StringTools.dumpBytes( attr.getBytes() ) );
             }
             else
             {
-                Attribute attr = entry.get( values[i][0] );
+                EntryAttribute attr = entry.get( values[i][0] );
 
                 if ( attr.contains( values[i][1] ) )
                 {
@@ -1240,16 +1240,16 @@
         {
             if ( "dn".equalsIgnoreCase( values[0][i][0] ) )
             {
-                assertEquals( values[0][i][1], entry.getDn() );
+                assertEquals( values[0][i][1], entry.getDn().getUpName() );
             }
             else if ( "jpegphoto".equalsIgnoreCase( values[0][i][0] ) )
             {
-                Attribute attr = entry.get( values[0][i][0] );
-                assertEquals( StringTools.dumpBytes( data ), StringTools.dumpBytes( (byte[]) attr.get() ) );
+                EntryAttribute attr = entry.get( values[0][i][0] );
+                assertEquals( StringTools.dumpBytes( data ), StringTools.dumpBytes( attr.getBytes() ) );
             }
             else
             {
-                Attribute attr = entry.get( values[0][i][0] );
+                EntryAttribute attr = entry.get( values[0][i][0] );
 
                 if ( attr.contains( values[0][i][1] ) )
                 {
@@ -1265,74 +1265,76 @@
         // Second entry
         entry = (LdifEntry) entries.get( 1 );
         assertTrue( entry.isChangeDelete() );
-        assertEquals( values[1][0][1], entry.getDn() );
+        assertEquals( values[1][0][1], entry.getDn().getUpName() );
 
         // Third entry
         entry = (LdifEntry) entries.get( 2 );
         assertTrue( entry.isChangeModRdn() );
-        assertEquals( values[2][0][1], entry.getDn() );
+        assertEquals( values[2][0][1], entry.getDn().getUpName() );
         assertEquals( values[2][1][0], entry.getNewRdn() );
         assertTrue( entry.isDeleteOldRdn() );
 
         // Forth entry
         entry = (LdifEntry) entries.get( 3 );
         assertTrue( entry.isChangeModDn() );
-        assertEquals( values[3][0][1], entry.getDn() );
+        assertEquals( values[3][0][1], entry.getDn().getUpName() );
         assertEquals( values[3][1][0], entry.getNewRdn() );
         assertFalse( entry.isDeleteOldRdn() );
         assertEquals( values[3][2][0], entry.getNewSuperior() );
 
         // Fifth entry
         entry = (LdifEntry) entries.get( 4 );
-        List<ModificationItemImpl> modifs = entry.getModificationItems();
+        List<Modification> modifs = entry.getModificationItems();
 
         assertTrue( entry.isChangeModify() );
-        assertEquals( values[4][0][1], entry.getDn() );
+        assertEquals( values[4][0][1], entry.getDn().getUpName() );
 
         // "add: postaladdress"
         // "postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086"
-        ModificationItemImpl item = (ModificationItemImpl) modifs.get( 0 );
-        assertEquals( DirContext.ADD_ATTRIBUTE, item.getModificationOp() );
-        assertEquals( values[4][1][0], item.getAttribute().getID() );
-        assertEquals( values[4][1][1], item.getAttribute().get( 0 ) );
+        Modification item = (Modification) modifs.get( 0 );
+        assertEquals( ModificationOperation.ADD_ATTRIBUTE, item.getOperation() );
+        assertEquals( values[4][1][0], item.getAttribute().getId() );
+        assertTrue( item.getAttribute().contains( values[4][1][1] ) );
 
         // "delete: description\n" +
-        item = (ModificationItemImpl) modifs.get( 1 );
-        assertEquals( DirContext.REMOVE_ATTRIBUTE, item.getModificationOp() );
-        assertEquals( values[4][2][0], item.getAttribute().getID() );
+        item = (Modification) modifs.get( 1 );
+        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, item.getOperation() );
+        assertEquals( values[4][2][0], item.getAttribute().getId() );
 
         // "replace: telephonenumber"
         // "telephonenumber: +1 408 555 1234"
         // "telephonenumber: +1 408 555 5678"
-        item = (ModificationItemImpl) modifs.get( 2 );
-        assertEquals( DirContext.REPLACE_ATTRIBUTE, item.getModificationOp() );
-        assertEquals( values[4][3][0], item.getAttribute().getID() );
-        assertEquals( values[4][3][1], item.getAttribute().get( 0 ) );
-        assertEquals( values[4][3][2], item.getAttribute().get( 1 ) );
+        item = (Modification) modifs.get( 2 );
+        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, item.getOperation() );
+        
+        assertEquals( values[4][3][0], item.getAttribute().getId() );
+        assertTrue( item.getAttribute().contains( values[4][3][1], values[4][3][2] ) );
 
         // "delete: facsimiletelephonenumber"
         // "facsimiletelephonenumber: +1 408 555 9876"
-        item = (ModificationItemImpl) modifs.get( 3 );
-        assertEquals( DirContext.REMOVE_ATTRIBUTE, item.getModificationOp() );
-        assertEquals( values[4][4][0], item.getAttribute().getID() );
-        assertEquals( values[4][4][1], item.getAttribute().get( 0 ) );
+        item = (Modification) modifs.get( 3 );
+        
+        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, item.getOperation() );
+
+        assertEquals( values[4][4][0], item.getAttribute().getId() );
+        assertTrue( item.getAttribute().contains( values[4][4][1] ) );
 
         // Sixth entry
         entry = (LdifEntry) entries.get( 5 );
         modifs = entry.getModificationItems();
 
         assertTrue( entry.isChangeModify() );
-        assertEquals( values[5][0][1], entry.getDn() );
+        assertEquals( values[5][0][1], entry.getDn().getUpName() );
 
         // "replace: postaladdress"
-        item = (ModificationItemImpl) modifs.get( 0 );
-        assertEquals( DirContext.REPLACE_ATTRIBUTE, item.getModificationOp() );
-        assertEquals( values[5][1][0], item.getAttribute().getID() );
+        item = (Modification) modifs.get( 0 );
+        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, item.getOperation() );
+        assertEquals( values[5][1][0], item.getAttribute().getId() );
 
         // "delete: description"
-        item = (ModificationItemImpl) modifs.get( 1 );
-        assertEquals( DirContext.REMOVE_ATTRIBUTE, item.getModificationOp() );
-        assertEquals( values[5][2][0], item.getAttribute().getID() );
+        item = (Modification) modifs.get( 1 );
+        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, item.getOperation() );
+        assertEquals( values[5][2][0], item.getAttribute().getId() );
     }
 
     public void testLdifParserRFC2849Sample7() throws NamingException, Exception
@@ -1352,7 +1354,7 @@
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
         assertTrue( entry.isChangeDelete() );
 
         // Check the control
@@ -1379,7 +1381,7 @@
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
         assertTrue( entry.isChangeDelete() );
 
         // Check the control
@@ -1406,7 +1408,7 @@
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn() );
+        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getUpName() );
         assertTrue( entry.isChangeDelete() );
 
         // Check the control
@@ -1507,9 +1509,9 @@
         List<LdifEntry> entries = reader.parseLdif( ldif );
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "ou=Users, dc=example, dc=com", entry.getDn() );
+        assertEquals( "ou=Users, dc=example, dc=com", entry.getDn().getUpName() );
 
-        Attribute attr = entry.get( "objectclass" );
+        EntryAttribute attr = entry.get( "objectclass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( "organizationalunit" ) );
 
@@ -1565,8 +1567,8 @@
 
         LdifEntry entry = (LdifEntry) entries.get( 0 );
 
-        assertEquals( "cn=browseRootAci,dc=example,dc=com", entry.getDn() );
-        Attribute attr = entry.get( "objectClass" );
+        assertEquals( "cn=browseRootAci,dc=example,dc=com", entry.getDn().getUpName() );
+        EntryAttribute attr = entry.get( "objectClass" );
         assertTrue( attr.contains( "top" ) );
         assertTrue( attr.contains( SchemaConstants.SUBENTRY_OC ) );
         assertTrue( attr.contains( "accessControlSubentry" ) );



Mime
View raw message