You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/03/18 19:44:30 UTC
svn commit: r1083011 - in /directory:
apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/
shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/
shared/trunk/ldap/model/src/main/java/org/apache/directory/share...
Author: elecharny
Date: Fri Mar 18 18:44:29 2011
New Revision: 1083011
URL: http://svn.apache.org/viewvc?rev=1083011&view=rev
Log:
o Removed the AvaSerializer and RdnSerializer
o Split the tests in two classes
o Renamed some tests
Added:
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java
- copied, changed from r1082924, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializerTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaSerializationTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializationTest.java
- copied, changed from r1082924, directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java
Removed:
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializerTest.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/AvaSerializer.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/RdnSerializer.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java
Modified:
directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java?rev=1083011&r1=1083010&r2=1083011&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java Fri Mar 18 18:44:29 2011
@@ -27,9 +27,7 @@ import java.io.ObjectOutput;
import java.util.Arrays;
import java.util.List;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.shared.ldap.model.name.Rdn;
-import org.apache.directory.shared.ldap.model.name.RdnSerializer;
/**
@@ -191,7 +189,7 @@ public class ParentIdAndRdn<ID extends C
for ( Rdn rdn : rdns )
{
- RdnSerializer.serialize( rdn, out );
+ rdn.writeExternal( out );
}
}
@@ -205,14 +203,9 @@ public class ParentIdAndRdn<ID extends C
for ( int i = 0; i < size; i++ )
{
- try
- {
- rdns[i] = RdnSerializer.deserialize( null, in );
- }
- catch ( LdapInvalidDnException lide )
- {
- throw new IOException( lide.getMessage() );
- }
+ Rdn rdn = new Rdn();
+ rdn.readExternal( in );
+ rdns[i] = rdn;
}
}
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java?rev=1083011&r1=1083010&r2=1083011&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java Fri Mar 18 18:44:29 2011
@@ -24,18 +24,10 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertTrue;
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 org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.name.Ava;
-import org.apache.directory.shared.ldap.model.name.AvaSerializer;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
-import org.apache.directory.shared.util.Strings;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -192,226 +184,4 @@ public class AvaTest
assertTrue( atav1.equals( atav2 ) );
}
-
-
- /** Serialization tests ------------------------------------------------- */
-
- /**
- * Test serialization of a simple ATAV
- */
- @Test
- public void testStringAtavSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "Test" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- out.writeObject( atav );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = (Ava)in.readObject();
-
- assertEquals( atav, atav2 );
- }
-
-
- @Test
- public void testBinaryAtavSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- byte[] normValue = Strings.getBytesUtf8("Test");
-
- Ava atav = new Ava( schemaManager, "userPKCS12", normValue );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- atav.writeExternal( out );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = new Ava( schemaManager );
- atav2.readExternal( in );
-
- assertEquals( atav, atav2 );
- }
-
-
- /**
- * Test serialization of a simple ATAV
- */
- @Test
- public void testNullAtavSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- out.writeObject( atav );
- fail();
- }
- catch ( IOException ioe )
- {
- assertTrue( true );
- }
- }
-
-
- @Test
- public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "uid", (String)null );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- out.writeObject( atav );
- fail();
- }
- catch ( IOException ioe )
- {
- String message = ioe.getMessage();
- assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
- }
- }
-
-
- @Test
- public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- out.writeObject( atav );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = (Ava)in.readObject();
-
- assertEquals( atav, atav2 );
- }
-
-
- /**
- * Test serialization of a simple ATAV
- */
- @Test
- public void testStringAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "Test" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
-
-
- @Test
- public void testBinaryAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- byte[] upValue = Strings.getBytesUtf8(" Test ");
-
- Ava atav = new Ava( schemaManager, "userPKCS12", upValue );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize( atav, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize(schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
-
-
- /**
- * Test static serialization of a simple ATAV
- */
- @Test
- public void testNullAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- AvaSerializer.serialize(atav, out);
- fail();
- }
- catch ( IOException ioe )
- {
- assertTrue( true );
- }
- }
-
-
- @Test( expected = IOException.class )
- public void testNullNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "UID", (String)null );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- fail();
- }
-
-
- @Test
- public void testEmptyNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "UID", (String)"" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize(schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
}
Added: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java?rev=1083011&view=auto
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java (added)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java Fri Mar 18 18:44:29 2011
@@ -0,0 +1,285 @@
+/*
+ * 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.name;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+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 org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.name.Ava;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+
+/**
+ * Test the class AttributeTypeAndValue
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class SchemaAwareAvaSerializationTest
+{
+
+ private static SchemaManager schemaManager;
+
+ @BeforeClass
+ public static void setup() throws Exception
+ {
+ schemaManager = new DefaultSchemaManager();
+ }
+
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testStringAtavSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "Test" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testBinaryAtavSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ byte[] normValue = Strings.getBytesUtf8("Test");
+
+ Ava atav = new Ava( schemaManager, "userPKCS12", normValue );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testNullAtavSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test
+ public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "uid", (String)null );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ String message = ioe.getMessage();
+ assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+ }
+ }
+
+
+ @Test
+ public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testStringAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "Test" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testBinaryAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ byte[] upValue = Strings.getBytesUtf8(" Test ");
+
+ Ava atav = new Ava( schemaManager, "userPKCS12", upValue );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test static serialization of a simple ATAV
+ */
+ @Test
+ public void testNullAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test( expected = IOException.class )
+ public void testNullNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "UID", (String)null );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+ fail();
+ }
+
+
+ @Test
+ public void testEmptyNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "UID", (String)"" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+}
Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java (from r1082924, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializerTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializerTest.java&r1=1082924&r2=1083011&rev=1083011&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializerTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java Fri Mar 18 18:44:29 2011
@@ -45,7 +45,7 @@ import com.mycila.junit.concurrent.Concu
*/
@RunWith(ConcurrentJunitRunner.class)
@Concurrency()
-public class SchemaAwareRdnSerializerTest
+public class SchemaAwareRdnSerializationTest
{
private static SchemaManager schemaManager;
Added: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaSerializationTest.java?rev=1083011&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaSerializationTest.java (added)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaSerializationTest.java Fri Mar 18 18:44:29 2011
@@ -0,0 +1,356 @@
+/*
+ * 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 static org.junit.Assert.assertTrue;
+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 org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.util.Strings;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+
+/**
+ * Test the AttributeTypeAndValue class serialization
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class AvaSerializationTest
+{
+ /** A null schemaManager used in tests */
+ SchemaManager schemaManager = null;
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testStringAtavSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "Test" );
+
+ atav.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testBinaryAtavSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ byte[] upValue = Strings.getBytesUtf8(" Test ");
+
+ Ava atav = new Ava( schemaManager, "CN", upValue );
+
+ atav.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testNullAtavSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test
+ public void testNullNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", (String)null );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ String message = ioe.getMessage();
+ assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+ }
+ }
+
+
+ @Test
+ public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", (String)null );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ String message = ioe.getMessage();
+ assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+ }
+ }
+
+
+ @Test
+ public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "test" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testEmptyUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testStringAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "Test" );
+
+ atav.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testBinaryAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ byte[] upValue = Strings.getBytesUtf8(" Test ");
+
+ Ava atav = new Ava( schemaManager, "CN", upValue );
+
+ atav.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test static serialization of a simple ATAV
+ */
+ @Test
+ public void testNullAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test
+ public void testNullUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", (String)null );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ atav.writeExternal( out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ String message = ioe.getMessage();
+ assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+ }
+ }
+
+
+ @Test
+ public void testEmptyNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testEmptyUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Ava atav = new Ava( schemaManager, "CN", "" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ atav.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Ava atav2 = new Ava( schemaManager );
+ atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+}
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=1083011&r1=1083010&r2=1083011&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 Fri Mar 18 18:44:29 2011
@@ -25,16 +25,9 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertTrue;
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 org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
-import org.apache.directory.shared.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -250,306 +243,4 @@ public class AvaTest
assertEquals( "a=a", atav.normalize() );
}
-
-
- /** Serialization tests ------------------------------------------------- */
-
- /**
- * Test serialization of a simple ATAV
- */
- @Test
- public void testStringAtavSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "Test" );
-
- atav.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- atav.writeExternal( out );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = new Ava( schemaManager );
- atav2.readExternal( in );
-
- assertEquals( atav, atav2 );
- }
-
-
- @Test
- public void testBinaryAtavSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- byte[] upValue = Strings.getBytesUtf8(" Test ");
-
- Ava atav = new Ava( schemaManager, "CN", upValue );
-
- atav.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- out.writeObject( atav );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = (Ava)in.readObject();
-
- assertEquals( atav, atav2 );
- }
-
-
- /**
- * Test serialization of a simple ATAV
- */
- @Test
- public void testNullAtavSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- out.writeObject( atav );
- fail();
- }
- catch ( IOException ioe )
- {
- assertTrue( true );
- }
- }
-
-
- @Test
- public void testNullNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", (String)null );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- out.writeObject( atav );
- fail();
- }
- catch ( IOException ioe )
- {
- String message = ioe.getMessage();
- assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
- }
- }
-
-
- @Test
- public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", (String)null );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- out.writeObject( atav );
- fail();
- }
- catch ( IOException ioe )
- {
- String message = ioe.getMessage();
- assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
- }
- }
-
-
- @Test
- public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "test" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- out.writeObject( atav );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = (Ava)in.readObject();
-
- assertEquals( atav, atav2 );
- }
-
-
- @Test
- public void testEmptyUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- out.writeObject( atav );
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = (Ava)in.readObject();
-
- assertEquals( atav, atav2 );
- }
-
-
- /**
- * Test serialization of a simple ATAV
- */
- @Test
- public void testStringAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "Test" );
-
- atav.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
-
-
- @Test
- public void testBinaryAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- byte[] upValue = Strings.getBytesUtf8(" Test ");
-
- Ava atav = new Ava( schemaManager, "CN", upValue );
-
- atav.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
-
-
- /**
- * Test static serialization of a simple ATAV
- */
- @Test
- public void testNullAtavStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- AvaSerializer.serialize(atav, out);
- fail();
- }
- catch ( IOException ioe )
- {
- assertTrue( true );
- }
- }
-
-
- @Test
- public void testNullUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", (String)null );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- try
- {
- AvaSerializer.serialize(atav, out);
- fail();
- }
- catch ( IOException ioe )
- {
- String message = ioe.getMessage();
- assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
- }
- }
-
-
- @Test
- public void testEmptyNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
-
-
- @Test
- public void testEmptyUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Ava atav = new Ava( schemaManager, "CN", "" );
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- AvaSerializer.serialize(atav, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Ava atav2 = AvaSerializer.deserialize( schemaManager, in );
-
- assertEquals( atav, atav2 );
- }
}
Copied: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializationTest.java (from r1082924, 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/RdnSerializationTest.java?p2=directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializationTest.java&p1=directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java&r1=1082924&r2=1083011&rev=1083011&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializerTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnSerializationTest.java Fri Mar 18 18:44:29 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.exception.LdapInvalidDnException;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,7 +42,7 @@ import com.mycila.junit.concurrent.Concu
*/
@RunWith(ConcurrentJunitRunner.class)
@Concurrency()
-public class RdnSerializerTest
+public class RdnSerializationTest
{
@Test
public void testRdnFullSerialization() throws IOException, LdapException, ClassNotFoundException
@@ -107,4 +108,213 @@ public class RdnSerializerTest
assertEquals( rdn1, rdn2 );
}
+
+
+ /**
+ * Test serialization of an empty Rdn
+ */
+ @Test
+ public void testEmptyRDNStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( "" );
+
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ @Test
+ public void testNullRdnStaticSerialization() throws IOException, ClassNotFoundException, LdapInvalidDnException
+ {
+ Rdn rdn = new Rdn();
+
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ /**
+ * Test serialization of a simple Rdn
+ */
+ @Test
+ public void testSimpleRdnStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( "a=b" );
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ /**
+ * Test serialization of a simple Rdn
+ */
+ @Test
+ public void testSimpleRdn2StaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( " ABC = DEF " );
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ /**
+ * Test serialization of a simple Rdn with no value
+ */
+ @Test
+ public void testSimpleRdnNoValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( " ABC =" );
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ /**
+ * Test serialization of a simple Rdn with one value
+ */
+ @Test
+ public void testSimpleRdnOneValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( " ABC = def " );
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ /**
+ * Test serialization of a simple Rdn with three values
+ */
+ @Test
+ public void testSimpleRdnThreeValuesStaticSerialization() throws LdapException, IOException,
+ ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( " A = a + B = b + C = c " );
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
+
+
+ /**
+ * Test serialization of a simple Rdn with three unordered values
+ */
+ @Test
+ public void testSimpleRdnThreeValuesUnorderedStaticSerialization() throws LdapException, IOException,
+ ClassNotFoundException
+ {
+ Rdn rdn = new Rdn( " B = b + A = a + C = c " );
+ rdn.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ rdn.writeExternal( out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ Rdn rdn2 = new Rdn();
+ rdn2.readExternal( in );
+
+ assertEquals( rdn, rdn2 );
+ }
}
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java?rev=1083011&r1=1083010&r2=1083011&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java Fri Mar 18 18:44:29 2011
@@ -34,7 +34,6 @@ import java.io.ObjectOutputStream;
import java.util.Iterator;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.apache.directory.shared.util.Strings;
import org.junit.Test;
@@ -1129,217 +1128,6 @@ public class RdnTest
}
- /** Static Serialization tests ------------------------------------------------- */
-
- /**
- * Test serialization of an empty Rdn
- */
- @Test
- public void testEmptyRDNStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Rdn rdn = new Rdn( "" );
-
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- @Test
- public void testNullRdnStaticSerialization() throws IOException, ClassNotFoundException, LdapInvalidDnException
- {
- Rdn rdn = new Rdn();
-
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- /**
- * Test serialization of a simple Rdn
- */
- @Test
- public void testSimpleRdnStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Rdn rdn = new Rdn( "a=b" );
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- /**
- * Test serialization of a simple Rdn
- */
- @Test
- public void testSimpleRdn2StaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Rdn rdn = new Rdn( " ABC = DEF " );
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- /**
- * Test serialization of a simple Rdn with no value
- */
- @Test
- public void testSimpleRdnNoValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Rdn rdn = new Rdn( " ABC =" );
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- /**
- * Test serialization of a simple Rdn with one value
- */
- @Test
- public void testSimpleRdnOneValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
- {
- Rdn rdn = new Rdn( " ABC = def " );
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize(rdn, out);
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- /**
- * Test serialization of a simple Rdn with three values
- */
- @Test
- public void testSimpleRdnThreeValuesStaticSerialization() throws LdapException, IOException,
- ClassNotFoundException
- {
- Rdn rdn = new Rdn( " A = a + B = b + C = c " );
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
- /**
- * Test serialization of a simple Rdn with three unordered values
- */
- @Test
- public void testSimpleRdnThreeValuesUnorderedStaticSerialization() throws LdapException, IOException,
- ClassNotFoundException
- {
- Rdn rdn = new Rdn( " B = b + A = a + C = c " );
- rdn.normalize();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( baos );
-
- RdnSerializer.serialize( rdn, out );
- out.flush();
-
- ObjectInputStream in = null;
-
- byte[] data = baos.toByteArray();
- in = new ObjectInputStream( new ByteArrayInputStream( data ) );
-
- Rdn rdn2 = RdnSerializer.deserialize( schemaManager, in );
-
- assertEquals( rdn, rdn2 );
- }
-
-
/**
* test an Rdn with empty value
*/