KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > naming > java > AbstractContextTest


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.naming.java;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.Properties JavaDoc;
23
24 import javax.naming.Context JavaDoc;
25 import javax.naming.InitialContext JavaDoc;
26 import javax.naming.LinkRef JavaDoc;
27 import javax.naming.NamingException JavaDoc;
28
29 import junit.framework.TestCase;
30
31 /**
32  *
33  *
34  * @version $Rev: 47502 $ $Date: 2004-09-29 14:04:42 -0700 (Wed, 29 Sep 2004) $
35  *
36  * */

37 public class AbstractContextTest extends TestCase {
38     protected ReadOnlyContext readOnlyContext;
39     protected Properties JavaDoc syntax;
40     protected Map JavaDoc envBinding;
41     protected Context JavaDoc initialContext;
42     protected Context JavaDoc compContext;
43     protected Context JavaDoc envContext;
44
45     public void testNothing() { }
46
47     protected void setUp() throws Exception JavaDoc {
48         System.setProperty("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
49         System.setProperty("java.naming.factory.url.pkgs", "org.apache.geronimo.naming");
50         System.setProperty("java.naming.provider.url", "rmi://localhost:1099");
51
52         initialContext = new InitialContext JavaDoc();
53
54         readOnlyContext = new ReadOnlyContext();
55
56         envBinding = new HashMap JavaDoc();
57         readOnlyContext.internalBind("env/hello", "Hello");
58         envBinding.put("hello", "Hello");
59         bind("env/world", "Hello World");
60         envBinding.put("world", "Hello World");
61         bind("env/here/there/anywhere", "long name");
62         envBinding.put("here", readOnlyContext.lookup("env/here"));
63         LinkRef JavaDoc link = new LinkRef JavaDoc("java:comp/env/hello");
64         bind("env/link", link);
65         envBinding.put("link", link);
66
67         RootContext.setComponentContext(readOnlyContext);
68
69         compContext = (Context JavaDoc) initialContext.lookup("java:comp");
70         envContext = (Context JavaDoc) initialContext.lookup("java:comp/env");
71
72         syntax = new Properties JavaDoc();
73     }
74
75     protected void bind(String JavaDoc name, Object JavaDoc value) throws NamingException JavaDoc {
76         readOnlyContext.internalBind(name, value);
77     }
78
79 }
80
Popular Tags