1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.jndi;
18
19
20 import java.util.ArrayList;
21
22 import javax.naming.directory.Attribute;
23 import javax.naming.directory.Attributes;
24
25 import org.apache.ldap.server.AbstractAdminTestCase;
26
27
28 /***
29 * Tests to validate whatever functionality we have for complying with
30 * <a href="http://www.faqs.org/rfcs/rfc2713.html">RFC 2713</a>.
31 *
32 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33 * @version $Rev: 264732 $
34 */
35 public class RFC2713Tests extends AbstractAdminTestCase
36 {
37 public void testSerialization() throws Exception
38 {
39 ArrayList colors = new ArrayList();
40 colors.add( "red" );
41 colors.add( "white" );
42 colors.add( "blue" );
43 sysRoot.bind( "cn=colors", colors );
44 colors = null;
45
46 Object obj = sysRoot.lookup( "cn=colors" );
47 assertTrue( obj instanceof ArrayList );
48 colors = ( ArrayList ) obj;
49 assertEquals( 3, colors.size() );
50 assertTrue( colors.contains( "red" ) );
51 assertTrue( colors.contains( "white" ) );
52 assertTrue( colors.contains( "blue" ) );
53
54 Attributes attrs = sysRoot.getAttributes( "cn=colors" );
55 Attribute attr = attrs.get( "objectClass" );
56 assertNotNull( attr );
57 assertEquals( 4, attr.size() );
58 assertTrue( attr.contains( "top" ) );
59 assertTrue( attr.contains( "javaObject" ) );
60 assertTrue( attr.contains( "javaContainer" ) );
61 assertTrue( attr.contains( "javaSerializedObject" ) );
62 attr = attrs.get( "javaClassName" );
63 assertNotNull( attr );
64 assertEquals( 1, attr.size() );
65 assertTrue( attr.contains( "java.util.ArrayList" ) );
66
67 attr = attrs.get( "javaSerializedData" );
68 assertNotNull( attr );
69 assertEquals( 1, attr.size() );
70 }
71 }