[jboss-cvs] JBossAS SVN: r95457 - trunk/testsuite/src/main/org/jboss/test/cluster/testutil.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 22 20:36:56 EDT 2009


Author: bstansberry at jboss.com
Date: 2009-10-22 20:36:56 -0400 (Thu, 22 Oct 2009)
New Revision: 95457

Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
Log:
[JBAS-7379][JBAS-7205] Set up some test infrastructure

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2009-10-23 00:35:01 UTC (rev 95456)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2009-10-23 00:36:56 UTC (rev 95457)
@@ -33,6 +33,7 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.core.StandardContext;
 import org.apache.commons.httpclient.Cookie;
@@ -91,11 +92,22 @@
          e.printStackTrace();
       }
    }
+   
    public static JBossCacheManager createManager(String warName, int maxInactiveInterval, 
                                                  boolean local, String passivationDir, 
                                                  boolean totalReplication, boolean marshalling, 
                                                  String jvmRoute, Set<PojoCache> allCaches)
    {
+      return createManager(warName, maxInactiveInterval, local, passivationDir, 
+                           totalReplication, marshalling, false, jvmRoute, allCaches);
+   }
+   
+   public static JBossCacheManager createManager(String warName, int maxInactiveInterval, 
+                                                 boolean local, String passivationDir, 
+                                                 boolean totalReplication, boolean marshalling,
+                                                 boolean purgeCacheLoader,
+                                                 String jvmRoute, Set<PojoCache> allCaches)
+   {
       PojoCache cache = createCache(local, passivationDir, totalReplication, marshalling, allCaches);
       return createManager(warName, maxInactiveInterval, cache, jvmRoute);
    }
@@ -112,15 +124,7 @@
       JBossCacheManager jbcm = new JBossCacheManager(distributedManagerFactory);
       jbcm.setSnapshotMode(SnapshotMode.INSTANT);
       
-      MockEngine engine = new MockEngine();
-      engine.setJvmRoute(jvmRoute);
-      MockHost host = new MockHost();
-      host.setName("localhost");
-      engine.addChild(host);
-      StandardContext container = new StandardContext();
-      container.setName(warName);
-      host.addChild(container);
-      container.setManager(jbcm);
+      setupContainer(warName, jvmRoute, jbcm);
       
       // Do this after assigning the manager to the container, or else
       // the container's setting will override ours
@@ -133,7 +137,13 @@
    public static PojoCache createCache(boolean local, String passivationDir, 
          boolean totalReplication, boolean marshalling, Set<PojoCache> allCaches)
    {
-      Configuration cfg = getConfiguration(local, passivationDir, totalReplication, marshalling);
+      return createCache(local, passivationDir, totalReplication, marshalling, false, allCaches);
+   }
+   
+   public static PojoCache createCache(boolean local, String passivationDir, 
+         boolean totalReplication, boolean marshalling, boolean purgeCacheLoader, Set<PojoCache> allCaches)
+   {
+      Configuration cfg = getConfiguration(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
       PojoCache cache = PojoCacheFactory.createCache(cfg, true);
       
       if (allCaches != null)
@@ -142,7 +152,7 @@
    }
    
    public static Configuration getConfiguration(boolean local, String passivationDir, 
-         boolean totalReplication, boolean marshalling)
+         boolean totalReplication, boolean marshalling, boolean purgeCacheLoader)
    {
       PojoCache temp = PojoCacheFactory.createCache(CONFIG_LOCATION, false);
       Configuration config = temp.getCache().getConfiguration();
@@ -159,6 +169,7 @@
          fclc.setProperties(clc.getFirstCacheLoaderConfig().getProperties());
          fclc.setLocation(passivationDir);
          fclc.setFetchPersistentState(true);
+         fclc.setPurgeOnStartup(purgeCacheLoader);
          ArrayList<IndividualCacheLoaderConfig> iclcs = new ArrayList<IndividualCacheLoaderConfig>();
          iclcs.add(fclc);
          clc.setIndividualCacheLoaderConfigs(iclcs);
@@ -196,6 +207,19 @@
    {
       distributedManagerFactory.clearCaches();
    }
+
+   public static void setupContainer(String warName, String jvmRoute, Manager mgr)
+   {
+      MockEngine engine = new MockEngine();
+      engine.setJvmRoute(jvmRoute);
+      MockHost host = new MockHost();
+      host.setName("localhost");
+      engine.addChild(host);
+      StandardContext container = new StandardContext();
+      container.setName(warName);
+      host.addChild(container);
+      container.setManager(mgr);
+   }
    
    public static JBossWebMetaData createWebMetaData(int maxSessions)
    {
@@ -248,12 +272,14 @@
       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 request = setupRequest(manager, sessionId);
+      invokeRequest(valve, request);
+   }
+   
+   public static void invokeRequest(Valve pipelineHead, Request request)
+      throws ServletException, IOException
+   {
+      pipelineHead.invoke(request, request.getResponse());
       // StandardHostValve calls request.getSession(false) on way out, so we will too
       request.getSession(false);
       request.recycle();
@@ -288,6 +314,17 @@
       return pipeline.getFirst();
    }
    
+   public static Request setupRequest(Manager manager, String sessionId)
+   {
+      MockRequest request = new MockRequest();
+      request.setRequestedSessionId(sessionId);
+      request.setContext((Context) manager.getContainer());
+      Response response = new Response();
+      request.setResponse(response);
+      return request;
+      
+   }
+   
    public static void cleanupPipeline(Manager manager)
    {
       Pipeline pipeline = manager.getContainer().getPipeline();




More information about the jboss-cvs-commits mailing list