directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1081992 - /directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntrySerializerTest.java
Date Tue, 15 Mar 2011 23:13:37 GMT
Author: elecharny
Date: Tue Mar 15 23:13:37 2011
New Revision: 1081992

URL: http://svn.apache.org/viewvc?rev=1081992&view=rev
Log:
o Added a test, used the EntrySerializer class

Modified:
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntrySerializerTest.java

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntrySerializerTest.java?rev=1081992&r1=1081991&r2=1081992&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntrySerializerTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntrySerializerTest.java
Tue Mar 15 23:13:37 2011
@@ -28,8 +28,8 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.EntrySerializer;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
@@ -76,15 +76,14 @@ public class SchemaAwareEntrySerializerT
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        entry1.writeExternal( out );
+        EntrySerializer.serialize( entry1, out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Entry entry2 = new DefaultEntry( schemaManager );
-        entry2.readExternal( in );
+        Entry entry2 = EntrySerializer.deserialize( schemaManager, in );
         
         assertEquals( entry1, entry2 );
         assertTrue( entry2.contains( "2.5.4.0", "top", "domain" ) );
@@ -105,16 +104,14 @@ public class SchemaAwareEntrySerializerT
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        entry1.writeExternal( out );
+        EntrySerializer.serialize( entry1, out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Entry entry2 = new DefaultEntry( schemaManager );
-        entry2.readExternal( in );
-        
+        Entry entry2 = EntrySerializer.deserialize( schemaManager, in );
 
         assertEquals( entry1, entry2 );
         assertTrue( entry2.contains( "ObjectClass", "top", "domain" ) );
@@ -130,16 +127,36 @@ public class SchemaAwareEntrySerializerT
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream( baos );
 
-        entry1.writeExternal( out );
+        EntrySerializer.serialize( entry1, out );
         
         ObjectInputStream in = null;
 
         byte[] data = baos.toByteArray();
         in = new ObjectInputStream( new ByteArrayInputStream( data ) );
 
-        Entry entry2 = new DefaultEntry( schemaManager );
-        entry2.readExternal( in );
+        Entry entry2 = EntrySerializer.deserialize( schemaManager, in );
+
+        assertEquals( entry1, entry2 );
+        assertEquals( 0, entry2.size() );
+    }
+
+
+    @Test
+    public void testEntryNoAttributesNoDnSerialization() throws IOException, LdapException,
ClassNotFoundException
+    {
+        Entry entry1 = LdifUtils.createEntry( schemaManager, "" ); 
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        EntrySerializer.serialize( entry1, out );
         
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Entry entry2 = EntrySerializer.deserialize( schemaManager, in );
 
         assertEquals( entry1, entry2 );
         assertEquals( 0, entry2.size() );



Mime
View raw message