1 22 package org.jboss.test.jaxr.scout.basic; 23 24 import junit.framework.TestCase; 25 26 import javax.naming.Context ; 27 import javax.naming.InitialContext ; 28 import javax.naming.NamingException ; 29 import javax.xml.registry.ConnectionFactory ; 30 import java.util.Properties ; 31 32 39 public class JaxrJNDIConnectionTestCase extends TestCase 40 { 41 public JaxrJNDIConnectionTestCase(String name) 42 { 43 super(name); 44 } 45 46 public void testJaxrJNDIConnection() throws Exception 47 { 48 String bindname = System.getProperty("jndi.bind.name"); 49 InitialContext ctx = getClientContext(); 50 ConnectionFactory factory = (ConnectionFactory ) ctx.lookup(bindname); 51 assertNotNull("Connection Factory from JNDI:", factory); 52 } 53 54 protected InitialContext getClientContext() throws NamingException 55 { 56 String hostname = System.getProperty("host.name"); 57 Properties env = new Properties (); 58 env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); 59 env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); 60 env.setProperty(Context.PROVIDER_URL, "jnp://" + hostname + ":1099"); 61 return new InitialContext (env); 62 } 63 } 64 | Popular Tags |