directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1079453 [2/2] - in /directory: apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/ apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ shared/trunk/integ/src/test/java/org/apac...
Date Tue, 08 Mar 2011 17:56:55 GMT
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java?rev=1079453&r1=1079452&r2=1079453&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java
Tue Mar  8 17:56:54 2011
@@ -106,7 +106,7 @@ public class StringValueAttributeTypeTes
         try
         {
             oOut = new ObjectOutputStream( out );
-            StringValue.serialize( value, oOut );
+            value.writeExternal( oOut );
         }
         catch ( IOException ioe )
         {
@@ -143,8 +143,10 @@ public class StringValueAttributeTypeTes
         try
         {
             oIn = new ObjectInputStream( in );
+            
+            StringValue value = new StringValue( at );
 
-            StringValue value = StringValue.deserialize( null, oIn );
+            value.readExternal( oIn );
 
             return value;
         }
@@ -308,17 +310,9 @@ public class StringValueAttributeTypeTes
         assertFalse( value1.equals( "test" ) );
         assertFalse( value1.equals( null ) );
         
-        assertFalse( value1.equals( valueString ) );
+        assertTrue( value1.equals( valueString ) );
         assertFalse( value1.equals( valueBytes ) );
     }
-
-    
-    
-    
-    
-    
-    
-    
     
     
     /**
@@ -326,16 +320,6 @@ public class StringValueAttributeTypeTes
      */
     @Test public void testBadConstructor()
     {
-        try
-        {
-            new StringValue( null, null );
-            fail();
-        }
-        catch ( IllegalArgumentException iae )
-        {
-            // Expected...
-        }
-        
         // create a AT without any syntax
         AttributeType attribute = new EntryUtils.AT( "1.1.3.1" );
         

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializerTest.java?rev=1079453&r1=1079452&r2=1079453&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializerTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializerTest.java
Tue Mar  8 17:56:54 2011
@@ -28,6 +28,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.util.StringConstants;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -60,234 +61,246 @@ public class ValueSerializerTest
     
     
     @Test
-    public void testBinaryValueWithDataSerialization() throws IOException
+    public void testBinaryValueWithDataSerialization() throws IOException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        BinaryValue.serialize( bv1, out );
+        bv1.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = (BinaryValue)BinaryValue.deserialize( null, in );
+        BinaryValue bvDeser = new BinaryValue( (AttributeType)null );
+        bvDeser.readExternal( in );
 
         assertEquals( bv1, bvDeser );
     }
     
     
     @Test
-    public void testBinaryValueWithEmptyDataSerialization() throws IOException
+    public void testBinaryValueWithEmptyDataSerialization() throws IOException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        BinaryValue.serialize( bv2, out );
+        bv2.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = (BinaryValue)BinaryValue.deserialize( null, in );
+        BinaryValue bvDeser = new BinaryValue( (AttributeType)null );
+        bvDeser.readExternal( in );
 
         assertEquals( bv2, bvDeser );
     }
     
     
     @Test
-    public void testBinaryValueNoDataSerialization() throws IOException
+    public void testBinaryValueNoDataSerialization() throws IOException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        BinaryValue.serialize( bv3, out );
+        bv3.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = (BinaryValue)BinaryValue.deserialize( null, in );
+        BinaryValue bvDeser = new BinaryValue( (AttributeType)null );
+        bvDeser.readExternal( in );
 
         assertEquals( bv3, bvDeser );
     }
     
     
     @Test
-    public void testStringValueWithDataSerialization() throws IOException
+    public void testStringValueWithDataSerialization() throws IOException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        StringValue.serialize( sv1, out );
+        sv1.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = (StringValue)StringValue.deserialize( null, in );
+        StringValue svDeser = new StringValue( (AttributeType)null );
+        svDeser.readExternal( in );
 
         assertEquals( sv1, svDeser );
     }
     
     
     @Test
-    public void testStringValueWithEmptyDataSerialization() throws IOException
+    public void testStringValueWithEmptyDataSerialization() throws IOException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        StringValue.serialize( sv2, out );
+        sv2.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = (StringValue)StringValue.deserialize( null, in );
+        StringValue svDeser = new StringValue( (AttributeType)null );
+        svDeser.readExternal( in );
 
         assertEquals( sv2, svDeser );
     }
     
     
     @Test
-    public void testStringValueNoDataSerialization() throws IOException
+    public void testStringValueNoDataSerialization() throws IOException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        StringValue.serialize( sv3, out );
+        sv3.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = (StringValue)StringValue.deserialize( null, in );
+        StringValue svDeser = new StringValue( (AttributeType)null );
+        svDeser.readExternal( in );
 
         assertEquals( sv3, svDeser );
     }
     
     
     @Test
-    public void testBinaryValueWithDataNormalizedSerialization() throws IOException, LdapException
+    public void testBinaryValueWithDataNormalizedSerialization() throws IOException, LdapException,
ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
         bv1n.normalize();
 
-        BinaryValue.serialize( bv1n, out );
+        bv1n.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = (BinaryValue)BinaryValue.deserialize( null, in );
+        BinaryValue bvDeser = new BinaryValue( (AttributeType)null );
+        bvDeser.readExternal( in );
 
         assertEquals( bv1n, bvDeser );
     }
     
     
     @Test
-    public void testBinaryValueWithEmptyDataNormalizedSerialization() throws IOException,
LdapException
+    public void testBinaryValueWithEmptyDataNormalizedSerialization() throws IOException,
LdapException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
         bv2n.normalize();
 
-        BinaryValue.serialize( bv2n, out );
+        bv2n.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = (BinaryValue)BinaryValue.deserialize( null, in );
+        BinaryValue bvDeser = new BinaryValue( (AttributeType)null );
+        bvDeser.readExternal( in );
 
         assertEquals( bv2n, bvDeser );
     }
     
     
     @Test
-    public void testBinaryValueNoDataNormalizedSerialization() throws IOException, LdapException
+    public void testBinaryValueNoDataNormalizedSerialization() throws IOException, LdapException,
ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
         bv3n.normalize();
 
-        BinaryValue.serialize( bv3n, out );
+        bv3n.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        BinaryValue bvDeser = (BinaryValue)BinaryValue.deserialize( null, in );
+        BinaryValue bvDeser = new BinaryValue( (AttributeType)null );
+        bvDeser.readExternal( in );
 
         assertEquals( bv3n, bvDeser );
     }
     
     
     @Test
-    public void testStringValueWithDataNormalizedSerialization() throws IOException, LdapException
+    public void testStringValueWithDataNormalizedSerialization() throws IOException, LdapException,
ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
         sv1n.normalize();
 
-        StringValue.serialize( sv1n, out );
+        sv1n.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = (StringValue)StringValue.deserialize( null, in );
+        StringValue svDeser = new StringValue( (AttributeType)null );
+        svDeser.readExternal( in );
 
         assertEquals( sv1n, svDeser );
     }
     
     
     @Test
-    public void testStringValueWithEmptyDataNormalizedSerialization() throws IOException,
LdapException
+    public void testStringValueWithEmptyDataNormalizedSerialization() throws IOException,
LdapException, ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
         sv2n.normalize();
 
-        StringValue.serialize( sv2n, out );
+        sv2n.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = (StringValue)StringValue.deserialize( null, in );
+        StringValue svDeser = new StringValue( (AttributeType)null );
+        svDeser.readExternal( in );
 
         assertEquals( sv2n, svDeser );
     }
     
     
     @Test
-    public void testStringValueNoDataNormalizedSerialization() throws IOException, LdapException
+    public void testStringValueNoDataNormalizedSerialization() throws IOException, LdapException,
ClassNotFoundException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
         sv3n.normalize();
 
-        StringValue.serialize( sv3n, out );
+        sv3n.writeExternal( out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        StringValue svDeser = (StringValue)StringValue.deserialize( null, in );
+        StringValue svDeser = new StringValue( (AttributeType)null );
+        svDeser.readExternal( in );
 
         assertEquals( sv3n, svDeser );
     }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java?rev=1079453&r1=1079452&r2=1079453&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
Tue Mar  8 17:56:54 2011
@@ -267,14 +267,15 @@ public class AvaTest
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        out.writeObject( atav );
+        atav.writeExternal( out );
 
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Ava atav2 = (Ava)in.readObject();
+        Ava atav2 = new Ava( schemaManager );
+        atav2.readExternal( in );
 
         assertEquals( atav, atav2 );
     }

Added: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnSerializerTest.java?rev=1079453&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnSerializerTest.java
(added)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnSerializerTest.java
Tue Mar  8 17:56:54 2011
@@ -0,0 +1,112 @@
+/*
+ *  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.model.name;
+
+import static org.junit.Assert.assertEquals;
+
+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.model.exception.LdapException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+/**
+ * Test the Dn Serialization
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class DnSerializerTest
+{
+    @Test
+    public void testDnFullSerialization() throws IOException, LdapException, ClassNotFoundException
+    {
+        Dn dn1 = new Dn( "gn=john + cn=doe, dc=example, dc=com" );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        dn1.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Dn dn2 = new Dn();
+        dn2.readExternal( in );
+
+        assertEquals( dn1, dn2 );
+    }
+
+
+    @Test
+    public void testDnEmptySerialization() throws IOException, LdapException, ClassNotFoundException
+    {
+        Dn dn1 = new Dn();
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        dn1.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Dn dn2 = new Dn();
+        dn2.readExternal( in );
+
+        assertEquals( dn1, dn2 );
+    }
+
+
+    @Test
+    public void testDnSimpleSerialization() throws IOException, LdapException, ClassNotFoundException
+    {
+        Dn dn1 = new Dn( "Cn = Doe" );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        dn1.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Dn dn2 = new Dn();
+        dn2.readExternal( in );
+
+        assertEquals( dn1, dn2 );
+        assertEquals( "Cn = Doe", dn2.getName() );
+        assertEquals( "cn=Doe", dn2.getNormName() );
+    }
+}

Added: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java?rev=1079453&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java
(added)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java
Tue Mar  8 17:56:54 2011
@@ -0,0 +1,110 @@
+/*
+ *  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.model.name;
+
+import static org.junit.Assert.assertEquals;
+
+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.model.exception.LdapException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+/**
+ * Test the Rdn Serialization
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class RdnSerializerTest
+{
+    @Test
+    public void testRdnFullSerialization() throws IOException, LdapException, ClassNotFoundException
+    {
+        Rdn rdn1 = new Rdn( "gn=john + cn=doe" );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn1.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn1, rdn2 );
+    }
+
+
+    @Test
+    public void testRdnEmptySerialization() throws IOException, LdapException, ClassNotFoundException
+    {
+        Rdn rdn1 = new Rdn();
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn1.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn1, rdn2 );
+    }
+
+
+    @Test
+    public void testRdnSimpleSerialization() throws IOException, LdapException, ClassNotFoundException
+    {
+        Rdn rdn1 = new Rdn( "cn=doe" );
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn1.writeExternal( out );
+        
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn1, rdn2 );
+    }
+}



Mime
View raw message