[jboss-cvs] JBossAS SVN: r106162 - in branches/Branch_No_Multicast/testsuite: imports and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 18 10:32:42 EDT 2010


Author: bstansberry at jboss.com
Date: 2010-06-18 10:32:40 -0400 (Fri, 18 Jun 2010)
New Revision: 106162

Added:
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorAutoDiscoveryUnitTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorTestBase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorAutoDiscoveryUnitTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiAutoDiscoveryTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestBase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/restart/NamingRestartTestBase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/HAJndiAutoDiscoveryUnitTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartAutoDiscoveryUnitTestCase.java
Modified:
   branches/Branch_No_Multicast/testsuite/build.xml
   branches/Branch_No_Multicast/testsuite/imports/config/tests-clustering.xml
   branches/Branch_No_Multicast/testsuite/imports/server-config.xml
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorUnitTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorUnitTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
   branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
Log:
[JBPAPP-4482] Some more test setup tweaks; add ability to exclude tests that rely on multicast

Modified: branches/Branch_No_Multicast/testsuite/build.xml
===================================================================
--- branches/Branch_No_Multicast/testsuite/build.xml	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/build.xml	2010-06-18 14:32:40 UTC (rev 106162)
@@ -1481,7 +1481,22 @@
       <patternset refid="profileservice.restart.excludes"/>
       <patternset refid="jbossmessaging.excludes"/>
       <patternset refid="springdeployer.excludes"/>
-   </patternset>
+   </patternset>   
+	
+	<!-- A placeholder patternset -->
+	<patternset id="empty.patternset"/>
+	<!-- Tests to exclude when we run on EC2 -->
+	<patternset id="ec2.excludes">
+	  <!-- These tests involve multicast-based HA-JNDI auto-discovery -->
+	  <exclude name="org/jboss/test/naming/test/NamingRestartAutoDiscoveryUnitTestCase.class"/>
+	  <exclude name="org/jboss/test/naming/test/HAJndiAutoDiscoveryTestCase.class"/>
+     <exclude name="org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorAutoDiscoveryUnitTestCase.class"/>
+     <exclude name="org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorAutoDiscoveryUnitTestCase.class"/>
+     <exclude name="org/jboss/test/cluster/multicfg/test/HAJndiAutoDiscoveryTestCase.class"/>
+     <exclude name="org/jboss/test/cluster/multicfg/test/GlobalDiscoveryDisableTestCase.class"/>
+     <!-- These programatically create UDP-based channels -->
+     <exclude name="org/jboss/test/cluster/defaultcfg/simpleweb/test/*TestCase.class"/>
+	</patternset>
 
    <!-- A target that allows for conditional dependency on the compilation and
 
@@ -1640,13 +1655,15 @@
       <server:stop name="${conf}"/>
    </target>
 	
-	<target name="tests-ec2"
+	<target name="tests-cluster-ec2"
       description="Runs the various test targets, but against cluster-ec2 config" depends="init">
 		
 		<property name="conf" value="cluster-ec2"/>
 		
-		<antcall target="jboss-all-config-tests" inheritrefs="true"/>
-		<antcall target="tests-clustering-ec2" inheritrefs="true"/>
+		<antcall target="jboss-all-config-tests" inheritrefs="true">
+			<param name="custom.excludes" value="ec2.excludes"/>
+	   </antcall>
+		<antcall target="tests-clustering-cluster-ec2" inheritrefs="true"/>
 	   
 	   <antcall target="tests-report"/>
 	   <!-- JBAS-5918 https://issues.apache.org/bugzilla/show_bug.cgi?id=41368 
@@ -2074,6 +2091,10 @@
    jbosstest.threadcount:      ${jbosstest.threadcount}
    jbosstest.beancount:        ${jbosstest.beancount}
          ]]></echo>
+  	
+  	
+  	   <property name="custom.excludes" value="empty.patternset"/>
+  	
       <mkdir dir="${build.reports}"/>
       <mkdir dir="${build.testlog}"/>
       <junit dir="${module.output}"
@@ -2117,6 +2138,7 @@
             <fileset dir="${build.classes}">
                <include name="**/*UnitTestCase.class"/>
                <patternset refid="all.excludes"/>
+               <patternset refid="${custom.excludes}"/>
                <exclude name="**/test/xa/test/XAUnitTestCase.class"/>
             </fileset>
          </batchtest>

Modified: branches/Branch_No_Multicast/testsuite/imports/config/tests-clustering.xml
===================================================================
--- branches/Branch_No_Multicast/testsuite/imports/config/tests-clustering.xml	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/imports/config/tests-clustering.xml	2010-06-18 14:32:40 UTC (rev 106162)
@@ -67,8 +67,8 @@
   </patternset>    
   <patternset id="cluster.excludes">
     <exclude name="org/jboss/test/cluster/**/*TestCase.class"/>
-  </patternset>
-
+  </patternset> 
+	
   <!--
     | Targets
   -->
@@ -464,7 +464,7 @@
     
   </target> 
   
-	<target name="tests-clustering-ec2">
+	<target name="tests-clustering-cluster-ec2">
 		
 		 <!-- Create tests-configs content for cluster-tcp-0/1 from the cluster-udp content -->
 	    <mkdir dir="${build.resources}/test-configs/cluster-tcp-0"/>
@@ -475,22 +475,26 @@
        <copy todir="${build.resources}/test-configs/cluster-tcp-1">
          <fileset dir="${build.resources}/test-configs/cluster-udp-1" />
        </copy>	
-		
+	
 	    <antcall target="tests-clustering">
 	      <param name="jboss.default.jgroups.stack" value="tcp"/>
 	      <param name="baseconf" value="cluster-ec2"/>
+	      <param name="cluster.excludes.refid" value="ec2.excludes"/>
 	    </antcall>
 	    <antcall target="run-clustered-ustxsticky-tests">
 	      <param name="jboss.default.jgroups.stack" value="tcp"/>
 	      <param name="baseconf" value="cluster-ec2"/>
+         <param name="cluster.excludes.refid" value="ec2.excludes"/>
 	    </antcall>
 	    <antcall target="run-clustered-profileservice-tests">
 	      <param name="jboss.default.jgroups.stack" value="tcp"/>
 	      <param name="baseconf" value="cluster-ec2"/>
+         <param name="cluster.excludes.refid" value="ec2.excludes"/>
 	    </antcall>
 	    <antcall target="run-tomcat-sso-clustered-tests">
 	      <param name="jboss.default.jgroups.stack" value="tcp"/>
 	      <param name="baseconf" value="cluster-ec2"/>
+         <param name="cluster.excludes.refid" value="ec2.excludes"/>
 	    </antcall>
 		
 	</target>
@@ -589,6 +593,9 @@
 	
    <!-- Executes a set of tests in a clustered environment -->  
    <target name="tests-clustering-unit">
+   	
+   	<property name="cluster.excludes.refid" value="empty.patternset"/>
+   	
       <mkdir dir="${build.reports}"/>
       <mkdir dir="${build.testlog}"/>
       <junit dir="${module.output}"
@@ -656,6 +663,7 @@
 
             <fileset dir="${build.classes}">
                <patternset refid="${cluster.includes.refid}"/>
+               <patternset refid="${cluster.excludes.refid}"/>
             	<patternset refid="badtest.excludes"/>
             </fileset>
          </batchtest>

Modified: branches/Branch_No_Multicast/testsuite/imports/server-config.xml
===================================================================
--- branches/Branch_No_Multicast/testsuite/imports/server-config.xml	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/imports/server-config.xml	2010-06-18 14:32:40 UTC (rev 106162)
@@ -1440,9 +1440,14 @@
             <include name="deployers/**"/>
          </fileset>         	
          </copy>
+      	<!-- Ensure we use the hdscanner config from "all" as the one 
+      	     from "production" and production-based configs like cluster-ec2
+      	     has an overly long scan period -->
+      	<copy tofile="${jboss.dist}/server/@{conf}/deploy/hdscanner-jboss-beans.xml"
+      	    file="${jboss.dist}/server/all/deploy/hdscanner-jboss-beans.xml"
+      	    overwrite="true"/>
          <!-- Overwrite any config content with that from the
-         resources/test-configs/@{conf}
-         -->
+         resources/test-configs/@{conf} -->
          <echo message="Overwriting config descriptors" />
          <copy todir="${jboss.dist}/server/@{conf}" overwrite="true" failonerror="false">
             <fileset dir="${build.resources}/test-configs/@{conf}" />

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorAutoDiscoveryUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorAutoDiscoveryUnitTestCase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorAutoDiscoveryUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.ejb2.test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.cluster.testutil.DBSetup;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * Tests the RetryInterceptor with HA-JNDI autodiscovery.
+ * This test is separate from the other SingleRetryInterceptor tests
+ * so it can be excluded in tests of configs that disable HA-JNDI auto-discovery.
+ * 
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Revision $
+ */
+public class RetryInterceptorAutoDiscoveryUnitTestCase extends RetryInterceptorTestBase
+{   
+   // NOTE: these variables must be static as apparently a separate instance
+   // of this class is created for each test.
+   private static boolean deployed0 = false;
+   private static boolean deployed1 = false;
+   
+   /**
+    * Create a new RetryInterceptorUnitTestCase.
+    * 
+    * @param name
+    */
+   public RetryInterceptorAutoDiscoveryUnitTestCase(String name)
+   {
+      super(name);
+      log = Logger.getLogger(getClass());
+   }
+
+   public static Test suite() throws Exception
+   {
+      return DBSetup.getDeploySetup(RetryInterceptorAutoDiscoveryUnitTestCase.class, "cif-ds.xml");
+   }
+   
+   /**
+    * Tests that the retry interceptor works properly if the naming context
+    * is established by using org.jnp.interfaces.NamingContextFactory
+    * and auto-discovery is enabled.
+    *  
+    * @throws Exception
+    */
+   public void testRetryWithJnpAndAutoDiscovery() throws Exception
+   {
+      getLog().debug("+++ Enter testRetryWithJnpAndAutoDiscovery()");
+      
+      // Create a jndi.properties in the temp dir with special configs
+      // to prevent autodiscovery spuriously discovering random servers
+      // on the network. When the RetryCaller runs, it will create a 
+      // special classloader that will pick up this file
+      if (customJndiDir == null)
+         customJndiDir = new File(System.getProperty("java.io.tmpdir"), 
+                                  "retry-int-test");
+      if (!customJndiDir.exists())
+         customJndiDir.mkdir();
+      customJndiProperties = new File(customJndiDir, "jndi.properties");
+      FileOutputStream fos = new FileOutputStream(customJndiProperties);
+      OutputStreamWriter writer = new OutputStreamWriter(fos);
+      writer.write(NamingContext.JNP_DISCOVERY_TTL + "=" + DISCOVERY_TTL + "\n");
+      if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
+      {
+         // The server isn't listening on the std multicast address
+         writer.write(NamingContext.JNP_DISCOVERY_GROUP + "=" + DISCOVERY_GROUP + "\n");
+      }
+      if (DISCOVERY_PARTITION != null && "".equals(DISCOVERY_PARTITION) == false)
+      {
+         // Limit to the partition this test environment is using
+         writer.write(NamingContext.JNP_PARTITION_NAME + "=" + DISCOVERY_PARTITION + "\n");
+      }
+      writer.close();
+      getLog().debug("Created custom jndi.properties at " + customJndiProperties + 
+                     " -- DISCOVERY_GROUP is " + DISCOVERY_GROUP +
+                     " -- DISCOVERY_PARTITION is " + DISCOVERY_PARTITION);
+      
+      
+      Properties env = getNamingProperties("org.jnp.interfaces.NamingContextFactory", true);
+      
+      InitialContext ctx = new InitialContext(env);
+      
+      sfsbTest(ctx, env);
+   }
+
+   protected boolean isDeployed0()
+   {
+      return deployed0;
+   }
+
+   protected void setDeployed0(boolean deployed)
+   {
+      deployed0 = deployed;
+   }
+
+   protected boolean isDeployed1()
+   {
+      return deployed1;
+   }
+
+   protected void setDeployed1(boolean deployed)
+   {
+      deployed1 = deployed;
+   }
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorAutoDiscoveryUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorTestBase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorTestBase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorTestBase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,519 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.ejb2.test;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Properties;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.ejb2.basic.interfaces.NodeAnswer;
+import org.jboss.test.cluster.ejb2.basic.interfaces.StatefulSession;
+import org.jboss.test.cluster.ejb2.basic.interfaces.StatelessSession;
+import org.jboss.test.cluster.ejb2.basic.interfaces.StatelessSessionHome;
+import org.jboss.test.testbean.interfaces.AComplexPK;
+import org.jboss.test.testbean.interfaces.EntityPK;
+import org.jboss.test.testbean.interfaces.EntityPKHome;
+import org.jboss.test.testbean.interfaces.StatefulSessionHome;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * Base class for tests of the RetryInterceptor.
+ * 
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Revision $
+ */
+public abstract class RetryInterceptorTestBase extends JBossClusteredTestCase
+{   
+   protected static final String DISCOVERY_TTL = System.getProperty("jbosstest.udp.ip_ttl", "1");
+   protected static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup");
+   protected static final String DISCOVERY_PARTITION = System.getProperty("jbosstest.partitionName", "DefaultPartition");
+   
+   protected static Logger log;
+   
+   protected static File customJndiDir = null;
+   protected static File customJndiProperties = null;
+   
+   static abstract class RetryCaller extends Thread
+   {
+      Properties env;
+      Throwable failure;
+      
+      RetryCaller(Properties env)
+      {
+         this.env = env;
+      }
+      
+      public void run()
+      {
+         ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+         try
+         {
+            if (customJndiProperties != null)
+            {
+               // Create a special classloader that will read in the 
+               // customJndiProperties file and include it in any 
+               // getResources("jndi.properties") request.
+               // We use this to allow running the server with
+               // HA-JNDI autodiscovery set to a custom address 
+               URL[] urls = new URL[]{ customJndiDir.toURL() };
+               ClassLoader cl = new URLClassLoader(urls, tccl);
+               Thread.currentThread().setContextClassLoader(cl);
+            }
+            
+            // Establish an initial context on this thread with the
+            // given properties -- needed for JBoss NamingContextFactory
+            // to work properly.  Meaningless otherwise            
+            new InitialContext(env);
+            
+            executeTest();
+         }
+         catch (Throwable t)
+         {
+            log.error(this + " caught an exception", t);
+            failure = t;
+         }
+         finally
+         {
+            Thread.currentThread().setContextClassLoader(tccl);
+         }
+      }
+      
+      protected abstract void executeTest() throws Throwable;
+      
+   }
+   
+   static class MultiRetryCaller extends RetryCaller
+   {
+      StatelessSessionHome slsbh;
+      StatelessSession slsb;
+      StatefulSessionHome sfsbh;
+      StatefulSession sfsb;
+      NodeAnswer node1;
+      EntityPKHome epkh;
+      EntityPK epk;
+      int other;
+      AComplexPK pk;
+      Logger log;
+      Throwable failure;
+      
+      MultiRetryCaller(Properties env,
+                  StatelessSessionHome slsbh, StatelessSession slsb,
+                      StatefulSessionHome sfsbh, StatefulSession sfsb,
+                      NodeAnswer node1,
+                      EntityPKHome epkh, EntityPK epk,
+                      int other, AComplexPK pk,
+                      Logger log)
+      {
+         super(env);
+         this.slsbh = slsbh;
+         this.slsb = slsb;
+         this.sfsbh = sfsbh;
+         this.sfsb = sfsb;
+         this.node1 = node1;
+         this.epkh = epkh;
+         this.epk = epk;
+         this.other = other;
+         this.pk = pk;
+         this.log = log;
+      }
+      
+      protected void executeTest() throws Throwable
+      {
+         // Test that the SFSB still works
+         
+         System.setProperty ("JBossCluster-DoFail", "once");
+         NodeAnswer node2 = sfsb.getNodeState ();      
+         log.debug (node2);
+         
+         assertTrue ("StatefulSession: Failover has occured", 
+                     !node1.nodeId.equals(node2.nodeId));
+         
+         assertTrue ("StatefulSession: Value is identical on replicated node", 
+                     "Bupple-Dupple".equals (node1.answer) &&
+                     node1.answer.equals(node2.answer) );
+         
+         log.debug("StatefulSession: Retry successful");
+         
+         // Test that the SFSB Home still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         sfsb = (StatefulSession)sfsbh.create("Hippie-Dippie");
+         
+         node2 = sfsb.getNodeState ();      
+         log.debug (node2);
+         
+         assertTrue ("StatefulSessionHome: Failover has occured", 
+                     !node1.nodeId.equals (node2.nodeId));
+         
+         log.debug("StatefulSessionHome: Retry successful");
+         
+         // Test that the SLSB still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         log.debug("StatelessSession: Now making 1 call on server1 ");
+         assertTrue("StatelessSession: Server1 has no calls", 0 == slsb.getCallCount());
+         
+         log.debug("StatelessSession: Retry successful");
+         
+         // Test that the SLSB Home still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         log.debug("Calling create on StatelessSessionHome...");
+         slsb = slsbh.create();
+         
+         log.debug("StatelessSessionHome: Retry successful");
+         
+         // Test that the entity bean still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         log.debug("Retrieving other field again, should be " + other + "...");
+         int newValue = epk.getOtherField();
+         assertEquals("pkBean.getOtherField() correct:", other, newValue);
+         
+         log.debug("EntityBean: Retry successful");
+         
+         // Test the entity home still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         epk = epkh.findByPrimaryKey(pk);
+
+         assertTrue("pkBean != null", epk != null);
+
+         log.debug("EntityBeanHome: Retry successful");
+      }
+   }
+   
+   static class SFSBRetryCaller extends RetryCaller
+   {
+      StatefulSessionHome sfsbh;
+      StatefulSession sfsb;
+      Throwable failure;
+      Logger log;
+      
+      SFSBRetryCaller(Properties env, StatefulSession sfsb, Logger log)
+      {
+         super(env);
+         this.sfsb = sfsb;
+         this.log = log;
+      }
+      
+      protected void executeTest() throws Throwable
+      {
+         // Test that the SFSB still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         NodeAnswer node2 = sfsb.getNodeState ();      
+         log.debug (node2);
+         
+         assertTrue ("StatefulSession: Failover has occured", node2 != null);
+         
+         log.debug("StatefulSession: Retry successful");
+         
+      }
+   }
+   static class DeferredRecoveryCaller extends RetryCaller
+   {
+      StatelessSession slsb;
+      Object result;
+   
+      DeferredRecoveryCaller(Properties env, StatelessSession slsb)
+      {
+         super(env);
+         this.slsb = slsb;
+      }
+      
+      public void executeTest() throws Throwable
+      {
+         // Test that the SLSB still works
+         System.setProperty ("JBossCluster-DoFail", "once");
+         result = new Long(slsb.getCallCount()); 
+      }
+   }
+   
+   /**
+    * Create a new RetryInterceptorUnitTestCase.
+    * 
+    * @param name
+    */
+   public RetryInterceptorTestBase(String name)
+   {
+      super(name);
+      log = Logger.getLogger(getClass());
+   }
+
+   protected void executeRetryTest(RetryCaller caller) 
+      throws InterruptedException, AssertionFailedError
+   {
+      caller.start();
+      
+      // Give the caller 15 secs to do its work
+      caller.join(15000);
+      
+      boolean alive = caller.isAlive();
+      if (alive)
+         caller.interrupt();
+      
+      assertFalse("Retry calls completed", alive);
+      
+      if (caller.failure instanceof AssertionFailedError)
+      {
+         throw (AssertionFailedError) caller.failure;
+      }
+      else if (caller.failure != null)
+      {
+         fail(caller.failure.getClass().getName() + " " + caller.failure.getMessage());
+      }
+   }
+   
+   protected void deferredRecoveryTest(boolean expectSuccess) throws Exception
+   {
+      getLog().debug("+++ Enter testDeferredRecovery");
+      
+      configureCluster();
+      
+      Properties env = getNamingProperties("org.jboss.naming.NamingContextFactory", 
+                                           false);
+      InitialContext ctx = new InitialContext(env);
+      
+      getLog().debug("Looking up the home nextgen.StatelessSession" + getJndiSuffix()+"...");
+      StatelessSessionHome  home =
+            (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession" + getJndiSuffix());
+      if (home!= null ) getLog().debug("ok");
+      getLog().debug("Calling create on StatelessSessionHome" + getJndiSuffix()+"...");
+      StatelessSession slsb = home.create();
+
+      getLog().debug("StatelessSession: Now making 1 call on server0 ");
+      assertEquals("StatelessSession: Server0 has no calls", 0, slsb.getCallCount());
+      
+      // Undeploy the ear
+      MBeanServerConnection[] adaptors = getAdaptors();
+      undeploy(adaptors[0], "test-retry.ear");
+      setDeployed0(false);
+      
+      sleep(1000);
+      
+      DeferredRecoveryCaller caller = new DeferredRecoveryCaller(env, slsb);
+      caller.start();
+      
+      sleep(1000);
+      
+      if (caller.isAlive()) // don't bother deploying otherwise
+      {
+         deploy(adaptors[1], "test-retry.ear");
+         setDeployed1(true);
+      }
+      
+      // Give the caller 3 secs to complete (extremely generous)
+      caller.join(3000);      
+      
+      if (caller.isAlive())
+         fail("Caller did not complete");
+      
+      if (expectSuccess)
+      {
+         assertTrue("Caller retrieved a long", (caller.result instanceof Long));
+         getLog().debug("StatefulSession: Retry successful");
+      }
+      else   
+      {
+         assertTrue("Caller failed as expected", caller.failure != null);
+         getLog().debug("StatefulSession: Retry failed as expected");
+      }
+      
+      getLog().debug("+++ Exit testDeferredRecovery");
+   }
+   
+   /**
+    * Tests that the retry interceptor works properly for an SFSB given
+    * a particular JNDI client configuration.
+    * 
+    * @param ctx
+    * @throws Exception
+    */
+   protected void sfsbTest(Context ctx, Properties env) throws Exception
+   {
+      configureCluster();
+      
+      getLog().debug("Looking up the home nextgen.StatefulSession" + getJndiSuffix()+"...");
+      StatefulSessionHome  statefulSessionHome =
+         (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession" + getJndiSuffix());
+      if (statefulSessionHome!= null ) getLog().debug("ok");
+         getLog().debug("Calling create on StatefulSessionHome" + getJndiSuffix()+"...");
+      StatefulSession statefulSession =
+         (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
+      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
+      getLog().debug("ok");
+      
+      NodeAnswer node1 = statefulSession.getNodeState ();
+      getLog ().debug (node1);
+      
+      // Reconfigure the cluster so the existing targets are invalid
+      // BES -- don't bother; we test that functionality in testRetryInterceptor
+      // just confirm that reestablishing the targets works
+//      reconfigureCluster();
+      
+      // Make calls on the bean in another thread so we can terminate
+      // after a reasonable period of time if the RetryInterceptor is looping
+      SFSBRetryCaller caller = new SFSBRetryCaller(env, statefulSession, getLog());
+      executeRetryTest(caller);
+      
+      getLog().debug("StatefulSession: Retry successful");
+   }
+   
+   protected Properties getNamingProperties(String namingFactoryClass, boolean autoDiscovery)
+      throws Exception
+   {
+      String[] urls = getHANamingURLs();
+      Properties env = new Properties();
+      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, namingFactoryClass);
+      env.setProperty(Context.PROVIDER_URL, urls[0]);
+      // Don't let the discovery packet off the test server so we don't
+      // get spurious responses from other servers on the network
+      env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
+      
+      if (!autoDiscovery)
+      {
+         env.setProperty("jnp.disableDiscovery", "true");
+      }
+      else
+      {
+         if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)      
+         {
+            // Use the multicast address this test environment is using
+            env.put(NamingContext.JNP_DISCOVERY_GROUP, DISCOVERY_GROUP);
+         }
+         if (DISCOVERY_PARTITION != null && "".equals(DISCOVERY_PARTITION) == false)
+         {
+            // Limit to the partition this test environment is using
+            env.put(NamingContext.JNP_PARTITION_NAME, DISCOVERY_PARTITION);
+         }
+      }  
+      
+      return env;
+   }
+   
+   protected String getJndiSuffix()
+   {
+      return "_Retry";
+   }
+   
+   protected void configureCluster() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+   
+      if (!isDeployed0())
+   {
+         deploy(adaptors[0], "test-retry.ear");
+         getLog().debug("Deployed test-retry.ear on server0");
+         setDeployed0(true);
+   }
+      if (isDeployed1())
+      {
+         undeploy(adaptors[1], "test-retry.ear");
+         getLog().debug("Undeployed test-retry.ear on server1");
+         setDeployed1(false);
+      }
+   
+      sleep(2000);
+   }
+   
+   protected void reconfigureCluster() throws Exception
+   {
+      MBeanServerConnection[] adaptors = getAdaptors();
+      deploy(adaptors[1], "test-retry.ear");
+      setDeployed1(true);
+      
+      sleep(2000);
+      
+      undeploy(adaptors[0], "test-retry.ear");
+      setDeployed0(false);
+      
+      sleep(2000);
+   }
+
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      if (customJndiProperties != null)
+      {
+         try
+         {
+            customJndiProperties.delete();
+            if (customJndiProperties.exists())
+               customJndiProperties.deleteOnExit();
+         }
+         catch (Exception e)
+         {
+            log.error("problem cleaning customJndiProperties", e);
+         }
+         
+         customJndiProperties = null;
+      }
+      
+      if (customJndiDir != null)
+      {
+         try
+         {
+            customJndiDir.delete();
+            if (customJndiDir.exists())
+               customJndiDir.deleteOnExit();
+         }
+         catch (Exception e)
+         {
+            log.error("problem cleaning customJndiDir", e);
+         }
+         
+         customJndiProperties = null;
+      }
+      
+      if (System.getProperty("JBossCluster-DoFail") != null)
+         System.setProperty("JBossCluster-DoFail", "false");
+      
+      MBeanServerConnection[] adaptors = getAdaptors();
+      if (isDeployed0())
+      {
+         undeploy(adaptors[0], "test-retry.ear");
+         getLog().debug("Undeployed test-retry.ear on server0");
+         setDeployed0(false);
+}
+      if (isDeployed1())
+      {
+         undeploy(adaptors[1], "test-retry.ear");
+         getLog().debug("Undeployed test-retry.ear on server1");
+         setDeployed1(false);
+      }
+   }
+
+   protected abstract boolean isDeployed0();
+
+   protected abstract void setDeployed0(boolean deployed);
+
+   protected abstract boolean isDeployed1();
+
+   protected abstract void setDeployed1(boolean deployed);
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorTestBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorUnitTestCase.java	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/RetryInterceptorUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -21,24 +21,15 @@
  */
 package org.jboss.test.cluster.defaultcfg.ejb2.test;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.Properties;
 import java.util.Random;
 
-import javax.management.MBeanServerConnection;
-import javax.naming.Context;
 import javax.naming.InitialContext;
 
-import junit.framework.AssertionFailedError;
 import junit.framework.Test;
 
 import org.jboss.logging.Logger;
 import org.jboss.proxy.ejb.RetryInterceptor;
-import org.jboss.test.JBossClusteredTestCase;
 import org.jboss.test.cluster.ejb2.basic.interfaces.NodeAnswer;
 import org.jboss.test.cluster.ejb2.basic.interfaces.StatefulSession;
 import org.jboss.test.cluster.ejb2.basic.interfaces.StatelessSession;
@@ -48,7 +39,6 @@
 import org.jboss.test.testbean.interfaces.EntityPK;
 import org.jboss.test.testbean.interfaces.EntityPKHome;
 import org.jboss.test.testbean.interfaces.StatefulSessionHome;
-import org.jnp.interfaces.NamingContext;
 
 /**
  * Tests the RetryInterceptor.
@@ -56,213 +46,13 @@
  * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
  * @version $Revision $
  */
-public class RetryInterceptorUnitTestCase extends JBossClusteredTestCase
+public class RetryInterceptorUnitTestCase extends RetryInterceptorTestBase
 {   
-   private static final String DISCOVERY_TTL = System.getProperty("jbosstest.udp.ip_ttl", "1");
-   private static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup");
-   private static final String DISCOVERY_PARTITION = System.getProperty("jbosstest.partitionName", "DefaultPartition");
-   
-   protected static Logger log;
-   
-   private static File customJndiDir = null;
-   private static File customJndiProperties = null;
-   
    // NOTE: these variables must be static as apparently a separate instance
    // of this class is created for each test.
    private static boolean deployed0 = false;
    private static boolean deployed1 = false;
    
-   static abstract class RetryCaller extends Thread
-   {
-      Properties env;
-      Throwable failure;
-      
-      RetryCaller(Properties env)
-      {
-         this.env = env;
-      }
-      
-      public void run()
-      {
-         ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-         try
-         {
-            if (customJndiProperties != null)
-            {
-               // Create a special classloader that will read in the 
-               // customJndiProperties file and include it in any 
-               // getResources("jndi.properties") request.
-               // We use this to allow running the server with
-               // HA-JNDI autodiscovery set to a custom address 
-               URL[] urls = new URL[]{ customJndiDir.toURL() };
-               ClassLoader cl = new URLClassLoader(urls, tccl);
-               Thread.currentThread().setContextClassLoader(cl);
-            }
-            
-            // Establish an initial context on this thread with the
-            // given properties -- needed for JBoss NamingContextFactory
-            // to work properly.  Meaningless otherwise            
-            new InitialContext(env);
-            
-            executeTest();
-         }
-         catch (Throwable t)
-         {
-            log.error(this + " caught an exception", t);
-            failure = t;
-         }
-         finally
-         {
-            Thread.currentThread().setContextClassLoader(tccl);
-         }
-      }
-      
-      protected abstract void executeTest() throws Throwable;
-      
-   }
-   
-   static class MultiRetryCaller extends RetryCaller
-   {
-      StatelessSessionHome slsbh;
-      StatelessSession slsb;
-      StatefulSessionHome sfsbh;
-      StatefulSession sfsb;
-      NodeAnswer node1;
-      EntityPKHome epkh;
-      EntityPK epk;
-      int other;
-      AComplexPK pk;
-      Logger log;
-      Throwable failure;
-      
-      MultiRetryCaller(Properties env,
-                  StatelessSessionHome slsbh, StatelessSession slsb,
-                      StatefulSessionHome sfsbh, StatefulSession sfsb,
-                      NodeAnswer node1,
-                      EntityPKHome epkh, EntityPK epk,
-                      int other, AComplexPK pk,
-                      Logger log)
-      {
-         super(env);
-         this.slsbh = slsbh;
-         this.slsb = slsb;
-         this.sfsbh = sfsbh;
-         this.sfsb = sfsb;
-         this.node1 = node1;
-         this.epkh = epkh;
-         this.epk = epk;
-         this.other = other;
-         this.pk = pk;
-         this.log = log;
-      }
-      
-      protected void executeTest() throws Throwable
-      {
-         // Test that the SFSB still works
-         
-         System.setProperty ("JBossCluster-DoFail", "once");
-         NodeAnswer node2 = sfsb.getNodeState ();      
-         log.debug (node2);
-         
-         assertTrue ("StatefulSession: Failover has occured", 
-                     !node1.nodeId.equals(node2.nodeId));
-         
-         assertTrue ("StatefulSession: Value is identical on replicated node", 
-                     "Bupple-Dupple".equals (node1.answer) &&
-                     node1.answer.equals(node2.answer) );
-         
-         log.debug("StatefulSession: Retry successful");
-         
-         // Test that the SFSB Home still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         sfsb = (StatefulSession)sfsbh.create("Hippie-Dippie");
-         
-         node2 = sfsb.getNodeState ();      
-         log.debug (node2);
-         
-         assertTrue ("StatefulSessionHome: Failover has occured", 
-                     !node1.nodeId.equals (node2.nodeId));
-         
-         log.debug("StatefulSessionHome: Retry successful");
-         
-         // Test that the SLSB still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         log.debug("StatelessSession: Now making 1 call on server1 ");
-         assertTrue("StatelessSession: Server1 has no calls", 0 == slsb.getCallCount());
-         
-         log.debug("StatelessSession: Retry successful");
-         
-         // Test that the SLSB Home still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         log.debug("Calling create on StatelessSessionHome...");
-         slsb = slsbh.create();
-         
-         log.debug("StatelessSessionHome: Retry successful");
-         
-         // Test that the entity bean still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         log.debug("Retrieving other field again, should be " + other + "...");
-         int newValue = epk.getOtherField();
-         assertEquals("pkBean.getOtherField() correct:", other, newValue);
-         
-         log.debug("EntityBean: Retry successful");
-         
-         // Test the entity home still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         epk = epkh.findByPrimaryKey(pk);
-
-         assertTrue("pkBean != null", epk != null);
-
-         log.debug("EntityBeanHome: Retry successful");
-      }
-   }
-   
-   static class SFSBRetryCaller extends RetryCaller
-   {
-      StatefulSessionHome sfsbh;
-      StatefulSession sfsb;
-      Throwable failure;
-      Logger log;
-      
-      SFSBRetryCaller(Properties env, StatefulSession sfsb, Logger log)
-      {
-         super(env);
-         this.sfsb = sfsb;
-         this.log = log;
-      }
-      
-      protected void executeTest() throws Throwable
-      {
-         // Test that the SFSB still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         NodeAnswer node2 = sfsb.getNodeState ();      
-         log.debug (node2);
-         
-         assertTrue ("StatefulSession: Failover has occured", node2 != null);
-         
-         log.debug("StatefulSession: Retry successful");
-         
-      }
-   }
-   static class DeferredRecoveryCaller extends RetryCaller
-   {
-      StatelessSession slsb;
-      Object result;
-   
-      DeferredRecoveryCaller(Properties env, StatelessSession slsb)
-      {
-         super(env);
-         this.slsb = slsb;
-      }
-      
-      public void executeTest() throws Throwable
-      {
-         // Test that the SLSB still works
-         System.setProperty ("JBossCluster-DoFail", "once");
-         result = new Long(slsb.getCallCount()); 
-      }
-   }
-   
    /**
     * Create a new RetryInterceptorUnitTestCase.
     * 
@@ -364,94 +154,12 @@
 
       getLog().debug("+++ Exit testRetryInterceptor");
    }
-
-   protected void executeRetryTest(RetryCaller caller) 
-      throws InterruptedException, AssertionFailedError
-   {
-      caller.start();
-      
-      // Give the caller 15 secs to do its work
-      caller.join(15000);
-      
-      boolean alive = caller.isAlive();
-      if (alive)
-         caller.interrupt();
-      
-      assertFalse("Retry calls completed", alive);
-      
-      if (caller.failure instanceof AssertionFailedError)
-      {
-         throw (AssertionFailedError) caller.failure;
-      }
-      else if (caller.failure != null)
-      {
-         fail(caller.failure.getClass().getName() + " " + caller.failure.getMessage());
-      }
-   }
    
    public void testDeferredRecovery() throws Exception
    {
       deferredRecoveryTest(true);
    }
    
-   protected void deferredRecoveryTest(boolean expectSuccess) throws Exception
-   {
-      getLog().debug("+++ Enter testDeferredRecovery");
-      
-      configureCluster();
-      
-      Properties env = getNamingProperties("org.jboss.naming.NamingContextFactory", 
-                                           false);
-      InitialContext ctx = new InitialContext(env);
-      
-      getLog().debug("Looking up the home nextgen.StatelessSession" + getJndiSuffix()+"...");
-      StatelessSessionHome  home =
-            (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession" + getJndiSuffix());
-      if (home!= null ) getLog().debug("ok");
-      getLog().debug("Calling create on StatelessSessionHome" + getJndiSuffix()+"...");
-      StatelessSession slsb = home.create();
-
-      getLog().debug("StatelessSession: Now making 1 call on server0 ");
-      assertEquals("StatelessSession: Server0 has no calls", 0, slsb.getCallCount());
-      
-      // Undeploy the ear
-      MBeanServerConnection[] adaptors = getAdaptors();
-      undeploy(adaptors[0], "test-retry.ear");
-      setDeployed0(false);
-      
-      sleep(1000);
-      
-      DeferredRecoveryCaller caller = new DeferredRecoveryCaller(env, slsb);
-      caller.start();
-      
-      sleep(1000);
-      
-      if (caller.isAlive()) // don't bother deploying otherwise
-      {
-         deploy(adaptors[1], "test-retry.ear");
-         setDeployed1(true);
-      }
-      
-      // Give the caller 3 secs to complete (extremely generous)
-      caller.join(3000);      
-      
-      if (caller.isAlive())
-         fail("Caller did not complete");
-      
-      if (expectSuccess)
-      {
-         assertTrue("Caller retrieved a long", (caller.result instanceof Long));
-         getLog().debug("StatefulSession: Retry successful");
-      }
-      else   
-      {
-         assertTrue("Caller failed as expected", caller.failure != null);
-         getLog().debug("StatefulSession: Retry failed as expected");
-      }
-      
-      getLog().debug("+++ Exit testDeferredRecovery");
-   }
-   
    /**
     * Tests that the retry interceptor works properly if the naming context
     * is established via RetryInterceptor.setRetryEnv()
@@ -479,217 +187,7 @@
       
       getLog().debug("+++ Exit testSetRetryEnv");
    }
-   
-   /**
-    * Tests that the retry interceptor works properly if the naming context
-    * is established by using org.jnp.interfaces.NamingContextFactory
-    * and auto-discovery is enabled.
-    *  
-    * @throws Exception
-    */
-   public void testRetryWithJnpAndAutoDiscovery() throws Exception
-   {
-      getLog().debug("+++ Enter testRetryWithJnpAndAutoDiscovery()");
-      
-      // Create a jndi.properties in the temp dir with special configs
-      // to prevent autodiscovery spuriously discovering random servers
-      // on the network. When the RetryCaller runs, it will create a 
-      // special classloader that will pick up this file
-      if (customJndiDir == null)
-         customJndiDir = new File(System.getProperty("java.io.tmpdir"), 
-                                  "retry-int-test");
-      if (!customJndiDir.exists())
-         customJndiDir.mkdir();
-      customJndiProperties = new File(customJndiDir, "jndi.properties");
-      FileOutputStream fos = new FileOutputStream(customJndiProperties);
-      OutputStreamWriter writer = new OutputStreamWriter(fos);
-      writer.write(NamingContext.JNP_DISCOVERY_TTL + "=" + DISCOVERY_TTL + "\n");
-      if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
-      {
-         // The server isn't listening on the std multicast address
-         writer.write(NamingContext.JNP_DISCOVERY_GROUP + "=" + DISCOVERY_GROUP + "\n");
-      }
-      if (DISCOVERY_PARTITION != null && "".equals(DISCOVERY_PARTITION) == false)
-      {
-         // Limit to the partition this test environment is using
-         writer.write(NamingContext.JNP_PARTITION_NAME + "=" + DISCOVERY_PARTITION + "\n");
-      }
-      writer.close();
-      getLog().debug("Created custom jndi.properties at " + customJndiProperties + 
-                     " -- DISCOVERY_GROUP is " + DISCOVERY_GROUP +
-                     " -- DISCOVERY_PARTITION is " + DISCOVERY_PARTITION);
-      
-      
-      Properties env = getNamingProperties("org.jnp.interfaces.NamingContextFactory", true);
-      
-      InitialContext ctx = new InitialContext(env);
-      
-      sfsbTest(ctx, env);
-   }
-   
-   /**
-    * Tests that the retry interceptor works properly for an SFSB given
-    * a particular JNDI client configuration.
-    * 
-    * @param ctx
-    * @throws Exception
-    */
-   protected void sfsbTest(Context ctx, Properties env) throws Exception
-   {
-      configureCluster();
-      
-      getLog().debug("Looking up the home nextgen.StatefulSession" + getJndiSuffix()+"...");
-      StatefulSessionHome  statefulSessionHome =
-         (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession" + getJndiSuffix());
-      if (statefulSessionHome!= null ) getLog().debug("ok");
-         getLog().debug("Calling create on StatefulSessionHome" + getJndiSuffix()+"...");
-      StatefulSession statefulSession =
-         (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
-      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
-      getLog().debug("ok");
-      
-      NodeAnswer node1 = statefulSession.getNodeState ();
-      getLog ().debug (node1);
-      
-      // Reconfigure the cluster so the existing targets are invalid
-      // BES -- don't bother; we test that functionality in testRetryInterceptor
-      // just confirm that reestablishing the targets works
-//      reconfigureCluster();
-      
-      // Make calls on the bean in another thread so we can terminate
-      // after a reasonable period of time if the RetryInterceptor is looping
-      SFSBRetryCaller caller = new SFSBRetryCaller(env, statefulSession, getLog());
-      executeRetryTest(caller);
-      
-      getLog().debug("StatefulSession: Retry successful");
-   }
-   
-   protected Properties getNamingProperties(String namingFactoryClass, boolean autoDiscovery)
-      throws Exception
-   {
-      String[] urls = getHANamingURLs();
-      Properties env = new Properties();
-      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, namingFactoryClass);
-      env.setProperty(Context.PROVIDER_URL, urls[0]);
-      // Don't let the discovery packet off the test server so we don't
-      // get spurious responses from other servers on the network
-      env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
-      
-      if (!autoDiscovery)
-      {
-         env.setProperty("jnp.disableDiscovery", "true");
-      }
-      else
-      {
-         if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)      
-         {
-            // Use the multicast address this test environment is using
-            env.put(NamingContext.JNP_DISCOVERY_GROUP, DISCOVERY_GROUP);
-         }
-         if (DISCOVERY_PARTITION != null && "".equals(DISCOVERY_PARTITION) == false)
-         {
-            // Limit to the partition this test environment is using
-            env.put(NamingContext.JNP_PARTITION_NAME, DISCOVERY_PARTITION);
-         }
-      }  
-      
-      return env;
-   }
-   
-   protected String getJndiSuffix()
-   {
-      return "_Retry";
-   }
-   
-   protected void configureCluster() throws Exception
-   {
-      MBeanServerConnection[] adaptors = getAdaptors();
-   
-      if (!isDeployed0())
-   {
-         deploy(adaptors[0], "test-retry.ear");
-         getLog().debug("Deployed test-retry.ear on server0");
-         setDeployed0(true);
-   }
-      if (isDeployed1())
-      {
-         undeploy(adaptors[1], "test-retry.ear");
-         getLog().debug("Undeployed test-retry.ear on server1");
-         setDeployed1(false);
-      }
-   
-      sleep(2000);
-   }
-   
-   protected void reconfigureCluster() throws Exception
-   {
-      MBeanServerConnection[] adaptors = getAdaptors();
-      deploy(adaptors[1], "test-retry.ear");
-      setDeployed1(true);
-      
-      sleep(2000);
-      
-      undeploy(adaptors[0], "test-retry.ear");
-      setDeployed0(false);
-      
-      sleep(2000);
-   }
 
-
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-      
-      if (customJndiProperties != null)
-      {
-         try
-         {
-            customJndiProperties.delete();
-            if (customJndiProperties.exists())
-               customJndiProperties.deleteOnExit();
-         }
-         catch (Exception e)
-         {
-            log.error("problem cleaning customJndiProperties", e);
-         }
-         
-         customJndiProperties = null;
-      }
-      
-      if (customJndiDir != null)
-      {
-         try
-         {
-            customJndiDir.delete();
-            if (customJndiDir.exists())
-               customJndiDir.deleteOnExit();
-         }
-         catch (Exception e)
-         {
-            log.error("problem cleaning customJndiDir", e);
-         }
-         
-         customJndiProperties = null;
-      }
-      
-      if (System.getProperty("JBossCluster-DoFail") != null)
-         System.setProperty("JBossCluster-DoFail", "false");
-      
-      MBeanServerConnection[] adaptors = getAdaptors();
-      if (isDeployed0())
-      {
-         undeploy(adaptors[0], "test-retry.ear");
-         getLog().debug("Undeployed test-retry.ear on server0");
-         setDeployed0(false);
-}
-      if (isDeployed1())
-      {
-         undeploy(adaptors[1], "test-retry.ear");
-         getLog().debug("Undeployed test-retry.ear on server1");
-         setDeployed1(false);
-      }
-   }
-
    protected boolean isDeployed0()
    {
       return deployed0;

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorAutoDiscoveryUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorAutoDiscoveryUnitTestCase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorAutoDiscoveryUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.ejb2.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.cluster.testutil.DBSetup;
+
+/**
+ * Tests the SingleRetryInterceptor with HA-JNDI autodiscovery.
+ * This test is separate from the other SingleRetryInterceptor tests
+ * so it can be exclude in tests of configs that disable HA-JNDI auto-discovery.
+ * 
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class SingleRetryInterceptorAutoDiscoveryUnitTestCase extends RetryInterceptorAutoDiscoveryUnitTestCase
+{   
+   // NOTE: these variables must be static as apparently a separate instance
+   // of this class is created for each test.
+   private static boolean deployed0 = false;
+   private static boolean deployed1 = false;
+   
+   /**
+    * Create a new SingleRetryInterceptorUnitTestCase.
+    * 
+    * @param name
+    */
+   public SingleRetryInterceptorAutoDiscoveryUnitTestCase(String name)
+   {
+      super(name);
+   }  
+
+
+   public static Test suite() throws Exception
+   {
+      return DBSetup.getDeploySetup(SingleRetryInterceptorAutoDiscoveryUnitTestCase.class, "cif-ds.xml");
+   }
+      
+   protected String getJndiSuffix()
+   {
+      return "_SingleRetry";
+   }
+
+   protected boolean isDeployed0()
+   {
+      return deployed0;
+   }
+   
+   protected void setDeployed0(boolean deployed)
+   {
+      deployed0 = deployed;
+   }
+   
+   protected boolean isDeployed1()
+   {
+      return deployed1;
+   }
+   
+   protected void setDeployed1(boolean deployed)
+   {
+      deployed1 = deployed;
+   }
+   
+}
\ No newline at end of file


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorAutoDiscoveryUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorUnitTestCase.java	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/defaultcfg/ejb2/test/SingleRetryInterceptorUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -21,11 +21,10 @@
  */
 package org.jboss.test.cluster.defaultcfg.ejb2.test;
 
-import org.jboss.logging.Logger;
-import org.jboss.test.cluster.testutil.DBSetup;
-
 import junit.framework.Test;
 
+import org.jboss.test.cluster.testutil.DBSetup;
+
 /**
  * Tests the SingleRetryInterceptor.
  * 

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiAutoDiscoveryTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiAutoDiscoveryTestCase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiAutoDiscoveryTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.multicfg.test;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * HA-JNDI clustering tests involving autodiscovery.
+ * This test is separate from the other HA-JNDI tests
+ * so it can be excluded in tests of configs that disable HA-JNDI auto-discovery.
+ *
+ * @author Jerry Gauthier
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @version $Revision$
+ */
+public class HAJndiAutoDiscoveryTestCase
+      extends HAJndiTestBase      
+{   
+   // BINDING KEYS and VALUES
+   private static final String LOCAL1_KEY = "org.jboss.test.cluster.test.Local1Key";
+   private static final String LOCAL1_VALUE = "Local1Value";
+   private static final String JNDI_KEY3 = "org.jboss.test.cluster.test.JNDIKey3";
+   private static final String JNDI_VALUE3 = "JNDIValue3";
+	
+   public HAJndiAutoDiscoveryTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(HAJndiAutoDiscoveryTestCase.class, "cross-server.jar");
+   }
+   
+   /**
+    * Test HA-JNDI AutoDiscovery
+    *
+    * @throws Exception
+    */
+   public void testAutoDiscovery()
+      throws Exception
+   {
+      getLog().debug("HAJndiTestCase.testAutoDiscovery()");
+      validateUrls();
+      
+      // this test doesn't run properly if node0=localhost or node0=127.0.0.1
+      // because the jndi code would find localhost:1099 server and would use 
+      // that one
+      if (NODE0 != null && (NODE0.equalsIgnoreCase("localhost") || NODE0.equalsIgnoreCase("127.0.0.1")))
+      {
+         getLog().debug("testAutoDiscovery() - test skipped because node0=localhost");
+         return;
+      }
+      
+      // bind to node1 locally
+      Context naming = getContext(NODE1_JNDI);
+      naming.bind(LOCAL1_KEY, LOCAL1_VALUE);
+      closeContext(naming);
+      
+      // bind to node0 using HA-JNDI
+      naming = getContext(NODE0_HAJNDI);
+      naming.bind(JNDI_KEY3, JNDI_VALUE3);  
+      closeContext(naming);
+     
+      //create context with AutoDiscovery enabled
+      naming = getAutoDiscoveryContext(false);
+      
+      // lookup local binding using HA-JNDI AutoDiscovery - should succeed
+      String value = (String)lookup(naming, LOCAL1_KEY, true);
+      assertEquals("local lookup with AutoDiscovery enabled", LOCAL1_VALUE, value);
+      
+      // lookup HA binding using HA-JNDI AutoDiscovery - should succeed
+      value = (String)lookup(naming, JNDI_KEY3, true);
+      assertEquals("lookup of HA-JNDI binding with AutoDiscovery enabled", JNDI_VALUE3, value);     
+      
+      // now disable AutoDiscovery and confirm that the same lookups fail
+      closeContext(naming);
+      naming = getAutoDiscoveryContext(true);
+      
+      // lookup local binding without HA-JNDI AutoDiscovery - should fail
+      value = (String)lookup(naming, LOCAL1_KEY, false);
+      assertNull("local lookup with AutoDiscovery disabled", value);
+      
+      // lookup HA binding without HA-JNDI AutoDiscovery - should fail
+      value = (String)lookup(naming, JNDI_KEY3, false);
+      assertNull("lookup of HA-JNDI binding with AutoDiscovery disabled", value);
+      
+      closeContext(naming);
+
+   }
+   
+   private Context getAutoDiscoveryContext(boolean autoDisabled)
+      throws Exception
+   {
+      // do not add any urls to the context
+      Properties env = new Properties();        
+      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+      // Don't let the discovery packet off the test server so we don't
+      // get spurious responses from other servers on the network
+      env.setProperty(NamingContext.JNP_DISCOVERY_TTL, DISCOVERY_TTL);
+
+      if (autoDisabled)
+      {
+         env.put(NamingContext.JNP_DISABLE_DISCOVERY, "true");
+      }
+      else 
+      {
+         if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)      
+         {
+            // Use the multicast address this test environment is using
+            env.put(NamingContext.JNP_DISCOVERY_GROUP, DISCOVERY_GROUP);
+         }
+         if (DISCOVERY_PARTITION != null && "".equals(DISCOVERY_PARTITION) == false)
+         {
+            // Limit to the partition this test environment is using
+            env.put(NamingContext.JNP_PARTITION_NAME, DISCOVERY_PARTITION);
+         }
+      }  
+        
+      Context naming = new InitialContext (env);
+      return naming;
+
+   }
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiAutoDiscoveryTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestBase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestBase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestBase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.multicfg.test;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * HA-JNDI clustering tests.
+ *
+ * @author Jerry Gauthier
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @version $Revision$
+ */
+public class HAJndiTestBase
+      extends JBossClusteredTestCase      
+{
+   // ENVIRONMENT PROPERTIES
+   protected static final String NODE0 = System.getProperty("node0");
+   protected static final String NODE0_JNDI = System.getProperty("node0.jndi.url");
+   protected static final String NODE1_JNDI = System.getProperty("node1.jndi.url");
+   protected static final String NODE0_HAJNDI = System.getProperty("node0.hajndi.url");
+   protected static final String NODE1_HAJNDI = System.getProperty("node1.hajndi.url");
+   protected static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup");
+   protected static final String DISCOVERY_TTL = System.getProperty("jbosstest.udp.ip_ttl", "1");
+   protected static final String DISCOVERY_PARTITION = System.getProperty("jbosstest.partitionName", "DefaultPartition");
+   
+   public HAJndiTestBase(String name)
+   {
+      super(name);
+   }
+  
+   protected Context getContext(String url)
+      throws Exception
+   {
+      Properties env = new Properties();        
+      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+      env.setProperty(Context.PROVIDER_URL, url);
+      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+		
+      Context naming = new InitialContext (env);
+      return naming;
+
+   }
+	
+   protected void closeContext(Context context)
+   {
+      try 
+      {
+         context.close();		   
+      }
+      catch (NamingException e)
+      {
+         // no action required
+      }
+   }	
+   
+   protected Object lookup(Context context, String name, boolean failIfMissing)
+   {	   
+      try
+      {
+         Object o = context.lookup(name);
+         log.info(name + " binding value: " + o);
+         return o;
+      }
+      catch (NamingException e)
+      {
+         if (failIfMissing)
+         {
+           String msg =   "Name " + name + " not found. " + e.getLocalizedMessage();
+           log.info(msg, e);
+           fail(msg);
+         }
+         else
+         {
+            log.debug("Name " + name + " not found.");
+         }
+         return null;
+      }	   
+   }
+   
+   protected void validateUrls()
+      throws Exception      
+   {
+      if (NODE0_JNDI == null)
+         throw new Exception("node0.jndi.url not defined.");
+         
+      if (NODE1_JNDI == null)
+         throw new Exception("node1.jndi.url not defined.");
+         
+      if (NODE0_HAJNDI == null)
+         throw new Exception("node0.hajndi.url not defined.");
+         
+      if (NODE1_HAJNDI == null)
+         throw new Exception("node1.hajndi.url not defined.");
+
+   }
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -31,7 +31,6 @@
 
 import org.jboss.test.cluster.ejb2.crossserver.CalledHome;
 import org.jboss.test.cluster.ejb2.crossserver.CalledRemote;
-import org.jboss.test.JBossClusteredTestCase;
 import org.jnp.interfaces.NamingContext;
 
 /**
@@ -42,17 +41,8 @@
  * @version $Revision$
  */
 public class HAJndiTestCase
-      extends JBossClusteredTestCase      
+      extends HAJndiTestBase      
 {
-   // ENVIRONMENT PROPERTIES
-   private static final String NODE0 = System.getProperty("node0");
-   private static final String NODE0_JNDI = System.getProperty("node0.jndi.url");
-   private static final String NODE1_JNDI = System.getProperty("node1.jndi.url");
-   private static final String NODE0_HAJNDI = System.getProperty("node0.hajndi.url");
-   private static final String NODE1_HAJNDI = System.getProperty("node1.hajndi.url");
-   private static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup");
-   private static final String DISCOVERY_TTL = System.getProperty("jbosstest.udp.ip_ttl", "1");
-   private static final String DISCOVERY_PARTITION = System.getProperty("jbosstest.partitionName", "DefaultPartition");
    
    // BINDING SUBCONTEXT NAMES
    private static final String SUBCON1 = "subcontext1";
@@ -62,19 +52,15 @@
    // BINDING KEYS and VALUES
    private static final String LOCAL0_KEY = "org.jboss.test.cluster.test.Local0Key";
    private static final String LOCAL0_VALUE = "Local0Value";
-   private static final String LOCAL1_KEY = "org.jboss.test.cluster.test.Local1Key";
-   private static final String LOCAL1_VALUE = "Local1Value";
    private static final String GLOBAL0_KEY = "org.jboss.test.cluster.test.Global0Key";
    private static final String GLOBAL0_VALUE = "Global0Value";
    private static final String CALLED_HOME_KEY = "cluster.ejb.CalledHome";
    private static final String JNDI_KEY = "org.jboss.test.cluster.test.JNDIKey";
-   private static final String JNDI_KEY3 = "org.jboss.test.cluster.test.JNDIKey3";
    private static final String SUB1_KEY = "org.jboss.test.cluster.test.Sub1Key";
    private static final String SUB2_KEY = "org.jboss.test.cluster.test.Sub2Key";
    private static final String SUB1A_KEY = "org.jboss.test.cluster.test.Sub1aKey";
    private static final String JNDI_VALUE1 = "JNDIValue1";
    private static final String JNDI_VALUE2 = "JNDIValue2";
-   private static final String JNDI_VALUE3 = "JNDIValue3";
    private static final String SUB1_VALUE = "Sub1Value";
    private static final String SUB2_VALUE = "Sub2Value";
    private static final String SUB1A_VALUE = "Sub1aValue";
@@ -328,162 +314,5 @@
       assertNotNull("lookup EJB binding on different server in cluster using HA-JNDI", home);
 
    }
-   
-   /**
-    * Test HA-JNDI AutoDiscovery
-    *
-    * @throws Exception
-    */
-   public void testAutoDiscovery()
-      throws Exception
-   {
-      getLog().debug("HAJndiTestCase.testAutoDiscovery()");
-      validateUrls();
-      
-      // this test doesn't run properly if node0=localhost or node0=127.0.0.1
-      // because the jndi code would find localhost:1099 server and would use 
-      // that one
-      if (NODE0 != null && (NODE0.equalsIgnoreCase("localhost") || NODE0.equalsIgnoreCase("127.0.0.1")))
-      {
-         getLog().debug("testAutoDiscovery() - test skipped because node0=localhost");
-         return;
-      }
-      
-      // bind to node1 locally
-      Context naming = getContext(NODE1_JNDI);
-      naming.bind(LOCAL1_KEY, LOCAL1_VALUE);
-      closeContext(naming);
-      
-      // bind to node0 using HA-JNDI
-      naming = getContext(NODE0_HAJNDI);
-      naming.bind(JNDI_KEY3, JNDI_VALUE3);  
-      closeContext(naming);
-     
-      //create context with AutoDiscovery enabled
-      naming = getAutoDiscoveryContext(false);
-      
-      // lookup local binding using HA-JNDI AutoDiscovery - should succeed
-      String value = (String)lookup(naming, LOCAL1_KEY, true);
-      assertEquals("local lookup with AutoDiscovery enabled", LOCAL1_VALUE, value);
-      
-      // lookup HA binding using HA-JNDI AutoDiscovery - should succeed
-      value = (String)lookup(naming, JNDI_KEY3, true);
-      assertEquals("lookup of HA-JNDI binding with AutoDiscovery enabled", JNDI_VALUE3, value);     
-      
-      // now disable AutoDiscovery and confirm that the same lookups fail
-      closeContext(naming);
-      naming = getAutoDiscoveryContext(true);
-      
-      // lookup local binding without HA-JNDI AutoDiscovery - should fail
-      value = (String)lookup(naming, LOCAL1_KEY, false);
-      assertNull("local lookup with AutoDiscovery disabled", value);
-      
-      // lookup HA binding without HA-JNDI AutoDiscovery - should fail
-      value = (String)lookup(naming, JNDI_KEY3, false);
-      assertNull("lookup of HA-JNDI binding with AutoDiscovery disabled", value);
-      
-      closeContext(naming);
 
-   }
-  
-   private Context getContext(String url)
-      throws Exception
-   {
-      Properties env = new Properties();        
-      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
-      env.setProperty(Context.PROVIDER_URL, url);
-      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
-		
-      Context naming = new InitialContext (env);
-      return naming;
-
-   }
-   
-   private Context getAutoDiscoveryContext(boolean autoDisabled)
-      throws Exception
-   {
-      // do not add any urls to the context
-      Properties env = new Properties();        
-      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
-      env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
-      // Don't let the discovery packet off the test server so we don't
-      // get spurious responses from other servers on the network
-      env.setProperty(NamingContext.JNP_DISCOVERY_TTL, DISCOVERY_TTL);
-
-      if (autoDisabled)
-      {
-         env.put(NamingContext.JNP_DISABLE_DISCOVERY, "true");
-      }
-      else 
-      {
-         if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)      
-         {
-            // Use the multicast address this test environment is using
-            env.put(NamingContext.JNP_DISCOVERY_GROUP, DISCOVERY_GROUP);
-         }
-         if (DISCOVERY_PARTITION != null && "".equals(DISCOVERY_PARTITION) == false)
-         {
-            // Limit to the partition this test environment is using
-            env.put(NamingContext.JNP_PARTITION_NAME, DISCOVERY_PARTITION);
-         }
-      }  
-        
-      Context naming = new InitialContext (env);
-      return naming;
-
-   }
-	
-   private void closeContext(Context context)
-   {
-      try 
-      {
-         context.close();		   
-      }
-      catch (NamingException e)
-      {
-         // no action required
-      }
-   }	
-   
-   private Object lookup(Context context, String name, boolean failIfMissing)
-   {	   
-      try
-      {
-         Object o = context.lookup(name);
-         log.info(name + " binding value: " + o);
-         return o;
-      }
-      catch (NamingException e)
-      {
-         if (failIfMissing)
-         {
-           String msg =   "Name " + name + " not found. " + e.getLocalizedMessage();
-           log.info(msg, e);
-           fail(msg);
-         }
-         else
-         {
-            log.debug("Name " + name + " not found.");
-         }
-         return null;
-      }	   
-   }
-   
-   private void validateUrls()
-      throws Exception      
-   {
-      if (NODE0_JNDI == null)
-         throw new Exception("node0.jndi.url not defined.");
-         
-      if (NODE1_JNDI == null)
-         throw new Exception("node1.jndi.url not defined.");
-         
-      if (NODE0_HAJNDI == null)
-         throw new Exception("node0.hajndi.url not defined.");
-         
-      if (NODE1_HAJNDI == null)
-         throw new Exception("node1.hajndi.url not defined.");
-
-   }
-
 }

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/restart/NamingRestartTestBase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/restart/NamingRestartTestBase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/restart/NamingRestartTestBase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.naming.restart;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.test.JBossTestCase;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * Base class for tests of client's ability to deal with JNDI restarting.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public abstract class NamingRestartTestBase extends JBossTestCase
+{
+   public NamingRestartTestBase(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      if (!isDeployed())
+         deploy("naming-restart.sar");
+      setDeployed(true);
+   }   
+   
+   protected void tearDown() throws Exception
+   {
+      if (isDeployed())
+      {
+         undeploy("naming-restart.sar");
+         setDeployed(false);
+      }
+      
+      super.tearDown();
+   }
+   
+   protected void lookupTest(Hashtable env) throws Exception
+   {
+      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
+      // static map in org.jnp.interfaces.NamingContext.
+      
+      // Redeploy the naming service
+      redeployNaming();
+      
+      Context ctx2 = createInitialContext(env);
+      NamingException ne = null;
+      try
+      {
+         assertEquals(ObjectBinder.VALUE, ctx2.lookup(ObjectBinder.NAME));
+      }
+      catch (NamingException e)
+      {
+         // Cache the exception to fail the test later, after
+         // we check that we can recover
+         log.error("Caught NamingException", e);
+         ne = e;
+      }
+      
+      // We recover from failure
+      if (ne != null)
+      {
+         try
+         {
+            assertEquals(ObjectBinder.VALUE, ctx2.lookup(ObjectBinder.NAME));
+         }
+         catch (Exception e)
+         {
+            log.error("Failed to reacquire server");
+         }
+         // Now fail due to the earlier failure
+         fail(ne.getMessage());         
+      }
+      
+      // Confirm the original context is still good
+      assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
+   }
+
+   protected 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;
+   }
+   protected void redeployNaming() throws Exception
+   {
+      setDeployed(false);
+      redeploy("naming-restart.sar");
+      setDeployed(true);
+   }
+   
+   protected abstract boolean isDeployed();
+   
+   protected abstract void setDeployed(boolean deployed);
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/restart/NamingRestartTestBase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/HAJndiAutoDiscoveryUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/HAJndiAutoDiscoveryUnitTestCase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/HAJndiAutoDiscoveryUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.naming.test;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.jboss.test.JBossTestCase;
+
+/** 
+ * Tests of HA-JNDI auto-discovery.
+ */
+public class HAJndiAutoDiscoveryUnitTestCase extends JBossTestCase
+{
+   private static final String DISCOVERY_TTL = System.getProperty("jbosstest.udp.ip_ttl", "1");
+   private static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup", "");
+   
+   /**
+    * Constructor for the SimpleUnitTestCase object
+    *
+    * @param name  Test name
+    */
+   public HAJndiAutoDiscoveryUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /** Test discovery with the partition name specified
+    *
+    * @throws Exception
+    */
+   public void testHaPartitionName() throws Exception
+   {
+      getLog().debug("+++ testHaPartitionName");
+      Properties env = new Properties();
+      String serverHost = getServerHost();
+      env.setProperty(Context.PROVIDER_URL, "jnp://" + serverHost + ":65535/");
+      env.setProperty("jnp.localAddress", serverHost);      
+      env.setProperty("jnp.partitionName", "DefaultPartition");
+      // Don't let the discovery packet off the test server so we don't
+      // get spurious responses from other servers on the network
+      env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
+      if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
+      {
+         // Server is not listening for discovery on std multicast address
+         // so we need to use the correct one
+         env.setProperty("jnp.discoveryGroup", DISCOVERY_GROUP);
+      }
+      getLog().debug("Creating InitialContext with env="+env);
+      InitialContext ctx = new InitialContext(env);
+      getLog().debug("Created InitialContext");
+      Object obj = ctx.lookup("invokers");
+      getLog().debug("lookup(invokers) : "+obj);
+      Context invokersCtx = (Context) obj;
+      NamingEnumeration list = invokersCtx.list("");
+      while( list.hasMore() )
+      {
+         Object entry = list.next();
+         getLog().debug(" + "+entry);
+      }
+      ctx.close();
+
+      // Now test discovery with a non-existent partition name
+      env.setProperty(Context.PROVIDER_URL, "jnp://" + getServerHost() + ":65535/");
+      env.setProperty("jnp.partitionName", "__NotTheDefaultPartition__");
+      try
+      {
+         ctx = new InitialContext(env);
+         getLog().debug("Created InitialContext");
+         obj = ctx.lookup("invokers");
+         fail("Was able to lookup(invokers): "+obj);
+      }
+      catch(NamingException e)
+      {
+         getLog().debug("Partition specific discovery failed as expected", e);
+      }
+   }
+
+   /** Test naming discovery with an explicit port
+    * 
+    * @throws Exception
+    */ 
+   public void testDiscoveryPort() throws Exception
+   {
+      getLog().debug("+++ testDiscoveryPort");
+      Properties env = new Properties();
+      String serverHost = getServerHost();
+      env.setProperty(Context.PROVIDER_URL, "jnp://" + serverHost + ":65535/");
+      env.setProperty("jnp.localAddress", serverHost);      
+      env.setProperty("jnp.discoveryPort", "1102");
+      // Don't let the discovery packet off the test server so we don't
+      // get spurious responses from other servers on the network
+      env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
+      if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
+      {
+         // Server is not listening for discovery on std multicast address
+         // so we need to use the correct one
+         env.setProperty("jnp.discoveryGroup", DISCOVERY_GROUP);
+      }
+      getLog().debug("Creating InitialContext with env="+env);
+      InitialContext ctx = new InitialContext(env);
+      getLog().debug("Created InitialContext");
+      Object obj = ctx.lookup("invokers");
+      getLog().debug("lookup(invokers) : "+obj);
+      Context invokersCtx = (Context) obj;
+      NamingEnumeration list = invokersCtx.list("");
+      while( list.hasMore() )
+      {
+         Object entry = list.next();
+         getLog().debug(" + "+entry);
+      }
+      ctx.close();
+   }
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/HAJndiAutoDiscoveryUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Added: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartAutoDiscoveryUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartAutoDiscoveryUnitTestCase.java	                        (rev 0)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartAutoDiscoveryUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.naming.test;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+
+import org.jboss.test.naming.restart.NamingRestartTestBase;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * A NamingRestartUnitTestCase involving HA-JNDI autodiscovery.
+ * This test is separate from the other HA-JNDI tests
+ * so it can be excluded in tests of configs that disable HA-JNDI auto-discovery.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class NamingRestartAutoDiscoveryUnitTestCase extends NamingRestartTestBase
+{
+   private static final String DISCOVERY_ADDRESS = "230.9.9.9";
+   private static final String DISCOVERY_PORT = "19102";
+   
+   private static boolean deployed = false;
+   
+   public NamingRestartAutoDiscoveryUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(NamingRestartAutoDiscoveryUnitTestCase.class, null);
+   }
+   
+   @Override
+   protected boolean isDeployed()
+   {
+      return deployed;
+   }
+
+   @Override
+   protected void setDeployed(boolean deployed)
+   {
+      NamingRestartAutoDiscoveryUnitTestCase.deployed = deployed;
+   }
+   
+   public void testAutoDiscoveryLookupAfterHANamingRestart() throws Exception
+   {
+      log.info("Running testAutoDiscoveryLookupAfterHANamingRestart");
+      
+      lookupTest(createNamingEnvironment(DISCOVERY_ADDRESS, DISCOVERY_PORT));
+   }
+
+   private Properties createNamingEnvironment(String mcastAddress, String mcastPort)
+   {
+      Properties env = new Properties();
+//      env.setProperty(NamingContext.JNP_PARTITION_NAME, PARTITION_NAME);
+      env.setProperty(NamingContext.JNP_LOCAL_ADDRESS, getServerHost());
+      env.setProperty(NamingContext.JNP_DISCOVERY_GROUP, mcastAddress);
+      env.setProperty(NamingContext.JNP_DISCOVERY_PORT, mcastPort);
+      return env;
+   }
+
+}


Property changes on: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartAutoDiscoveryUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/NamingRestartUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -22,7 +22,6 @@
 
 package org.jboss.test.naming.test;
 
-import java.util.Hashtable;
 import java.util.Properties;
 
 import javax.naming.Binding;
@@ -34,7 +33,7 @@
 
 import junit.framework.Test;
 
-import org.jboss.test.JBossTestCase;
+import org.jboss.test.naming.restart.NamingRestartTestBase;
 import org.jboss.test.naming.restart.ObjectBinder;
 import org.jnp.interfaces.MarshalledValuePair;
 import org.jnp.interfaces.NamingContext;
@@ -45,12 +44,10 @@
  * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
  * @version $Revision$
  */
-public class NamingRestartUnitTestCase extends JBossTestCase
+public class NamingRestartUnitTestCase extends NamingRestartTestBase
 {
    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 BIND_NAME = "BindName";
    private static final String BIND_VALUE = "BindValue";
@@ -69,26 +66,16 @@
       return getDeploySetup(NamingRestartUnitTestCase.class, null);
    }
    
-   protected void setUp() throws Exception
+   @Override
+   protected boolean isDeployed()
    {
-      super.setUp();
-      
-      if (!deployed)
-         deploy("naming-restart.sar");
-      deployed = true;
+      return deployed;
    }
-   
-   
-   
-   protected void tearDown() throws Exception
+
+   @Override
+   protected void setDeployed(boolean deployed)
    {
-      if (deployed)
-      {
-         undeploy("naming-restart.sar");
-         deployed = false;
-      }
-      
-      super.tearDown();
+      NamingRestartUnitTestCase.deployed = deployed;
    }
 
    public void testBind() throws Exception
@@ -161,13 +148,6 @@
       
       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
    {
@@ -176,50 +156,6 @@
       lookupTest(createNamingEnvironment(NAMING_PORT));
    }
    
-   private void lookupTest(Hashtable env) throws Exception
-   {
-      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
-      // static map in org.jnp.interfaces.NamingContext.
-      
-      // Redeploy the naming service
-      redeployNaming();
-      
-      Context ctx2 = createInitialContext(env);
-      NamingException ne = null;
-      try
-      {
-         assertEquals(ObjectBinder.VALUE, ctx2.lookup(ObjectBinder.NAME));
-      }
-      catch (NamingException e)
-      {
-         // Cache the exception to fail the test later, after
-         // we check that we can recover
-         log.error("Caught NamingException", e);
-         ne = e;
-      }
-      
-      // We recover from failure
-      if (ne != null)
-      {
-         try
-         {
-            assertEquals(ObjectBinder.VALUE, ctx2.lookup(ObjectBinder.NAME));
-         }
-         catch (Exception e)
-         {
-            log.error("Failed to reacquire server");
-         }
-         // Now fail due to the earlier failure
-         fail(ne.getMessage());         
-      }
-      
-      // Confirm the original context is still good
-      assertEquals(ObjectBinder.VALUE, ctx1.lookup(ObjectBinder.NAME));
-   }
-   
    public void testList() throws Exception
    {
       log.info("Running testList()");
@@ -433,31 +369,4 @@
       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_LOCAL_ADDRESS, getServerHost());
-      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;
-      redeploy("naming-restart.sar");
-      deployed = true;
-   }
-
 }

Modified: branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java
===================================================================
--- branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java	2010-06-18 14:15:20 UTC (rev 106161)
+++ branches/Branch_No_Multicast/testsuite/src/main/org/jboss/test/naming/test/SimpleUnitTestCase.java	2010-06-18 14:32:40 UTC (rev 106162)
@@ -21,19 +21,18 @@
  */
 package org.jboss.test.naming.test;
 
-import org.jboss.test.JBossTestCase;
+import java.util.Properties;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
+import javax.naming.Name;
 import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.Name;
-import javax.naming.NameClassPair;
 
-import java.net.InetAddress;
-import java.util.Properties;
+import org.jboss.test.JBossTestCase;
 
 /** Simple unit tests for the jndi implementation. Note that there cannot
  * be any security related tests in this file as typically it is not run
@@ -41,9 +40,6 @@
  */
 public class SimpleUnitTestCase extends JBossTestCase
 {
-   private static final String DISCOVERY_TTL = System.getProperty("jbosstest.udp.ip_ttl", "1");
-   private static final String DISCOVERY_GROUP = System.getProperty("jbosstest.udpGroup", "");
-   
    /**
     * Constructor for the SimpleUnitTestCase object
     *
@@ -225,94 +221,6 @@
          getLog().debug("lookup(foo) failed as expected", e);
       }
    }
-
-   /** Test discovery with the partition name specified
-    *
-    * @throws Exception
-    */
-   public void testHaPartitionName() throws Exception
-   {
-      getLog().debug("+++ testHaPartitionName");
-      Properties env = new Properties();
-      String serverHost = getServerHost();
-      env.setProperty(Context.PROVIDER_URL, "jnp://" + serverHost + ":65535/");
-      env.setProperty("jnp.localAddress", serverHost);      
-      env.setProperty("jnp.partitionName", "DefaultPartition");
-      // Don't let the discovery packet off the test server so we don't
-      // get spurious responses from other servers on the network
-      env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
-      if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
-      {
-         // Server is not listening for discovery on std multicast address
-         // so we need to use the correct one
-         env.setProperty("jnp.discoveryGroup", DISCOVERY_GROUP);
-      }
-      getLog().debug("Creating InitialContext with env="+env);
-      InitialContext ctx = new InitialContext(env);
-      getLog().debug("Created InitialContext");
-      Object obj = ctx.lookup("invokers");
-      getLog().debug("lookup(invokers) : "+obj);
-      Context invokersCtx = (Context) obj;
-      NamingEnumeration list = invokersCtx.list("");
-      while( list.hasMore() )
-      {
-         Object entry = list.next();
-         getLog().debug(" + "+entry);
-      }
-      ctx.close();
-
-      // Now test discovery with a non-existent partition name
-      env.setProperty(Context.PROVIDER_URL, "jnp://" + getServerHost() + ":65535/");
-      env.setProperty("jnp.partitionName", "__NotTheDefaultPartition__");
-      try
-      {
-         ctx = new InitialContext(env);
-         getLog().debug("Created InitialContext");
-         obj = ctx.lookup("invokers");
-         fail("Was able to lookup(invokers): "+obj);
-      }
-      catch(NamingException e)
-      {
-         getLog().debug("Partition specific discovery failed as expected", e);
-      }
-   }
-
-   /** Test naming discovery with an explicit port
-    * 
-    * @throws Exception
-    */ 
-   public void testDiscoveryPort() throws Exception
-   {
-      getLog().debug("+++ testDiscoveryPort");
-      Properties env = new Properties();
-      String serverHost = getServerHost();
-      env.setProperty(Context.PROVIDER_URL, "jnp://" + serverHost + ":65535/");
-      env.setProperty("jnp.localAddress", serverHost);      
-      env.setProperty("jnp.discoveryPort", "1102");
-      // Don't let the discovery packet off the test server so we don't
-      // get spurious responses from other servers on the network
-      env.setProperty("jnp.discoveryTTL", DISCOVERY_TTL);
-      if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
-      {
-         // Server is not listening for discovery on std multicast address
-         // so we need to use the correct one
-         env.setProperty("jnp.discoveryGroup", DISCOVERY_GROUP);
-      }
-      getLog().debug("Creating InitialContext with env="+env);
-      InitialContext ctx = new InitialContext(env);
-      getLog().debug("Created InitialContext");
-      Object obj = ctx.lookup("invokers");
-      getLog().debug("lookup(invokers) : "+obj);
-      Context invokersCtx = (Context) obj;
-      NamingEnumeration list = invokersCtx.list("");
-      while( list.hasMore() )
-      {
-         Object entry = list.next();
-         getLog().debug(" + "+entry);
-      }
-      ctx.close();
-   }
-
    public void testHttpInvoker() throws Exception
    {
       getLog().debug("+++ testHttpInvoker");



More information about the jboss-cvs-commits mailing list