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.AbstractAdminTestCase;
21  import org.apache.ldap.server.configuration.ShutdownConfiguration;
22  
23  
24  /***
25   * Tests the shutdown operation on the JNDI provider.
26   *
27   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28   * @version $Rev: 264732 $
29   */
30  public class ShutdownTest extends AbstractAdminTestCase
31  {
32      protected void tearDown() throws Exception
33      {
34          // since we shutdown the system already there is no point why the
35          // tearDown code should try to shut it down as well - in fact the
36          // tearDown super method will throw an LdapServiceUnavailableException
37          sysRoot = null;
38      }
39  
40  
41      /***
42       *
43       * @throws Exception if the test fails by generating a null context
44       */
45      public void testShutdownNonNullContext() throws Exception
46      {
47          setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
48          assertNotNull( sysRoot );
49      }
50  
51  
52      /***
53       *
54       *
55       * @throws Exception
56       */
57      public void testShutdownRestart() throws Exception
58      {
59          setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
60          assertNotNull( sysRoot );
61  
62          // restart the system now
63          setSysRoot( "uid=admin,ou=system", "secret", configuration );
64          
65          // Shutdown again (tearDown is overriden)
66          setSysRoot( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
67      }
68  }