[jboss-cvs] JBossAS SVN: r65160 - in trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web: test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 6 11:19:16 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-09-06 11:19:16 -0400 (Thu, 06 Sep 2007)
New Revision: 65160
Modified:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java
Log:
Fix web session passivation tests
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java 2007-09-06 15:17:23 UTC (rev 65159)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/field/test/FieldBasedSessionPassivationTestCase.java 2007-09-06 15:19:16 UTC (rev 65160)
@@ -40,19 +40,19 @@
public FieldBasedSessionPassivationTestCase(String name)
{
super(name);
- warName_ = "/http-field/";
+ warName_ = "/http-field-pass/";
concatenate();
}
public static Test suite() throws Exception
{
Test t1 = JBossClusteredTestCase.getDeploySetup(FieldBasedSessionPassivationTestCase.class,
- "jbosscache-helper.sar, http-field.war");
+ "jbosscache-helper.sar, http-field-pass.war");
return t1;
}
protected String getWarName()
{
- return "http-field";
+ return "http-field-pass";
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java 2007-09-06 15:17:23 UTC (rev 65159)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/AttributeBasedSessionPassivationTestCase.java 2007-09-06 15:19:16 UTC (rev 65160)
@@ -38,20 +38,20 @@
public AttributeBasedSessionPassivationTestCase(String name)
{
super(name);
- warName_ = "/http-scoped-attr/";
+ warName_ = "/http-attr-pass/";
concatenate();
}
protected String getWarName()
{
- return "http-scoped-attr";
+ return "http-attr-pass";
}
public static Test suite() throws Exception
{
Test t1 = JBossClusteredTestCase.getDeploySetup(AttributeBasedSessionPassivationTestCase.class,
- "jbosscache-helper.sar, http-scoped-attr.war");
+ "jbosscache-helper.sar, http-attr-pass.war");
return t1;
}
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-09-06 15:17:23 UTC (rev 65159)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/SessionPassivationTestCase.java 2007-09-06 15:19:16 UTC (rev 65160)
@@ -23,16 +23,16 @@
import java.io.IOException;
import java.net.HttpURLConnection;
+import java.util.HashSet;
+import java.util.Set;
import javax.management.MBeanServerConnection;
-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.test.JBossClusteredTestCase;
import org.jboss.test.cluster.testutil.SessionTestUtil;
import org.jboss.test.cluster.testutil.WebTestBase;
@@ -51,38 +51,42 @@
protected String setUrl;
protected String getUrl;
+ protected String invalidateUrl;
protected String warName_;
protected String setUrlBase_;
protected String getUrlBase_;
+ protected String invalidateUrlBase_;
+ private String warFqn_;
- private ObjectName warObjectName;
- private String warFqn_;
+ private Set<HttpClient> clients = new HashSet<HttpClient>();
public SessionPassivationTestCase(String name)
{
super(name);
- warName_ = "/http-scoped/";
+ warName_ = "/http-session-pass/";
setUrlBase_ = "setSession.jsp";
getUrlBase_ = "getAttribute.jsp";
-
+ invalidateUrlBase_ = "invalidateSession.jsp";
+
concatenate();
}
protected void concatenate()
{
- setUrl = warName_ +setUrlBase_;
- getUrl = warName_ +getUrlBase_;
+ setUrl = warName_ + setUrlBase_;
+ getUrl = warName_ + getUrlBase_;
+ invalidateUrl = warName_ + invalidateUrlBase_;
}
protected String getWarName()
{
- return "http-scoped";
+ return "http-session-pass";
}
public static Test suite() throws Exception
{
Test t1 = JBossClusteredTestCase.getDeploySetup(SessionPassivationTestCase.class,
- "jbosscache-helper.sar, http-scoped.war");
+ "jbosscache-helper.sar, http-session-pass.war");
return t1;
}
@@ -90,17 +94,6 @@
{
super.setUp();
- if (warObjectName == null)
- {
- String oname = "jboss.web:J2EEApplication=none,J2EEServer=none," +
- "j2eeType=WebModule,name=//localhost/" + getWarName();
- warObjectName = new ObjectName(oname);
-
- Object[] names = {"JSESSION", "localhost", getWarName() };
- Fqn fqn = new Fqn(names);
- warFqn_ = fqn.toString();
- }
-
MBeanServerConnection[] adaptors = getAdaptors();
if (!deployed0)
{
@@ -116,8 +109,21 @@
protected void tearDown() throws Exception
{
-// clear();
super.tearDown();
+
+ // Invalidate any sessions to leave the cache clean
+ for (HttpClient client : clients)
+ {
+ try
+ {
+ setCookieDomainToThisServer(client, servers_[0]);
+ makeGet(client, baseURL0_ +invalidateUrl);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed clearing client " + client, e);
+ }
+ }
}
/**
@@ -133,17 +139,18 @@
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
+ clients.add(client);
// Set the session attribute first
makeGet(client, baseURL0_ +setUrl);
// Get the Attribute set
String attr0 = checkDeserialization(client, baseURL0_ +getUrl, false);
- // sleep up to 11 secs to allow max idle to be reached
+ // sleep up to 16 secs to allow max idle to be reached
// and tomcat background process to run
- // assuming that max idle in jboss-web.xml = 10 secs
+ // assuming that max idle in jboss-web.xml = 5 secs
// and tomcat background process is using the default = 10 secs
- sleepThread(11100);
+ sleepThread(16000);
// activate the session by requesting the attribute
// Make connection to server 0 and get
@@ -167,36 +174,30 @@
MBeanServerConnection[] adaptors = getAdaptors();
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
+ clients.add(client);
// Set the session attribute first
makeGet(client, baseURL0_ +setUrl);
// Get the Attribute set; confirm session wasn't deserialized
String attr0 = checkDeserialization(client, baseURL0_ +getUrl, false);
- // passivation-min-idle-time is set to 1 sec, so sleep that
+ // passivation-min-idle-time is set to 2 secs, so sleep that
// long so our session can be passivated
- sleepThread(1100);
+ sleepThread(2100);
// 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();
- HttpClient[] clients = new HttpClient[(20 - numberOfActiveSessions + 1)];
- String[] attrs = new String[clients.length];
- for (int i = 0; i < clients.length; i++)
+ HttpClient[] newClients = new HttpClient[(20)];
+ for (int i = 0; i < newClients.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]);
+ newClients[i] = new HttpClient();
+ clients.add(newClients[i]);
+ makeGet(newClients[i], baseURL0_ +setUrl);
+ makeGet(newClients[i], baseURL0_ +getUrl);
}
- getLog().debug("to reach max active sessions we needed to create " + clients.length + " clients");
-
- // Make connection to server 0 and get
- // activate the session and confirm that it was deserialized (passivated)
- setCookieDomainToThisServer(client, servers_[0]);
+ // access the session and confirm that it was deserialized (passivated/activated)
String attr2 = checkDeserialization(client, baseURL0_ + getUrl, true);
assertEquals("attribute match after activation", attr0, attr2);
@@ -223,7 +224,8 @@
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
-
+ clients.add(client);
+
// Set the session attribute first
makeGet(client, baseURL0_ +setUrl);
More information about the jboss-cvs-commits
mailing list