[Jboss-cvs] JBossAS SVN: r56041 - in branches/Branch_4_0/testsuite/src: main/org/jboss/test/cluster/test resources/cluster/http resources/cluster/http/http-cross-ctx-first resources/cluster/http/http-field resources/cluster/http/http-scoped
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 17 18:11:36 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-17 18:11:31 -0400 (Thu, 17 Aug 2006)
New Revision: 56041
Modified:
branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java
branches/Branch_4_0/testsuite/src/resources/cluster/http/getattribute.jsp
branches/Branch_4_0/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp
branches/Branch_4_0/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp
branches/Branch_4_0/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp
Log:
[JBAS-3528] Correctly track if session is new
Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java 2006-08-17 22:02:48 UTC (rev 56040)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java 2006-08-17 22:11:31 UTC (rev 56041)
@@ -21,8 +21,14 @@
*/
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 +424,65 @@
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));
+ }
+
+
+ /**
+ * 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.
Modified: branches/Branch_4_0/testsuite/src/resources/cluster/http/getattribute.jsp
===================================================================
--- branches/Branch_4_0/testsuite/src/resources/cluster/http/getattribute.jsp 2006-08-17 22:02:48 UTC (rev 56040)
+++ branches/Branch_4_0/testsuite/src/resources/cluster/http/getattribute.jsp 2006-08-17 22:11:31 UTC (rev 56041)
@@ -3,6 +3,8 @@
String TEST_HTTP = (String) session.getAttribute("TEST_HTTP");
String flag = TEST_HTTP != null ? "true" : "false";
response.setHeader("X-SawTestHttpAttribute", flag);
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
%>
<h2>Server info : <%=application.getServerInfo()%>:<%=request.getServerPort()%></h2>
Modified: branches/Branch_4_0/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp
===================================================================
--- branches/Branch_4_0/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp 2006-08-17 22:02:48 UTC (rev 56040)
+++ branches/Branch_4_0/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp 2006-08-17 22:11:31 UTC (rev 56041)
@@ -3,6 +3,9 @@
import="org.jboss.test.cluster.web.Person"
%>
<%
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
+
String name = ((Person)session.getAttribute("TEST_PERSON")).getName();
response.setHeader("FIRST", name);
Modified: branches/Branch_4_0/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp
===================================================================
--- branches/Branch_4_0/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp 2006-08-17 22:02:48 UTC (rev 56040)
+++ branches/Branch_4_0/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp 2006-08-17 22:11:31 UTC (rev 56041)
@@ -7,9 +7,12 @@
<%@ page import="org.jboss.test.cluster.web.aop.Student"%>
<%
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
+
Student ben = (Student)session.getAttribute("TEST_PERSON");
- String flag = ben != null ? "true" : "false";
- response.setHeader("X-SawTestHttpAttribute", flag);
+ String flag = ben != null ? "true" : "false";
+ response.setHeader("X-SawTestHttpAttribute", flag);
Address addr = (Address)ben.getAddress();
flag = addr != null ? "true" : "false";
response.setHeader("X-SawTestHttpAttribute", flag);
Modified: branches/Branch_4_0/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp
===================================================================
--- branches/Branch_4_0/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp 2006-08-17 22:02:48 UTC (rev 56040)
+++ branches/Branch_4_0/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp 2006-08-17 22:11:31 UTC (rev 56041)
@@ -5,6 +5,7 @@
<% Person joe = ((Person)session.getAttribute("TEST_PERSON"));
String flag = joe != null ? "true" : "false";
response.setHeader("X-SawTestHttpAttribute", flag);
-
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
%>
<%= ((Person)session.getAttribute("TEST_PERSON")).getName() %>
More information about the jboss-cvs-commits
mailing list