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 org.apache.ldap.server.AbstractCoreTest;
21
22 import javax.naming.directory.Attributes;
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
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
54 {
55 overrides.put( EnvKeys.SYNC, "true" );
56 sysRoot = setSysRoot( "uid=admin,ou=system", "secret" );
57 Attributes users = sysRoot.getAttributes( "ou=users" );
58
59
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 }