[jboss-cvs] JBossAS SVN: r64788 - in branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src: resources/naming/restart and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 22 16:43:29 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-08-22 16:43:28 -0400 (Wed, 22 Aug 2007)
New Revision: 64788

Modified:
   branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
   branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/resources/naming/restart/jboss-service.xml
Log:
[JBAS-4622] Test when no java.naming.provider.url is specified

Modified: branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java	2007-08-22 20:12:39 UTC (rev 64787)
+++ branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java	2007-08-22 20:43:28 UTC (rev 64788)
@@ -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
       {
@@ -210,12 +220,22 @@
       // Confirm the original context is still good
       assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
    }
+
+   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;
+   }
    
    public void testList() throws Exception
    {
       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 +269,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 +303,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 +343,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 +373,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 +403,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);
    }
    
    /**
@@ -426,11 +446,20 @@
    {
       String namingURL = getServerHost() + ":" + port;
       Properties env = new Properties();
-      env.setProperty("java.naming.provider.url", namingURL);
-      env.setProperty("jnp.disableDiscovery", "true");
+      env.setProperty(Context.PROVIDER_URL, namingURL);
+      env.setProperty(NamingContext.JNP_DISABLE_DISCOVERY, "true");
       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 void redeployNaming() throws Exception
    {
       deployed = false;

Modified: branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/resources/naming/restart/jboss-service.xml
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/resources/naming/restart/jboss-service.xml	2007-08-22 20:12:39 UTC (rev 64787)
+++ branches/JBoss_4_0_5_GA_JBAS-4574/testsuite/src/resources/naming/restart/jboss-service.xml	2007-08-22 20:43:28 UTC (rev 64788)
@@ -51,9 +51,14 @@
       
       <depends optional-attribute-name="LookupPool"
          proxy-type="attribute">jboss.system:service=ThreadPool</depends>
-
-      <!-- Test doesn't need auto discovery via multicast -->
-      <attribute name="DiscoveryDisabled">true</attribute>
+         
+      <attribute name="DiscoveryDisabled">false</attribute>
+      <attribute name="AutoDiscoveryBindAddress">${jboss.bind.address}</attribute>
+      <!-- Use a custom Multicast Address and group port for auto-discovery -->
+      <attribute name="AutoDiscoveryAddress">230.9.9.9</attribute>
+      <attribute name="AutoDiscoveryGroup">19102</attribute>
+      <!-- The TTL (time-to-live) for autodiscovery IP multicast packets -->
+      <attribute name="AutoDiscoveryTTL">1</attribute>
       
       <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</attribute>
 




More information about the jboss-cvs-commits mailing list