[jboss-cvs] JBossAS SVN: r64807 - trunk/testsuite/src/main/org/jboss/test/naming/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 23 13:13:58 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-08-23 13:13:58 -0400 (Thu, 23 Aug 2007)
New Revision: 64807

Modified:
   trunk/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
Log:
[JBAS-4622] Test when no provider url is given

Modified: trunk/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java	2007-08-23 17:13:13 UTC (rev 64806)
+++ trunk/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java	2007-08-23 17:13:58 UTC (rev 64807)
@@ -22,6 +22,7 @@
 
 package org.jboss.test.naming.test;
 
+import java.util.Hashtable;
 import java.util.Properties;
 
 import javax.naming.Binding;
@@ -36,6 +37,7 @@
 import org.jboss.test.JBossTestCase;
 import org.jboss.test.naming.restart.ObjectBinder;
 import org.jnp.interfaces.MarshalledValuePair;
+import org.jnp.interfaces.NamingContext;
 
 /**
  * A NamingRestartUnitTestCase.
@@ -45,8 +47,11 @@
  */
 public class NamingRestartUnitTestCase extends JBossTestCase
 {
-   private static final String namingPort = "19099";
-   private static final String haNamingPort = "19100";
+   private static final String NAMING_PORT = "19099";
+   private static final String HA_NAMING_PORT = "19100";
+   private static final String DISCOVERY_ADDRESS = "230.9.9.9";
+   private static final String DISCOVERY_PORT = "19102";
+   private static final String PARTITION_NAME = "DefaultPartition";
  
    private static final String BIND_NAME = "BindName";
    private static final String BIND_VALUE = "BindValue";
@@ -91,7 +96,7 @@
    {
       log.info("Running testBind()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -123,7 +128,7 @@
    {
       log.info("Running testCreateSubcontext()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -155,21 +160,26 @@
    {
       log.info("Running testLookupAfterHANamingRestart");
       
-      lookupTest(haNamingPort);
+      lookupTest(createNamingEnvironment(HA_NAMING_PORT));
    }
+   
+   public void testAutoDiscoveryLookupAfterHANamingRestart() throws Exception
+   {
+      log.info("Running testAutoDiscoveryLookupAfterHANamingRestart");
+      
+      lookupTest(createNamingEnvironment(DISCOVERY_ADDRESS, DISCOVERY_PORT));
+   }
 
    public void testLookupAfterNamingRestart() throws Exception
    {
       log.info("Running testLookupAfterNamingRestart");
       
-      lookupTest(namingPort);
+      lookupTest(createNamingEnvironment(NAMING_PORT));
    }
    
-   private void lookupTest(String port) throws Exception
+   private void lookupTest(Hashtable env) throws Exception
    {
-      Properties env = createNamingEnvironment(port);
-      
-      Context ctx1 = new InitialContext(env);
+      Context ctx1 = createInitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
       
       // HOLD ONTO REF to ctx1 so the ref to it does not get gc'ed from
@@ -178,7 +188,7 @@
       // Redeploy the naming service
       redeployNaming();
       
-      Context ctx2 = new InitialContext(env);
+      Context ctx2 = createInitialContext(env);
       NamingException ne = null;
       try
       {
@@ -215,7 +225,7 @@
    {
       log.info("Running testList()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -249,7 +259,7 @@
    {
       log.info("Running testListBindings()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -283,7 +293,7 @@
    {
       log.info("Running testLookupLink()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -323,7 +333,7 @@
    {
       log.info("Running testRebind()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -353,7 +363,7 @@
    {
       log.info("Running testUnbind()");
       
-      Properties env = createNamingEnvironment(namingPort);
+      Properties env = createNamingEnvironment(NAMING_PORT);
       
       Context ctx1 = new InitialContext(env);
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
@@ -383,14 +393,14 @@
    {
       log.info("Running testBadBindingHALookup");
       
-      badBindingLookupTest(haNamingPort);
+      badBindingLookupTest(HA_NAMING_PORT);
    }
 
    public void testBadBindingLookup() throws Exception
    {
       log.info("Running testBadBindingLookup");
       
-      badBindingLookupTest(namingPort);
+      badBindingLookupTest(NAMING_PORT);
    }
    
    /**
@@ -431,6 +441,25 @@
       return env;
    }
 
+   private Properties createNamingEnvironment(String mcastAddress, String mcastPort)
+   {
+      Properties env = new Properties();
+//      env.setProperty(NamingContext.JNP_PARTITION_NAME, PARTITION_NAME);
+      env.setProperty(NamingContext.JNP_DISCOVERY_GROUP, mcastAddress);
+      env.setProperty(NamingContext.JNP_DISCOVERY_PORT, mcastPort);
+      return env;
+   }
+
+   private Context createInitialContext(Hashtable env) throws NamingException
+   {
+      Context ctx1 = new InitialContext(env);
+      if (ctx1.getEnvironment().get(NamingContext.JNP_DISCOVERY_GROUP) != null)
+      {
+         ctx1.removeFromEnvironment(Context.PROVIDER_URL);
+      }
+      return ctx1;
+   }
+
    private void redeployNaming() throws Exception
    {
       deployed = false;




More information about the jboss-cvs-commits mailing list