[jboss-cvs] JBossAS SVN: r64213 - in trunk/testsuite/src/main/org/jboss/test/cluster: multicfg and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 23 22:36:31 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-07-23 22:36:31 -0400 (Mon, 23 Jul 2007)
New Revision: 64213

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCaseNew.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/CacheInvalidationUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/StatefulPassivationExpirationUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/ClusterFileTransferTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DRMTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DistributedStateTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAPartitionStateTransferTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java
Log:
[JBAS-4552] Move cluster tests into cluster package
[JBAS-4553] Reorg cluster tests to prevent unnecessary repetition

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/BeanUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,290 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.ejb2.test;
+
+
+import java.util.Date;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+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.StatefulSessionHome;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Test SLSB for load-balancing behaviour
+ *
+ * @author  <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class BeanUnitTestCase extends JBossClusteredTestCase
+{
+   static boolean deployed = false;
+   public static int test = 0;
+   static Date startDate = new Date();
+   
+   protected final String namingFactory =
+   System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+   
+   protected final String providerURL =
+   System.getProperty(Context.PROVIDER_URL);
+   
+   public BeanUnitTestCase (String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(BeanUnitTestCase.class, "testbeancluster.jar");
+      return t1;
+   }
+
+   public void testStatelessBeanLoadBalancing() 
+      throws Exception
+   {       
+      getLog().debug(++test+"- "+"Trying the context...");
+      
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[0]);
+      InitialContext ctx = new InitialContext(env1);
+      
+      getLog().debug("Test Stateless Bean load-balancing");
+      getLog().debug("==================================");
+      getLog().debug(++test+"- "+"Looking up the home nextgen.StatelessSession...");
+      StatelessSessionHome  statelessSessionHome =
+      (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession");
+      if (statelessSessionHome!= null ) getLog().debug("ok");
+         getLog().debug(++test+"- "+"Calling create on StatelessSessionHome...");
+      StatelessSession statelessSession =
+      (StatelessSession)statelessSessionHome.create();
+      assertTrue("statelessSessionHome.create() != null", statelessSession != null);
+      getLog().debug("ok");
+      
+      getLog().debug(++test+"- "+"Calling getEJBHome() on StatelessSession...");
+      assertTrue("statelessSession.getEJBHome() != null", statelessSession.getEJBHome() != null);
+      getLog().debug("ok");
+      
+      getLog().debug(++test+"- "+"Reseting the number of calls made on beans (making 2 calls)... ");
+      for (int i=0; i<6; i++)
+      {
+         getLog().debug(++test+"- "+" Reseting number... ");
+         statelessSession.resetNumberOfCalls ();         
+      }
+      
+      getLog().debug(++test+"- "+"Now making 20 calls on this remote... ");
+      for (int i=0; i<20; i++)
+      {
+         getLog().debug(++test+"- "+" Calling remote... ");
+         statelessSession.makeCountedCall ();         
+      }
+      
+      getLog().debug(++test+"- "+"Getting the number of calls that have been performed on each bean... ");
+      long node1 = statelessSession.getCallCount();
+      getLog().debug(++test+"- "+"One node has received: " + node1);
+      
+      long node2 = statelessSession.getCallCount();
+      getLog().debug(++test+"- "+"The other node has received: " + node2);
+      
+      if (node1 == node2 &&
+          node1 == 10)
+      {
+         getLog().debug(++test+"- "+"Test is ok.");
+      }
+      else
+      {
+         getLog().debug(++test+"- "+"Something wrong has happened! Calls seems not to have been load-balanced.");
+         fail ("Calls have not been correctly load-balanced on the SLSB remote interface.");
+      }
+      
+      statelessSession.remove();
+      getLog().debug("ok");
+   }
+   
+   public void testRoundRobin() throws Exception
+   {
+      getLog().debug("+++ Enter testRoundRobin");
+      
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[0]);
+      InitialContext ctx = new InitialContext(env1);
+      
+      // Do 4 home lookups in case different lookups lead to different patterns
+      for (int i = 0; i < 4; i++)
+      {
+         StatelessSessionHome  home =
+            (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession");
+         assertTrue("home != null", home != null);
+         getLog().debug("lookup " + i + " ok");
+         
+         String last = null;
+         for (int j = 0; j < 10; j++)
+         {
+            StatelessSession slsb = home.create();
+            assertTrue("slsb != null", slsb != null);
+            getLog().debug("create " + j + " ok");
+            
+            for (int k = 0; k < 3; k++)
+            {
+               String cur = slsb.getBindAddress();
+               if (cur == null)
+               {
+                  getLog().debug("jboss.bind.address property not set; aborting");
+                  return;
+               }
+               
+               assertFalse("Target switched", cur.equals(last));
+               last = cur;
+            }
+            
+            getLog().debug("target switching " + j + " ok");
+         }
+      }
+      
+      getLog().debug("+++ Exit testRoundRobin");
+   }
+
+   public void testStatelessBeanColocation() throws Exception
+   {       
+      getLog().debug(++test+"- "+"Trying the context...");
+      
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[0]);
+      InitialContext ctx = new InitialContext(env1);
+      
+      getLog().debug("Test Stateless Bean colocation");
+      getLog().debug("==================================");
+      getLog().debug(++test+"- "+"Looking up the home nextgen.StatelessSession...");
+      StatelessSessionHome  statelessSessionHome =
+      (StatelessSessionHome) ctx.lookup("nextgen_StatelessSession");
+      if (statelessSessionHome!= null ) getLog().debug("ok");
+         getLog().debug(++test+"- "+"Calling create on StatelessSessionHome...");
+      StatelessSession statelessSession = (StatelessSession)statelessSessionHome.create();
+      assertTrue("statelessSessionHome.create() != null", statelessSession != null);
+      getLog().debug("ok");
+
+      getLog().debug(++test+"- "+"reset number of calls");
+      statelessSession.resetNumberOfCalls();
+      statelessSession.resetNumberOfCalls();
+
+      // This should make two calls on the same node
+      getLog().debug(++test+"- "+"callBusinessMethodB");
+      String jndiURL = urls[0] + "/nextgen_StatelessSession";
+      statelessSession.callBusinessMethodB(jndiURL);
+      
+      getLog().debug(++test+"- "+"Getting the number of calls that have been performed on each bean... ");
+      long node1 = statelessSession.getCallCount();
+      getLog().debug(++test+"- "+"One node has received: " + node1);
+      
+      long node2 = statelessSession.getCallCount();
+      getLog().debug(++test+"- "+"The other node has received: " + node2);
+      
+      if ((node1 == 2 && node2 == 0) || (node1 == 0 && node2 == 2))
+      {
+         getLog().debug(++test+"- "+"Test is ok.");
+      }
+      else
+      {
+         getLog().debug(++test+"- "+"Something wrong has happened! Calls should have been colocated.");
+         fail ("Calls have not been correctly colocated.");
+      }
+      getLog().debug("ok");
+   }            
+   
+   public void testStatefulBeanFailover() 
+   throws Exception
+   {       
+      getLog().debug(++test+"- "+"Trying the context...");
+      
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[0]);
+      InitialContext ctx = new InitialContext(env1);
+      
+      getLog().debug("Test Stateful Bean Failover");
+      getLog().debug("==================================");
+      getLog().debug(++test+"- "+"Looking up the home nextgen.StatefulSession...");
+      StatefulSessionHome  statefulSessionHome =
+      (StatefulSessionHome) ctx.lookup("nextgen_StatefulSession");
+      if (statefulSessionHome!= null ) getLog().debug("ok");
+         getLog().debug(++test+"- "+"Calling create on StatefulSessionHome...");
+      StatefulSession statefulSession =
+      (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
+      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
+      getLog().debug("ok");
+      
+      NodeAnswer node1 = statefulSession.getNodeState ();
+      getLog ().debug (node1);
+      
+      // Now we switch to the other node, simulating a failure on node 1
+      //
+      System.setProperty ("JBossCluster-DoFail", "once");
+      NodeAnswer node2 = statefulSession.getNodeState ();      
+      getLog ().debug (node2);
+      
+      assertTrue ("No failover has occured!", !node1.nodeId.equals (node2.nodeId));
+      
+      assertTrue ("Value is not identical on replicated node", "Bupple-Dupple".equals (node1.answer) &&
+                     node1.answer.equals (node2.answer) );
+
+      // we change our name to see if it replicates to node 1
+      //
+      statefulSession.setName ("Changed");
+      
+      // now we travel back on node 1
+      //
+      System.setProperty ("JBossCluster-DoFail", "once");
+      node1 = statefulSession.getNodeState ();
+      getLog ().debug (node1);
+      
+      assertTrue ("No failover has occured!", !node1.nodeId.equals (node2.nodeId));
+      
+      assertTrue ("Value is not identical on replicated node", "Changed".equals (node1.answer) );      
+      
+      statefulSession.remove();
+      getLog().debug("ok");
+   }  
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCaseNew.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/BeanUnitTestCaseNew.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCaseNew.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/BeanUnitTestCaseNew.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,207 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.ejb2.test;
+
+
+import java.util.Date;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+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.testbean.interfaces.StatelessSessionHome;
+import org.jboss.test.testbean.interfaces.StatefulSessionHome;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Test SLSB for load-balancing behaviour
+ *
+ * @author  <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>12 avril 2002 Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ * <UL>
+ * <LI>Anil.Saldhana at jboss.org</LI>
+ * </UL>
+ */
+
+public class BeanUnitTestCaseNew extends JBossClusteredTestCase
+{
+   static boolean deployed = false;
+   public static int test = 0;
+   static Date startDate = new Date();
+   
+   private String[] servernames= {"jnp://localhost:1099", "jnp://localhost:1199"};
+   
+   protected final String namingFactory =
+   System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+   
+   protected final String providerURL =
+   System.getProperty(Context.PROVIDER_URL);
+   
+   public BeanUnitTestCaseNew (String name) {
+      super(name);
+      try{
+      	 //Setting servernames gives us flexibility.
+      	//Further flexibility can be brought by reading the servernames
+      	//from a properties file
+          this.setServerNames(servernames);
+      }catch(Exception e){
+          	getLog().debug(  "Passing servernames croacked");
+          }
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(BeanUnitTestCaseNew.class, "testbeancluster.jar");
+      return t1;
+   }
+
+   public void testStatelessBeanLoadBalancing() 
+   throws Exception
+   {   
+   	  getLog().debug(++test+"- "+"Trying the context...");
+      
+      Context ctx = new InitialContext();
+      getLog().debug("OK");
+      
+      ///*
+      getLog().debug("");
+      getLog().debug("Test Stateless Bean load-balancing");
+      getLog().debug("==================================");
+      getLog().debug("");
+      getLog().debug(++test+"- "+"Looking up the home nextgen.StatelessSession...");
+      StatelessSessionHome  statelessSessionHome =
+      (StatelessSessionHome) ctx.lookup("nextgen.StatelessSession");
+      if (statelessSessionHome!= null ) getLog().debug("ok");
+      getLog().debug(++test+"- "+"Calling create on StatelessSessionHome...");
+      StatelessSession statelessSession =
+      (StatelessSession)statelessSessionHome.create();
+      assertTrue("statelessSessionHome.create() != null", statelessSession != null);
+      getLog().debug("ok");
+      
+      getLog().debug(++test+"- "+"Calling getEJBHome() on StatelessSession...");
+      assertTrue("statelessSession.getEJBHome() != null", statelessSession.getEJBHome() != null);
+      getLog().debug("ok");
+      
+      getLog().debug(++test+"- "+"Reseting the number of calls made on beans (making 2 calls)... ");
+      for (int i=0; i<6; i++)
+      {
+         getLog().debug(++test+"- "+" Reseting number... ");
+         statelessSession.resetNumberOfCalls ();         
+      }
+      
+      getLog().debug(++test+"- "+"Now making 20 calls on this remote... ");
+      for (int i=0; i<20; i++)
+      {
+         getLog().debug(++test+"- "+" Calling remote... ");
+         statelessSession.makeCountedCall ();         
+      }
+      
+      getLog().debug(++test+"- "+"Getting the number of calls that have been performed on each bean... ");
+      long node1 = statelessSession.getCallCount();
+      getLog().debug(++test+"- "+"One node has received: " + node1);
+      
+      long node2 = statelessSession.getCallCount();
+      getLog().debug(++test+"- "+"The other node has received: " + node2);
+      
+      if (node1 == node2 &&
+          node1 == 10)
+      {
+         getLog().debug(++test+"- "+"Test is ok.");
+      }
+      else
+      {
+         getLog().debug(++test+"- "+"Something wrong has happened! Calls seems not to have been load-balanced.");
+         fail ("Calls have not been correctly load-balanced on the SLSB remote interface.");
+      }
+      
+      statelessSession.remove();
+      getLog().debug("ok");
+   }            
+   
+   public void testStatefulBeanFailover() 
+   throws Exception
+   {       
+      getLog().debug(++test+"- "+"Trying the context...");
+      
+      Context ctx = new InitialContext();
+      getLog().debug("OK");
+      
+      ///*
+      getLog().debug("");
+      getLog().debug("Test Stateful Bean Failover");
+      getLog().debug("==================================");
+      getLog().debug("");
+      getLog().debug(++test+"- "+"Looking up the home nextgen.StatefulSession...");
+      StatefulSessionHome  statefulSessionHome =
+      (StatefulSessionHome) ctx.lookup("nextgen.StatefulSession");
+      if (statefulSessionHome!= null ) getLog().debug("ok");
+         getLog().debug(++test+"- "+"Calling create on StatefulSessionHome...");
+      StatefulSession statefulSession =
+      (StatefulSession)statefulSessionHome.create("Bupple-Dupple");
+      assertTrue("statefulSessionHome.create() != null", statefulSession != null);
+      getLog().debug("ok");
+      
+      NodeAnswer node1 = statefulSession.getNodeState ();
+      getLog ().debug (node1);
+      
+      // Now we switch to the other node, simulating a failure on node 1
+      //
+      System.setProperty ("JBossCluster-DoFail", "once");
+      NodeAnswer node2 = statefulSession.getNodeState ();      
+      getLog ().debug (node2);
+      
+      assertTrue ("No failover has occured!", !node1.nodeId.equals (node2.nodeId));
+      
+      assertTrue ("Value is not identical on replicated node", "Bupple-Dupple".equals (node1.answer) &&
+                     node1.answer.equals (node2.answer) );
+
+      // we change our name to see if it replicates to node 1
+      //
+      statefulSession.setName ("Changed");
+      
+      // now we travel back on node 1
+      //
+      System.setProperty ("JBossCluster-DoFail", "once");
+      node1 = statefulSession.getNodeState ();
+      getLog ().debug (node1);
+      
+      assertTrue ("No failover has occured!", !node1.nodeId.equals (node2.nodeId));
+      
+      assertTrue ("Value is not identical on replicated node", "Changed".equals (node1.answer) );      
+      
+      statefulSession.remove();
+      getLog().debug("ok");
+   }            
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/CacheInvalidationUnitTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/CacheInvalidationUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/CacheInvalidationUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/CacheInvalidationUnitTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,101 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.ejb2.test;
+
+import java.util.Properties;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.ejb2.basic.interfaces.NodeAnswer;
+import org.jboss.test.cluster.ejb2.basic.interfaces.SessionToEntity;
+import org.jboss.test.cluster.ejb2.basic.interfaces.SessionToEntityHome;
+import org.jboss.test.cluster.testutil.DBSetup;
+import org.jboss.test.testbean.interfaces.AComplexPK;
+
+/** Tests of the clustering cache invalidation framework
+ *
+ * @author  Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class CacheInvalidationUnitTestCase extends JBossClusteredTestCase
+{
+   public CacheInvalidationUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+      Test t1 = getDeploySetup(CacheInvalidationUnitTestCase.class,
+         "test-cif.ear");
+
+      suite.addTest(t1);
+
+      // Create an initializer for the test suite
+      DBSetup wrapper = new DBSetup(suite);
+      return wrapper;
+   }
+
+   public void testCacheInvalidation()
+      throws Exception
+   {
+      log.info("+++ testCacheInvalidation");
+
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[0]);
+      InitialContext ctx1 = new InitialContext(env1);
+
+      SessionToEntityHome home1 =
+         (SessionToEntityHome) ctx1.lookup("cif.StatefulSession");
+      AComplexPK key = new AComplexPK(true, 0, 0, 0, "testCacheInvalidation");
+      SessionToEntity bean1 = home1.create(key);
+      String msg = bean1.createEntity();
+      log.info("create#1, "+msg);
+      // Call accessEntity twice to validate data is consistent on both nodes
+      NodeAnswer answer1 = bean1.accessEntity();
+      log.info("Answer1: "+answer1);
+      NodeAnswer answer2 = bean1.accessEntity();
+      log.info("Answer2: "+answer2);
+      assertTrue("accessCount == 2", bean1.getAccessCount() == 2);
+      assertTrue("answer1.nodeId != answer2.nodeId",
+         answer1.nodeId.equals(answer2.nodeId) == false);
+
+      // Call validateAccessCount twice to validate data is consistent on both nodes
+      answer1 = bean1.validateAccessCount(2);
+      log.info(answer1);
+      answer2 = bean1.validateAccessCount(2);
+      log.info(answer2);
+      assertTrue("answer1.nodeId != answer2.nodeId",
+         answer1.nodeId.equals(answer2.nodeId) == false);
+      bean1.remove();
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/StatefulPassivationExpirationUnitTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/testbeancluster/test/StatefulPassivationExpirationUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/StatefulPassivationExpirationUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/ejb2/test/StatefulPassivationExpirationUnitTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,211 @@
+/*
+ * 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.ejb2.test;
+
+
+import java.util.Date;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.cluster.ejb2.basic.interfaces.NodeAnswer;
+import org.jboss.test.cluster.ejb2.basic.interfaces.StatefulSession;
+import org.jboss.test.testbean.interfaces.StatefulSessionHome;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Test passivation and expiration of clustered SLSBs.
+ *
+ * @author  <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @author Scott.Stark at jboss.org
+ * @author Brian Stansberry
+ * 
+ * @version $Revision: 56924 $
+ */
+public class StatefulPassivationExpirationUnitTestCase extends JBossClusteredTestCase
+{
+   static boolean deployed = false;
+   public static int test = 0;
+   static Date startDate = new Date();
+   
+   protected final String namingFactory =
+   System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+   
+   protected final String providerURL =
+   System.getProperty(Context.PROVIDER_URL);
+   
+   public StatefulPassivationExpirationUnitTestCase (String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(StatefulPassivationExpirationUnitTestCase.class, "testbeancluster.jar");
+      return t1;
+   }
+
+   /**
+    * The test creates 500 stateful session beans, executes some calls to
+    * stress state replication, waits for passivation and exipration to kick
+    * in, and then updates the sessions to produce the session removal
+    * conflict seen in JBAS-1560. This is sensative to timing issues so a
+    * failure in activation can show up; we catch any NoSuchObjectExceptio
+    * to handle this.
+    * 
+    * @throws Exception
+    */ 
+   public void testStatefulPassivationExpiration()
+      throws Exception
+   {
+      log.info("+++ testStatefulPassivationExpiration");
+
+      // Connect to the server0 JNDI
+      String[] urls = getNamingURLs();
+      Properties env1 = new Properties();
+      env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+         "org.jnp.interfaces.NamingContextFactory");
+      env1.setProperty(Context.PROVIDER_URL, urls[0]);
+      InitialContext ctx = new InitialContext(env1);
+
+      int beanCount = 500;
+      StatefulSessionHome home =
+         (StatefulSessionHome) ctx.lookup("nextgen_ExpiredStatefulSession");
+      long start = System.currentTimeMillis();
+      log.info("Start bean creation");
+      StatefulSession[] beans = new StatefulSession[beanCount];
+      long[] accessStamp = new long[beanCount];
+      for(int n = 0; n < beans.length; n ++)
+      {
+         beans[n] = (StatefulSession) home.create("testStatefulPassivationExpiration#"+n);
+         accessStamp[n] = System.currentTimeMillis();
+      }
+      long end = System.currentTimeMillis();
+      log.info("End bean creation, elapsed="+(end - start));
+
+      int N = 5000;
+      long min = 99999, max = 0, maxInactive = 0;
+      for(int n = 0; n < N; n ++)
+      {
+         int id = n % beans.length;
+         StatefulSession bean = beans[id];
+         if (bean == null)
+            continue;  // bean timed out and removed
+         String name = "testStatefulPassiviationExpiration#"+id;
+         long callStart = System.currentTimeMillis();
+         long inactive = callStart - accessStamp[id];
+         try
+         {
+            bean.setName(name);
+            NodeAnswer node = bean.getNodeState();
+            long now = System.currentTimeMillis();            
+            long elapsed = now - callStart;
+            accessStamp[id] = now;
+            assertTrue("NodeAnswer == "+name, node.answer.equals(name));
+            min = Math.min(min, elapsed);
+            max = Math.max(max, elapsed);
+            maxInactive = Math.max(maxInactive, inactive);
+            log.debug(n+", elapsed="+elapsed+", inactive="+inactive);
+         }
+         catch (java.rmi.NoSuchObjectException nso)
+         {
+            log.debug(n+" Caught NoSuchObjectException on bean " + id + " -- inactive time = " + inactive);
+            // Remove the bean as it will never succeed again
+            beans[id] = null;
+         }
+      }
+      log.info(N+" calls complete, max="+max+", min="+min+", maxInactive="+maxInactive);
+
+      Thread.sleep(15000);
+      start = System.currentTimeMillis();
+      for(int n = 0; n < beans.length; n ++)
+      {
+         beans[n] = (StatefulSession) home.create("testStatefulPassivationExpiration#"+n);
+         accessStamp[n] = System.currentTimeMillis();
+      }
+      end = System.currentTimeMillis();
+      log.info("End second round bean creation, elapsed="+(end - start));
+      for(int n = 0; n < N; n ++)
+      {
+         int id = n % beans.length;
+         StatefulSession bean = beans[id];
+         if (bean == null)
+            continue;  // bean timed out and removed
+         String name = "testStatefulPassiviationExpiration#"+id;
+         long callStart = System.currentTimeMillis();
+         long inactive = callStart - accessStamp[id];
+         try
+         {
+            bean.setName(name);
+            NodeAnswer node = bean.getNodeState();
+            long now = System.currentTimeMillis();
+            long elapsed = now - callStart;
+            accessStamp[id] = now;
+            assertTrue("NodeAnswer == "+name, node.answer.equals(name));
+            min = Math.min(min, elapsed);
+            max = Math.max(max, elapsed);
+            maxInactive = Math.max(maxInactive, inactive);
+            log.debug(n+", elapsed="+elapsed+", inactive="+inactive);
+         }
+         catch (java.rmi.NoSuchObjectException nso)
+         {
+            log.debug(n+" Caught NoSuchObjectException on bean " + id + " -- inactive time = " + (callStart - accessStamp[id]));
+            // Remove the bean as it will never succeed again
+            beans[id] = null;
+         }
+      }
+      log.info(N+" calls complete, max="+max+", min="+min+", maxInactive="+maxInactive);
+      // BES -- max call time check removed, as it can randomly fail if there is a long GC pause
+      // assertTrue("max < 3000", max < 3000 );
+
+      for(int n = 0; n < beans.length; n ++)
+      {
+         try
+         {
+            if (beans[n] != null)
+               beans[n].remove();
+         }
+         catch (java.rmi.NoSuchObjectException nso)
+         {
+            log.debug("Caught NoSuchObjectException removing bean " + n);
+         }
+      }
+      
+      // Confirm that the bean cache is empty
+      String oNameS = "jboss.j2ee:jndiName=ExpiredStatefulSession,plugin=cache,service=EJB";
+      ObjectName oName = new ObjectName(oNameS);
+      RMIAdaptor[] adaptors = getAdaptors();      
+      Long cacheCount = (Long) adaptors[0].getAttribute(oName, "CacheSize");
+      assertEquals("CacheSize is zero", 0, cacheCount.longValue());
+      // Checking the passivated count is invalid, as it doesn't get reduced
+      // when remove() is called on a bean -- only when the passivation cleanup
+      // thread runs
+      //cacheCount = (Long) adaptors[0].getAttribute(oName, "PassivatedCount");
+      //assertEquals("PassivatedCount is zero", 0, cacheCount.longValue());
+   }
+}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/ClusterFileTransferTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/ClusterFileTransferTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/ClusterFileTransferTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,133 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.io.File;
+import java.io.Reader;
+import java.io.FileReader;
+import java.io.FileOutputStream;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author  Scott Marlow <smarlow at novell.com>
+ *
+ */
+
+public class ClusterFileTransferTestCase extends TestCase
+{
+   // NODExSERVERSTR properties are defined in the testsuite/build.xml
+   private static String NODE0SERVERSTR = System.getProperty( "jbosstest.cluster.node0.serverroot" );
+   private static String NODE1SERVERSTR = System.getProperty( "jbosstest.cluster.node1.serverroot" );
+   
+   private static final File NODE0SERVERFOLDER = new File(NODE0SERVERSTR);
+   private static final File NODE0FARMFOLDER = new File(NODE0SERVERFOLDER, "farm");
+   private static final File NODE1SERVERFOLDER = new File(NODE1SERVERSTR);
+   private static final File NODE1FARMFOLDER = new File(NODE1SERVERFOLDER, "farm");
+
+   // Processing file /home/smarlow/apps/CrimePortalBeans.jar
+   int [] fileAsBunchaIntValues = {80,75,3,4,10,0,0,0,0,0,241,74,213,48,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,77,69,84,65,45,73,78,70,47,80,75,3,4,20,0,8,0,8,0,240,74,213,48,0,0,0,0,0,0,0,0,0,0,0,0,20,0,0,0,77,69,84,65,45,73,78,70,47,77,65,78,73,70,69,83,84,46,77,70,243,77,204,203,76,75,45,46,209,13,75,45,42,206,204,207,179,82,48,212,51,224,229,114,204,67,18,113,44,72,76,206,72,85,0,138,1,37,77,245,140,21,120,185,156,139,82,19,75,82,83,116,157,42,65,26,76,244,140,116,147,140,44,20,52,130,75,243,20,124,51,147,139,242,139,43,139,75,82,115,139,21,60,243,146,245,52,121,185,120,185,0,80,75,7,8,64,231,109,35,92,0,0,0,104,0,0,0,80,75,3,4,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,80,75,3,4,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,80,75,3,4,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,27,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47!
 ,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,80,75,3,4,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,42,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,109,112,108,101,109,101,110,116,97,116,105,111,110,47,80,75,3,4,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,38,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,110,116,101,114,102,97,99,101,115,47,80,75,3,4,20,0,8,0,8,0,241,74,213,48,0,0,0,0,0,0,0,0,0,0,0,0,63,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,109,112,108,101,109,101,110,116,97,116,105,111,110,47,71,97,110,103,68,105,115,112,117,116,101,66,101,97,110,46,99,108,97,115,115,157,84,105,111,211,64,16,125,155,166,117,18,76,122,64,203,93,194,157,163,212,220,87,185,218,0,133,170,2,68,81,37,62,110,194,54,184,36,118,228,108,74,249,81,124,0,65,145,64,226,7,240,163,16,!
 111,109,227,38,105,17,18,138,236,221,157,157,121,243,230,205,56,63,127
,125,251,1,96,22,75,57,140,97,38,139,81,156,207,242,232,88,184,144,67,26,51,25,92,52,235,37,243,186,108,94,87,114,184,138,107,25,92,207,224,70,6,55,77,196,45,11,115,22,110,91,184,35,96,213,125,79,171,77,45,112,120,121,93,110,200,77,71,173,215,156,21,213,233,184,190,87,141,238,230,4,108,25,4,170,163,213,235,197,238,251,142,128,88,18,24,185,237,122,174,190,43,48,84,44,173,10,164,171,254,107,37,48,186,236,122,234,105,183,85,83,193,75,89,107,210,50,177,236,215,101,115,85,6,174,57,199,198,180,126,227,18,103,110,185,30,184,45,213,246,3,45,155,78,77,73,175,227,172,73,183,233,111,168,192,113,91,237,166,106,41,79,75,77,46,206,162,244,26,15,220,78,187,171,213,2,29,73,106,212,83,239,12,159,249,152,27,97,139,75,37,82,203,241,34,50,50,199,120,67,233,167,181,249,62,254,164,76,183,44,75,173,6,74,106,18,202,61,220,172,171,182,73,212,177,112,55,186,123,161,90,36,34,176,135,251,249,186,118,55,66,79,155,167,231,146,250,68,199,241,142,210,253,114,9,28,43,254,93,75,163,85,110,197,239,6,117,245,2!
 00,53,82,236,31,40,108,214,132,218,152,194,1,27,251,49,105,225,158,141,251,152,23,152,50,23,78,147,222,206,138,14,92,175,177,208,93,91,83,129,192,228,75,159,242,21,254,180,168,208,96,141,183,10,54,22,80,53,175,7,54,30,226,145,133,69,27,143,241,68,160,208,147,112,54,145,160,80,44,148,10,108,84,211,232,56,61,224,18,41,81,220,118,56,183,224,251,111,171,50,208,33,227,29,18,36,158,54,38,176,79,224,230,127,183,89,96,108,187,236,103,181,117,85,167,190,147,59,212,141,92,15,109,219,163,162,146,166,246,193,172,188,167,76,45,78,129,223,53,96,97,175,28,215,119,158,83,84,77,105,149,108,113,186,70,100,187,173,60,214,58,19,117,179,87,249,185,210,14,83,212,12,198,29,225,12,254,253,54,163,253,200,194,198,23,119,250,209,99,223,46,116,248,157,182,205,169,201,66,38,119,163,179,138,19,252,176,199,192,121,68,138,63,170,206,191,137,148,25,32,174,25,218,57,79,124,31,228,233,6,134,184,3,114,229,175,16,229,236,23,164,62,134,190,135,140,141,171,241,79,195,198,97,238,236,200,19,71,112,148,43,39,27,211!
 ,49,74,3,195,196,1,42,229,87,159,145,58,46,9,243,9,67,223,145,126,245,
21,195,19,35,91,176,202,180,111,33,179,133,236,22,115,241,240,33,73,147,15,67,199,8,60,142,179,36,107,82,77,133,169,43,113,42,179,59,78,242,252,175,65,129,197,69,73,29,250,24,66,195,253,112,35,161,241,64,15,227,225,132,241,73,218,83,97,240,253,184,238,60,121,78,236,49,156,250,107,143,72,29,101,245,211,216,203,228,219,104,249,24,237,20,159,52,45,167,249,156,73,244,188,30,147,202,26,92,155,184,131,114,158,34,228,233,30,184,108,66,238,108,2,82,9,207,124,62,14,84,85,236,9,20,73,224,185,127,7,206,236,26,88,68,41,14,92,10,7,37,150,99,175,145,163,242,5,249,65,57,46,144,251,37,202,113,185,167,71,249,164,71,249,112,208,76,143,202,97,92,229,55,80,75,7,8,88,200,183,43,60,3,0,0,160,6,0,0,80,75,3,4,20,0,8,0,8,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,110,116,101,114,102,97,99,101,115,47,71,97,110,103,68,105,115,112,117,116,101,46,99,108,97,115,115,77,143,77,78,195,48,16,133,223,!
 180,161,134,242,211,34,54,28,161,108,106,113,4,16,165,82,22,69,130,19,56,97,90,57,74,236,200,118,74,185,26,11,14,192,161,16,147,74,69,93,140,70,239,211,123,163,121,63,191,95,223,0,230,152,42,92,40,92,42,92,17,38,142,63,150,221,103,124,8,129,99,226,119,66,54,203,239,114,194,120,177,43,185,77,214,187,168,48,33,92,111,56,173,138,131,173,143,16,134,179,189,243,205,119,161,228,103,91,51,97,186,52,110,243,100,99,219,37,158,87,102,107,8,247,101,176,13,183,62,36,83,235,130,141,139,122,109,108,237,183,28,180,117,137,195,218,148,28,245,81,80,206,244,81,93,11,210,47,69,197,101,34,220,244,104,167,185,42,244,34,127,60,208,219,189,49,52,86,191,114,227,19,255,127,61,34,16,6,50,67,233,60,200,164,23,78,68,141,68,101,178,149,144,83,156,29,19,153,113,239,197,249,31,80,75,7,8,114,234,130,39,222,0,0,0,42,1,0,0,80,75,3,4,20,0,8,0,8,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,59,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,110,116,101,1!
 14,102,97,99,101,115,47,71,97,110,103,68,105,115,112,117,116,101,72,11
1,109,101,46,99,108,97,115,115,149,80,187,78,3,65,12,28,135,112,11,9,143,32,81,192,31,36,77,92,81,209,1,1,20,69,66,130,47,216,91,57,209,158,238,110,79,123,155,40,223,70,193,7,240,81,8,95,144,2,45,133,139,25,207,120,108,127,126,189,127,0,152,98,100,48,52,56,49,56,37,100,46,138,77,66,184,25,79,22,46,250,74,154,16,147,45,57,23,91,183,188,180,190,12,27,137,236,235,36,113,105,157,180,252,100,235,213,131,111,155,117,146,91,194,96,182,117,210,36,31,234,214,224,204,224,92,169,183,176,142,78,30,125,169,115,47,255,200,159,67,37,211,194,110,172,198,253,59,171,51,19,70,157,157,75,165,249,37,47,196,37,194,69,71,109,89,138,156,103,243,187,31,217,213,78,22,43,207,175,82,133,36,251,37,9,215,191,242,251,221,237,251,94,70,32,244,180,14,244,77,212,39,244,113,168,40,83,148,41,111,112,164,232,88,81,15,131,111,80,75,7,8,41,67,208,147,219,0,0,0,77,1,0,0,80,75,3,4,20,0,8,0,8,0,123,130,120,48,0,0,0,0,0,0,0,0,0,0,0,0,20,0,0,0,77,69,84,65,45,73,78,70,47,101,106,98,45,106,97,114,46,120,109,108,157,82,2!
 01,110,194,48,16,189,243,21,174,207,141,7,144,42,209,202,4,137,69,45,85,23,36,232,161,39,100,146,1,140,18,59,242,56,85,249,251,58,64,83,34,212,30,154,131,165,204,248,45,243,198,114,240,153,103,236,3,29,105,107,250,188,35,218,156,161,73,108,170,205,166,207,167,243,215,168,215,187,185,141,58,156,145,87,38,85,153,53,216,231,123,36,62,136,91,242,106,252,58,90,188,207,38,12,119,171,104,167,28,155,189,13,159,166,35,198,35,128,121,105,216,179,78,156,165,61,121,204,233,154,77,77,34,0,198,139,49,155,24,143,174,112,154,144,61,170,15,53,68,101,136,117,69,27,96,242,194,89,139,253,246,241,173,247,197,29,192,46,128,4,149,70,36,54,135,212,167,112,210,95,118,151,109,17,254,121,240,118,42,197,7,182,195,33,177,150,141,86,149,100,92,43,73,66,170,18,136,27,218,50,69,74,156,46,124,213,25,101,101,152,195,133,92,216,90,233,204,134,204,152,71,242,18,206,111,53,241,149,7,163,114,140,239,149,217,140,53,21,165,71,9,117,181,121,121,107,67,41,16,229,88,88,231,85,38,14,30,197,183,152,208,149,251,181,74,!
 144,196,25,221,67,64,73,56,96,155,116,14,115,235,255,65,40,225,132,188
,28,37,201,20,209,159,140,121,145,97,30,98,86,85,24,231,172,213,138,143,147,31,73,154,228,167,244,35,191,47,48,158,7,52,174,203,76,66,163,220,68,120,23,132,85,226,235,246,200,6,85,109,208,73,184,232,253,172,25,26,123,14,134,46,94,68,75,66,253,114,190,0,80,75,7,8,136,247,178,11,113,1,0,0,29,3,0,0,80,75,3,4,20,0,8,0,8,0,17,114,211,48,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,77,69,84,65,45,73,78,70,47,106,98,111,115,115,46,120,109,108,205,82,193,82,194,48,16,189,247,43,98,239,105,20,46,142,19,202,8,5,71,198,17,70,202,193,19,147,182,219,18,12,73,39,73,169,126,155,7,63,201,95,48,20,168,138,227,197,147,199,125,251,222,102,223,230,189,191,190,209,254,243,70,160,45,104,195,149,236,249,23,193,185,143,64,166,42,227,178,232,249,139,120,140,47,253,126,232,209,179,104,58,140,31,103,35,180,78,148,49,104,182,24,220,221,14,61,132,144,143,9,153,12,28,70,72,20,71,104,50,152,206,231,168,27,116,8,25,221,251,13,97,101,109,121,69,72,93,215,65,35,14,148,46,200,186,3,64,50,155,145,6,90,118,151,157,192,85,1!
 26,232,121,180,65,66,39,165,32,45,232,82,115,3,56,1,38,27,16,81,3,102,183,108,83,236,106,88,39,88,178,13,132,55,76,22,17,55,101,101,129,146,22,61,210,82,81,25,55,14,178,48,214,149,35,124,214,7,70,75,193,169,146,57,47,90,188,233,149,76,91,110,221,187,251,169,17,228,172,18,118,118,68,41,57,33,124,19,239,182,199,66,177,12,39,76,48,153,2,46,149,224,233,75,232,78,113,56,202,138,5,185,118,194,90,233,167,128,239,140,231,44,5,19,140,185,54,246,122,203,184,96,137,112,107,255,58,170,117,65,78,109,184,223,195,248,95,155,124,80,149,204,30,84,194,229,159,12,98,236,76,238,91,95,194,225,50,240,35,63,148,28,210,245,1,80,75,7,8,178,77,114,2,77,1,0,0,251,2,0,0,80,75,1,2,20,3,10,0,0,0,0,0,241,74,213,48,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,16,0,237,65,0,0,0,0,77,69,84,65,45,73,78,70,47,80,75,1,2,20,3,20,0,8,0,8,0,240,74,213,48,64,231,109,35,92,0,0,0,104,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,164,129,39,0,0,0,77,69,84,65,45,73,78,70,47,77,65,78,73,70,69,83,84,46,77,70,80,75,1,2,20,3,10,0,0,0,0,0!
 ,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,16,0,237,6
5,197,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,80,75,1,2,20,3,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,0,0,0,0,0,0,16,0,237,65,239,0,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,80,75,1,2,20,3,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0,0,0,0,16,0,237,65,31,1,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,80,75,1,2,20,3,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,42,0,0,0,0,0,0,0,0,0,16,0,237,65,88,1,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,109,112,108,101,109,101,110,116,97,116,105,111,110,47,80,75,1,2,20,3,10,0,0,0,0,0,188,82,212,48,0,0,0,0,0,0,0,0,0,0,0,0,38,0,0,0,0,0,0,0,0,0,16,0,237,65,160,1,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,110,116,101,114,102,97,99,101,115,47,80,75,1,2,20,3,20,0,8,0,8,0,241,7!
 4,213,48,88,200,183,43,60,3,0,0,160,6,0,0,63,0,0,0,0,0,0,0,0,0,0,0,164,129,228,1,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,109,112,108,101,109,101,110,116,97,116,105,111,110,47,71,97,110,103,68,105,115,112,117,116,101,66,101,97,110,46,99,108,97,115,115,80,75,1,2,20,3,20,0,8,0,8,0,188,82,212,48,114,234,130,39,222,0,0,0,42,1,0,0,55,0,0,0,0,0,0,0,0,0,0,0,164,129,141,5,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,110,116,101,114,102,97,99,101,115,47,71,97,110,103,68,105,115,112,117,116,101,46,99,108,97,115,115,80,75,1,2,20,3,20,0,8,0,8,0,188,82,212,48,41,67,208,147,219,0,0,0,77,1,0,0,59,0,0,0,0,0,0,0,0,0,0,0,164,129,208,6,0,0,99,114,105,109,101,112,111,114,116,97,108,47,98,101,97,110,115,47,102,97,105,108,111,118,101,114,47,105,110,116,101,114,102,97,99,101,115,47,71,97,110,103,68,105,115,112,117,116,101,72,111,109,101,46,99,108,97,115,115,80,75,1,2,2!
 0,3,20,0,8,0,8,0,123,130,120,48,136,247,178,11,113,1,0,0,29,3,0,0,20,0
,0,0,0,0,0,0,0,0,0,0,164,129,20,8,0,0,77,69,84,65,45,73,78,70,47,101,106,98,45,106,97,114,46,120,109,108,80,75,1,2,20,3,20,0,8,0,8,0,17,114,211,48,178,77,114,2,77,1,0,0,251,2,0,0,18,0,0,0,0,0,0,0,0,0,0,0,164,129,199,9,0,0,77,69,84,65,45,73,78,70,47,106,98,111,115,115,46,120,109,108,80,75,5,6,0,0,0,0,12,0,12,0,165,3,0,0,84,11,0,0,0,0
+   };
+
+
+   public ClusterFileTransferTestCase(String testCaseName)
+   {
+      super(testCaseName);
+   }
+
+   public void setUp()
+   {
+
+   }
+
+   public void tearDown()
+   {
+   }
+
+   public void testFarmDeploy() throws Exception
+   {
+
+      File node1File = new File(NODE1FARMFOLDER,"farmtestfile.jar");
+      File node0File = new File(NODE0FARMFOLDER,"farmtestfile.jar");
+      if(node1File.delete() ||              // ensure target of farm deploy doesn't exist
+         node0File.delete())
+         Thread.sleep(3000);                // wait for app to undeploy
+      // generate test file to be farm deployed (note the file cannot be deployed but should be propagated across farm)
+      generateTestArchive(node0File, fileAsBunchaIntValues);
+
+      int retry = 15;
+      while (!node1File.exists() && (retry-- > 0)  ) {
+         Thread.sleep(1000);
+      }
+
+      Thread.sleep(3000);                   // give the scanner time to pick up the app
+
+      assertTrue("farm deployment test file "+node0File +" did not propagate to " + node1File,node1File.exists());
+      verifyFilesAreEqual(node0File, node1File);
+
+      // delete app
+      assertTrue("Deleted " + node1File, node1File.delete());
+      retry = 15;
+      while (node0File.exists() && (retry-- > 0)  ) {
+         Thread.sleep(1000);
+      }
+      assertFalse(node0File + " removed", node0File.exists());
+
+      generateTestArchive(node1File, fileAsBunchaIntValues);
+      retry = 15;
+      while (!node0File.exists() && (retry-- > 0)  ) {
+         Thread.sleep(1000);
+      }
+      Thread.sleep(3000);                   // give the scanner time to pick up the app
+      assertTrue("farm deployment test file "+node1File +" did not propagate to " + node0File,node0File.exists());
+      verifyFilesAreEqual(node0File, node1File);
+   }
+
+   public void generateTestArchive(File outputFile, int[] pattern) throws Exception
+   {
+      outputFile.delete();
+      outputFile.createNewFile();
+      FileOutputStream writer = new FileOutputStream(outputFile);
+      for (int looper = 0; looper < pattern.length; looper++ )
+         writer.write(pattern[looper]);
+      writer.close();
+   }
+
+
+   public void verifyFilesAreEqual(File file1, File file2) throws Exception
+   {
+      assertTrue("farm deployment test file1 length ("+file1.length()+") not equal to file2 length("+file2.length()+")", file1.length() == file2.length());
+      Reader reader1 = new FileReader(file1);
+      Reader reader2 = new FileReader(file2);
+      int val1, val2;
+      while((val1 = reader1.read()) > -1)
+      {
+         val2 = reader2.read();
+         assertTrue( "farm deployment test ("+val1+") not equal to ("+val2+")",val1 == val2);
+      }
+      
+      reader1.close();
+      reader2.close();
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/ClusterFileTransferTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DRMTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DRMTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DRMTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,169 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Vector;
+
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.Notification;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptorExt;
+import org.jboss.jmx.adaptor.rmi.RMINotificationListener;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.hapartition.drm.IReplicants;
+
+/** 
+ * Tests of the DistributedReplicantManagerImpl.
+ *
+ * @author  Scott.Stark at jboss.org
+ * @author  Brian.Stansberry at jboss.com
+ * @version $Revision$
+ */
+public class DRMTestCase extends JBossClusteredTestCase
+{  
+   static class TestListener extends UnicastRemoteObject
+      implements RMINotificationListener
+   {
+      private static final long serialVersionUID = 1;
+      private Logger log;
+
+      public TestListener(Logger log) throws RemoteException
+      {
+         this.log = log;
+      }
+      public void handleNotification(Notification notification, Object handback)
+         throws RemoteException
+      {
+         log.info("handleNotification, "+notification);
+      }
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = getDeploySetup(DRMTestCase.class, "drm-tests.sar");
+      return t1;
+   }
+
+   public DRMTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testStateReplication()
+      throws Exception
+   {
+      log.debug("+++ testStateReplication");
+      log.info("java.rmi.server.hostname="+System.getProperty("java.rmi.server.hostname"));
+      RMIAdaptor[] adaptors = getAdaptors();
+      String[] servers = super.getServers();
+      RMIAdaptorExt server0 = (RMIAdaptorExt) adaptors[0];
+      log.info("server0: "+server0);
+      ObjectName clusterService = new ObjectName("jboss:service=DefaultPartition");
+      Vector view0 = (Vector) server0.getAttribute(clusterService, "CurrentView");
+      log.info("server0: CurrentView, "+view0);
+      log.debug("+++ testStateReplication 1");
+      ObjectName drmService = new ObjectName("jboss.test:service=DRMTestCase");
+      IReplicants drm0 = (IReplicants)
+         MBeanServerInvocationHandler.newProxyInstance(server0, drmService,
+         IReplicants.class, true);
+      log.debug("+++ testStateReplication 2");
+      log.info(MBeanServerInvocationHandler.class.getProtectionDomain());
+      TestListener listener = new TestListener(log);
+      server0.addNotificationListener(drmService, listener, null, null);
+      log.info("server0 addNotificationListener");
+      log.debug("+++ testStateReplication 3");
+      String address = (String) drm0.lookupLocalReplicant();
+      log.debug("+++ testStateReplication 4");
+      log.info("server0: lookupLocalReplicant: "+address);
+      assertTrue("server0: address("+address+") == server0("+servers[0]+")",
+         address.equals(servers[0]));
+
+      RMIAdaptorExt server1 = (RMIAdaptorExt) adaptors[1];
+      log.info("server1: "+server1);
+      Vector view1 = (Vector) server1.getAttribute(clusterService, "CurrentView");
+      log.info("server1: CurrentView, "+view1);
+      IReplicants drm1 = (IReplicants)
+         MBeanServerInvocationHandler.newProxyInstance(server1, drmService,
+         IReplicants.class, true);
+      server1.addNotificationListener(drmService, listener, null, null);
+      log.info("server1 addNotificationListener");
+      address = (String) drm1.lookupLocalReplicant();
+      log.info("server1: lookupLocalReplicant: "+address);
+      assertTrue("server1: address("+address+") == server1("+servers[1]+")",
+         address.equals(servers[1]));
+
+      List replicants0 = drm0.lookupReplicants();
+      List replicants1 = drm1.lookupReplicants();
+      assertTrue("size of replicants0 == replicants1)",
+         replicants0.size() == replicants1.size());
+      HashSet testSet = new HashSet(replicants0);
+      for(int n = 0; n < replicants0.size(); n ++)
+      {
+         Object entry = replicants1.get(n);
+         assertTrue("replicants0 contains:"+entry, testSet.contains(entry));
+      }
+
+      //
+      for(int n = 0; n < 10; n ++)
+      {
+         drm0.add("key"+n, "data"+n+".0");
+         drm1.add("key"+n, "data"+n+".1");
+      }
+      for(int n = 0; n < 10; n ++)
+      {
+         String key = "key"+n;
+         log.info("key: "+key);
+         replicants0 = drm0.lookupReplicants(key);
+         replicants1 = drm1.lookupReplicants(key);
+         log.info("replicants0: "+replicants0);
+         log.info("replicants1: "+replicants1);
+         HashSet testSet0 = new HashSet(replicants0);
+         HashSet testSet1 = new HashSet(replicants1);
+         assertTrue("size of replicants0 == replicants1)",
+            replicants0.size() == replicants1.size());
+         Object entry = drm0.lookupLocalReplicant(key);
+         log.info("drm0.lookupLocalReplicant, key="+key+", entry="+entry);
+         assertTrue("replicants0 contains:"+entry, testSet0.contains(entry));
+         assertTrue("replicants1 contains:"+entry, testSet1.contains(entry));
+         entry = drm1.lookupLocalReplicant(key);
+         log.info("drm1.lookupLocalReplicant, key="+key+", entry="+entry);
+         assertTrue("replicants0 contains:"+entry, testSet0.contains(entry));
+         assertTrue("replicants1 contains:"+entry, testSet1.contains(entry));
+      }
+
+      for(int n = 0; n < 10; n ++)
+         drm0.remove("key"+n);
+
+      server0.removeNotificationListener(drmService, listener);
+      server1.removeNotificationListener(drmService, listener);
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DRMTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DistributedStateTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DistributedStateTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DistributedStateTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,222 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Collection;
+import java.util.Vector;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.Notification;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.hapartition.ds.DistributedStateUser;
+import org.jboss.test.cluster.hapartition.ds.IDistributedState;
+import org.jboss.test.cluster.hapartition.ds.IDistributedState.NotifyData;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptorExt;
+import org.jboss.jmx.adaptor.rmi.RMINotificationListener;
+
+/** Tests of http session replication
+ *
+ * @author  Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DistributedStateTestCase extends JBossClusteredTestCase
+{
+   private static final String NOTIFY_KEY = "NotifyKey";
+   private static final String NOTIFY_VALUE = "NotifyValue";
+   // note - this static variable must match the category defined in ds-tests.sar
+   private static final String NOTIFY_CATEGORY = "DistributedStateTestCase";
+   
+   class TestListener extends UnicastRemoteObject
+      implements RMINotificationListener
+   {
+      private String type = null;
+      private Object data = null;
+      
+      TestListener() throws RemoteException
+      {
+      }
+      
+      public void handleNotification(Notification notification, Object handback)
+         throws RemoteException
+      {
+         System.out.println(notification);
+         type = notification.getType();
+         data = notification.getUserData();
+      }
+      
+      public String getNotificationType()
+      {
+         return type;
+      }
+      
+      public Object getNotificationData()
+      {
+         return data;
+      }
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = getDeploySetup(DistributedStateTestCase.class, "ds-tests.sar");
+      return t1;
+   }
+
+   public DistributedStateTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testStateReplication()
+      throws Exception
+   {
+      log.debug("+++ testStateReplication");
+      
+      RMIAdaptor[] adaptors = getAdaptors();
+      RMIAdaptorExt server0 = (RMIAdaptorExt) adaptors[0];
+      log.info("server0: "+server0);
+      ObjectName clusterService = new ObjectName("jboss:service=DefaultPartition");
+      Vector view0 = (Vector) server0.getAttribute(clusterService, "CurrentView");
+      log.info("server0: CurrentView, "+view0);
+      ObjectName dsService = new ObjectName("jboss.test:service=DistributedStateTestCase");
+      IDistributedState ds0 = (IDistributedState)
+         MBeanServerInvocationHandler.newProxyInstance(server0, dsService,
+         IDistributedState.class, true);
+      TestListener listener0 = new TestListener();
+      server0.addNotificationListener(dsService, listener0, null, null);
+      ds0.put("key0", "value0");
+      String value = (String) ds0.get("key0");
+      log.info("server0: get(key0): "+value);
+      assertTrue("server0: value == value0", value.equals("value0"));
+
+      RMIAdaptorExt server1 = (RMIAdaptorExt) adaptors[1];
+      log.info("server1: "+server1);
+      Vector view1 = (Vector) server1.getAttribute(clusterService, "CurrentView");
+      log.info("server1: CurrentView, "+view1);
+      IDistributedState ds1 = (IDistributedState)
+         MBeanServerInvocationHandler.newProxyInstance(server1, dsService,
+         IDistributedState.class, true);
+      TestListener listener1 = new TestListener();
+      server1.addNotificationListener(dsService, listener1, null, null);
+      value = (String) ds1.get("key0");
+      log.info("server1: get(key0): "+value);
+      assertTrue("server1: value == value0", value.equals("value0"));
+      ds1.put("key0", "value1");
+      value = (String) ds1.get("key0");
+      assertTrue("server1: value == value1("+value+")", value.equals("value1"));
+      value = (String) ds0.get("key0");
+      assertTrue("server0: value == value1("+value+")", value.equals("value1"));
+      
+      ds1.put("key1", "value11");
+      Collection categories = ds0.listAllCategories();
+      assertEquals("server0 categories size", 1, categories.size());
+      categories = ds1.listAllCategories();
+      assertEquals("server1 categories size", 1, categories.size());
+      
+      String category = (String)categories.iterator().next();
+      Collection keys = ds0.listAllKeys(category);
+      assertEquals("server0 keys size", 2, keys.size());
+      keys = ds1.listAllKeys(category);
+      assertEquals("server1 keys size", 2, keys.size());
+      Collection vals = ds0.listAllValues(category);
+      assertEquals("server0 values size", 2, vals.size());
+      vals = ds1.listAllValues(category);
+      assertEquals("server1 values size", 2, vals.size());
+
+      ds0.remove("key0");
+      value = (String) ds1.get("key0");
+      assertTrue("server1: value == null("+value+")", value == null);
+      value = (String) ds0.get("key0");
+      assertTrue("server0: value == null("+value+")", value == null);
+
+      // set a key/value on server0 and test its notifications on both servers
+      ds0.put(NOTIFY_KEY, NOTIFY_VALUE);
+      Thread.sleep(5000);
+      
+      // check the change notification on server0
+      String type = listener0.getNotificationType();
+      NotifyData data = (NotifyData)listener0.getNotificationData();
+      assertTrue("server0: change notification type = " + type, type.equals(DistributedStateUser.NOTIFY_CHANGE));
+      assertNotNull("server0: change notification data is null", data);
+      String cat = data.category;
+      String key = (String)data.key;
+      String val = (String)data.value;
+      boolean isLocal = data.locallyModified;
+      assertTrue("server0: change notification category = " + cat, cat.equals(NOTIFY_CATEGORY));
+      assertTrue("server0: change notification key = " + key, key.equals(NOTIFY_KEY));
+      assertTrue("server0: change notification value = " + val, val.equals(NOTIFY_VALUE));
+      assertTrue("server0: change notification isLocal = " + isLocal, isLocal == true);
+      
+      // check the change notification on server1
+      type = listener1.getNotificationType();
+      data = (NotifyData)listener1.getNotificationData();
+      assertTrue("server1: change notification type = " + type, type.equals(DistributedStateUser.NOTIFY_CHANGE));
+      assertNotNull("server1: change notification data is null", data);
+      cat = data.category;
+      key = (String)data.key;
+      val = (String)data.value;
+      isLocal = data.locallyModified;
+      assertTrue("server1: change notification category = " + cat, cat.equals(NOTIFY_CATEGORY));
+      assertTrue("server1: change notification key = " + key, key.equals(NOTIFY_KEY));
+      assertTrue("server1: change notification value = " + val, val.equals(NOTIFY_VALUE));
+      assertTrue("server1: change notification isLocal = " + isLocal, isLocal == false);
+      
+      // remove the key from server1 and check its notifications
+      ds1.remove(NOTIFY_KEY);
+      Thread.sleep(5000);
+      
+      // check the remove notification on server0
+      type = listener0.getNotificationType();
+      data = (NotifyData)listener0.getNotificationData();
+      assertTrue("server0: removal notification type = " + type, type.equals(DistributedStateUser.NOTIFY_REMOVAL));
+      assertNotNull("server0: removal notification data is null", data);
+      cat = data.category;
+      key = (String)data.key;
+      val = (String)data.value;
+      isLocal = data.locallyModified;
+      assertTrue("server0: removal notification category = " + cat, cat.equals(NOTIFY_CATEGORY));
+      assertTrue("server0: removal notification key = " + key, key.equals(NOTIFY_KEY));
+      assertTrue("server01: removal notification value = " + val, val.equals(NOTIFY_VALUE));
+      assertTrue("server0: removal notification isLocal = " + isLocal, isLocal == false);
+      
+      // check the remove notification on server1
+      type = listener1.getNotificationType();
+      data = (NotifyData)listener1.getNotificationData();
+      assertTrue("server1: removal notification type = " + type, type.equals(DistributedStateUser.NOTIFY_REMOVAL));
+      assertNotNull("server1: removal notification data is null", data);
+      cat = data.category;
+      key = (String)data.key;
+      val = (String)data.value;
+      isLocal = data.locallyModified;
+      assertTrue("server1: removal notification category = " + cat, cat.equals(NOTIFY_CATEGORY));
+      assertTrue("server1: removal notification key = " + key, key.equals(NOTIFY_KEY));
+      assertTrue("server1: removal notification value = " + val, val.equals(NOTIFY_VALUE));
+      assertTrue("server1: removal notification isLocal = " + isLocal, isLocal == true);
+      
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/DistributedStateTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/HAJndiTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAJndiTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,476 @@
+/*
+ * 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 junit.framework.Test;
+
+import org.jboss.test.cluster.ejb2.crossserver.CalledHome;
+import org.jboss.test.cluster.ejb2.crossserver.CalledRemote;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * HA-JNDI clustering tests.
+ *
+ * @author Jerry Gauthier
+ * @version $Revision$
+ */
+public class HAJndiTestCase
+      extends JBossClusteredTestCase      
+{
+   // 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");
+   
+   // BINDING SUBCONTEXT NAMES
+   private static final String SUBCON1 = "subcontext1";
+   private static final String SUBCON1A = "subcontext1a";   
+   private static final String SUBCON2 = "subcontext2";
+   
+   // 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";
+	
+   public HAJndiTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(HAJndiTestCase.class, "cross-server.jar");
+   }
+
+   /**
+    * Test local bindings using local and HA-JNDI lookups
+    *
+    * @throws Exception
+    */
+   public void testLocalBinding()
+      throws Exception
+   {
+      getLog().debug("HAJndiTestCase.testLocalBinding()");
+      validateUrls();
+      
+      // bind to node0 locally
+      Context naming = getContext(NODE0_JNDI);
+      naming.bind(LOCAL0_KEY, LOCAL0_VALUE);
+      closeContext(naming);
+      
+      // lookup binding locally on Node0 - should succeed
+      naming = getContext(NODE0_JNDI);
+      String value = (String)lookup(naming, LOCAL0_KEY, true);
+      closeContext(naming);
+      assertEquals("lookup local binding on same server", LOCAL0_VALUE, value);
+      
+      // lookup binding locally on Node1 - should fail
+      naming = getContext(NODE1_JNDI);
+      value = (String)lookup(naming, LOCAL0_KEY, false);
+      closeContext(naming);
+      assertNull("lookup local binding on different server in cluster", value);
+      
+      // lookup binding using HA-JNDI on Node0 - should succeed
+      naming = getContext(NODE0_HAJNDI);
+      value = (String)lookup(naming, LOCAL0_KEY, true);
+      closeContext(naming);
+      assertEquals("lookup local binding on same server using HA-JNDI", LOCAL0_VALUE, value);
+      
+      // lookup binding using HA-JNDI on Node1 - should succeed
+      naming = getContext(NODE1_HAJNDI);
+      value = (String)lookup(naming, LOCAL0_KEY, true);
+      closeContext(naming);
+      assertEquals("lookup local binding on different server in cluster using HA-JNDI", LOCAL0_VALUE, value);
+   }
+   
+   /**
+    * Test HA-JNDI bindings using local and HA-JNDI lookups
+    *
+    * @throws Exception
+    */
+   public void testHAJndiBinding()
+      throws Exception
+   {
+      getLog().debug("HAJndiTestCase.testHAJndiBinding()");
+      validateUrls();
+      
+      // bind to node0 using HA-JNDI
+      Context naming = getContext(NODE0_HAJNDI);
+      naming.bind(GLOBAL0_KEY, GLOBAL0_VALUE);
+      closeContext(naming);
+      
+      // lookup binding locally on Node0 - should fail
+      naming = getContext(NODE0_JNDI);
+      String value = (String)lookup(naming, GLOBAL0_KEY, false);
+      closeContext(naming);
+      assertNull("lookup HA-JNDI binding on same server using local JNDI", value);
+      
+      // lookup binding locally on Node1 - should fail
+      naming = getContext(NODE1_JNDI);
+      value = (String)lookup(naming, GLOBAL0_KEY, false);
+      closeContext(naming);
+      assertNull("lookup HA-JNDI binding on different server in cluster using local JNDI", value);
+      
+      // lookup binding using HA-JNDI on Node0 - should succeed
+      naming = getContext(NODE0_HAJNDI);
+      value = (String)lookup(naming, GLOBAL0_KEY, true);
+      closeContext(naming);
+      assertEquals("lookup HA-JNDI binding on same server using HA-JNDI", GLOBAL0_VALUE, value);
+      
+      // lookup binding using HA-JNDI on Node1 - should succeed
+      naming = getContext(NODE1_HAJNDI);
+      value = (String)lookup(naming, GLOBAL0_KEY, true);
+      closeContext(naming);
+      assertEquals("lookup HA-JNDI binding on different server in cluster using HA-JNDI", GLOBAL0_VALUE, value);
+ 
+   }
+   
+   /**
+    * Test HA-JNDI operations
+    *
+    * @throws Exception
+    */
+   public void testHAJndiOperations()
+      throws Exception
+   {
+      getLog().debug("HAJndiTestCase.testHAJndiOperations()");
+      validateUrls();
+      
+      // bind to node0 using HA-JNDI
+      Context naming = getContext(NODE0_HAJNDI);
+      naming.bind(JNDI_KEY, JNDI_VALUE1);     
+     
+      // lookup binding using HA-JNDI on Node0 - should succeed
+      String value = (String)lookup(naming, JNDI_KEY, true);
+      assertEquals("lookup after initial HA-JNDI binding operation", JNDI_VALUE1, value);
+      
+      // bind it again - this should fail with NameAlreadyBoundException      
+      try
+      {
+         naming.bind(JNDI_KEY, JNDI_VALUE1);
+         fail("binding key a second time in HA-JNDI should throw NamingException");
+      }
+      catch (NamingException ne)
+      {
+         assertTrue("binding key a second time in HA-JNDI should throw NamingException", ne instanceof NamingException);
+      }
+      
+      // rebind it using a different value
+      naming.rebind(JNDI_KEY, JNDI_VALUE2);  
+      
+      // lookup binding - should return new value
+      value = (String)lookup(naming, JNDI_KEY, true);
+      assertEquals("lookup after HA-JNDI rebind operation", JNDI_VALUE2, value);
+      
+      // unbind it
+      naming.unbind(JNDI_KEY);  
+      
+      // lookup binding - should fail with NamingException
+      value = (String)lookup(naming, JNDI_KEY, false);
+      assertNull("lookup after HA-JNDI unbind operation", value);
+      
+      closeContext(naming);  
+   }
+   
+   /**
+    * Test HA-JNDI bindings using subcontexts
+    *
+    * @throws Exception
+    */
+   public void testHAJndiSubcontexts()
+      throws Exception
+   {
+      getLog().debug("HAJndiTestCase.testHAJndiSubcontexts()");
+      validateUrls();
+      
+      // create subcontexts
+      Context naming = getContext(NODE0_HAJNDI);
+      Context sub1 = naming.createSubcontext(SUBCON1);
+      Context sub2 = naming.createSubcontext(SUBCON2);
+      Context sub1a = sub1.createSubcontext(SUBCON1A);
+      
+      // bind something to each subcontext
+      sub1.bind(SUB1_KEY, SUB1_VALUE);
+      sub2.bind(SUB2_KEY, SUB2_VALUE);
+      sub1a.bind(SUB1A_KEY, SUB1A_VALUE);      
+     
+      // close contexts
+      naming.close();
+      sub1.close();
+      sub2.close();
+      sub1a.close();           
+     
+      // lookup bindings using HA-JNDI on Node0 - should succeed
+      naming = getContext(NODE0_HAJNDI);
+      sub1 = (Context)lookup(naming, SUBCON1, true);  
+      String value = (String)lookup(sub1, SUB1_KEY, true);
+      assertEquals("lookup subcontext HA-JNDI binding on same server in cluster using HA-JNDI", SUB1_VALUE, value);
+      
+      // lookup bindings using HA-JNDI on Node1 - should succeed
+      naming = getContext(NODE1_HAJNDI);
+      sub2 = (Context)lookup(naming, SUBCON2, true);
+      value = (String)lookup(sub2, SUB2_KEY, true);
+      assertEquals("lookup subcontext HA-JNDI binding on different server in cluster using HA-JNDI", SUB2_VALUE, value);
+      
+      sub1a = (Context)lookup(naming, SUBCON1 + "/" + SUBCON1A, true);
+      value = (String)lookup(sub1a, SUB1A_KEY, true);
+      assertEquals("lookup nested subcontext HA-JNDI binding on different server in cluster using HA-JNDI", SUB1A_VALUE, value);
+      
+      naming.close();
+      sub1.close();
+      sub2.close();
+      sub1a.close();
+ 
+   }
+
+   /**
+    * Test EJB Bindings using local and HA-JNDI lookups
+    *
+    * @throws Exception
+    */
+   public void testEJBBinding()
+      throws Exception
+   {
+      getLog().debug("HAJndiTestCase.testEJBBinding()");
+      validateUrls();
+      
+      // CalledHome EJB is contained in cross-server.jar and bound during deployment
+ 
+      // lookup binding locally on Node0 - should succeed
+      Context naming = getContext(NODE0_JNDI);
+      CalledHome home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
+      if (home != null)
+      { // ensure that EJB is operational  
+         CalledRemote remote = home.create();
+         remote.remove();
+      }
+      closeContext(naming);
+      assertNotNull("lookup EJB binding on same server using local JNDI", home);
+      
+      // lookup binding locally on Node1 - should succeed
+      naming = getContext(NODE1_JNDI);
+      home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
+      if (home != null)
+      {   // ensure that EJB is operational 
+         CalledRemote remote = home.create();
+         remote.remove();
+      }
+      closeContext(naming);
+      assertNotNull("lookup EJB binding on different server in cluster using local JNDI", home);
+      
+      // lookup binding using HA-JNDI on Node0 - should succeed
+      naming = getContext(NODE0_HAJNDI);
+      home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
+      if (home != null)
+      {   // ensure that EJB is operational 
+         CalledRemote remote = home.create();
+         remote.remove();
+      }
+      closeContext(naming);
+      assertNotNull("lookup EJB binding on same server using HA-JNDI", home);
+      
+      // lookup binding using HA-JNDI on Node1 - should succeed
+      naming = getContext(NODE1_HAJNDI);
+      home = (CalledHome)lookup(naming, CALLED_HOME_KEY, true);
+      if (home != null)
+      {   // ensure that EJB is operational 
+         CalledRemote remote = home.create();
+         remote.remove();
+      }
+      closeContext(naming);
+      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
+      if (NODE0 != null && NODE0.equalsIgnoreCase("localhost") )
+      {
+         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("jnp.discoveryTTL", DISCOVERY_TTL);
+
+      if (autoDisabled)
+      {
+         env.put("jnp.disableDiscovery", "true");
+      }
+      else if (DISCOVERY_GROUP != null && "".equals(DISCOVERY_GROUP) == false)
+      {
+         // USe the multicast address this test environment is using
+         env.put("jnp.discoveryGroup", DISCOVERY_GROUP);
+      }
+        
+      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: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAPartitionStateTransferTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAPartitionStateTransferTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAPartitionStateTransferTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.Vector;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.hapartition.state.BadHAPartitionStateException;
+import org.jboss.test.cluster.hapartition.state.CustomStateHAPartitionStateTransfer;
+import org.jboss.test.cluster.hapartition.state.SimpleHAPartitionStateTransfer;
+
+/**
+ * Tests of HAPartitionImpl's state transfer.
+ * 
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class HAPartitionStateTransferTestCase extends JBossClusteredTestCase
+{
+
+   public HAPartitionStateTransferTestCase(String name)
+   {
+      super(name);
+   }        
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(HAPartitionStateTransferTestCase.class, "partitionstatetransfer.sar");
+      return t1;
+   } 
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+   
+   public void testFailedStateProvider() throws Exception
+   {
+      RMIAdaptor[] adaptors = getAdaptors();
+      
+      ObjectName recorder = new ObjectName("jboss:service=BadProviderPartitionRecorder");
+      
+      Exception e = (Exception) adaptors[1].getAttribute(recorder, "StartupException");      
+
+      assertNotNull("Partition caught exception", e);
+      
+      Throwable parent = e;
+      Throwable cause = e.getCause();
+      while (cause != null)
+      {
+         parent = cause;
+         cause = parent.getCause();
+      }
+      
+      assertTrue("Correct type of Exception caught", parent instanceof IllegalStateException);
+      
+      // Confirm the bad partition is removed from the current view
+      ObjectName partition = new ObjectName("jboss:service=BadProviderPartition");
+      Vector view = (Vector) adaptors[0].getAttribute(partition, "CurrentView");
+      assertEquals("View size after failure is correct", 1, view.size());
+   }
+
+   public void testBadStateIntegration() throws Exception
+   {
+      RMIAdaptor[] adaptors = getAdaptors();
+      
+      ObjectName recorder = new ObjectName("jboss:service=BadStatePartitionRecorder");
+      
+      Exception e = (Exception) adaptors[1].getAttribute(recorder, "StartupException");
+
+      assertNotNull("Partition caught exception", e);
+      
+      Throwable parent = e;
+      Throwable cause = e.getCause();
+      while (cause != null)
+      {
+         parent = cause;
+         cause = parent.getCause();
+      }
+      
+      assertTrue("Correct type of Exception caught", parent instanceof BadHAPartitionStateException);
+      
+      // Confirm the bad partition is removed from the current view
+      ObjectName partition = new ObjectName("jboss:service=BadStatePartition");
+      Vector view = (Vector) adaptors[0].getAttribute(partition, "CurrentView");
+      assertEquals("View size after failure is correct", 1, view.size());
+   }
+   
+   public void testNoStateTransfer() throws Exception
+   {
+      RMIAdaptor[] adaptors = getAdaptors();
+      
+      ObjectName partition = new ObjectName("jboss:service=NoStatePartitionRecorder");
+      
+      Exception e = (Exception) adaptors[1].getAttribute(partition, "StartupException");
+
+      assertNull("Partition started successfully", e);
+      
+   }
+   
+   public void testGoodStateTransfer() throws Exception
+   {
+      RMIAdaptor[] adaptors = getAdaptors();
+      
+      ObjectName partition = new ObjectName("jboss:service=GoodStatePartitionRecorder");
+      
+      Exception e = (Exception) adaptors[1].getAttribute(partition, "StartupException");
+
+      assertNull("Partition started successfully", e);
+      
+      ObjectName simple = new ObjectName("jboss.test:service=SimpleHAPartitionStateTransfer");
+      
+      Object simpleState = adaptors[1].getAttribute(simple, "TransferredState");
+      
+      assertEquals("Got simple state", SimpleHAPartitionStateTransfer.SIMPLE, simpleState);
+      
+      ObjectName custom = new ObjectName("jboss.test:service=CustomStateHAPartitionStateTransfer");
+      
+      Object customState = adaptors[1].getAttribute(custom, "TransferredState");
+      
+      assertNotNull("Got custom state", customState);
+      assertEquals("Got correct custom state", CustomStateHAPartitionStateTransfer.CUSTOM, customState.toString());
+   }
+
+   /**
+    * In this subclass this is a no-op because we are deliberately
+    * deploying a sar that will fail in deployment
+    */
+   public void testServerFound() throws Exception
+   {
+      // do nothing
+   }
+   
+   
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/test/HAPartitionStateTransferTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/FieldBasedTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/FieldBasedTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,212 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.web.field.test;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.multicfg.web.test.ScopedTestCase;
+import org.jboss.test.cluster.testutil.SessionTestUtil;
+
+/**
+ * Clustering test case of get/set under non-scoped class loader.
+ * Replication granularity is attribute-based.
+ *
+ * @author Ben Wang
+ * @author Brian Stansberry
+ * @version $Id$
+ */
+public class FieldBasedTestCase
+      extends ScopedTestCase
+{ 
+   
+   protected String modifySubjectUrl;
+   protected String modifySubjectUrlBase_;
+   
+   public FieldBasedTestCase(String name)
+   {
+      super(name);
+      warName_ = "/http-field/";
+      modifySubjectUrlBase_ = "modifySubject.jsp";
+      concatenate();
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(FieldBasedTestCase.class,
+            "jbosscache-helper.sar, http-field.war");
+      return t1;
+   }
+
+   protected void concatenate()
+   {
+      super.concatenate();
+      modifySubjectUrl = warName_ +modifySubjectUrlBase_;
+   }
+   
+   protected String getWarName()
+   {
+      return "http-field";
+   }
+   
+   public void testSubjectObserver() throws Exception
+   {
+      getLog().debug("Enter testSubjectObserver");
+
+      getLog().debug(setUrl + ":::::::" + modifySubjectUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+      
+      // Find out the session id and use it to build an FQN
+      String sessionID = getSessionID(client, servers_[0]);
+      // Strip off the jvmRoute, if there is one
+      sessionID = stripJvmRoute(sessionID);
+      String sessionFqn = "/JSESSION/localhost" + warName_ + sessionID;
+      
+      RMIAdaptor[] adaptors = getAdaptors();
+      
+      // Get the session from the cache
+      Object origVersion = SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn); 
+      
+      // Modify the POJO stored in the session, but don't touch the
+      // session attributes (a reference to the POJO is stored in the 
+      // servlet context)
+      makeGet(client, baseURL0_ +modifySubjectUrl);
+      
+      // Get the session from the cache
+      Object newVersion = SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn);
+      
+      // The byte[] should have been updated because the POJO was
+      assertFalse("Session body has been updated", 
+                  origVersion.equals(newVersion));
+      
+      this.sleepThread(DEFAULT_SLEEP);
+      
+      // Get the session from the server1 cache
+      Object replVersion = SessionTestUtil.getSessionVersion(adaptors[1], sessionFqn);
+      
+      if (replVersion == null)
+      {
+         // Since we haven't accessed the session on server 1,
+         // see if it is in a buddy subtree
+         replVersion = SessionTestUtil.getBuddySessionVersion(adaptors[1], sessionFqn);
+      }
+      
+      // Should match the one on server0
+      assertTrue("Session body was replicated", 
+                 newVersion.equals(replVersion));
+   }
+   
+   public void testObserverRemoval() throws Exception
+   {
+      getLog().debug("Enter testObserverRemoval");
+
+      getLog().debug(setUrl + ":::::::" + modifySubjectUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+      
+      // Find out the session id and use it to build an FQN
+      String sessionID = getSessionID(client, servers_[0]);
+      // Strip off the jvmRoute, if there is one
+      sessionID = stripJvmRoute(sessionID);
+      String sessionFqn = "/JSESSION/localhost" + warName_ + sessionID;
+      
+      this.sleepThread(DEFAULT_SLEEP);
+      
+      // Switch over to server1 and get the POJO, which will also
+      // cause it to be stored in the servlet context on that server
+      setCookieDomainToThisServer(client, servers_[1]);
+      makeGet(client, baseURL1_ + getUrl);
+      
+      this.sleepThread(DEFAULT_SLEEP);
+      
+      // Now switch back to server0 and remove the POJO from the session
+      setCookieDomainToThisServer(client, servers_[0]);
+      makeGet(client, baseURL0_ + removeUrl);
+      
+      RMIAdaptor[] adaptors = getAdaptors();
+      
+      // Get the session from the cache
+      Object origVersion = SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn); 
+      
+      // Modify the POJO that was originally stored in the session
+      // (a reference to the POJO is stored in the servlet context)
+      // Use a new client with no session cookie so we don't touch the session
+      HttpClient client2 = new HttpClient();
+      makeGet(client2, baseURL0_ +modifySubjectUrl);
+      
+      // Get the session from the cache
+      Object newVersion = SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn); 
+      
+      // The version should not have been updated
+      assertEquals("Session version has not been updated", 
+                   origVersion, newVersion);
+      
+      this.sleepThread(DEFAULT_SLEEP);
+      
+      // Get the session from the server1 cache
+      Object replVersion = SessionTestUtil.getSessionVersion(adaptors[1], sessionFqn); 
+      
+      if (replVersion == null)
+      {
+         // Since we haven't accessed the session on server 1,
+         // see if it is in a buddy subtree
+         replVersion = SessionTestUtil.getBuddySessionVersion(adaptors[1], sessionFqn);
+      }
+      
+      // Should match the one on server0
+      assertEquals("Session body was replicated", 
+                   newVersion, replVersion);
+      
+      // Make connection to server 1 and again modify the POJO via servlet ctx
+      // Again use a fresh client so we don't touch the session
+      HttpClient client3 = new HttpClient();
+      makeGet(client3, baseURL1_ + modifySubjectUrl);
+      
+      // Again get the session from the server1 cache
+      Object newReplVersion = SessionTestUtil.getSessionVersion(adaptors[1], sessionFqn); 
+      
+      if (newReplVersion == null)
+      {
+         // Since we haven't accessed the session on server 1,
+         // see if it is in a buddy subtree
+         newReplVersion = SessionTestUtil.getBuddySessionVersion(adaptors[1], sessionFqn);
+      }
+      
+      // The byte[] should not have been updated
+      assertEquals("Session body has not been updated on server1", 
+                   replVersion, newReplVersion);
+      
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/StateTransferTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/StateTransferTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,215 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.web.field.test;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.testutil.SessionTestUtil;
+import org.jboss.test.cluster.testutil.WebTestBase;
+
+/**
+ * Tests the use of the TreeCache.activateRegion()/inactivateRegion().
+ * 
+ * TODO add a concurrency test.
+ * 
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class StateTransferTestCase extends WebTestBase
+{
+
+   private static final Object[] NULL_ARGS = new Object[] {};
+   private static final String[] NULL_TYPES = new String[] {};
+   
+   private static final ObjectName CACHE_OBJECT_NAME;
+   static
+   {
+      try
+      {
+         CACHE_OBJECT_NAME =
+            new ObjectName("jboss.cache:service=TomcatClusteringCache");
+      }
+      catch (MalformedObjectNameException e)
+      {
+         throw new ExceptionInInitializerError(e);
+      }
+   }
+   
+   private static boolean deployed0 = true;
+   private static boolean deployed1 = true;
+   
+   protected String setUrl_;
+   protected String getUrl_;
+   protected String setUrlBase_;
+   protected String getUrlBase_;
+   
+   private ObjectName warObjectName;
+   private RMIAdaptor adaptor0_;
+   private RMIAdaptor adaptor1_;
+   private String warFqn_;
+   
+   /**
+    * Create a new StateTransferTestCase.
+    * 
+    * @param name
+    */
+   public StateTransferTestCase(String name)
+   {
+      super(name);
+      setUrlBase_ = "setSession.jsp";
+      getUrlBase_ = "getAttribute.jsp";
+      concatenate();
+   }
+
+   protected void concatenate()
+   {
+      String contextPath = "/" + getWarName() + "/";
+      setUrl_ = contextPath +setUrlBase_;
+      getUrl_ = contextPath +getUrlBase_;
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(StateTransferTestCase.class,
+            "jbosscache-helper.sar, http-scoped.war");
+      return t1;
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      if (warObjectName == null)
+      {
+         String oname = "jboss.web:J2EEApplication=none,J2EEServer=none," +
+                        "j2eeType=WebModule,name=//localhost/" + getWarName();
+         warObjectName = new ObjectName(oname);
+         
+         RMIAdaptor[] adaptors = getAdaptors();
+         adaptor0_ = adaptors[0];
+         adaptor1_ = adaptors[1];
+         
+         Object[] names = {"JSESSION", "localhost", getWarName() };
+         Fqn fqn = new Fqn(names);
+         warFqn_ = fqn.toString();
+      }
+      
+      if (!deployed0)
+      {
+         deploy(adaptor0_, getWarName() + ".war");
+         deployed0 = true;
+      }
+      
+      if (!deployed1)
+      {
+         deploy(adaptor1_, getWarName() + ".war");
+         deployed1 = true;
+      }
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped";
+   }
+   
+   public void testActivationInactivation() throws Exception
+   {
+      getLog().debug("Enter testActivationInactivation");
+
+      getLog().debug(setUrl_ + ":::::::" + getUrl_);
+      
+      // Stop the war on server1
+      undeploy(adaptor1_, getWarName() + ".war");
+
+      // Confirm the war isn't available on server1
+      HttpClient client0 = new HttpClient();
+      makeGetFailed(client0, baseURL1_ +setUrl_);
+      
+      // Create 3 sessions on server0
+      HttpClient[] clients = new HttpClient[3];
+      String[] attrs = new String[clients.length];
+      for (int i = 0; i < clients.length; i++)
+      {
+         clients[i] = new HttpClient();
+         makeGet(clients[i], baseURL0_ +setUrl_);
+         attrs[i] = makeGet(clients[i], baseURL0_ + getUrl_);
+         // Set cookie domain to server1
+         this.setCookieDomainToThisServer(clients[i], servers_[1]);
+      }
+      
+      getLog().debug("Sessions created");
+      
+      // Confirm there are no sessions in the server1 cache
+      Set sessions = SessionTestUtil.getSessionIds(adaptor1_, warFqn_);
+      
+      assertTrue("server1 has no cached sessions", sessions.size() == 0);
+      
+      getLog().debug("Server1 has no cached sessions");
+      
+      // Start the war on server1
+      deploy(adaptor1_, getWarName() + ".war");
+      
+      getLog().debug("Server1 started");
+      
+      // Confirm the sessions are in the server1 cache
+      sessions = SessionTestUtil.getSessionIds(adaptor1_, warFqn_);
+
+      assertEquals("server1 has cached sessions", clients.length, sessions.size());
+      
+      getLog().debug("Server1 has cached sessions");
+      
+      for (int i = 0; i < clients.length; i++)
+      {
+         String attr = makeGet(clients[i], baseURL1_ + getUrl_);
+         assertEquals("attribute matches for client " + i, attrs[i], attr);
+      }
+      
+      getLog().debug("Attributes match");
+      
+      // Sleep a bit in case the above get triggers replication that takes
+      // a while -- don't want a repl to arrive after the cache is cleared
+      sleep(500);
+      
+      // Stop the war on server0
+      undeploy(adaptor0_, getWarName() + ".war");
+      
+      // Confirm there are no sessions in the server0 cache
+      sessions = SessionTestUtil.getSessionIds(adaptor0_, warFqn_);
+      
+      assertTrue("server0 has no cached sessions", sessions.size() == 0);
+      
+      getLog().debug("Server0 has no cached sessions");
+   }
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/UndeployFieldTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/field/test/UndeployFieldTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,42 @@
+package org.jboss.test.cluster.multicfg.web.field.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.multicfg.web.test.UndeployTestCase;
+
+/**
+ * Tests that a clustered session still functions properly on the second
+ * node after the webapp is undeployed from the first node.
+ * <p/>
+ * This version tests a FieldBasedClusteredSession.
+ * 
+ * @author Brian Stansberry
+ * @version $Id$
+ */
+public class UndeployFieldTestCase extends UndeployTestCase
+{
+
+   public UndeployFieldTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected String getContextPath()
+   {
+      return "/http-scoped-field/";
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped-field.war";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployFieldTestCase.class,
+            "http-scoped-field.war");
+      return t1;
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/AttributeBasedConcurrentTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/AttributeBasedConcurrentTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,57 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.web.test;
+
+import junit.framework.Test;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossClusteredTestCase;
+
+import java.util.Random;
+
+import EDU.oswego.cs.dl.util.concurrent.Semaphore;
+
+/**
+ * Simple clustering test case of get/set. It is attribute based granularity with concurrent access.
+ *
+ * @author Ben Wang
+ * @version $Revision: 1.0
+ */
+public class AttributeBasedConcurrentTestCase
+      extends SessionBasedConcurrentTestCase
+{
+   public AttributeBasedConcurrentTestCase(String name)
+   {
+      super(name);
+      setURLName_ = "/http-scoped-attr/testsessionreplication.jsp";
+      getURLName_ = "/http-scoped-attr/getattribute.jsp";
+   }
+
+   // Use different war file
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(AttributeBasedConcurrentTestCase.class,
+            "http-scoped-attr.war");
+      return t1;
+   }
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/ScopedAttrBasedTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedAttrBasedTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,58 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.web.test;
+
+import junit.framework.Test;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Clustering test case of get/set under scoped class loader.
+ * Replication granularity is attribute-based.
+ *
+ * @author Ben Wang
+ * @version $Revision: 1.0
+ */
+public class ScopedAttrBasedTestCase
+      extends ScopedTestCase
+{
+
+   public ScopedAttrBasedTestCase(String name)
+   {
+      super(name);
+      warName_ = "/http-scoped-attr/";
+
+      concatenate();
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped-attr";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedAttrBasedTestCase.class,
+            "http-scoped-attr.war");
+      return t1;
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/ScopedTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,637 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.web.test;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.jboss.cache.Fqn;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.testutil.WebTestBase;
+
+/**
+ * Clustering test case of get/set under scoped class loader.
+ *
+ * @author Ben Wang
+ * @version $Revision: 1.0
+ */
+public class ScopedTestCase
+      extends WebTestBase
+{
+   protected String setUrl;
+   protected String getUrl;
+   protected String modifyUrl;
+   protected String modifyNoSetUrl;
+   protected String removeUrl;
+   protected String invalidateUrl;
+   protected String clearUrl;
+   protected String attrListUrl;
+   protected String bindUrl_;
+   protected String protectedUrl_;
+   protected String securityCheckUrl_;
+   protected String loginFormUrl_;
+   protected String setSecuritySubjectUrl_;
+   protected String getSecuritySubjectUrl_;
+   protected String warName_;
+   protected String setUrlBase_;
+   protected String getUrlBase_;
+   protected String modifyUrlBase_;
+   protected String modifyNoSetUrlBase_;
+   protected String removeUrlBase_;
+   protected String invalidateUrlBase_;
+   protected String clearUrlBase_;
+   protected String bindUrlBase_;
+   protected String attrListUrlBase_;
+   protected String protectedUrlBase_;
+   protected String securityCheckUrlBase_;
+   protected String loginFormUrlBase_;
+   protected String setSecuritySubjectUrlBase_;
+   protected String getSecuritySubjectUrlBase_;
+   
+   private ObjectName warObjectName;
+   private String warFqn_;
+
+   public ScopedTestCase(String name)
+   {
+      super(name);
+      warName_ = "/http-scoped/";
+      setUrlBase_ = "setSession.jsp";
+      getUrlBase_ = "getAttribute.jsp";
+      modifyUrlBase_ = "modifyAttribute.jsp";
+      modifyNoSetUrlBase_ = "modifyAttributeNoSet.jsp";
+      removeUrlBase_ = "removeAttribute.jsp";
+      invalidateUrlBase_ = "invalidateSession.jsp";
+      clearUrlBase_ = "clearCache.jsp";
+      bindUrlBase_ = "bindSession.jsp?Binding=";
+      protectedUrlBase_ = "index.html";
+      securityCheckUrlBase_ = "j_security_check";
+      loginFormUrlBase_ = "login.html";
+      attrListUrlBase_ = "attributeNames.jsp";
+      setSecuritySubjectUrlBase_  = "setSecuritySubject.jsp";
+      getSecuritySubjectUrlBase_ =  "getSecuritySubject.jsp";
+
+      concatenate();
+   }
+
+   protected void concatenate()
+   {
+      setUrl = warName_ +setUrlBase_;
+      getUrl = warName_ +getUrlBase_;
+      modifyUrl = warName_ +modifyUrlBase_;
+      modifyNoSetUrl = warName_ +modifyNoSetUrlBase_;
+      removeUrl = warName_ +removeUrlBase_;
+      invalidateUrl = warName_ +invalidateUrlBase_;
+      clearUrl = warName_ +clearUrlBase_;
+      bindUrl_ = warName_ + bindUrlBase_;
+      protectedUrl_ = warName_ + protectedUrlBase_;
+      securityCheckUrl_ = warName_ + securityCheckUrlBase_;
+      loginFormUrl_ = warName_ + loginFormUrlBase_;
+      attrListUrl = warName_ + attrListUrlBase_;
+      setSecuritySubjectUrl_ = warName_ + setSecuritySubjectUrlBase_;
+      getSecuritySubjectUrl_ = warName_ + getSecuritySubjectUrlBase_;
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedTestCase.class,
+            "http-scoped.war");
+      return t1;
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      if (warObjectName == null)
+      {
+         String oname = "jboss.web:J2EEApplication=none,J2EEServer=none," +
+                        "j2eeType=WebModule,name=//localhost/" + getWarName();
+         warObjectName = new ObjectName(oname);
+         
+         RMIAdaptor[] adaptors = getAdaptors();
+         
+         Object[] names = {"JSESSION", "localhost", getWarName() };
+         Fqn fqn = new Fqn(names);
+         warFqn_ = fqn.toString();
+      }
+   }
+
+   protected void tearDown() throws Exception
+   {
+//      clear();
+      super.tearDown();
+   }
+
+   /**
+    * Main method that deals with the Http Session Replication Test
+    *
+    * @throws Exception
+    */
+   public void testNonPrimitiveGet()
+         throws Exception
+   {
+      String attr = "";
+      getLog().debug("Enter testNonPrimitiveGet");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+
+      // Create a method instance.
+      // Get the Attribute set
+      attr = makeGet(client, baseURL0_ +getUrl);
+
+      sleepThread(DEFAULT_SLEEP);
+
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr2 = makeGet(client, baseURL1_ +getUrl);
+
+      assertEquals("Get attribute should be but is ", attr, attr2);
+      getLog().debug("Exit testNonPrimitiveGet");
+   }
+
+   /**
+    * Test session modify with non-primitive get/modify.
+    *
+    * @throws Exception
+    */
+   public void testNonPrimitiveModify()
+         throws Exception
+   {
+      String attr = "";
+      getLog().debug("Enter testNonPrimitiveModify");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+
+      // Get the Attribute set
+      String attrOld = makeGet(client, baseURL0_ +getUrl);
+
+      // Modify a method instance.
+      makeGet(client, baseURL0_ +modifyUrl);
+
+      // Get the Attribute set
+      attr = makeGet(client, baseURL0_ +getUrl);
+
+      sleepThread(DEFAULT_SLEEP);
+
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr2 = makeGet(client, baseURL1_ +getUrl);
+
+      // Check the result
+      assertFalse("Old attribute should be different from new one.",
+                  attrOld.equals(attr));
+      assertEquals("Attributes should be the same", attr, attr2);
+      getLog().debug("Exit testNonPrimitiveModify");
+   }
+
+   /**
+    * Test session modify with non-primitive get/modify.
+    *
+    * @throws Exception
+    */
+   public void testNonPrimitiveRepeatedModify()
+         throws Exception
+   {
+      String attr = "";
+      getLog().info("Enter testNonPrimitiveRepeatedModify");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+
+      // Get the Attribute set
+      String attrOld = makeGetWithState(client, baseURL0_ +getUrl);
+
+      // Modify a method instance.
+      makeGet(client, baseURL0_ +modifyUrl);
+
+      // Get the Attribute set
+      attr = makeGetWithState(client, baseURL0_ +getUrl);
+
+      sleepThread(DEFAULT_SLEEP);
+
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr2 = makeGetWithState(client, baseURL1_ +getUrl);
+
+      // Check the result
+      assertFalse("Old attribute should be different from new one.",
+                  attrOld.equals(attr));
+      assertEquals("Attributes should be the same", attr, attr2);
+
+
+      // Modify a method instance.
+      makeGet(client, baseURL1_ +modifyUrl);
+
+      // Get the Attribute set
+      attr = makeGetWithState(client, baseURL1_ +getUrl);
+
+      sleepThread(DEFAULT_SLEEP);
+
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[0]);
+      attr2 = makeGetWithState(client, baseURL0_ +getUrl);
+
+      // Check the result
+      assertEquals("Attributes should be the same after second modify", attr, attr2);
+      getLog().debug("Exit testNonPrimitiveRepeatedModify");
+   }
+
+   /**
+    * Test session modify with non-primitive remove.
+    *
+    * @throws Exception
+    */
+   public void testNonPrimitiveRemove()
+         throws Exception
+   {
+      getLog().debug("Enter testNonPrimitiveRemove");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+
+      // Modify a method instance.
+      makeGet(client, baseURL0_ +modifyUrl);
+
+      // Get the Attribute set
+      makeGet(client, baseURL0_ +getUrl);
+
+      // Get the list of attributes
+      String attrList = makeGet(client, baseURL0_ +attrListUrl);
+      
+      assertTrue("TEST_PERSON is an attribute", attrList.indexOf("TEST_PERSON") > -1);
+
+      sleepThread(DEFAULT_SLEEP);
+
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      // Get the Attribute set
+      makeGet(client, baseURL1_ +getUrl);      
+      // Get the list of attributes
+      String attrList1 = makeGet(client, baseURL1_ +attrListUrl);
+      
+      assertTrue("TEST_PERSON is an attribute on server1", attrList1.indexOf("TEST_PERSON") > -1);
+      
+      // Remove the attribute
+      makeGet(client, baseURL1_ +removeUrl);
+      // Attribute is now null. Should have not OK response.
+      makeGetFailed(client, baseURL1_ +getUrl);
+
+      // Confirm the attribute is gone from the list
+      attrList1 = makeGet(client, baseURL1_ +attrListUrl);
+      
+      assertTrue("TEST_PERSON should not be an attribute", attrList1.indexOf("TEST_PERSON") == -1);
+      
+      sleepThread(DEFAULT_SLEEP);
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[0]);
+      // Attribute is now null. Should have not OK response.
+      makeGetFailed(client, baseURL0_ +getUrl);
+
+      // Confirm the attribute is gone from the list
+      attrList = makeGet(client, baseURL0_ +attrListUrl);
+      
+      assertTrue("TEST_PERSON is not an attribute on server0", attrList.indexOf("TEST_PERSON") == -1);
+
+      getLog().debug("Exit testNonPrimitiveRemove");
+   }
+
+   /**
+    * Test session modify with non-primitive get/modify from node2 and see if it replicates correctly
+    * on node1 or not.
+    *
+    * @throws Exception
+    */
+   public void testNonPrimitiveModifyFromAlternativeNode()
+         throws Exception
+   {
+      String attr = "";
+      getLog().debug("Enter testNonPrimitiveModifyFromAlternativeNode");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+
+      // Get the Attribute set
+      String attrOld = makeGet(client, baseURL0_ +getUrl);
+      
+      sleepThread(DEFAULT_SLEEP);
+      
+      // Switch to server 1 and get the attribute
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attrOld1 = makeGet(client, baseURL1_ +getUrl);
+      
+      assertEquals("Attributes should be the same", attrOld, attrOld1);
+
+      // Modify the attribute.
+      makeGet(client, baseURL1_ +modifyUrl);
+      String attr2 = makeGet(client, baseURL1_ +getUrl);
+
+      sleepThread(400);
+      
+      // Switch back to server 0 and get the attribute
+      setCookieDomainToThisServer(client, servers_[0]);
+      attr = makeGet(client, baseURL0_ +getUrl);
+
+      assertEquals("Attributes should be the same", attr, attr2);
+      getLog().debug("Exit testNonPrimitiveModifyModifyFromAlternativeNode");
+   }
+
+   /**
+    * Test invalidate session
+    *
+    * @throws Exception
+    */
+   public void testInvalidate()
+         throws Exception
+   {
+      getLog().debug("Enter testInvalidate");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      invalidate();
+      
+      getLog().debug("Exit testInvalidate");  
+   }
+   
+   public void testSessionBindingEvent()
+      throws Exception
+   {
+      String attr = "";
+      getLog().debug("Enter testSessionBindingEvent");
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+      
+      // Bind a new HttpSessionListener to the session
+      // and check that there is a valueBound() event
+      attr = makeGet(client, baseURL0_ + bindUrl_ + "new");
+      assertTrue("Got OK when binding a new listener", 
+                 (attr != null && attr.indexOf("OK") >= 0 ) );
+      
+      // Rebind the same HttpSessionListener to the session
+      // and check that there is no valueUnbound()
+      attr = makeGet(client, baseURL0_ + bindUrl_ + "rebind");
+      assertTrue("Got OK when rebinding an existing listener", 
+                 (attr != null && attr.indexOf("OK") >= 0 ) );
+      
+      // Replace the HttpSessionListener with another one
+      // and check that there is a valueUnbound()
+      attr = makeGet(client, baseURL0_ + bindUrl_ + "replace");
+      assertTrue("Got OK when replacing a listener", 
+                 (attr != null && attr.indexOf("OK") >= 0 ) );
+      
+      // Remove the same HttpSessionListener
+      // and check that there is a valueUnbound()
+      attr = makeGet(client, baseURL0_ + bindUrl_ + "remove");
+      assertTrue("Got OK when removing a listener", 
+                 (attr != null && attr.indexOf("OK") >= 0 ) );
+   }
+   
+   public void testExcludeSecuritySubject() throws Exception
+   {
+      getLog().debug("Enter testExcludeSecuritySubject");
+   
+      getLog().debug(setSecuritySubjectUrl_ + ":::::::" + getSecuritySubjectUrl_);
+   
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+   
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setSecuritySubjectUrl_);
+   
+      // Confirm the attribute is available from the server where it was set
+      String attrOrig = makeGet(client, baseURL0_ +getSecuritySubjectUrl_);
+      assertTrue("javax.security.auth.subject available locally", 
+            attrOrig.indexOf("javax.security.auth.Subject") > -1);
+      
+      sleepThread(DEFAULT_SLEEP);
+      
+      // Check if the attribute replicated
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attrRepl = makeGet(client, baseURL1_ +getSecuritySubjectUrl_);
+      assertTrue("javax.security.Subject did not replicate", attrRepl.indexOf("java.lang.String") > -1);
+   }
+   
+   /**
+    * Test for JBAS-3528 (http://jira.jboss.com/jira/browse/JBAS-3528).
+    * 
+    * @throws Exception
+    */
+   public void testIsNew() throws Exception
+   {
+      getLog().debug("Enter testIsNew");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+      
+      sleepThread(DEFAULT_SLEEP);
+
+      // Let's switch to server 2 to retrieve the session attribute.
+      setCookieDomainToThisServer(client, servers_[1]);
+      assertFalse("Session is not new", checkNew(client, baseURL1_ + getUrl));
+      
+      sleepThread(DEFAULT_SLEEP);
+
+      // Let's switch to server 1 to ensure its correct there as well.
+      setCookieDomainToThisServer(client, servers_[0]);
+      assertFalse("Session is not new", checkNew(client, baseURL0_ + getUrl));      
+   }
+
+
+   /**
+    * Makes a http call to the given url and confirms that a non-null
+    * header X-SessionIsNew is returned.  Converts the value
+    * of the header to a boolean and returns it.
+    *
+    * @param client
+    * @param url
+    */
+   protected boolean checkNew(HttpClient client, String url)
+   {
+      getLog().info("checkNew(): trying to get from url " +url);
+
+      GetMethod method = new GetMethod(url);
+      int responseCode = 0;
+      try
+      {
+         responseCode = client.executeMethod(method);
+      } catch (IOException e)
+      {
+         e.printStackTrace();
+         fail("HttpClient executeMethod fails." +e.toString());
+      }
+      assertTrue("Get OK with url: " +url + " responseCode: " +responseCode
+        , responseCode == HttpURLConnection.HTTP_OK);
+
+      Header hdr = method.getResponseHeader("X-SessionIsNew");
+      assertNotNull("Got X-SessionIsNew header", hdr);
+      String value = hdr.getValue();
+      assertNotNull("Got non-nullX-SessionIsNew header", value);
+      
+      return Boolean.valueOf(value).booleanValue();
+   }
+
+   protected void invalidate() throws Exception
+   {
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+
+      // Get the Attribute set
+      String attr0 = makeGet(client, baseURL0_ +getUrl);
+
+      sleepThread(DEFAULT_SLEEP);
+      
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr1 = makeGet(client, baseURL1_ + getUrl);
+      
+      assertEquals("attributes match", attr0, attr1);
+      
+      // Invalidate the session
+      makeGet(client, baseURL1_ +invalidateUrl);
+
+      sleepThread(DEFAULT_SLEEP + 200); // wait a bit longer to propagate
+
+      // Make connection to server 0 and get
+      setCookieDomainToThisServer(client, servers_[0]);
+      // Session is invalidated. Should have not OK response.
+      makeGetFailed(client, baseURL0_ + getUrl);
+   }
+
+   protected void clear() throws Exception
+   {
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +clearUrl);
+   }
+
+   /** 
+    * Test ability for a FORM auth based app to have failover without requiring
+    * a new sign-on
+    * 
+    * This test will not pass until a FormAuthenticator that makes
+    * use of cached usernames and passwords is available.
+    * 
+    * @throws Exception
+    */ 
+   public void badtestFormAuthFailover() throws Exception
+   {
+      log.info("+++ testFormAuthFailover");
+      
+      // Start by accessing the war's protected url
+      HttpClient client = new HttpClient();
+      
+      String body = makeGet(client, baseURL0_ + protectedUrl_);
+      if( body.indexOf("j_security_check") < 0 )
+         fail("get of "+protectedUrl_+" not redirected to login page");
+      
+      HttpState state = client.getState();
+      Cookie[] cookies = state.getCookies();
+      String sessionID = null;
+      for(int c = 0; c < cookies.length; c ++)
+      {
+         Cookie k = cookies[c];
+         if( k.getName().equalsIgnoreCase("JSESSIONID") )
+            sessionID = k.getValue();
+      }
+      log.debug("Saw JSESSIONID="+sessionID);
+
+      // Submit the login form
+      PostMethod formPost = new PostMethod(baseURL0_ + securityCheckUrl_);
+      formPost.addRequestHeader("Referer", baseURL0_ + loginFormUrl_);
+      formPost.addParameter("j_username", "admin");
+      formPost.addParameter("j_password", "admin");
+      int responseCode = client.executeMethod(formPost.getHostConfiguration(),
+         formPost, state);
+      String response = formPost.getStatusText();
+      log.debug("responseCode="+responseCode+", response="+response);
+      assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
+         responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
+
+      //  Follow the redirect to the index.html page
+      body = makeGet(client, baseURL0_ + protectedUrl_);
+      if( body.indexOf("j_security_check") > 0 )
+         fail("get of "+baseURL0_ + protectedUrl_+" redirected to login page");
+
+      // Switch to the second server
+      setCookieDomainToThisServer(client, servers_[1]);
+
+      sleepThread(DEFAULT_SLEEP);
+      
+      // Now try getting the protected url on the second server 
+      body = makeGet(client, baseURL1_ + protectedUrl_);
+      if( body.indexOf("j_security_check") > 0 )
+         fail("get of "+baseURL1_ + protectedUrl_+" redirected to login page");       
+   }
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/SessionBasedConcurrentTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/SessionBasedConcurrentTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,171 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.web.test;
+
+import junit.framework.Test;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.testutil.WebTestBase;
+
+import java.util.Random;
+
+import EDU.oswego.cs.dl.util.concurrent.Semaphore;
+
+/**
+ * Simple clustering test case of get/set. It is session based granularity with concurrent access.
+ *
+ * @author Ben Wang
+ * @version $Revision: 1.0
+ */
+public class SessionBasedConcurrentTestCase
+      extends WebTestBase
+{
+   Throwable ex_ = null;
+   final int PERMITS = 100;
+   Semaphore sem_ = new Semaphore(PERMITS);
+   String setURLName_;
+   String getURLName_;
+
+   public SessionBasedConcurrentTestCase(String name)
+   {
+      super(name);
+      setURLName_ = "/http-sr/testsessionreplication.jsp";
+      getURLName_ = "/http-sr/getattribute.jsp";
+   }
+
+   protected void setUp() throws Exception {
+      super.setUp();
+      ex_ = null;
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(SessionBasedConcurrentTestCase.class,
+            "http-sr.war");
+      return t1;
+   }
+
+   /**
+    * Test different set in different servers.
+    * @throws Exception
+    */
+   public void testConcurrentPut()
+         throws Exception
+   {
+      int TIMES = 10;
+      for(int i=0; i < 10; i++)
+      {
+         String threadName = "startWithServer_1_ " +i;
+         Thread t1 = runThread(threadName, baseURL0_, baseURL1_, servers_[1], TIMES, i);
+         threadName = "startWithServer_2_ " +i;
+         Thread t2 = runThread(threadName, baseURL1_, baseURL0_, servers_[0], TIMES, i);
+         t1.start();
+         t2.start();
+      }
+
+      sleepThread(1000);
+      while(true) {
+         if(sem_.permits() != PERMITS)
+         {
+            sleepThread(1000);
+            continue;
+         } else
+         {
+            break;
+         }
+      }
+
+      if(ex_ != null)
+      {
+         fail("Test fail " +ex_);
+      }
+   }
+
+   /**
+    * Thread to execute the http request.
+    * @param threadName
+    * @return
+    */
+   protected Thread runThread(final String threadName, final String baseURL0, final String baseURL1,
+                              final String server2, final int TIMES, final int SEED) {
+      return new Thread(threadName) {
+         Random rand = new Random(SEED);
+         public void run() {
+            try {
+               sem_.acquire();
+            } catch (InterruptedException e) {
+               e.printStackTrace();
+               ex_ = e;
+               return;
+            }
+
+            try {
+               for(int i=0; i < TIMES; i++)
+               {
+                  work();
+                  // Random numbder between [0, 200].
+                  long msecs = rand.nextInt(200);
+                  sleepThread(msecs);
+               }
+            } finally {
+               sem_.release();
+            }
+         }
+
+         protected void work() {
+            String attr = "";
+            getLog().debug("Enter runThread");
+
+            String setURLName = setURLName_;
+            String getURLName = getURLName_;
+
+            getLog().debug(setURLName + ":::::::" + getURLName);
+
+            // Create an instance of HttpClient.
+            HttpClient client = new HttpClient();
+
+            try {
+               // Set the session attribute first
+               makeGet(client, baseURL0 +setURLName);
+   
+               // Get the Attribute set by testsessionreplication.jsp
+               attr = makeGetWithState(client, baseURL0 +getURLName);
+   
+               // Let's switch to server 2 to retrieve the session attribute.
+               getLog().debug("Switching to server " +server2);
+               setCookieDomainToThisServer(client, server2);
+               String attr2 = makeGet(client, baseURL1 +getURLName);
+   
+               // Check the result
+              assertEquals("Http session replication attribtues retrieved from both servers ", attr, attr2);
+            } catch (Throwable ex) {
+               ex_ = ex;
+            }
+
+            getLog().debug("Http Session Replication has happened");
+            getLog().debug("Exit runThread");
+         }
+      };
+  }
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/UndeployAttrTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployAttrTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,41 @@
+package org.jboss.test.cluster.multicfg.web.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Tests that a clustered session still functions properly on the second
+ * node after the webapp is undeployed from the first node.
+ * <p/>
+ * This version tests an AttributeBasedClusteredSession.
+ * 
+ * @author Brian Stansberry
+ * @version $Id$
+ */
+public class UndeployAttrTestCase extends UndeployTestCase
+{
+
+   public UndeployAttrTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected String getContextPath()
+   {
+      return "/http-scoped-attr/";
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped-attr.war";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployAttrTestCase.class,
+            "http-scoped-attr.war");
+      return t1;
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/UndeployTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/UndeployTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,136 @@
+package org.jboss.test.cluster.multicfg.web.test;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.testutil.WebTestBase;
+
+/**
+ * Tests that a clustered session still functions properly on the second
+ * node after the webapp is undeployed from the first node.
+ * <p/>
+ * This version tests a SessionBasedClusteredSession.
+ * 
+ * @author Brian Stansberry
+ * @version $Id$
+ */
+public class UndeployTestCase extends WebTestBase
+{
+   protected String setUrl_;
+   protected String getUrl_;
+   protected String setUrlBase_;
+   protected String getUrlBase_;
+   
+   protected boolean deployed0_ = true;
+   protected boolean deployed1_ = true;
+   
+   public UndeployTestCase(String name)
+   {
+      super(name);
+      setUrlBase_ = "setSession.jsp";
+      getUrlBase_ = "getAttribute.jsp";
+
+      concatenate();
+   }
+   
+   protected String getContextPath()
+   {
+      return "/http-scoped/";
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped.war";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(UndeployTestCase.class,
+            "http-scoped.war");
+      return t1;
+   }
+
+   /**
+    * Main method that deals with the Http Session Replication Test
+    *
+    * @throws Exception
+    */
+   public void testRedeploy()
+         throws Exception
+   {
+      String attr = "";
+      getLog().info("Enter testRedeploy");
+
+      getLog().debug(setUrl_ + ":::::::" + getUrl_);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl_);
+
+      // Create a method instance.
+      // Get the Attribute set
+      attr = makeGetWithState(client, baseURL0_ +getUrl_);
+      
+      reconfigureCluster();
+
+      sleepThread(DEFAULT_SLEEP);
+
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr2 = makeGetWithState(client, baseURL1_ + getUrl_);
+
+      assertEquals("Get attribute should be but is ", attr, attr2);
+      getLog().debug("Exit testRedeploy");
+   }
+
+   protected void concatenate()
+   {
+      setUrl_ = getContextPath() +setUrlBase_;
+      getUrl_ = getContextPath() +getUrlBase_;
+   }   
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      configureCluster();
+   }
+
+   protected void configureCluster() throws Exception
+   {
+      RMIAdaptor[] adaptors = getAdaptors();
+      String warName = getWarName();
+      if (!deployed0_)
+      {
+         deploy(adaptors[0], warName);
+         getLog().debug("Deployed " + warName + " on server0");
+         deployed0_ = true;
+      }
+      if (!deployed1_)
+      {
+         deploy(adaptors[1], warName);
+         getLog().debug("Deployed " + warName + " on server1");
+         deployed1_ = true;
+      }
+   
+      sleep(2000);
+   }
+   
+   protected void reconfigureCluster() throws Exception
+   {
+      RMIAdaptor[] adaptors = getAdaptors();
+      deploy(adaptors[1], getWarName());
+      deployed1_ = true;
+      
+      sleep(2000);
+      
+      undeploy(adaptors[0], getWarName());
+      deployed0_ = false;
+      
+      sleep(2000);
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java (from rev 64055, trunk/testsuite/src/main/org/jboss/test/cluster/test/WebSessionTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/multicfg/web/test/WebSessionTestCase.java	2007-07-24 02:36:31 UTC (rev 64213)
@@ -0,0 +1,225 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.web.test;
+
+import java.net.HttpURLConnection;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.testutil.WebTestBase;
+
+/** Tests of http session replication
+ *
+ * @author  Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class WebSessionTestCase extends JBossClusteredTestCase
+{
+   /** 
+    * Standard number of ms to pause between http requests
+    * to give session time to replicate
+    */
+   public static final long DEFAULT_SLEEP = WebTestBase.DEFAULT_SLEEP;
+   
+   public WebSessionTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = getDeploySetup(WebSessionTestCase.class, "dist-ss.war");
+      return t1;
+   }
+
+   /** This makes 2 requests to the jbosstest.cluster.node0 /dist-ss/StatefulSessionServlet
+    * followed by 2 requests to the jbosstest.cluster.node1 /dist-ss/StatefulSessionServlet
+    * using the same session ID to validate that the session is replicated
+    * with the current value and updated correctly. The session AccessCount
+    * value is returned via the X-AccessCount header which should be 4 after
+    * the last request.
+    * 
+    * @throws Exception
+    */ 
+   public void testServletSessionFailover()
+      throws Exception
+   {
+      getLog().debug("+++ testServletSessionFailover");
+
+      String[] servers = super.getServers();
+      String[] httpURLs  = super.getHttpURLs();
+      // Access the StatefulSessionServlet of dist-ss.war at server0 twice
+      String baseURL0 = httpURLs[0];
+      HttpClient httpConn = new HttpClient();
+      GetMethod servletGet0 = new GetMethod(baseURL0+"/dist-ss/StatefulSessionServlet/");
+      int responseCode = httpConn.executeMethod(servletGet0);
+      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+      Header accessCount = servletGet0.getResponseHeader("X-AccessCount");
+      int count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 1, count);
+      // Get the state for the JSESSIONID
+      HttpState state = httpConn.getState();
+      servletGet0 = new GetMethod(baseURL0+"/dist-ss/StatefulSessionServlet/");
+      responseCode = httpConn.executeMethod(servletGet0.getHostConfiguration(),
+         servletGet0, state);
+      accessCount = servletGet0.getResponseHeader("X-AccessCount");
+      count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 2, count);
+      // Get the JSESSIONID so we can reset the host
+      Cookie[] cookies = state.getCookies();
+      Cookie sessionID = null;
+      for(int c = 0; c < cookies.length; c ++)
+      {
+         Cookie k = cookies[c];
+         if( k.getName().equalsIgnoreCase("JSESSIONID") )
+            sessionID = k;
+      }
+      log.info("Saw JSESSIONID="+sessionID);
+      // Reset the domain so that the cookie will be sent to server1
+      sessionID.setDomain(servers[1]);
+      state.addCookie(sessionID);
+      _sleep(DEFAULT_SLEEP);
+
+      // Access the StatefulSessionServlet of dist-ss.war at server1 twice
+      String baseURL1 = httpURLs[1];
+      GetMethod servletGet1 = new GetMethod(baseURL1+"/dist-ss/StatefulSessionServlet/");
+      responseCode = httpConn.executeMethod(servletGet1.getHostConfiguration(),
+         servletGet1, state);
+      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+      accessCount = servletGet1.getResponseHeader("X-AccessCount");
+      count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 3, count);
+      servletGet1 = new GetMethod(baseURL1+"/dist-ss/StatefulSessionServlet/");
+      responseCode = httpConn.executeMethod(servletGet1.getHostConfiguration(),
+         servletGet1, state);
+      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+      accessCount = servletGet1.getResponseHeader("X-AccessCount");
+      count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 4, count);
+   }
+
+   /** This makes 4 requests alternating between the jbosstest.cluster.node0
+    * /dist-ss/StatefulSessionServlet and jbosstest.cluster.node1 /dist-ss/StatefulSessionServlet
+    * using the same session ID to validate that the session is replicated
+    * with the current value and updated correctly. The session AccessCount
+    * value is returned via the X-AccessCount header which should be 4 after
+    * the last request.
+    * 
+    * Note: this test is not currently working since current http session
+    * replication assumes sticky session. It does not support random load
+    * balancing.
+    * bwang.
+    *
+    * @throws Exception
+    */ 
+   public void testServletSessionLoadBalancing()
+      throws Exception
+   {
+      getLog().debug("+++ testServletSessionLoadBalancing");
+
+      String[] servers = getServers();
+      String[] httpURLs  = super.getHttpURLs();
+      String baseURL0 = httpURLs[0];
+      String baseURL1 = baseURL0;
+      if( servers.length > 1 )
+      {
+        baseURL1 = httpURLs[1];
+      }
+      // Access the StatefulSessionServlet of dist-ss.war at server0 twice
+      HttpClient httpConn = new HttpClient();
+      GetMethod servletGet0 = new GetMethod(baseURL0+"/dist-ss/StatefulSessionServlet/");
+      int responseCode = httpConn.executeMethod(servletGet0);
+      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+      Header accessCount = servletGet0.getResponseHeader("X-AccessCount");
+      int count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 1, count);
+      // Get the state for the JSESSIONID
+      HttpState state = httpConn.getState();
+      // Get the JSESSIONID so we can reset the host
+      Cookie[] cookies = state.getCookies();
+      Cookie sessionID = null;
+      for(int c = 0; c < cookies.length; c ++)
+      {
+         Cookie k = cookies[c];
+         if( k.getName().equalsIgnoreCase("JSESSIONID") )
+            sessionID = k;
+      }
+      log.info("Saw JSESSIONID="+sessionID);
+      // Reset the domain so that the cookie will be sent to server1
+      sessionID.setDomain(servers[1]);
+      state.addCookie(sessionID);
+      _sleep(DEFAULT_SLEEP);
+      // Access the StatefulSessionServlet of dist-ss.war at server1 twice
+      GetMethod servletGet1 = new GetMethod(baseURL1+"/dist-ss/StatefulSessionServlet/");
+      responseCode = httpConn.executeMethod(servletGet1.getHostConfiguration(),
+         servletGet1, state);
+      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+      accessCount = servletGet1.getResponseHeader("X-AccessCount");
+      count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 2, count);
+
+      _sleep(DEFAULT_SLEEP);
+      // Reset the domain so that the cookie will be sent to server0
+      sessionID.setDomain(servers[0]);
+      state.addCookie(sessionID);
+      servletGet0 = new GetMethod(baseURL0+"/dist-ss/StatefulSessionServlet/");
+      responseCode = httpConn.executeMethod(servletGet0.getHostConfiguration(),
+         servletGet0, state);
+      accessCount = servletGet0.getResponseHeader("X-AccessCount");
+      count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 3, count);
+
+      _sleep(DEFAULT_SLEEP);
+      // Reset the domain so that the cookie will be sent to server1
+      sessionID.setDomain(servers[1]);
+      state.addCookie(sessionID);
+      servletGet1 = new GetMethod(baseURL1+"/dist-ss/StatefulSessionServlet/");
+      responseCode = httpConn.executeMethod(servletGet1.getHostConfiguration(),
+         servletGet1, state);
+      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+      accessCount = servletGet1.getResponseHeader("X-AccessCount");
+      count = Integer.parseInt(accessCount.getValue());
+      assertEquals("X-AccessCount ", 4, count);
+   }
+
+
+   /**
+    * Sleep for specified time
+    *
+    * @param msecs
+    */
+   protected void _sleep(long msecs)
+   {
+      try {
+         Thread.sleep(msecs);
+      } catch (InterruptedException e) {
+         e.printStackTrace();
+      }
+   }
+
+}




More information about the jboss-cvs-commits mailing list