1 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 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 } 80 | Popular Tags |