[jboss-cvs] JBossAS SVN: r64680 - in trunk/testsuite/src: main/org/jboss/test/cluster/testutil and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 18 11:24:45 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-08-18 11:24:44 -0400 (Sat, 18 Aug 2007)
New Revision: 64680

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/web/DeserializationSensor.java
   trunk/testsuite/src/resources/cluster/http/http-field/getDeserialized.jsp
   trunk/testsuite/src/resources/cluster/http/http-scoped/getDeserialized.jsp
Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
   trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java
   trunk/testsuite/src/resources/cluster/http/http-field/setSession.jsp
   trunk/testsuite/src/resources/cluster/http/http-scoped/setSession.jsp
Log:
[JBAS-4613] JBossCacheManager active session count should include backup sessions

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java	2007-08-18 15:23:53 UTC (rev 64679)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java	2007-08-18 15:24:44 UTC (rev 64680)
@@ -21,11 +21,16 @@
   */
 package org.jboss.test.cluster.defaultcfg.web.test;
 
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
 import javax.management.ObjectName;
 
 import junit.framework.Test;
 
+import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
 import org.jboss.cache.Fqn;
 import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
 import org.jboss.test.JBossClusteredTestCase;
@@ -41,35 +46,16 @@
 public class SessionPassivationTestCase
       extends WebTestBase
 {
+   private static boolean deployed0 = true;
+   private static boolean deployed1 = true;
+   
    protected String setUrl;
    protected String getUrl;
-   protected String modifyUrl;
-   protected String modifyNoSetUrl;
-   protected String removeUrl;
-   protected String invalidateUrl;
-   protected String clearUrl;
-   protected String attrListUrl;
-   protected String bindUrl_;
-   protected String protectedUrl_;
-   protected String securityCheckUrl_;
-   protected String loginFormUrl_;
-   protected String setSecuritySubjectUrl_;
-   protected String getSecuritySubjectUrl_;
+   protected String getDeserializedUrl;
    protected String warName_;
    protected String setUrlBase_;
    protected String getUrlBase_;
-   protected String modifyUrlBase_;
-   protected String modifyNoSetUrlBase_;
-   protected String removeUrlBase_;
-   protected String invalidateUrlBase_;
-   protected String clearUrlBase_;
-   protected String bindUrlBase_;
-   protected String attrListUrlBase_;
-   protected String protectedUrlBase_;
-   protected String securityCheckUrlBase_;
-   protected String loginFormUrlBase_;
-   protected String setSecuritySubjectUrlBase_;
-   protected String getSecuritySubjectUrlBase_;
+   protected String getDeserializedUrlBase_;
    
    private ObjectName warObjectName;
    private String warFqn_;
@@ -80,18 +66,7 @@
       warName_ = "/http-scoped/";
       setUrlBase_ = "setSession.jsp";
       getUrlBase_ = "getAttribute.jsp";
-      modifyUrlBase_ = "modifyAttribute.jsp";
-      modifyNoSetUrlBase_ = "modifyAttributeNoSet.jsp";
-      removeUrlBase_ = "removeAttribute.jsp";
-      invalidateUrlBase_ = "invalidateSession.jsp";
-      clearUrlBase_ = "clearCache.jsp";
-      bindUrlBase_ = "bindSession.jsp?Binding=";
-      protectedUrlBase_ = "index.html";
-      securityCheckUrlBase_ = "j_security_check";
-      loginFormUrlBase_ = "login.html";
-      attrListUrlBase_ = "attributeNames.jsp";
-      setSecuritySubjectUrlBase_  = "setSecuritySubject.jsp";
-      getSecuritySubjectUrlBase_ =  "getSecuritySubject.jsp";
+      getDeserializedUrlBase_ = "getDeserialized.jsp";
 
       concatenate();
    }
@@ -100,18 +75,7 @@
    {
       setUrl = warName_ +setUrlBase_;
       getUrl = warName_ +getUrlBase_;
-      modifyUrl = warName_ +modifyUrlBase_;
-      modifyNoSetUrl = warName_ +modifyNoSetUrlBase_;
-      removeUrl = warName_ +removeUrlBase_;
-      invalidateUrl = warName_ +invalidateUrlBase_;
-      clearUrl = warName_ +clearUrlBase_;
-      bindUrl_ = warName_ + bindUrlBase_;
-      protectedUrl_ = warName_ + protectedUrlBase_;
-      securityCheckUrl_ = warName_ + securityCheckUrlBase_;
-      loginFormUrl_ = warName_ + loginFormUrlBase_;
-      attrListUrl = warName_ + attrListUrlBase_;
-      setSecuritySubjectUrl_ = warName_ + setSecuritySubjectUrlBase_;
-      getSecuritySubjectUrl_ = warName_ + getSecuritySubjectUrlBase_;
+      getDeserializedUrl = warName_ +getDeserializedUrlBase_;
    }
    
    protected String getWarName()
@@ -136,12 +100,22 @@
                         "j2eeType=WebModule,name=//localhost/" + getWarName();
          warObjectName = new ObjectName(oname);
          
-         RMIAdaptor[] adaptors = getAdaptors();
-         
          Object[] names = {"JSESSION", "localhost", getWarName() };
          Fqn fqn = new Fqn(names);
          warFqn_ = fqn.toString();
       }
+      
+      RMIAdaptor[] adaptors = getAdaptors();
+      if (!deployed0)
+      {
+         deploy(adaptors[0]);
+         deployed0 = true;
+      }
+      if (!deployed1)
+      {
+         deploy(adaptors[1]);
+         deployed1 = true;
+      }
    }
 
    protected void tearDown() throws Exception
@@ -157,7 +131,7 @@
     */
    public void testSessionPassivationWMaxIdle() throws Exception
    {
-      getLog().debug("Enter testSessionPassivationWMaxActive");
+      getLog().debug("Enter testSessionPassivationWMaxIdle");
 
       getLog().debug(setUrl + ":::::::" + getUrl);
 
@@ -191,14 +165,14 @@
       sleepThread(11000);
       
       RMIAdaptor[] adaptors = getAdaptors();
-      getLog().debug("Session in the cache = " + SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn));
+
       //session is passivate should not exist in the cache
-      assertNull("Session is passivated therefore it is not in the cache...", SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn));
+//      assertFalse("Session is passivated therefore it is not in the cache...", SessionTestUtil.exists(adaptors[0], sessionFqn));
       
-      // activate the session by requesting the attrribute
+      // activate the session by requesting the attribute
       // Make connection to server 0 and get
       setCookieDomainToThisServer(client, servers_[0]);
-      String attr2 = makeGet(client, baseURL0_ + getUrl);
+      String attr2 = checkDeserialization(client, baseURL0_ + getDeserializedUrl);
       
       assertEquals("attribute match after activation", attr0, attr2);
    }
@@ -238,7 +212,7 @@
       // check for replication first
       assertEquals("attributes match", attr0, attr1);
       
-      // Create 3 more sessions on server0
+      // Create enough sessions on server0 to trigger passivation
       // assuming that max-active-sessions is set to 20 in jboss-web.xml
       getLog().debug("current active sessions = " + SessionTestUtil.getSessionIds(adaptors[0], warFqn_));
       int numberOfActiveSessions = SessionTestUtil.getSessionIds(adaptors[0], warFqn_).size(); 
@@ -254,14 +228,13 @@
       }
       getLog().debug("to reach max active sessions we needed to create " + clients.length + " clients");
       
-      getLog().debug("Session in the cache = " + SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn));
-      //session is passivate should not exist in the cache
-      assertNull("Session is passivated therefore it is not in the cache...",  SessionTestUtil.getSessionVersion(adaptors[0], sessionFqn));
+      // Confirm passivation
+//      assertFalse("Session is passivated therefore it is not in the cache...",  SessionTestUtil.exists(adaptors[0], sessionFqn));
       
-      // activate the session by requesting the attrribute
+      // activate the session by requesting the attribute
       // Make connection to server 0 and get
       setCookieDomainToThisServer(client, servers_[0]);
-      String attr2 = makeGet(client, baseURL0_ + getUrl);
+      String attr2 = checkDeserialization(client, baseURL0_ + getDeserializedUrl);
       
       assertEquals("attribute match after activation", attr0, attr2);      
    }
@@ -277,17 +250,14 @@
        
        getLog().debug(setUrl + ":::::::" + getUrl);
        
-       // force deployment
+       // Undeploy from server1 to ensure that a redeploy on server0
+       // results in sessions coming from disk, not server1
        RMIAdaptor[] adaptors = getAdaptors();
-       String warName = getWarName() + ".war";
-       deploy(adaptors[0], warName);
-       deploy(adaptors[1], warName);
+       deployed1 = false;
+       undeploy(adaptors[1]);
        
        sleep(2000);
           
-        // the code above should be removed when we figure out what's wrong 
-        // with configure cluster.
-       
        // Create an instance of HttpClient.
        HttpClient client = new HttpClient();
 
@@ -300,21 +270,14 @@
        //   Get the Attribute set
        String attr = makeGetWithState(client, baseURL0_ +getUrl);
        
-       // Make connection to server 1 and get
-       setCookieDomainToThisServer(client, servers_[1]);
-       String attr2 = makeGetWithState(client, baseURL1_ + getUrl);
-       
-       assertEquals("attribute match", attr, attr2);
-       
-       
-       
        // undeploy server0, which passivates the session to the distributed store
-       undeploy(adaptors[0], warName);
-       
+       deployed0 = false;
+       undeploy(adaptors[0]);       
 
        sleep(2000);    
        // redeploy the application on server 0
-       deploy(adaptors[0], warName);
+       deploy(adaptors[0]);
+       deployed0 = true;
 
        sleep(2000);
        
@@ -327,4 +290,55 @@
        getLog().debug("Exit testRedeploy");
        
    }
+   
+   private void deploy(RMIAdaptor adaptor) throws Exception
+   {
+      deploy(adaptor, getWarName() + ".war");   
+   }
+   
+   private void undeploy(RMIAdaptor adaptor) throws Exception
+   {
+      undeploy(adaptor, getWarName() + ".war");   
+   }/**
+    * Makes a http call to the jsp that retrieves the attribute stored on the
+    * session. When the attribute values mathes with the one retrieved earlier,
+    * we have HttpSessionReplication.
+    * Makes use of commons-httpclient library of Apache
+    *
+    * @param client
+    * @param url
+    * @return session attribute
+    */
+   protected String checkDeserialization(HttpClient client, String url)
+      throws IOException
+   {
+      getLog().debug("checkDeserialization(): trying to get from url " +url);
+
+      GetMethod method = new GetMethod(url);
+      int responseCode = 0;
+      try
+      {
+         responseCode = client.executeMethod(method);
+      } catch (IOException e)
+      {
+         e.printStackTrace();
+         fail("HttpClient executeMethod fails." +e.toString());
+      }
+      assertTrue("Get OK with url: " +url + " responseCode: " +responseCode
+        , responseCode == HttpURLConnection.HTTP_OK);
+      
+      Header hdr = method.getResponseHeader("X-SessionDeserialzied");
+      Boolean sawAttr = hdr != null ? Boolean.valueOf(hdr.getValue()) : Boolean.FALSE;
+      assertTrue("Session was deserialized", sawAttr.booleanValue());
+      
+      // Read the response body.
+      byte[] responseBody = method.getResponseBody();
+
+      // Release the connection.
+//      method.releaseConnection();
+
+      // Deal with the response.
+      // Use caution: ensure correct character encoding and is not binary data
+      return new String(responseBody);
+   }
 }

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2007-08-18 15:23:53 UTC (rev 64679)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2007-08-18 15:24:44 UTC (rev 64680)
@@ -22,10 +22,26 @@
 
 package org.jboss.test.cluster.testutil;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
+import org.apache.catalina.core.StandardContext;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.loader.FileCacheLoaderConfig;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheFactory;
 import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
 import org.jboss.test.cluster.web.CacheHelper;
+import org.jboss.test.cluster.web.MockContainer;
+import org.jboss.web.tomcat.service.session.JBossCacheManager;
 
 /**
  * Utilities for session testing.
@@ -36,7 +52,73 @@
 public class SessionTestUtil
 {  
    private static final String[] TYPES = { String.class.getName() };
+   private static final String CONFIG_LOCATION = "cluster/http/jboss-web-test-service.xml";
    
+   public static JBossCacheManager createManager(String warName, int maxInactiveInterval, 
+                                                 boolean local, String passivationDir, 
+                                                 boolean totalReplication, boolean marshalling)
+   {
+      PojoCache cache = createCache(local, passivationDir, totalReplication, marshalling, true);
+      return createManager(warName, maxInactiveInterval, cache);
+   }
+   
+   public static JBossCacheManager createManager(String warName, 
+                                                 int maxInactiveInterval, 
+                                                 PojoCache cache)
+   {
+      JBossCacheManager jbcm = new JBossCacheManager(cache);
+      
+      MockContainer parent = new MockContainer();
+      parent.setName("localhost");
+      StandardContext container = new StandardContext();
+      container.setName(warName);
+      parent.addChild(container);
+      jbcm.setContainer(container);
+      jbcm.setMaxInactiveInterval(maxInactiveInterval);
+      
+      jbcm.setSnapshotMode("instant");
+   
+   return jbcm;      
+   }
+   
+   public static PojoCache createCache(boolean local, String passivationDir, 
+         boolean totalReplication, boolean marshalling, boolean start)
+   {
+      Configuration cfg = getConfiguration(local, passivationDir, totalReplication, marshalling);
+      return PojoCacheFactory.createCache(cfg, start);
+   }
+   
+   public static Configuration getConfiguration(boolean local, String passivationDir, 
+         boolean totalReplication, boolean marshalling)
+   {
+      XmlConfigurationParser parser = new XmlConfigurationParser();
+      Configuration config = parser.parseFile(CONFIG_LOCATION);
+      if (local)
+         config.setCacheMode(CacheMode.LOCAL);
+      if (passivationDir == null)
+      {
+         config.setCacheLoaderConfig(null);
+      }
+      else
+      {
+         CacheLoaderConfig clc = config.getCacheLoaderConfig();
+         FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
+         fclc.setProperties(clc.getFirstCacheLoaderConfig().getProperties());
+         fclc.setLocation(passivationDir);
+         ArrayList<IndividualCacheLoaderConfig> iclcs = new ArrayList<IndividualCacheLoaderConfig>();
+         iclcs.add(fclc);
+         clc.setIndividualCacheLoaderConfigs(iclcs);
+      }
+      
+      BuddyReplicationConfig brc = config.getBuddyReplicationConfig();
+      brc.setEnabled(!totalReplication);
+      
+      config.setUseRegionBasedMarshalling(marshalling);
+      config.setInactiveOnStartup(marshalling);
+      
+      return config;
+   } 
+   
    public static Object getSessionVersion(RMIAdaptor adaptor, String sessionFqn) throws Exception
    {
       return adaptor.invoke(CacheHelper.OBJECT_NAME, 
@@ -54,6 +136,15 @@
                             TYPES);
    }
    
+   public static boolean exists(RMIAdaptor adaptor, String fqn) throws Exception
+   {
+      Boolean b = (Boolean) adaptor.invoke(CacheHelper.OBJECT_NAME, 
+                                           "exists", 
+                                           new Object[] { fqn }, 
+                                           TYPES);
+      return b.booleanValue();
+   }
+   
    public static Set getSessionIds(RMIAdaptor adaptor, String warFqn) throws Exception
    {
       return (Set) adaptor.invoke(CacheHelper.OBJECT_NAME, 
@@ -76,5 +167,117 @@
             new Object[0], new String[0]);
    }
 
+   /**
+    * Loops, continually calling {@link #areCacheViewsComplete(org.jboss.cache.Cache[])}
+    * until it either returns true or <code>timeout</code> ms have elapsed.
+    *
+    * @param caches  caches which must all have consistent views
+    * @param timeout max number of ms to loop
+    * @throws RuntimeException if <code>timeout</code> ms have elapse without
+    *                          all caches having the same number of members.
+    */
+   public static void blockUntilViewsReceived(Cache[] caches, long timeout)
+   {
+      long failTime = System.currentTimeMillis() + timeout;
+
+      while (System.currentTimeMillis() < failTime)
+      {
+         sleepThread(100);
+         if (areCacheViewsComplete(caches))
+         {
+            return;
+         }
+      }
+
+      throw new RuntimeException("timed out before caches had complete views");
+   }
+
+   /**
+    * Checks each cache to see if the number of elements in the array
+    * returned by {@link CacheSPI#getMembers()} matches the size of
+    * the <code>caches</code> parameter.
+    *
+    * @param caches caches that should form a View
+    * @return <code>true</code> if all caches have
+    *         <code>caches.length</code> members; false otherwise
+    * @throws IllegalStateException if any of the caches have MORE view
+    *                               members than caches.length
+    */
+   public static boolean areCacheViewsComplete(Cache[] caches)
+   {
+      return areCacheViewsComplete(caches, true);
+   }
+
+   public static boolean areCacheViewsComplete(Cache[] caches, boolean barfIfTooManyMembers)
+   {
+      int memberCount = caches.length;
+
+      for (int i = 0; i < memberCount; i++)
+      {
+         if (!isCacheViewComplete(caches[i], memberCount, barfIfTooManyMembers))
+         {
+            return false;
+         }
+      }
+
+      return true;
+   }
+
+   public static boolean isCacheViewComplete(Cache c, int memberCount, boolean barfIfTooManyMembers)
+   {
+      CacheSPI cache = (CacheSPI) c;
+      List members = cache.getMembers();
+      if (members == null || memberCount > members.size())
+      {
+         return false;
+      }
+      else if (memberCount < members.size())
+      {
+         if (barfIfTooManyMembers)
+         {
+            // This is an exceptional condition
+            StringBuffer sb = new StringBuffer("Cache at address ");
+            sb.append(cache.getLocalAddress());
+            sb.append(" had ");
+            sb.append(members.size());
+            sb.append(" members; expecting ");
+            sb.append(memberCount);
+            sb.append(". Members were (");
+            for (int j = 0; j < members.size(); j++)
+            {
+               if (j > 0)
+               {
+                  sb.append(", ");
+               }
+               sb.append(members.get(j));
+            }
+            sb.append(')');
+
+            throw new IllegalStateException(sb.toString());
+         }
+         else return false;
+      }
+
+      return true;
+   }
+
+
+   /**
+    * Puts the current thread to sleep for the desired number of ms, suppressing
+    * any exceptions.
+    *
+    * @param sleeptime number of ms to sleep
+    */
+   public static void sleepThread(long sleeptime)
+   {
+      try
+      {
+         Thread.sleep(sleeptime);
+      }
+      catch (InterruptedException ie)
+      {
+      }
+   }
+
    private SessionTestUtil() {}
 }

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java	2007-08-18 15:23:53 UTC (rev 64679)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java	2007-08-18 15:24:44 UTC (rev 64680)
@@ -110,6 +110,11 @@
       return result;
    }
    
+   public boolean exists(String fqn)
+   {
+      return getCache().getRoot().hasChild(Fqn.fromString(fqn));
+   }
+   
    public Set getSessionIds(String warFqn) throws Exception
    {
       Set result = new HashSet();

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java	2007-08-18 15:23:53 UTC (rev 64679)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java	2007-08-18 15:24:44 UTC (rev 64680)
@@ -2,6 +2,8 @@
 
 import java.util.Set;
 
+import org.jboss.cache.Fqn;
+
 public interface CacheHelperMBean
 {
    Object getSessionVersion(String sessionFqn);
@@ -10,6 +12,8 @@
 
    Set getSessionIds(String warFqn) throws Exception;
    
+   boolean exists(String fqn);
+   
    Set getSSOIds() throws Exception;
    
    void setLeaveInstalledAfterShutdown();

Added: trunk/testsuite/src/main/org/jboss/test/cluster/web/DeserializationSensor.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/DeserializationSensor.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/DeserializationSensor.java	2007-08-18 15:24:44 UTC (rev 64680)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.cluster.web;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * Class that detects if it has been deserialized.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+public class DeserializationSensor implements Serializable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+   
+   private transient boolean deserialized = false;
+   
+   public boolean isDeserialized()
+   {
+      boolean result = deserialized;
+      deserialized = false;
+      return result;
+   }
+   
+   private void readObject(ObjectInputStream in) 
+      throws IOException, ClassNotFoundException
+   {
+      in.defaultReadObject();
+      deserialized = true;
+   }
+   
+   private void writeObject(ObjectOutputStream out) 
+      throws IOException
+   {
+      out.defaultWriteObject();
+   }
+}


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

Added: trunk/testsuite/src/resources/cluster/http/http-field/getDeserialized.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/getDeserialized.jsp	                        (rev 0)
+++ trunk/testsuite/src/resources/cluster/http/http-field/getDeserialized.jsp	2007-08-18 15:24:44 UTC (rev 64680)
@@ -0,0 +1,19 @@
+<%@page contentType="text/html"
+   import="java.util.*"
+   import="javax.servlet.ServletContext"
+   import="org.jboss.test.cluster.web.aop.Person"
+   import="org.jboss.test.cluster.web.aop.Address"
+   import="org.jboss.test.cluster.web.DeserializationSensor"
+%>
+
+<%
+   DeserializationSensor sensor = (DeserializationSensor) session.getAttribute("TEST_DESERIALIZATION");
+   response.setHeader("X-SessionDeserialzied", sensor.isDeserialized() ? "true" : "false");
+   
+   Person joe = (Person)session.getAttribute("TEST_PERSON");
+   Address addr = (Address)joe.getAddress();
+%>
+
+<%=joe.getName() %>
+<%=addr.getZip() %>
+<%=joe.getLanguages() %>

Modified: trunk/testsuite/src/resources/cluster/http/http-field/setSession.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/setSession.jsp	2007-08-18 15:23:53 UTC (rev 64679)
+++ trunk/testsuite/src/resources/cluster/http/http-field/setSession.jsp	2007-08-18 15:24:44 UTC (rev 64680)
@@ -3,6 +3,7 @@
    import="javax.servlet.ServletContext"
    import="org.jboss.test.cluster.web.aop.Person"
    import="org.jboss.test.cluster.web.aop.Address"
+   import="org.jboss.test.cluster.web.DeserializationSensor"
 %>
 
 <html>
@@ -18,6 +19,7 @@
    ben.setName("Ben");
    ben.setAddress(addr);
    session.setAttribute("TEST_PERSON", ben);
+   session.setAttribute("TEST_DESERIALIZATION", new DeserializationSensor());
    
    // Bind ben to the servlet context as well so it can be
    // accessed without involving the session

Added: trunk/testsuite/src/resources/cluster/http/http-scoped/getDeserialized.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/getDeserialized.jsp	                        (rev 0)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/getDeserialized.jsp	2007-08-18 15:24:44 UTC (rev 64680)
@@ -0,0 +1,10 @@
+<%@page contentType="text/html"
+   import="java.util.*"
+   import="org.jboss.test.cluster.web.Person"
+   import="org.jboss.test.cluster.web.DeserializationSensor"
+%>
+<%
+   DeserializationSensor sensor = (DeserializationSensor) session.getAttribute("TEST_DESERIALIZATION");
+   response.setHeader("X-SessionDeserialzied", sensor.isDeserialized() ? "true" : "false");
+%>
+<%=((Person)session.getAttribute("TEST_PERSON")).getName() %>

Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/setSession.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/setSession.jsp	2007-08-18 15:23:53 UTC (rev 64679)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/setSession.jsp	2007-08-18 15:24:44 UTC (rev 64680)
@@ -1,6 +1,7 @@
 <%@page contentType="text/html"
    import="java.util.*"
    import="org.jboss.test.cluster.web.Person"
+   import="org.jboss.test.cluster.web.DeserializationSensor"
 %>
 
 <html>
@@ -10,6 +11,7 @@
    session.setAttribute("TEST_ID",id); 
    Person ben=new Person("Ben", 55);
    session.setAttribute("TEST_PERSON", ben);
+   session.setAttribute("TEST_DESERIALIZATION", new DeserializationSensor());
 %>
 <%=id%>
 




More information about the jboss-cvs-commits mailing list