[jboss-cvs] JBossAS SVN: r75640 - in trunk/testsuite/src/main/org/jboss/test/cluster: defaultcfg/web/test and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 10 17:41:35 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-07-10 17:41:35 -0400 (Thu, 10 Jul 2008)
New Revision: 75640

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java
Removed:
   trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/MockEngine.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/MockHost.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java
Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JvmRouteValveUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
Log:
[JBAS-5751] Add some test infrastructure

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JvmRouteValveUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JvmRouteValveUnitTestCase.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/simpleweb/test/JvmRouteValveUnitTestCase.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -29,7 +29,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.test.cluster.web.jvmroute.MockJBossManager;
 import org.jboss.test.cluster.web.jvmroute.MockRequest;
-import org.jboss.test.cluster.web.jvmroute.MockValve;
+import org.jboss.test.cluster.web.mocks.MockValve;
 import org.jboss.web.tomcat.service.session.JvmRouteValve;
 
 /**

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -127,6 +127,8 @@
             log.error("Failed clearing client " + client, e);
          }
       }
+      
+      clients.clear();
    }
    
    protected boolean isCleanCacheOnRedeploy()

Added: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/CacheConfigTestSetup.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.testutil;
+
+import java.net.InetAddress;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class CacheConfigTestSetup extends JBossTestSetup
+{
+   private static final Logger log = Logger.getLogger(CacheConfigTestSetup.class);
+   
+   public static Test getTestSetup(Class clazz, final PojoCache[] caches, final boolean local, final String passivationDir, final boolean totalReplication, final boolean marshalling)
+      throws Exception
+   {
+      final TestSuite suite = new TestSuite();
+      suite.addTest(new TestSuite(clazz));
+      return new CacheConfigTestSetup(suite, caches, local, passivationDir, totalReplication, marshalling);
+   }
+   
+   private PojoCache[] pojoCaches;
+   private String passivationDir;
+   private boolean local;
+   private boolean totalReplication;
+   private boolean marshalling;
+   
+   /**
+    * Create a new CacheConfigTestSetup.
+    * 
+    * @param test
+    * @throws Exception
+    */
+   public CacheConfigTestSetup(Test test, PojoCache[] caches, boolean local, String passivationDir, boolean totalReplication, final boolean marshalling) throws Exception
+   {
+      super(test);
+      this.pojoCaches = caches;
+      this.passivationDir = passivationDir;
+      this.local = local;
+      this.totalReplication = totalReplication;
+      this.marshalling = marshalling;
+   }
+   
+   protected void setUp() throws Exception
+   {
+      if (pojoCaches == null) return;
+      String bind_addr = System.getProperty("jgroups.bind_addr");
+      String mcast_addr = System.getProperty("jgroups.udp.mcast_addr");
+      String mcast_port =  System.getProperty("jgroups.udp.mcast_port");
+      
+      try
+      {
+         System.setProperty("jgroups.bind_addr", System.getProperty("jbosstest.cluster.node1", InetAddress.getLocalHost().getHostAddress()));
+         String udpGroup = System.getProperty("jbosstest.udpGroup", "233.54.54.54");
+         if (udpGroup.trim().length() ==0)
+            udpGroup = "233.54.54.54";
+         System.setProperty("jgroups.udp.mcast_addr", udpGroup);
+         System.setProperty("jgroups.udp.mcast_port", String.valueOf(54545));
+         
+         for (int i = 0; i < pojoCaches.length; i++)
+         {
+            pojoCaches[i] = SessionTestUtil.createCache(local, passivationDir, totalReplication, marshalling, null);
+         }
+      }
+      finally
+      {
+         if (bind_addr == null)
+            System.clearProperty("jgroups.bind_addr");
+         else
+            System.setProperty("jgroups.bind_addr", bind_addr);
+         if (mcast_addr == null)
+            System.clearProperty("jgroups.udp.mcast_addr");
+         else
+            System.setProperty("jgroups.udp.mcast_addr", mcast_addr);
+         if (mcast_port == null)
+            System.clearProperty("jgroups.udp.mcast_port");
+         else
+            System.setProperty("jgroups.udp.mcast_port", mcast_port);
+      }
+      
+      // wait a few seconds so that the cluster stabilize
+      synchronized (this)
+      {
+         wait(2000);
+      }
+   }
+
+   protected void tearDown() throws Exception
+   {
+      if (pojoCaches != null)
+      {
+         for (int i = 0; i < pojoCaches.length; i++)
+         {
+            try
+            {   
+               PojoCache pc = pojoCaches[i];
+               pojoCaches[i] = null;
+               pc.stop();
+               pc.destroy();
+            }
+            catch (Exception ex)
+            {
+               log.error("Failed stopping cache " + i);
+            }
+         }         
+      }
+   }
+
+}

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -22,12 +22,19 @@
 
 package org.jboss.test.cluster.testutil;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
 import javax.management.MBeanServerConnection;
+import javax.servlet.ServletException;
 
+import org.apache.catalina.Context;
+import org.apache.catalina.Manager;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Response;
 import org.apache.catalina.core.StandardContext;
 import org.apache.commons.httpclient.Cookie;
 import org.apache.commons.httpclient.HttpClient;
@@ -51,8 +58,11 @@
 import org.jboss.metadata.web.jboss.ReplicationTrigger;
 import org.jboss.metadata.web.jboss.SnapshotMode;
 import org.jboss.test.cluster.web.CacheHelper;
-import org.jboss.test.cluster.web.MockEngine;
-import org.jboss.test.cluster.web.MockHost;
+import org.jboss.test.cluster.web.mocks.MockEngine;
+import org.jboss.test.cluster.web.mocks.MockHost;
+import org.jboss.test.cluster.web.mocks.MockRequest;
+import org.jboss.test.cluster.web.mocks.RequestHandler;
+import org.jboss.test.cluster.web.mocks.RequestHandlerValve;
 import org.jboss.web.tomcat.service.session.JBossCacheManager;
 
 /**
@@ -163,6 +173,48 @@
       return webMetaData;
    }
    
+   public static void invokeRequest(Manager manager, RequestHandler handler, String sessionId)
+      throws ServletException, IOException
+   {
+      Valve valve = setupPipeline(manager, handler);
+      MockRequest request = new MockRequest();
+      request.setRequestedSessionId(sessionId);
+      request.setContext((Context) manager.getContainer());
+      Response response = new Response();
+      request.setResponse(response);
+      valve.invoke(request, response);
+      request.recycle();
+   }
+   
+   public static Valve setupPipeline(Manager manager, RequestHandler requestHandler)
+   {
+      Pipeline pipeline = manager.getContainer().getPipeline();
+      
+      // Clean out any existing request handler
+      Valve[] valves = pipeline.getValves();
+      RequestHandlerValve mockValve = null;
+      for (Valve valve: valves)
+      {
+         if (valve instanceof RequestHandlerValve)         
+         {
+            mockValve = (RequestHandlerValve) valve;
+            break;
+         }
+      }
+      
+      if (mockValve == null)
+      {
+         mockValve = new RequestHandlerValve(requestHandler);
+         pipeline.addValve(mockValve);
+      }
+      else
+      {
+         mockValve.setRequestHandler(requestHandler);
+      }
+      
+      return pipeline.getFirst();
+   }
+   
    public static Object getSessionVersion(MBeanServerConnection adaptor, String sessionFqn) throws Exception
    {
       return adaptor.invoke(CacheHelper.OBJECT_NAME, 

Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -1,70 +0,0 @@
-/*
- * 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.web;
-
-import org.apache.catalina.Loader;
-import org.apache.catalina.Pipeline;
-import org.apache.catalina.core.ContainerBase;
-import org.apache.catalina.core.StandardPipeline;
-
-/**
- * Mock Container impl to wrap a JBossCacheManager in unit tests.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class MockContainer extends ContainerBase
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 1L;
-   
-   private Loader loader;
-   
-   private Pipeline pipeline;
-
-   @Override
-   public Loader getLoader()
-   {
-      if (loader == null)
-      {
-         loader = new MockLoader();
-         loader.setContainer(this);
-      }
-      return loader;
-   }
-
-   public Pipeline getPipeline()
-   {
-      if (pipeline == null)
-      {
-         pipeline = new StandardPipeline(this);
-      }
-      return pipeline;
-   }
-
-   public void setLoader(Loader loader)
-   {
-      this.loader = loader;
-   }
-
-}

Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockEngine.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/MockEngine.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/MockEngine.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -1,88 +0,0 @@
-/*
- * 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.web;
-
-import org.apache.catalina.Engine;
-import org.apache.catalina.Service;
-
-/**
- * @author Brian Stansberry
- *
- */
-public class MockEngine extends MockContainer implements Engine
-{
-   private static final long serialVersionUID = 1L;
-   
-   private Service service;
-   private String defaultHost = "localhost";
-   private String jvmRoute;
-   
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Engine#getDefaultHost()
-    */
-   public String getDefaultHost()
-   {
-      return defaultHost;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Engine#getJvmRoute()
-    */
-   public String getJvmRoute()
-   {
-      return jvmRoute;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Engine#getService()
-    */
-   public Service getService()
-   {
-      return service;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Engine#setDefaultHost(java.lang.String)
-    */
-   public void setDefaultHost(String arg0)
-   {
-      this.defaultHost = arg0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Engine#setJvmRoute(java.lang.String)
-    */
-   public void setJvmRoute(String arg0)
-   {
-      this.jvmRoute = arg0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Engine#setService(org.apache.catalina.Service)
-    */
-   public void setService(Service arg0)
-   {
-      this.service = arg0;
-   }
-
-}

Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockHost.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/MockHost.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/MockHost.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -1,180 +0,0 @@
-/*
- * 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.web;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Host;
-
-/**
- * @author Brian Stansberry
- *
- */
-public class MockHost extends MockContainer implements Host
-{
-   private static final long serialVersionUID = 1L;
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#addAlias(java.lang.String)
-    */
-   public void addAlias(String arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#findAliases()
-    */
-   public String[] findAliases()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#getAppBase()
-    */
-   public String getAppBase()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#getAutoDeploy()
-    */
-   public boolean getAutoDeploy()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#getConfigClass()
-    */
-   public String getConfigClass()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#getDeployOnStartup()
-    */
-   public boolean getDeployOnStartup()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#getXmlNamespaceAware()
-    */
-   public boolean getXmlNamespaceAware()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#getXmlValidation()
-    */
-   public boolean getXmlValidation()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#map(java.lang.String)
-    */
-   public Context map(String arg0)
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#removeAlias(java.lang.String)
-    */
-   public void removeAlias(String arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#setAppBase(java.lang.String)
-    */
-   public void setAppBase(String arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#setAutoDeploy(boolean)
-    */
-   public void setAutoDeploy(boolean arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#setConfigClass(java.lang.String)
-    */
-   public void setConfigClass(String arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#setDeployOnStartup(boolean)
-    */
-   public void setDeployOnStartup(boolean arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#setXmlNamespaceAware(boolean)
-    */
-   public void setXmlNamespaceAware(boolean arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.apache.catalina.Host#setXmlValidation(boolean)
-    */
-   public void setXmlValidation(boolean arg0)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-}

Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -1,119 +0,0 @@
-/*
- * 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.web;
-
-import java.beans.PropertyChangeListener;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Loader;
-
-/**
- * Mock Loader impl for use in unit tests.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class MockLoader implements Loader
-{
-   private Container container;
-   
-   public void addPropertyChangeListener(PropertyChangeListener listener)
-   {
-      // TODO Auto-generated method stub
-   }
-
-   public void addRepository(String repository)
-   {
-      // TODO Auto-generated method stub
-   }
-
-   public void backgroundProcess()
-   {
-      // TODO Auto-generated method stub
-   }
-
-   public String[] findRepositories()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public ClassLoader getClassLoader()
-   {      
-      return container == null ? getClass().getClassLoader() 
-                               : container.getClass().getClassLoader();
-   }
-
-   public Container getContainer()
-   {
-      return container;
-   }
-
-   public boolean getDelegate()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   public String getInfo()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public boolean getReloadable()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   public boolean modified()
-   {
-      // TODO Auto-generated method stub
-      return false;
-   }
-
-   public void removePropertyChangeListener(PropertyChangeListener listener)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   public void setContainer(Container container)
-   {
-      this.container = container;
-   }
-
-   public void setDelegate(boolean delegate)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   public void setReloadable(boolean reloadable)
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-}

Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java	2008-07-10 21:30:53 UTC (rev 75639)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.test.cluster.web.jvmroute;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Valve;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.jboss.servlet.http.HttpEvent;
-
-/**
- * @author Brian Stansberry
- *
- */
-public class MockValve implements Valve
-{
-   private Request invokedRequest;
-   private Response invokedResponse;
-   
-   /**
-    * Create a new MockValve.
-    * 
-    */
-   public MockValve()
-   {
-   }
-
-   public void backgroundProcess()
-   {
-   }
-
-   public void event(Request request, Response response, HttpEvent event) throws IOException, ServletException
-   {
-   }
-
-   public String getInfo()
-   {
-      return "MockValve";
-   }
-
-   public Valve getNext()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public void invoke(Request request, Response response) throws IOException, ServletException
-   {
-      this.invokedRequest = request;
-      this.invokedResponse = response;
-   }
-
-   public void setNext(Valve valve)
-   {
-
-   }
-
-   public Request getInvokedRequest()
-   {
-      return invokedRequest;
-   }
-
-   public Response getInvokedResponse()
-   {
-      return invokedResponse;
-   }
-   
-   
-
-}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class BasicRequestHandler implements RequestHandler
+{
+   private Set<String> namesToCheck = new HashSet<String>();
+   private boolean checkAttributeNames;
+   private Map<String, Object> checkedAttributes = new HashMap<String, Object>();
+   private Set<String> attributeNames = new HashSet<String>();
+   private String sessionId;
+   private long lastAccessedTime;
+   private int maxInactiveInterval;
+   private long creationTime;
+   private boolean newSession;
+   private HttpSession session;
+   
+   /**
+    * Create a new AbstractRequestHandler.
+    * 
+    */
+   public BasicRequestHandler(Set<String> toCheck, boolean checkNames)
+   {      
+      if (toCheck != null)
+         this.namesToCheck.addAll(toCheck);
+      this.checkAttributeNames = checkNames;
+   }
+
+   public void handleRequest(Request request, Response response)
+   {
+      this.session = request.getSession();
+      this.sessionId = session.getId();
+      this.lastAccessedTime = session.getLastAccessedTime();
+      this.maxInactiveInterval = session.getMaxInactiveInterval();
+      this.newSession = session.isNew();
+      this.creationTime = session.getCreationTime();
+      
+      if (this.checkAttributeNames)
+      {
+         Enumeration<String> e = session.getAttributeNames();
+         while (e.hasMoreElements())
+            attributeNames.add(e.nextElement());
+      }
+      
+      if (namesToCheck != null)
+      {
+         for (String name : namesToCheck)
+         {
+            checkedAttributes.put(name, session.getAttribute(name));
+         }
+      }
+   }
+
+   public String getSessionId()
+   {
+      return sessionId;
+   }
+
+   public long getLastAccessedTime()
+   {
+      return lastAccessedTime;
+   }
+
+   public int getMaxInactiveInterval()
+   {
+      return maxInactiveInterval;
+   }
+
+   public boolean isNewSession()
+   {
+      return newSession;
+   }
+
+   public long getCreationTime()
+   {
+      return creationTime;
+   }
+
+   public Map<String, Object> getCheckedAttributes()
+   {
+      return checkedAttributes;
+   }
+
+   public Set<String> getAttributeNames()
+   {
+      return attributeNames;
+   }
+
+   public HttpSession getSession()
+   {
+      return session;
+   }
+
+   public boolean isCheckAttributeNames()
+   {
+      return checkAttributeNames;
+   }   
+   
+   
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java (from rev 75633, trunk/testsuite/src/main/org/jboss/test/cluster/web/MockContainer.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,70 @@
+/*
+ * 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.web.mocks;
+
+import org.apache.catalina.Loader;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.core.ContainerBase;
+import org.apache.catalina.core.StandardPipeline;
+
+/**
+ * Mock Container impl to wrap a JBossCacheManager in unit tests.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class MockContainer extends ContainerBase
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private Loader loader;
+   
+   private Pipeline pipeline;
+
+   @Override
+   public Loader getLoader()
+   {
+      if (loader == null)
+      {
+         loader = new MockLoader();
+         loader.setContainer(this);
+      }
+      return loader;
+   }
+
+   public Pipeline getPipeline()
+   {
+      if (pipeline == null)
+      {
+         pipeline = new StandardPipeline(this);
+      }
+      return pipeline;
+   }
+
+   public void setLoader(Loader loader)
+   {
+      this.loader = loader;
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java (from rev 75632, trunk/testsuite/src/main/org/jboss/test/cluster/web/MockEngine.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,88 @@
+/*
+ * 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.web.mocks;
+
+import org.apache.catalina.Engine;
+import org.apache.catalina.Service;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockEngine extends MockContainer implements Engine
+{
+   private static final long serialVersionUID = 1L;
+   
+   private Service service;
+   private String defaultHost = "localhost";
+   private String jvmRoute;
+   
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Engine#getDefaultHost()
+    */
+   public String getDefaultHost()
+   {
+      return defaultHost;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Engine#getJvmRoute()
+    */
+   public String getJvmRoute()
+   {
+      return jvmRoute;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Engine#getService()
+    */
+   public Service getService()
+   {
+      return service;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Engine#setDefaultHost(java.lang.String)
+    */
+   public void setDefaultHost(String arg0)
+   {
+      this.defaultHost = arg0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Engine#setJvmRoute(java.lang.String)
+    */
+   public void setJvmRoute(String arg0)
+   {
+      this.jvmRoute = arg0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Engine#setService(org.apache.catalina.Service)
+    */
+   public void setService(Service arg0)
+   {
+      this.service = arg0;
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java (from rev 75632, trunk/testsuite/src/main/org/jboss/test/cluster/web/MockHost.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,180 @@
+/*
+ * 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.web.mocks;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Host;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockHost extends MockContainer implements Host
+{
+   private static final long serialVersionUID = 1L;
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#addAlias(java.lang.String)
+    */
+   public void addAlias(String arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#findAliases()
+    */
+   public String[] findAliases()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#getAppBase()
+    */
+   public String getAppBase()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#getAutoDeploy()
+    */
+   public boolean getAutoDeploy()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#getConfigClass()
+    */
+   public String getConfigClass()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#getDeployOnStartup()
+    */
+   public boolean getDeployOnStartup()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#getXmlNamespaceAware()
+    */
+   public boolean getXmlNamespaceAware()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#getXmlValidation()
+    */
+   public boolean getXmlValidation()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#map(java.lang.String)
+    */
+   public Context map(String arg0)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#removeAlias(java.lang.String)
+    */
+   public void removeAlias(String arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#setAppBase(java.lang.String)
+    */
+   public void setAppBase(String arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#setAutoDeploy(boolean)
+    */
+   public void setAutoDeploy(boolean arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#setConfigClass(java.lang.String)
+    */
+   public void setConfigClass(String arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#setDeployOnStartup(boolean)
+    */
+   public void setDeployOnStartup(boolean arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#setXmlNamespaceAware(boolean)
+    */
+   public void setXmlNamespaceAware(boolean arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.apache.catalina.Host#setXmlValidation(boolean)
+    */
+   public void setXmlValidation(boolean arg0)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java (from rev 75632, trunk/testsuite/src/main/org/jboss/test/cluster/web/MockLoader.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,119 @@
+/*
+ * 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.web.mocks;
+
+import java.beans.PropertyChangeListener;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Loader;
+
+/**
+ * Mock Loader impl for use in unit tests.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class MockLoader implements Loader
+{
+   private Container container;
+   
+   public void addPropertyChangeListener(PropertyChangeListener listener)
+   {
+      // TODO Auto-generated method stub
+   }
+
+   public void addRepository(String repository)
+   {
+      // TODO Auto-generated method stub
+   }
+
+   public void backgroundProcess()
+   {
+      // TODO Auto-generated method stub
+   }
+
+   public String[] findRepositories()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public ClassLoader getClassLoader()
+   {      
+      return container == null ? getClass().getClassLoader() 
+                               : container.getClass().getClassLoader();
+   }
+
+   public Container getContainer()
+   {
+      return container;
+   }
+
+   public boolean getDelegate()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public String getInfo()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public boolean getReloadable()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public boolean modified()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public void removePropertyChangeListener(PropertyChangeListener listener)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   public void setContainer(Container container)
+   {
+      this.container = container;
+   }
+
+   public void setDelegate(boolean delegate)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   public void setReloadable(boolean reloadable)
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import java.io.IOException;
+
+import org.apache.catalina.Manager;
+import org.apache.catalina.Session;
+import org.apache.catalina.connector.Request;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockRequest extends Request
+{
+   private Session session;
+   private String requestedSessionId;
+   private boolean requestedSessionIdFromURL;
+   
+   /**
+    * Create a new MockRequest.
+    * 
+    */
+   public MockRequest()
+   {      
+   }
+
+   @Override
+   public String getRequestedSessionId()
+   {
+      return requestedSessionId;
+   }
+
+   public void setRequestedSessionId(String requestedSessionId)
+   {
+      this.requestedSessionId = requestedSessionId;
+   }
+
+   
+   @Override
+   protected Session doGetSession(boolean create)
+   {
+      if (session == null)
+      {      
+         Manager manager = getContext().getManager();
+         if (requestedSessionId != null)
+         {
+            try {
+                session = manager.findSession(requestedSessionId);
+            } catch (IOException e) {
+                session = null;
+            }
+         }
+         
+         if (session == null && create)
+         {
+            session = manager.createSession(requestedSessionId);
+         }
+         
+         if (session != null)
+         {
+            session.access();
+         }
+      
+      }
+      
+      if (session != null && !session.isValid())
+      {
+         session = null;
+         doGetSession(create);
+      }
+      
+      return session;
+   }
+   
+   public void setSession(Session session)
+   {
+      this.session = session;
+   }
+
+   @Override
+   public boolean isRequestedSessionIdFromURL()
+   {
+      return requestedSessionIdFromURL;
+   }
+
+   public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
+   {
+      this.requestedSessionIdFromURL = requestedSessionIdFromURL;
+   }
+
+   @Override
+   public void recycle()
+   {
+      if (session != null)
+         session.endAccess();
+   }   
+
+   
+}

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java (from rev 75632, trunk/testsuite/src/main/org/jboss/test/cluster/web/jvmroute/MockValve.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.jboss.servlet.http.HttpEvent;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockValve implements Valve
+{
+   private Request invokedRequest;
+   private Response invokedResponse;
+   
+   /**
+    * Create a new MockValve.
+    * 
+    */
+   public MockValve()
+   {
+   }
+
+   public void backgroundProcess()
+   {
+   }
+
+   public void event(Request request, Response response, HttpEvent event) throws IOException, ServletException
+   {
+   }
+
+   public String getInfo()
+   {
+      return "MockValve";
+   }
+
+   public Valve getNext()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public void invoke(Request request, Response response) throws IOException, ServletException
+   {
+      this.invokedRequest = request;
+      this.invokedResponse = response;
+   }
+
+   public void setNext(Valve valve)
+   {
+
+   }
+
+   public Request getInvokedRequest()
+   {
+      return invokedRequest;
+   }
+
+   public Response getInvokedResponse()
+   {
+      return invokedResponse;
+   }
+   
+   
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import java.io.Serializable;
+
+/**
+ * Simple wrapper around a string that will trigger replication on a get if
+ * SET_AND_NON_PRIMITIVE_GET is used.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public class MutableObject implements Serializable
+{   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -8800180646736265624L;
+ 
+   private String string;
+
+   /**
+    * Create a new MutableObject.
+    * 
+    */
+   public MutableObject(String string)
+   {
+      this.string = string;
+   }
+
+   public String getString()
+   {
+      return this.string;
+   }
+
+   public void setString(String string)
+   {
+      this.string = string;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof MutableObject)
+      {
+         return this.string.equals(((MutableObject) obj).string);
+      }
+      return false;
+   }
+
+   @Override
+   public int hashCode()
+   {      
+      return this.string.hashCode();
+   }
+
+   @Override
+   public String toString()
+   {
+      return this.string;
+   }
+   
+   
+   
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public interface RequestHandler
+{
+   void handleRequest(Request request, Response response);
+}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class RequestHandlerValve extends MockValve
+{
+   private RequestHandler requestHandler;
+   
+   public RequestHandlerValve(RequestHandler handler)
+   {
+      this.requestHandler = handler;
+   }
+
+   public String getInfo()
+   {
+      return "RequestHandlerValve";
+   }
+
+   public void invoke(Request request, Response response) throws IOException, ServletException
+   {
+      super.invoke(request, response);
+      requestHandler.handleRequest(request, response);
+   }
+
+   public RequestHandler getRequestHandler()
+   {
+      return requestHandler;
+   }
+
+   public void setRequestHandler(RequestHandler requestHandler)
+   {
+      this.requestHandler = requestHandler;
+   }  
+   
+   
+   
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java	2008-07-10 21:41:35 UTC (rev 75640)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web.mocks;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class SetAttributesRequestHandler extends BasicRequestHandler
+{
+   private Map<String, Object> toStore;
+   
+   /**
+    * Create a new EstablishSessionRequestHandler.
+    * 
+    */
+   public SetAttributesRequestHandler(Map<String, Object> toStore, boolean checkNames)
+   {      
+      super(toStore.keySet(), checkNames);
+      this.toStore = toStore;
+   }
+
+   public void handleRequest(Request request, Response response)
+   {
+      super.handleRequest(request, response);
+      
+      HttpSession session = getSession();
+      for (Map.Entry<String,Object> entry : toStore.entrySet())
+      {
+         session.setAttribute(entry.getKey(), entry.getValue());
+      }      
+   }
+   
+   
+
+   
+}




More information about the jboss-cvs-commits mailing list