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; 21 import java.util.Map; 22 import java.util.Properties; 23 24 import javax.naming.Context; 25 import javax.naming.InitialContext; 26 import javax.naming.LinkRef; 27 import javax.naming.NamingException; 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 syntax; 40 protected Map envBinding; 41 protected Context initialContext; 42 protected Context compContext; 43 protected Context envContext; 44 45 public void testNothing() { } 46 47 protected void setUp() throws Exception { 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(); 53 54 readOnlyContext = new ReadOnlyContext(); 55 56 envBinding = new HashMap(); 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 link = new LinkRef("java:comp/env/hello"); 64 bind("env/link", link); 65 envBinding.put("link", link); 66 67 RootContext.setComponentContext(readOnlyContext); 68 69 compContext = (Context) initialContext.lookup("java:comp"); 70 envContext = (Context) initialContext.lookup("java:comp/env"); 71 72 syntax = new Properties(); 73 } 74 75 protected void bind(String name, Object value) throws NamingException { 76 readOnlyContext.internalBind(name, value); 77 } 78 79 }