KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > jndi > RFC2713Tests


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.ldap.server.jndi;
18
19
20 import org.apache.ldap.server.AbstractCoreTest;
21
22 import javax.naming.directory.Attribute JavaDoc;
23 import javax.naming.directory.Attributes JavaDoc;
24 import java.util.ArrayList JavaDoc;
25
26
27 /**
28  * Tests to validate whatever functionality we have for complying with
29  * <a HREF="http://www.faqs.org/rfcs/rfc2713.html">RFC 2713</a>.
30  *
31  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
32  * @version $Rev$
33  */

34 public class RFC2713Tests extends AbstractCoreTest
35 {
36     public void testSerialization() throws Exception JavaDoc
37     {
38         ArrayList JavaDoc colors = new ArrayList JavaDoc();
39         colors.add( "red" );
40         colors.add( "white" );
41         colors.add( "blue" );
42         sysRoot.bind( "cn=colors", colors );
43         colors = null;
44
45         Object JavaDoc obj = sysRoot.lookup( "cn=colors" );
46         assertTrue( obj instanceof ArrayList JavaDoc );
47         colors = ( ArrayList JavaDoc ) obj;
48         assertEquals( 3, colors.size() );
49         assertTrue( colors.contains( "red" ) );
50         assertTrue( colors.contains( "white" ) );
51         assertTrue( colors.contains( "blue" ) );
52
53         Attributes JavaDoc attrs = sysRoot.getAttributes( "cn=colors" );
54         Attribute JavaDoc 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