KickJava   Java API By Example, From Geeks To Geeks.

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


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

29 public class ShutdownTest extends AbstractCoreTest
30 {
31     protected void tearDown() throws Exception JavaDoc
32     {
33         // since we shutdown the system already there is no point why the
34
// tearDown code should try to shut it down as well - in fact the
35
// tearDown super method will throw an LdapServiceUnavailableException
36
sysRoot = null;
37     }
38
39
40     /**
41      *
42      * @throws Exception if the test fails by generating a null context
43      */

44     public void testShutdownNonNullContext() throws Exception JavaDoc
45     {
46         overrides.put( EnvKeys.SHUTDOWN, "true" );
47
48         try
49         {
50             setSysRoot( "uid=admin,ou=system", "secret" );
51         }
52         finally
53         {
54             overrides.remove( EnvKeys.SHUTDOWN );
55         }
56
57         assertNotNull( sysRoot );
58     }
59
60
61     /**
62      *
63      *
64      * @throws Exception
65      */

66     public void testShutdownRestart() throws Exception JavaDoc
67     {
68         overrides.put( EnvKeys.SHUTDOWN, "true" );
69
70         try
71         {
72             setSysRoot( "uid=admin,ou=system", "secret" );
73         }
74         finally
75         {
76             overrides.remove( EnvKeys.SHUTDOWN );
77         }
78
79         assertNotNull( sysRoot );
80
81         // restart the system now
82
setSysRoot( "uid=admin,ou=system", "secret" );
83     }
84 }
85
Popular Tags