1 17 package org.apache.ldap.server.jndi; 18 19 20 import org.apache.ldap.server.AbstractCoreTest; 21 22 import javax.naming.directory.Attribute ; 23 import javax.naming.directory.Attributes ; 24 import java.util.ArrayList ; 25 26 27 34 public class RFC2713Tests extends AbstractCoreTest 35 { 36 public void testSerialization() throws Exception 37 { 38 ArrayList colors = new ArrayList (); 39 colors.add( "red" ); 40 colors.add( "white" ); 41 colors.add( "blue" ); 42 sysRoot.bind( "cn=colors", colors ); 43 colors = null; 44 45 Object obj = sysRoot.lookup( "cn=colors" ); 46 assertTrue( obj instanceof ArrayList ); 47 colors = ( ArrayList ) obj; 48 assertEquals( 3, colors.size() ); 49 assertTrue( colors.contains( "red" ) ); 50 assertTrue( colors.contains( "white" ) ); 51 assertTrue( colors.contains( "blue" ) ); 52 53 Attributes attrs = sysRoot.getAttributes( "cn=colors" ); 54 Attribute attr = attrs.get( "objectClass" ); 55 assertNotNull( attr ); 56 assertEquals( 4, attr.size() ); 57 assertTrue( attr.contains( "top" ) ); 58 assertTrue( attr.contains( "javaObject" ) ); 59 assertTrue( attr.contains( "javaContainer" ) ); 60 assertTrue( attr.contains( "javaSerializedObject" ) ); 61 attr = attrs.get( "javaClassName" ); 62 assertNotNull( attr ); 63 assertEquals( 1, attr.size() ); 64 assertTrue( attr.contains( "java.util.ArrayList" ) ); 65 66 attr = attrs.get( "javaSerializedData" ); 67 assertNotNull( attr ); 68 assertEquals( 1, attr.size() ); 69 } 70 } 71 | Popular Tags |