directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1081953 - in /directory/shared/trunk/ldap/model/src: main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializerTest.java
Date Tue, 15 Mar 2011 21:36:55 GMT
Author: elecharny
Date: Tue Mar 15 21:36:55 2011
New Revision: 1081953

URL: http://svn.apache.org/viewvc?rev=1081953&view=rev
Log:
o A small fix in DefaultEntry
o Used the EntrySerializer which uses the read/writeExternal methods to test serialization

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
    directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializerTest.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java?rev=1081953&r1=1081952&r2=1081953&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
Tue Mar 15 21:36:55 2011
@@ -518,6 +518,11 @@ public final class DefaultEntry implemen
      */
     private void initObjectClassAT()
     {
+        if ( schemaManager == null )
+        {
+            return;
+        }
+        
         try
         {
             if ( objectClassAttributeType == null )

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializerTest.java?rev=1081953&r1=1081952&r2=1081953&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializerTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializerTest.java
Tue Mar 15 21:36:55 2011
@@ -58,15 +58,14 @@ public class EntrySerializerTest
         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();
-        entry2.readExternal( in );
+        Entry entry2 = EntrySerializer.deserialize( null, in );
 
         assertEquals( entry1, entry2 );
         assertTrue( entry2.contains( "ObjectClass", "top", "domain" ) );
@@ -86,15 +85,14 @@ public class EntrySerializerTest
         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();
-        entry2.readExternal( in );
+        Entry entry2 = EntrySerializer.deserialize( null, in );
 
         assertEquals( entry1, entry2 );
         assertTrue( entry2.contains( "ObjectClass", "top", "domain" ) );
@@ -110,15 +108,36 @@ public class EntrySerializerTest
         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();
-        entry2.readExternal( in );
+        Entry entry2 = EntrySerializer.deserialize( null, in );
+
+        assertEquals( entry1, entry2 );
+        assertEquals( 0, entry2.size() );
+    }
+
+
+    @Test
+    public void testEntryNoAttributesNoDnSerialization() throws IOException, LdapException,
ClassNotFoundException
+    {
+        Entry entry1 = LdifUtils.createEntry( "" ); 
+        
+        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( null, in );
 
         assertEquals( entry1, entry2 );
         assertEquals( 0, entry2.size() );



Mime
View raw message