[Jboss-cvs] JBossAS SVN: r56072 - branches/JBoss_4_0_4_GA_JBAS-3526/testsuite/src/main/org/jboss/test/cluster/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 18 12:13:21 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-18 12:13:20 -0400 (Fri, 18 Aug 2006)
New Revision: 56072
Modified:
branches/JBoss_4_0_4_GA_JBAS-3526/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java
Log:
[JBAS-3526] Port JBAS-3528 Patch for 4.0.4.GA
Modified: branches/JBoss_4_0_4_GA_JBAS-3526/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java
===================================================================
--- branches/JBoss_4_0_4_GA_JBAS-3526/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java 2006-08-18 16:12:24 UTC (rev 56071)
+++ branches/JBoss_4_0_4_GA_JBAS-3526/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java 2006-08-18 16:13:20 UTC (rev 56072)
@@ -21,8 +21,13 @@
*/
package org.jboss.test.cluster.test;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
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.test.JBossClusteredTestCase;
/**
@@ -418,7 +423,71 @@
String attrRepl = makeGet(client, baseURL1_ +getSecuritySubjectUrl_);
assertTrue("javax.security.Subject did not replicate", attrRepl.indexOf("java.lang.String") > -1);
}
+
+ /**
+ * Test for JBAS-3528 (http://jira.jboss.com/jira/browse/JBAS-3528).
+ *
+ * @throws Exception
+ */
+ public void testIsNew() throws Exception
+ {
+ getLog().debug("Enter testIsNew");
+ getLog().debug(setUrl + ":::::::" + getUrl);
+
+ // Create an instance of HttpClient.
+ HttpClient client = new HttpClient();
+
+ // Set the session attribute first
+ makeGet(client, baseURL0_ +setUrl);
+
+ sleepThread(DEFAULT_SLEEP);
+
+ // Let's switch to server 2 to retrieve the session attribute.
+ setCookieDomainToThisServer(client, servers_[1]);
+ assertFalse("Session is not new", checkNew(client, baseURL1_ + getUrl));
+
+ sleepThread(DEFAULT_SLEEP);
+
+ // Let's switch to server 1 to ensure its correct there as well.
+ setCookieDomainToThisServer(client, servers_[0]);
+ assertFalse("Session is not new", checkNew(client, baseURL0_ + getUrl));
+ }
+
+
+ /**
+ * Makes a http call to the given url and confirms that a non-null
+ * header X-SessionIsNew is returned. Converts the value
+ * of the header to a boolean and returns it.
+ *
+ * @param client
+ * @param url
+ */
+ protected boolean checkNew(HttpClient client, String url)
+ {
+ getLog().info("checkNew(): 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-SessionIsNew");
+ assertNotNull("Got X-SessionIsNew header", hdr);
+ String value = hdr.getValue();
+ assertNotNull("Got non-nullX-SessionIsNew header", value);
+
+ return Boolean.valueOf(value).booleanValue();
+ }
+
protected void invalidate() throws Exception
{
// Create an instance of HttpClient.
More information about the jboss-cvs-commits
mailing list