[jboss-cvs] JBossAS SVN: r78928 - in branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster: web and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 29 09:23:25 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-09-29 09:23:25 -0400 (Mon, 29 Sep 2008)
New Revision: 78928

Added:
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/ClusteredSessionNotificationPolicyTestCase.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockClusteredSessionNotificationPolicy.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionAttributeListener.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionBindingListener.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionListener.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/InvalidateSessionRequestHandler.java
   branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/RemoveAttributesRequestHandler.java
Log:
[JBAS-5778] Testing with mocks

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/ClusteredSessionNotificationPolicyTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/ClusteredSessionNotificationPolicyTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/test/ClusteredSessionNotificationPolicyTestCase.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -0,0 +1,620 @@
+/*
+ * 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.test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.apache.catalina.Context;
+import org.jboss.cache.aop.PojoCache;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.cluster.web.notification.MockClusteredSessionNotificationPolicy;
+import org.jboss.test.cluster.web.notification.MockHttpSessionAttributeListener;
+import org.jboss.test.cluster.web.notification.MockHttpSessionBindingListener;
+import org.jboss.test.cluster.web.notification.MockHttpSessionListener;
+import org.jboss.test.cluster.web.util.BasicRequestHandler;
+import org.jboss.test.cluster.web.util.CacheConfigTestSetup;
+import org.jboss.test.cluster.web.util.InvalidateSessionRequestHandler;
+import org.jboss.test.cluster.web.util.RemoveAttributesRequestHandler;
+import org.jboss.test.cluster.web.util.SetAttributesRequestHandler;
+import org.jboss.test.cluster.web.util.WebSessionTestUtil;
+import org.jboss.web.tomcat.service.session.JBossCacheManager;
+
+/**
+ * Tests of handling of servlet spec notifications. 
+ * 
+ * @author Brian Stansberry
+ */
+public class ClusteredSessionNotificationPolicyTestCase extends JBossTestCase
+{
+   protected static PojoCache[] pojoCaches = new PojoCache[2];
+
+   protected static long testId = System.currentTimeMillis();
+   
+   protected static boolean useBuddyRepl = Boolean.valueOf(System.getProperty("jbosstest.cluster.web.cache.br")).booleanValue();
+   
+   protected Logger log = Logger.getLogger(getClass());   
+   
+   protected Set<JBossCacheManager> managers = new HashSet<JBossCacheManager>();
+   
+   protected Map<String, Object> allAttributes;
+   protected Map<String, Object> immutables;
+   protected Map<String, Object> mutables;
+   protected Map<String, Object> attributes;
+   protected MockHttpSessionBindingListener attribute = new MockHttpSessionBindingListener();
+   protected Map<String, Object> newAttributes;
+   protected MockHttpSessionBindingListener newAttribute = new MockHttpSessionBindingListener();
+   
+   public ClusteredSessionNotificationPolicyTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return CacheConfigTestSetup.getTestSetup(ClusteredSessionNotificationPolicyTestCase.class, pojoCaches, false, !useBuddyRepl, false);
+   }
+
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      attributes = new HashMap<String, Object>();
+      attributes.put("KEY", attribute);
+      attributes = Collections.unmodifiableMap(attributes);
+      
+      newAttributes = new HashMap<String, Object>();
+      newAttributes.put("KEY", newAttribute);
+      newAttributes = Collections.unmodifiableMap(newAttributes);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      for (JBossCacheManager manager : managers)    
+      {
+         try
+         {
+            manager.stop();
+         }
+         catch (RuntimeException ignored)
+         {
+            log.debug("tearDown(): Caught exception cleaning up manager -- " + ignored.getLocalizedMessage()); 
+         }
+      }
+      managers.clear();
+      
+      attribute.invocations.clear();
+      newAttribute.invocations.clear();
+   }
+   
+   protected int getReplicationGranularity()
+   {
+      return WebMetaData.REPLICATION_GRANULARITY_SESSION;
+   }
+   
+   protected int getReplicationTrigger()
+   {
+      return WebMetaData.SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET;
+   }
+   
+   public void testSessionLifecycleWithNotifications() throws Exception
+   {
+      log.info("++++ Starting testSessionLifecycleWithNotifications ++++");
+      sessionLifecycleTest(true);
+   }
+   
+   public void testSessionLifecycleWithoutNotifications() throws Exception
+   {
+      log.info("++++ Starting testSessionLifecycleWithoutNotifications ++++");
+      sessionLifecycleTest(false);
+   }
+   
+   private void sessionLifecycleTest(boolean notify) throws Exception
+   {
+      String warname = String.valueOf(++testId);
+      
+      // A war with a maxInactive of 30 mins maxUnreplicated of 0
+      JBossCacheManager[] mgrs = getCacheManagers(warname, 1800, 0);
+      JBossCacheManager jbcm0 = mgrs[0];
+      JBossCacheManager jbcm1 = mgrs[1];
+      
+      assertTrue(jbcm0.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
+      MockClusteredSessionNotificationPolicy mcsnp0 = (MockClusteredSessionNotificationPolicy) jbcm0.getNotificationPolicy();
+      assertNotNull("capability set", mcsnp0.getClusteredSessionExpriationNotificationCapability());
+      mcsnp0.setResponse(notify);
+      
+      assertTrue(jbcm1.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
+      MockClusteredSessionNotificationPolicy mcsnp1 = (MockClusteredSessionNotificationPolicy) jbcm1.getNotificationPolicy();
+      assertNotNull("capability set", mcsnp1.getClusteredSessionExpriationNotificationCapability());
+      mcsnp1.setResponse(notify);
+      
+      MockHttpSessionListener hsl0 = new MockHttpSessionListener();
+      MockHttpSessionAttributeListener hsal0 = new MockHttpSessionAttributeListener();      
+      Context ctx = (Context) jbcm0.getContainer();
+      ctx.setApplicationLifecycleListeners(new Object[]{ hsl0 });  
+      ctx.setApplicationEventListeners(new Object[]{ hsal0 });  
+      
+      MockHttpSessionListener hsl1 = new MockHttpSessionListener();
+      MockHttpSessionAttributeListener hsal1 = new MockHttpSessionAttributeListener();      
+      ctx = (Context) jbcm1.getContainer();
+      ctx.setApplicationLifecycleListeners(new Object[]{ hsl1 });  
+      ctx.setApplicationEventListeners(new Object[]{ hsal1 }); 
+      
+      // Initial request
+      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
+      WebSessionTestUtil.invokeRequest(jbcm0, setHandler, null);
+      
+      validateNewSession(setHandler);
+      String sessionId = setHandler.getSessionId();
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl0.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.BOUND, attribute.invocations.get(0));
+         
+         validateNoNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ newAttribute });
+         clearNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ attribute });
+      }
+      
+      // Modify attribute request
+      setHandler = new SetAttributesRequestHandler(newAttributes, false);
+      WebSessionTestUtil.invokeRequest(jbcm0, setHandler, sessionId);
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REPLACED, hsal0.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.UNBOUND, attribute.invocations.get(0));
+         assertEquals(1, newAttribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.BOUND, newAttribute.invocations.get(0));
+         
+         validateNoNotifications(hsl0, null, hsl1, hsal1, null);
+         clearNotifications(null, hsal0, null, null, new MockHttpSessionBindingListener[]{ attribute, newAttribute });
+      }
+      
+      // Remove attribute request
+      RemoveAttributesRequestHandler removeHandler = new RemoveAttributesRequestHandler(newAttributes.keySet(), false);
+      WebSessionTestUtil.invokeRequest(jbcm0, removeHandler, sessionId);
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal0.invocations.get(0));
+         assertEquals(1, newAttribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.UNBOUND, newAttribute.invocations.get(0));
+         
+         validateNoNotifications(hsl0, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ attribute });
+         clearNotifications(null, hsal0, null, null, new MockHttpSessionBindingListener[]{ newAttribute });
+      }
+      
+      // Failover request
+      setHandler = new SetAttributesRequestHandler(attributes, false);
+      WebSessionTestUtil.invokeRequest(jbcm1, setHandler, sessionId);
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl1.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.CREATED, hsl1.invocations.get(0));
+         assertEquals(1, hsal1.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal1.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.BOUND, attribute.invocations.get(0));
+         
+         validateNoNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ newAttribute });
+         clearNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ attribute });
+      }
+      
+      // Invalidate session request
+      InvalidateSessionRequestHandler invalidateHandler = new InvalidateSessionRequestHandler(attributes.keySet(), false);
+      WebSessionTestUtil.invokeRequest(jbcm1, invalidateHandler, sessionId);
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl1.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.DESTROYED, hsl1.invocations.get(0));
+         assertEquals(1, hsal1.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal1.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.UNBOUND, attribute.invocations.get(0));
+         
+         validateNoNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ newAttribute });
+         clearNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ attribute });
+      }
+   }
+   
+   public void testSessionExpirationWithNotifications() throws Exception
+   {
+      log.info("++++ Starting testSessionExpirationWithNotifications ++++");
+      sessionExpirationTest(true);
+   }
+   
+   public void testSessionExpirationWithoutNotifications() throws Exception
+   {
+      log.info("++++ Starting testSessionExpirationWithoutNotifications ++++");
+      sessionExpirationTest(false);
+   }
+   
+   private void sessionExpirationTest(boolean notify) throws Exception
+   {
+      String warname = String.valueOf(++testId);
+      
+      // A war with a maxInactive of 3 secs and a maxUnreplicated of 0
+      JBossCacheManager[] mgrs = getCacheManagers(warname, 2, 0);
+      JBossCacheManager jbcm0 = mgrs[0];
+      JBossCacheManager jbcm1 = mgrs[1];
+      
+      assertTrue(jbcm0.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
+      MockClusteredSessionNotificationPolicy mcsnp0 = (MockClusteredSessionNotificationPolicy) jbcm0.getNotificationPolicy();
+      assertNotNull("capability set", mcsnp0.getClusteredSessionExpriationNotificationCapability());
+      mcsnp0.setResponse(notify);
+      
+      assertTrue(jbcm1.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
+      MockClusteredSessionNotificationPolicy mcsnp1 = (MockClusteredSessionNotificationPolicy) jbcm1.getNotificationPolicy();
+      assertNotNull("capability set", mcsnp1.getClusteredSessionExpriationNotificationCapability());
+      mcsnp1.setResponse(notify);
+      
+      MockHttpSessionListener hsl0 = new MockHttpSessionListener();
+      MockHttpSessionAttributeListener hsal0 = new MockHttpSessionAttributeListener();      
+      Context ctx = (Context) jbcm0.getContainer();
+      ctx.setApplicationLifecycleListeners(new Object[]{ hsl0 });  
+      ctx.setApplicationEventListeners(new Object[]{ hsal0 }); 
+      
+      MockHttpSessionListener hsl1 = new MockHttpSessionListener();
+      MockHttpSessionAttributeListener hsal1 = new MockHttpSessionAttributeListener();      
+      ctx = (Context) jbcm1.getContainer();
+      ctx.setApplicationLifecycleListeners(new Object[]{ hsl1 });  
+      ctx.setApplicationEventListeners(new Object[]{ hsal1 }); 
+      
+      // Initial request
+      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
+      WebSessionTestUtil.invokeRequest(jbcm0, setHandler, null);
+      
+      validateNewSession(setHandler);
+      
+      String sessionId = setHandler.getSessionId();
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl0.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.BOUND, attribute.invocations.get(0));
+         
+         validateNoNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ newAttribute });
+         clearNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ attribute });         
+      }
+      
+      // Failover request
+      setHandler = new SetAttributesRequestHandler(newAttributes, false);
+      WebSessionTestUtil.invokeRequest(jbcm1, setHandler, sessionId);
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl1.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.CREATED, hsl1.invocations.get(0));
+         assertEquals(1, hsal1.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REPLACED, hsal1.invocations.get(0));
+         assertEquals(1, newAttribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.BOUND, newAttribute.invocations.get(0));
+         
+         validateNoNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ attribute });
+         clearNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ newAttribute });         
+      }
+      
+      Thread.sleep(2100);
+      
+      jbcm0.backgroundProcess();
+      jbcm1.backgroundProcess();
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl0.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.DESTROYED, hsl0.invocations.get(0));
+         assertEquals(1, hsl1.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.DESTROYED, hsl1.invocations.get(0));
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal0.invocations.get(0));
+         assertEquals(1, hsal1.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal1.invocations.get(0));
+         assertEquals(1, newAttribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.UNBOUND, newAttribute.invocations.get(0));
+         
+         validateNoNotifications(null, null, null, null, new MockHttpSessionBindingListener[]{ attribute });
+         clearNotifications(hsl0, hsal0, hsl1, hsal1, new MockHttpSessionBindingListener[]{ newAttribute });         
+      }
+   }
+   
+   public void testUndeployWithNotifications() throws Exception
+   {
+      log.info("++++ Starting testUndeployWithNotifications ++++");
+      undeployTest(true);
+   }
+   
+   public void testUndeployWithoutNotifications() throws Exception
+   {
+      log.info("++++ Starting testUndeployWithoutNotifications ++++");
+      undeployTest(false);
+   }
+   
+   private void undeployTest(boolean notify) throws Exception
+   {
+      String warname = String.valueOf(++testId);
+      
+      // A war with a maxInactive of 3 secs and a maxUnreplicated of 0
+      JBossCacheManager[] mgrs = getCacheManagers(warname, 2, 0);
+      JBossCacheManager jbcm0 = mgrs[0];
+      JBossCacheManager jbcm1 = mgrs[1];
+      
+      assertTrue(jbcm0.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
+      MockClusteredSessionNotificationPolicy mcsnp0 = (MockClusteredSessionNotificationPolicy) jbcm0.getNotificationPolicy();
+      assertNotNull("capability set", mcsnp0.getClusteredSessionExpriationNotificationCapability());
+      mcsnp0.setResponse(notify);
+      
+      assertTrue(jbcm1.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
+      MockClusteredSessionNotificationPolicy mcsnp1 = (MockClusteredSessionNotificationPolicy) jbcm1.getNotificationPolicy();
+      assertNotNull("capability set", mcsnp1.getClusteredSessionExpriationNotificationCapability());
+      mcsnp1.setResponse(notify);
+      
+      MockHttpSessionListener hsl0 = new MockHttpSessionListener();
+      MockHttpSessionAttributeListener hsal0 = new MockHttpSessionAttributeListener();      
+      Context ctx = (Context) jbcm0.getContainer();
+      ctx.setApplicationLifecycleListeners(new Object[]{ hsl0 });  
+      ctx.setApplicationEventListeners(new Object[]{ hsal0 });  
+      
+      MockHttpSessionListener hsl1 = new MockHttpSessionListener();
+      MockHttpSessionAttributeListener hsal1 = new MockHttpSessionAttributeListener();      
+      ctx = (Context) jbcm1.getContainer();
+      ctx.setApplicationLifecycleListeners(new Object[]{ hsl1 });  
+      ctx.setApplicationEventListeners(new Object[]{ hsal1 }); 
+      
+      // Initial request
+      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
+      WebSessionTestUtil.invokeRequest(jbcm0, setHandler, null);
+      
+      validateNewSession(setHandler);
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl0.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.BOUND, attribute.invocations.get(0));
+         
+         validateNoNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ newAttribute });
+         clearNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ attribute });
+         
+      }
+      
+      jbcm0.stop();
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         assertEquals(1, hsl0.invocations.size());
+         assertEquals(MockHttpSessionListener.Type.DESTROYED, hsl0.invocations.get(0));
+         assertEquals(1, hsal0.invocations.size());
+         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal0.invocations.get(0));
+         assertEquals(1, attribute.invocations.size());
+         assertEquals(MockHttpSessionBindingListener.Type.UNBOUND, attribute.invocations.get(0));
+         
+         validateNoNotifications(null, null, hsl1, hsal1, new MockHttpSessionBindingListener[]{ newAttribute });
+         clearNotifications(hsl0, hsal0, null, null, new MockHttpSessionBindingListener[]{ attribute });
+         
+         
+      }
+      
+      jbcm1.stop();
+      
+      if (!notify)
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+      else
+      {
+         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
+      }
+   }
+   
+   private void validateNoNotifications(MockHttpSessionListener hsl0, MockHttpSessionAttributeListener hsal0,
+         MockHttpSessionListener hsl1, MockHttpSessionAttributeListener hsal1)
+   {
+      validateNoNotifications(hsl0, hsal0, hsl1, hsal1, new MockHttpSessionBindingListener[]{ attribute, newAttribute});
+   }
+   
+   private void validateNoNotifications(MockHttpSessionListener hsl0, MockHttpSessionAttributeListener hsal0,
+         MockHttpSessionListener hsl1, MockHttpSessionAttributeListener hsal1, MockHttpSessionBindingListener[] hsbls)
+   {
+      if (hsl0 != null)
+      {
+         assertEquals(0, hsl0.invocations.size());
+      }
+      if (hsal0 != null)
+      {
+         assertEquals(0, hsal0.invocations.size());
+      }
+      if (hsl1 != null)
+      {
+         assertEquals(0, hsl1.invocations.size());
+      }
+      if (hsal1 != null)
+      {
+         assertEquals(0, hsal1.invocations.size());
+      }
+      
+      if (hsbls != null)
+      {
+         for (int i = 0; i < hsbls.length; i++)
+         {
+            assertEquals("Binding listener " + i + "  has no notifications", 0, hsbls[i].invocations.size());
+         }
+      }
+      
+      clearNotifications(hsl0, hsal0, hsl1, hsal1, hsbls);
+   }
+   
+   private void clearNotifications(MockHttpSessionListener hsl0, MockHttpSessionAttributeListener hsal0,
+         MockHttpSessionListener hsl1, MockHttpSessionAttributeListener hsal1)
+   {
+      clearNotifications(hsl0, hsal0, hsl1, hsal1, new MockHttpSessionBindingListener[]{ attribute, newAttribute});
+   }
+   
+   private void clearNotifications(MockHttpSessionListener hsl0, MockHttpSessionAttributeListener hsal0,
+         MockHttpSessionListener hsl1, MockHttpSessionAttributeListener hsal1, MockHttpSessionBindingListener[] hsbls)
+   {      
+
+      if (hsl0 != null)
+      {
+         hsl0.invocations.clear();
+      }
+      if (hsal0 != null)
+      {
+         hsal0.invocations.clear();
+      }
+      if (hsl1 != null)
+      {
+         hsl1.invocations.clear();
+      }
+      if (hsal1 != null)
+      {
+         hsal1.invocations.clear();
+      }
+      
+      if (hsbls != null)
+      {
+         for (int i = 0; i < hsbls.length; i++)
+         {
+            hsbls[i].invocations.clear();
+         }
+      }
+   }
+   
+   protected JBossCacheManager[] getCacheManagers(String warname, int maxInactive, int maxUnreplicated)
+      throws Exception
+   {
+      JBossCacheManager jbcm0 = WebSessionTestUtil.createManager(warname, maxInactive, pojoCaches[0], null);
+      WebMetaData metadata = WebSessionTestUtil.getWebMetaData(getReplicationGranularity(), getReplicationTrigger(), true, maxUnreplicated);
+      metadata.setClusteredSessionNotificationPolicy(MockClusteredSessionNotificationPolicy.class.getName());
+      jbcm0.init(warname, metadata, false, true);
+      this.managers.add(jbcm0);
+      jbcm0.start();
+      
+      JBossCacheManager jbcm1 = WebSessionTestUtil.createManager(warname, maxInactive, pojoCaches[1], null);
+      metadata = WebSessionTestUtil.getWebMetaData(getReplicationGranularity(), getReplicationTrigger(), true, maxUnreplicated);
+      metadata.setClusteredSessionNotificationPolicy(MockClusteredSessionNotificationPolicy.class.getName());
+      jbcm1.init(warname, metadata, false, true);
+      this.managers.add(jbcm1);
+      jbcm1.start();
+      
+      return new JBossCacheManager[]{jbcm0, jbcm1};
+   }
+   
+   protected void validateExpectedAttributes(Map<String, Object> expected, BasicRequestHandler handler)
+   {
+      assertFalse(handler.isNewSession());
+      
+      if (handler.isCheckAttributeNames())
+      {
+         assertEquals(expected.size(), handler.getAttributeNames().size());
+      }
+      Map<String, Object> checked = handler.getCheckedAttributes();
+      assertEquals(expected.size(), checked.size());
+      for (Map.Entry<String, Object> entry : checked.entrySet())
+         assertEquals(entry.getKey(), expected.get(entry.getKey()), entry.getValue());
+      
+   }
+   
+   protected void validateNewSession(BasicRequestHandler handler)
+   {
+      assertTrue(handler.isNewSession());
+      assertEquals(handler.getCreationTime(), handler.getLastAccessedTime());
+      if (handler.isCheckAttributeNames())
+      {
+         assertEquals(0, handler.getAttributeNames().size());
+      }
+      Map<String, Object> checked = handler.getCheckedAttributes();
+      for (Map.Entry<String, Object> entry : checked.entrySet())
+         assertNull(entry.getKey(), entry.getValue());
+   }
+   
+
+}


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

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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;
+   }   
+   
+   
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/BasicRequestHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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;
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockContainer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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;
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockEngine.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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
+
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockHost.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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
+
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockLoader.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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();
+   }   
+
+   
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockRequest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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.CometEvent;
+import org.apache.catalina.Valve;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @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, CometEvent 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;
+   }
+   
+   
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MockValve.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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;
+   }
+   
+   
+   
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/MutableObject.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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);
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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;
+   }  
+   
+   
+   
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/RequestHandlerValve.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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());
+      }      
+   }
+   
+   
+
+   
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/mocks/SetAttributesRequestHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockClusteredSessionNotificationPolicy.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockClusteredSessionNotificationPolicy.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockClusteredSessionNotificationPolicy.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -0,0 +1,115 @@
+/*
+ * 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.notification;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionManagementStatus;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy;
+import org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicyBase;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockClusteredSessionNotificationPolicy extends ClusteredSessionNotificationPolicyBase
+      implements
+         ClusteredSessionNotificationPolicy
+{
+   private boolean response;
+   public final List<PolicyInvocation> invocations = new ArrayList<PolicyInvocation>();
+   
+   public enum Type { ATTRIBUTE, BINDING, SESSION };
+   
+   /* (non-Javadoc)
+    * @see org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy#isHttpSessionAttributeListenerInvocationAllowed(org.jboss.web.tomcat.service.session.notification.ClusteredSessionManagementStatus, org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause, java.lang.String, boolean)
+    */
+   public boolean isHttpSessionAttributeListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      invocations.add(new PolicyInvocation(Type.ATTRIBUTE, status, cause, attributeName, local));
+      return response;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy#isHttpSessionBindingListenerInvocationAllowed(org.jboss.web.tomcat.service.session.notification.ClusteredSessionManagementStatus, org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause, java.lang.String, boolean)
+    */
+   public boolean isHttpSessionBindingListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+   {
+      invocations.add(new PolicyInvocation(Type.BINDING, status, cause, attributeName, local));
+      return response;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationPolicy#isHttpSessionListenerInvocationAllowed(org.jboss.web.tomcat.service.session.notification.ClusteredSessionManagementStatus, org.jboss.web.tomcat.service.session.notification.ClusteredSessionNotificationCause, boolean)
+    */
+   public boolean isHttpSessionListenerInvocationAllowed(ClusteredSessionManagementStatus status,
+         ClusteredSessionNotificationCause cause, boolean local)
+   {
+      invocations.add(new PolicyInvocation(Type.SESSION, status, cause, null, local));
+      return response;
+   }
+
+   public boolean getResponse()
+   {
+      return response;
+   }
+
+   public void setResponse(boolean response)
+   {
+      this.response = response;
+   }
+   
+   public List<PolicyInvocation> getInvocations()
+   {
+      return invocations;
+   }
+   
+   public void clear()
+   {
+      invocations.clear();
+   }
+   
+   public static class PolicyInvocation
+   {
+      public final Type type;
+      public final ClusteredSessionManagementStatus status;
+      public final ClusteredSessionNotificationCause cause;
+      public final String attributeName;
+      public final boolean local;
+      
+      private PolicyInvocation(Type type, ClusteredSessionManagementStatus status,
+            ClusteredSessionNotificationCause cause, String attributeName, boolean local)
+      {
+         this.type = type;
+         this.status = status;
+         this.cause = cause;
+         this.attributeName = attributeName;
+         this.local = local;
+      }
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockClusteredSessionNotificationPolicy.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionAttributeListener.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionAttributeListener.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionAttributeListener.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -0,0 +1,67 @@
+/*
+ * 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.notification;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+import org.jboss.test.cluster.web.notification.MockHttpSessionBindingListener.Type;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockHttpSessionAttributeListener implements HttpSessionAttributeListener
+{
+   public enum Type { ADDED, REMOVED, REPLACED };
+   
+   public final List<Type> invocations = new ArrayList<Type>();
+
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionAttributeListener#attributeAdded(javax.servlet.http.HttpSessionBindingEvent)
+    */
+   public void attributeAdded(HttpSessionBindingEvent arg0)
+   {
+      invocations.add(Type.ADDED);
+   }
+
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)
+    */
+   public void attributeRemoved(HttpSessionBindingEvent arg0)
+   {
+      invocations.add(Type.REMOVED);
+   }
+
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionAttributeListener#attributeReplaced(javax.servlet.http.HttpSessionBindingEvent)
+    */
+   public void attributeReplaced(HttpSessionBindingEvent arg0)
+   {
+      invocations.add(Type.REPLACED);
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionAttributeListener.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionBindingListener.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionBindingListener.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionBindingListener.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -0,0 +1,68 @@
+/*
+ * 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.notification;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockHttpSessionBindingListener implements HttpSessionBindingListener, Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   public enum Type { BOUND, UNBOUND };
+   
+   public transient List<Type> invocations = new ArrayList<Type>();
+
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
+    */
+   public void valueBound(HttpSessionBindingEvent arg0)
+   {
+      getInvocations().add(Type.BOUND);
+   }
+
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
+    */
+   public void valueUnbound(HttpSessionBindingEvent arg0)
+   {
+      getInvocations().add(Type.UNBOUND);
+   }
+
+   private List<Type> getInvocations()
+   {
+      if (invocations == null)
+      {
+         invocations = new ArrayList<Type>();
+      }
+      return invocations;
+   }
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionBindingListener.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionListener.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionListener.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionListener.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -0,0 +1,57 @@
+/*
+ * 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.notification;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class MockHttpSessionListener implements HttpSessionListener
+{
+   public enum Type { CREATED, DESTROYED };
+   
+   public final List<Type> invocations = new ArrayList<Type>();
+   
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
+    */
+   public void sessionCreated(HttpSessionEvent arg0)
+   {
+      invocations.add(Type.CREATED);
+   }
+
+   /* (non-Javadoc)
+    * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
+    */
+   public void sessionDestroyed(HttpSessionEvent arg0)
+   {
+      invocations.add(Type.DESTROYED);
+   }
+
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/notification/MockHttpSessionListener.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/InvalidateSessionRequestHandler.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/InvalidateSessionRequestHandler.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/InvalidateSessionRequestHandler.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -0,0 +1,55 @@
+/*
+ * 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.util;
+
+import java.util.Set;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class InvalidateSessionRequestHandler extends BasicRequestHandler
+{   
+   /**
+    * Create a new RemoveAttributesRequestHandler.
+    * 
+    */
+   public InvalidateSessionRequestHandler(Set<String> toCheck, boolean checkNames)
+   {      
+      super(toCheck, checkNames);
+   }
+
+   public void handleRequest(Request request, Response response)
+   {
+      super.handleRequest(request, response);
+      
+      getSession().invalidate();
+   }
+   
+   
+
+   
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/InvalidateSessionRequestHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/RemoveAttributesRequestHandler.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/RemoveAttributesRequestHandler.java	                        (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/RemoveAttributesRequestHandler.java	2008-09-29 13:23:25 UTC (rev 78928)
@@ -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.util;
+
+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 RemoveAttributesRequestHandler extends BasicRequestHandler
+{
+   private Set<String> toRemove;
+   
+   /**
+    * Create a new RemoveAttributesRequestHandler.
+    * 
+    */
+   public RemoveAttributesRequestHandler(Set<String> toRemove, boolean checkNames)
+   {      
+      super(toRemove, checkNames);
+      this.toRemove = toRemove;
+   }
+
+   public void handleRequest(Request request, Response response)
+   {
+      super.handleRequest(request, response);
+      
+      HttpSession session = getSession();
+      for (String key : toRemove)
+      {
+         session.removeAttribute(key);
+      }      
+   }
+   
+   
+
+   
+}


Property changes on: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/web/util/RemoveAttributesRequestHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list