KickJava   Java API By Example, From Geeks To Geeks.

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


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.Attributes JavaDoc;
23
24
25 /**
26  * Tests the sync operation on the JNDI provider.
27  *
28  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
29  * @version $Rev$
30  */

31 public class SyncTest extends AbstractCoreTest
32 {
33     /**
34      * Makes sure the changes to the JNDI provider take effect where a sync op
35      * does not throw an exception due to a null context being returned.
36      *
37      * @throws Exception if the test fails by generating a null context
38      */

39     public void testSyncNoException() throws Exception JavaDoc
40     {
41         overrides.put( EnvKeys.SYNC, "true" );
42         sysRoot = setSysRoot( "uid=admin,ou=system", "secret" );
43         assertNotNull( sysRoot );
44     }
45
46
47     /**
48      * Makes sure entries can still be accessed after a sync operation.
49      * Considering the cache I don't know just how effective such a test is.
50      *
51      * @throws Exception if the test fails to retrieve and verify an entry
52      */

53     public void testPostSyncLookup() throws Exception JavaDoc
54     {
55         overrides.put( EnvKeys.SYNC, "true" );
56         sysRoot = setSysRoot( "uid=admin,ou=system", "secret" );
57         Attributes JavaDoc users = sysRoot.getAttributes( "ou=users" );
58
59         // assert making sure the entry is ok
60
assertNotNull( users );
61         assertNotNull( users.get( "ou" ) );
62         assertTrue( users.get( "ou" ).contains( "users" ) );
63         assertNotNull( users.get( "objectClass" ) );
64         assertTrue( users.get( "objectClass" ).contains( "top" ) );
65         assertTrue( users.get( "objectClass" ).contains( "organizationalUnit" ) );
66     }
67 }
68
Popular Tags