KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > naming > SynchronizedContextTest


1 /*
2  * Copyright 2004,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 package org.apache.naming;
17
18 import java.util.Hashtable JavaDoc;
19
20 import javax.naming.Context JavaDoc;
21
22 import junit.framework.Test;
23 import junit.framework.TestSuite;
24 import junit.textui.TestRunner;
25
26
27 /**
28  * Unit tests for basic ops on a {@link SynchronizedContext}.
29  *
30  * @version $Revision: 1.2 $ $Date: 2003/11/30 05:36:07 $
31  */

32 public class SynchronizedContextTest extends AbstractContextTest {
33     
34     public SynchronizedContextTest(String JavaDoc name) {
35         super(name);
36     }
37
38     public static void main(String JavaDoc[] args) {
39         TestRunner.run(suite());
40     }
41
42     public static Test suite() {
43         TestSuite suite = new TestSuite(SynchronizedContextTest.class);
44         suite.setName("Synchronized Context Tests");
45         return suite;
46     }
47     
48     protected Context JavaDoc makeInitialContext() {
49         try {
50             Hashtable JavaDoc env = new Hashtable JavaDoc();
51             env.put(SynchronizedContext.SYNCHRONIZED, "true");
52             NamingContext ctx = new NamingContext(env, "root");
53             return new SynchronizedContext(ctx);
54         } catch (Exception JavaDoc ex) {
55             fail("Failed to create SynchronizedContext");
56         }
57         return null;
58     }
59     
60     protected boolean isGetNameInNamespaceSupported() {
61         return false;
62     }
63     
64     public void testIsSynchronized() throws Exception JavaDoc {
65         assertTrue(SynchronizedContext.isSynchronized(initialContext.getEnvironment()));
66         Hashtable JavaDoc env = new Hashtable JavaDoc();
67         env.put(SynchronizedContext.SYNCHRONIZED, "false");
68         assertFalse(SynchronizedContext.isSynchronized(env));
69         env = null;
70         assertFalse(SynchronizedContext.isSynchronized(env));
71     }
72 }
73
Popular Tags