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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 5 18:42:06 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-07-05 18:42:06 -0400 (Thu, 05 Jul 2007)
New Revision: 63850

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/test/AttributeBasedSessionPassivationTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/test/FieldBasedSessionPassivationTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/test/SessionPassivationTestCase.java
Log:
Separate session passivation tests into their own classes

Added: trunk/testsuite/src/main/org/jboss/test/cluster/test/AttributeBasedSessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/test/AttributeBasedSessionPassivationTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/test/AttributeBasedSessionPassivationTestCase.java	2007-07-05 22:42:06 UTC (rev 63850)
@@ -0,0 +1,58 @@
+/*
+ * 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.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * @author bstansberry
+ *
+ */
+public class AttributeBasedSessionPassivationTestCase extends SessionPassivationTestCase
+{
+   /**
+    * @param name
+    */
+   public AttributeBasedSessionPassivationTestCase(String name)
+   {
+      super(name);
+      warName_ = "/http-scoped-attr/";
+
+      concatenate();
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped-attr";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(AttributeBasedSessionPassivationTestCase.class,
+            "jbosscache-helper.sar, http-scoped-attr.war");
+      return t1;
+   }
+
+}


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

Added: trunk/testsuite/src/main/org/jboss/test/cluster/test/FieldBasedSessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/test/FieldBasedSessionPassivationTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/test/FieldBasedSessionPassivationTestCase.java	2007-07-05 22:42:06 UTC (rev 63850)
@@ -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.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * @author bstansberry
+ *
+ */
+public class FieldBasedSessionPassivationTestCase extends SessionPassivationTestCase
+{
+
+   /**
+    * @param name
+    */
+   public FieldBasedSessionPassivationTestCase(String name)
+   {
+      super(name);
+      warName_ = "/http-field/";
+      concatenate();
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(FieldBasedSessionPassivationTestCase.class,
+            "jbosscache-helper.sar, http-field.war");
+      return t1;
+   }
+   
+   protected String getWarName()
+   {
+      return "http-field";
+   }
+}


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

Added: trunk/testsuite/src/main/org/jboss/test/cluster/test/SessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/test/SessionPassivationTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/test/SessionPassivationTestCase.java	2007-07-05 22:42:06 UTC (rev 63850)
@@ -0,0 +1,266 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.cluster.test;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.jboss.cache.Fqn;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Session passivation tests.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 1.0
+ */
+public class SessionPassivationTestCase
+      extends BaseTest
+{
+   protected String setUrl;
+   protected String getUrl;
+   protected String modifyUrl;
+   protected String modifyNoSetUrl;
+   protected String removeUrl;
+   protected String invalidateUrl;
+   protected String clearUrl;
+   protected String attrListUrl;
+   protected String bindUrl_;
+   protected String protectedUrl_;
+   protected String securityCheckUrl_;
+   protected String loginFormUrl_;
+   protected String setSecuritySubjectUrl_;
+   protected String getSecuritySubjectUrl_;
+   protected String warName_;
+   protected String setUrlBase_;
+   protected String getUrlBase_;
+   protected String modifyUrlBase_;
+   protected String modifyNoSetUrlBase_;
+   protected String removeUrlBase_;
+   protected String invalidateUrlBase_;
+   protected String clearUrlBase_;
+   protected String bindUrlBase_;
+   protected String attrListUrlBase_;
+   protected String protectedUrlBase_;
+   protected String securityCheckUrlBase_;
+   protected String loginFormUrlBase_;
+   protected String setSecuritySubjectUrlBase_;
+   protected String getSecuritySubjectUrlBase_;
+   
+   private ObjectName warObjectName;
+   private String warFqn_;
+
+   public SessionPassivationTestCase(String name)
+   {
+      super(name);
+      warName_ = "/http-scoped/";
+      setUrlBase_ = "setSession.jsp";
+      getUrlBase_ = "getAttribute.jsp";
+      modifyUrlBase_ = "modifyAttribute.jsp";
+      modifyNoSetUrlBase_ = "modifyAttributeNoSet.jsp";
+      removeUrlBase_ = "removeAttribute.jsp";
+      invalidateUrlBase_ = "invalidateSession.jsp";
+      clearUrlBase_ = "clearCache.jsp";
+      bindUrlBase_ = "bindSession.jsp?Binding=";
+      protectedUrlBase_ = "index.html";
+      securityCheckUrlBase_ = "j_security_check";
+      loginFormUrlBase_ = "login.html";
+      attrListUrlBase_ = "attributeNames.jsp";
+      setSecuritySubjectUrlBase_  = "setSecuritySubject.jsp";
+      getSecuritySubjectUrlBase_ =  "getSecuritySubject.jsp";
+
+      concatenate();
+   }
+
+   protected void concatenate()
+   {
+      setUrl = warName_ +setUrlBase_;
+      getUrl = warName_ +getUrlBase_;
+      modifyUrl = warName_ +modifyUrlBase_;
+      modifyNoSetUrl = warName_ +modifyNoSetUrlBase_;
+      removeUrl = warName_ +removeUrlBase_;
+      invalidateUrl = warName_ +invalidateUrlBase_;
+      clearUrl = warName_ +clearUrlBase_;
+      bindUrl_ = warName_ + bindUrlBase_;
+      protectedUrl_ = warName_ + protectedUrlBase_;
+      securityCheckUrl_ = warName_ + securityCheckUrlBase_;
+      loginFormUrl_ = warName_ + loginFormUrlBase_;
+      attrListUrl = warName_ + attrListUrlBase_;
+      setSecuritySubjectUrl_ = warName_ + setSecuritySubjectUrlBase_;
+      getSecuritySubjectUrl_ = warName_ + getSecuritySubjectUrlBase_;
+   }
+   
+   protected String getWarName()
+   {
+      return "http-scoped";
+   }
+
+   public static Test suite() throws Exception
+   {
+      Test t1 = JBossClusteredTestCase.getDeploySetup(SessionPassivationTestCase.class,
+            "jbosscache-helper.sar, http-scoped.war");
+      return t1;
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      if (warObjectName == null)
+      {
+         String oname = "jboss.web:J2EEApplication=none,J2EEServer=none," +
+                        "j2eeType=WebModule,name=//localhost/" + getWarName();
+         warObjectName = new ObjectName(oname);
+         
+         RMIAdaptor[] adaptors = getAdaptors();
+         
+         Object[] names = {"JSESSION", "localhost", getWarName() };
+         Fqn fqn = new Fqn(names);
+         warFqn_ = fqn.toString();
+      }
+   }
+
+   protected void tearDown() throws Exception
+   {
+//      clear();
+      super.tearDown();
+   }
+   
+   /**
+    * Tests the ability to passivate session when max idle for session is reached
+    * 
+    * @throws Exception
+    */
+   public void testSessionPassivationWMaxIdle() throws Exception
+   {
+      getLog().debug("Enter testSessionPassivationWMaxActive");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+      
+      // Get the Attribute set
+      String attr0 = makeGet(client, baseURL0_ +getUrl);
+      
+      // Find out the session id and use it to build an FQN
+      String sessionID = getSessionID(client, servers_[0]);
+      // Strip off the jvmRoute, if there is one
+      sessionID = stripJvmRoute(sessionID);
+      String sessionFqn = "/JSESSION/localhost" + warName_ + sessionID;
+      
+      sleepThread(DEFAULT_SLEEP);
+      
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr1 = makeGet(client, baseURL1_ + getUrl);
+      
+      // check for replication first
+      assertEquals("attributes match", attr0, attr1);
+      
+      // sleep up to 11 secs to allow max idle to be reached 
+      // and tomcat background process to run
+      // assuming that max idle in jboss-web.xml = 10 secs
+      // and tomcat background process is using the default = 10 secs
+      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));
+      
+      // activate the session by requesting the attrribute
+      // Make connection to server 0 and get
+      setCookieDomainToThisServer(client, servers_[0]);
+      String attr2 = makeGet(client, baseURL0_ + getUrl);
+      
+      assertEquals("attribute match after activation", attr0, attr2);
+   }
+   
+   /**
+    * Tests the ability to passivate session when max number of active sessions reached
+    * 
+    * @throws Exception
+    */
+   public void testSessionPassivationWMaxActive() throws Exception
+   {
+      getLog().debug("Enter testSessionPassivationWMaxActive");
+
+      getLog().debug(setUrl + ":::::::" + getUrl);
+
+      RMIAdaptor[] adaptors = getAdaptors();
+      // Create an instance of HttpClient.
+      HttpClient client = new HttpClient();
+      // Set the session attribute first
+      makeGet(client, baseURL0_ +setUrl);
+      
+      // Get the Attribute set
+      String attr0 = makeGet(client, baseURL0_ +getUrl);
+      
+      // Find out the session id and use it to build an FQN
+      String sessionID = getSessionID(client, servers_[0]);
+      // Strip off the jvmRoute, if there is one
+      sessionID = stripJvmRoute(sessionID);
+      String sessionFqn = "/JSESSION/localhost" + warName_ + sessionID;
+      
+      sleepThread(DEFAULT_SLEEP);
+      
+      // Make connection to server 1 and get
+      setCookieDomainToThisServer(client, servers_[1]);
+      String attr1 = makeGet(client, baseURL1_ + getUrl);
+      
+      // check for replication first
+      assertEquals("attributes match", attr0, attr1);
+      
+      // Create 3 more sessions on server0
+      // 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(); 
+      HttpClient[] clients = new HttpClient[(20 - numberOfActiveSessions + 1)];
+      String[] attrs = new String[clients.length];
+      for (int i = 0; i < clients.length; i++)
+      {
+         clients[i] = new HttpClient();
+         makeGet(clients[i], baseURL0_ +setUrl);
+         attrs[i] = makeGet(clients[i], baseURL0_ + getUrl);
+         // Set cookie domain to server1
+         this.setCookieDomainToThisServer(clients[i], servers_[1]);
+      }
+      getLog().debug("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));
+      
+      // activate the session by requesting the attrribute
+      // Make connection to server 0 and get
+      setCookieDomainToThisServer(client, servers_[0]);
+      String attr2 = makeGet(client, baseURL0_ + getUrl);
+      
+      assertEquals("attribute match after activation", attr0, attr2);      
+   }
+}


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




More information about the jboss-cvs-commits mailing list