1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.jndi;
21
22
23 import org.apache.directory.server.core.DirectoryService;
24 import org.apache.directory.server.core.integ.CiRunner;
25 import static org.apache.directory.server.core.integ.IntegrationUtils.*;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertTrue;
28 import static org.junit.Assert.assertNotNull;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31
32 import javax.naming.directory.Attribute;
33 import javax.naming.directory.Attributes;
34 import javax.naming.ldap.LdapContext;
35 import java.util.ArrayList;
36
37
38
39
40
41
42
43
44
45 @RunWith ( CiRunner.class )
46 public class RFC2713IT
47 {
48 public static DirectoryService service;
49
50
51 @Test
52 @SuppressWarnings("unchecked")
53 public void testSerializatin() throws Exception
54 {
55 LdapContext sysRoot = getSystemContext( service );
56
57 ArrayList<String> colors = new ArrayList<String>();
58 colors.add( "red" );
59 colors.add( "white" );
60 colors.add( "blue" );
61 sysRoot.bind( "cn=colors", colors );
62
63 Object obj = sysRoot.lookup( "cn=colors" );
64 assertTrue( obj instanceof ArrayList );
65 colors = ( ArrayList<String> ) obj;
66 assertEquals( 3, colors.size() );
67 assertTrue( colors.contains( "red" ) );
68 assertTrue( colors.contains( "white" ) );
69 assertTrue( colors.contains( "blue" ) );
70
71 Attributes attrs = sysRoot.getAttributes( "cn=colors" );
72 Attribute attr = attrs.get( "objectClass" );
73 assertNotNull( attr );
74 assertEquals( 4, attr.size() );
75 assertTrue( attr.contains( "top" ) );
76 assertTrue( attr.contains( "javaObject" ) );
77 assertTrue( attr.contains( "javaContainer" ) );
78 assertTrue( attr.contains( "javaSerializedObject" ) );
79 attr = attrs.get( "javaClassName" );
80 assertNotNull( attr );
81 assertEquals( 1, attr.size() );
82 assertTrue( attr.contains( "java.util.ArrayList" ) );
83
84 attr = attrs.get( "javaSerializedData" );
85 assertNotNull( attr );
86 assertEquals( 1, attr.size() );
87 }
88 }