1 22 package org.objectweb.petals.kernel.registry.jndi; 23 24 import java.util.Hashtable ; 25 26 import javax.naming.NamingException ; 27 28 import junit.framework.TestCase; 29 30 35 public class NamingContextFactoryTest extends TestCase { 36 37 public void testGetInitialContext() throws NamingException { 38 NamingContextFactory namingContextFactory = new NamingContextFactory(); 39 Hashtable <String , String > env = new Hashtable <String , String >(); 40 env.put("java.naming.factory.host", "127.0.0.1"); 41 env.put("java.naming.factory.port", "9999"); 42 NamingContextImpl namingContextImpl = (NamingContextImpl) namingContextFactory 43 .getInitialContext(env); 44 assertEquals(namingContextImpl.jndiConnection.host, "127.0.0.1"); 45 assertEquals(namingContextImpl.jndiConnection.port, 9999); 46 } 47 48 public void testGetInitialContextException() throws NamingException { 49 NamingContextFactory namingContextFactory = new NamingContextFactory(); 50 Hashtable <String , String > env = new Hashtable <String , String >(); 51 env.put("java.naming.factory.port", "9999"); 52 try { 53 namingContextFactory.getInitialContext(env); 54 fail(); 55 } catch (Exception e) { 56 } 58 } 59 60 public void testGetInitialContextException1() throws NamingException { 61 NamingContextFactory namingContextFactory = new NamingContextFactory(); 62 Hashtable <String , String > env = new Hashtable <String , String >(); 63 env.put("java.naming.factory.host", "127.0.0.1"); 64 try { 65 namingContextFactory.getInitialContext(env); 66 fail(); 67 } catch (Exception e) { 68 } 70 } 71 72 } 73 | Popular Tags |