1 22 package org.jboss.test.naming.test; 23 24 import java.net.URL ; 25 import java.net.InetAddress ; 26 import java.util.Properties ; 27 28 import javax.naming.InitialContext ; 29 30 import junit.framework.Test; 31 32 import org.jboss.test.JBossTestCase; 33 34 40 public class JNDIBindingUnitTestCase extends JBossTestCase 41 { 42 public JNDIBindingUnitTestCase(String name) 43 { 44 super(name); 45 } 46 47 51 public void testBindings() throws Exception 52 { 53 InitialContext ctx = getInitialContext(); 54 URL jbossHome = (URL ) ctx.lookup("urls/jboss-home"); 56 assertTrue("urls/jboss-home == URL(http://www.jboss.org)", 57 jbossHome.toString().equals("http://www.jboss.org")); 58 59 InetAddress localhost = (InetAddress ) ctx.lookup("hosts/localhost"); 61 InetAddress localhost2 = InetAddress.getByName("127.0.0.1"); 62 assertTrue("hosts/localhost InetAddress(127.0.0.1)", 63 localhost.getHostAddress().equals(localhost2.getHostAddress())); 64 65 Properties props = (Properties ) ctx.lookup("maps/testProps"); 67 assertTrue("Properties(key1) == value1", props.getProperty("key1").equals("value1")); 68 assertTrue("Properties(key2) == value2", props.getProperty("key2").equals("value2")); 69 } 70 71 public static Test suite() throws Exception 72 { 73 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 74 URL service = loader.getResource("naming/services/bindings-service.xml"); 75 return getDeploySetup(JNDIBindingUnitTestCase.class, service.toString()); 76 } 77 78 } 79 | Popular Tags |