1 17 18 package org.apache.geronimo.naming.java; 19 20 import javax.naming.InitialContext ; 21 import javax.naming.LinkRef ; 22 23 import junit.framework.TestCase; 24 25 32 public class ThreadContextTest extends TestCase { 33 34 private Throwable failure = null; 35 public void testThreadInheritence() throws Throwable { 36 Thread worker = new Thread () { 37 public void run() { 38 try { 39 assertEquals("Hello", new InitialContext ().lookup("java:comp/env/hello")); 40 } catch (Throwable e) { 41 failure = e; 42 } 43 } 44 }; 45 worker.start(); 46 worker.join(); 47 if (failure != null) { 48 throw failure; 49 } 50 } 51 52 protected void setUp() throws Exception { 53 System.setProperty("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory"); 54 System.setProperty("java.naming.factory.url.pkgs", "org.apache.geronimo.naming"); 55 System.setProperty("java.naming.provider.url", "rmi://localhost:1099"); 56 57 ReadOnlyContext readOnlyContext = new ReadOnlyContext(); 58 readOnlyContext.internalBind("env/hello", "Hello"); 59 readOnlyContext.internalBind("env/world", "Hello World"); 60 readOnlyContext.internalBind("env/link", new LinkRef ("java:comp/env/hello")); 61 RootContext.setComponentContext(readOnlyContext); 62 } 63 } 64 | Popular Tags |