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 javax.naming.directory.Attributes;
21
22 import org.apache.ldap.server.AbstractAdminTestCase;
23 import org.apache.ldap.server.configuration.SyncConfiguration;
24
25
26 /***
27 * Tests the sync operation on the JNDI provider.
28 *
29 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30 * @version $Rev: 264732 $
31 */
32 public class SyncTest extends AbstractAdminTestCase
33 {
34 /***
35 * Makes sure the changes to the JNDI provider take effect where a sync op
36 * does not throw an exception due to a null context being returned.
37 *
38 * @throws Exception if the test fails by generating a null context
39 */
40 public void testSyncNoException() throws Exception
41 {
42 sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
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 sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
56
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 }