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 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          // 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  }