1 17 package org.apache.geronimo.system.properties; 18 19 import javax.naming.InitialContext ; 20 import javax.naming.NamingException ; 21 22 import junit.framework.TestCase; 23 24 26 public class NamingPropertiesTest extends TestCase { 27 private static final String NAMING_FACTORY_INITIAL = "com.sun.jndi.rmi.registry.RegistryContextFactory"; 28 private static final String FACTORY_URL_PKGS = "org.apache.geronimo.naming"; 29 private static final String PROVIDER_URL = "rmi://localhost:1099"; 30 31 public void testNamingFactoryInitial() throws Exception { 32 33 assertNull(this.getClass().getClassLoader().getResource("jndi.properties")); 34 35 try { 36 new InitialContext (); 37 System.out.println("Something is wrong, initial context can be constructed"); 38 } catch (NamingException ne) { 40 } 42 assertNull(System.getProperty(NamingProperties.JAVA_NAMING_FACTORY_INITIAL)); 43 assertNull(System.getProperty(NamingProperties.JAVA_NAMING_FACTORY_URL_PKGS)); 44 assertNull(System.getProperty(NamingProperties.JAVA_NAMING_PROVIDER_URL)); 45 NamingProperties namingProperties = new NamingProperties(NAMING_FACTORY_INITIAL, FACTORY_URL_PKGS, PROVIDER_URL); 46 assertEquals(System.getProperty(NamingProperties.JAVA_NAMING_FACTORY_INITIAL), NAMING_FACTORY_INITIAL); 47 assertEquals(System.getProperty(NamingProperties.JAVA_NAMING_FACTORY_URL_PKGS), FACTORY_URL_PKGS); 48 assertEquals(System.getProperty(NamingProperties.JAVA_NAMING_PROVIDER_URL), PROVIDER_URL); 49 50 assertEquals(namingProperties.getNamingFactoryInitial(), NAMING_FACTORY_INITIAL); 51 assertEquals(namingProperties.getNamingFactoryUrlPkgs(), FACTORY_URL_PKGS); 52 assertEquals(namingProperties.getNamingProviderUrl(), PROVIDER_URL); 53 54 try { 55 Class.forName("NAME_FACTORY_INITIAL"); 59 new InitialContext (); 60 } catch (ClassNotFoundException e) { 61 } 62 } 63 } 64 | Popular Tags |