[Jboss-cvs] JBossAS SVN: r56043 - in trunk/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-field-jdk5 resources/cluster/http/http-scoped
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 17 18:54:57 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-17 18:54:55 -0400 (Thu, 17 Aug 2006)
New Revision: 56043
Modified:
trunk/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java
trunk/testsuite/src/resources/cluster/http/getattribute.jsp
trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp
trunk/testsuite/src/resources/cluster/http/http-field-jdk5/getAttribute.jsp
trunk/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp
trunk/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp
Log:
[JBAS-3528] Correctly track if session is new
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java 2006-08-17 22:41:01 UTC (rev 56042)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/test/ScopedTestCase.java 2006-08-17 22:54:55 UTC (rev 56043)
@@ -21,13 +21,16 @@
*/
package org.jboss.test.cluster.test;
+import java.io.IOException;
import java.net.HttpURLConnection;
import junit.framework.Test;
import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.jboss.test.JBossClusteredTestCase;
@@ -441,7 +444,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.
Modified: trunk/testsuite/src/resources/cluster/http/getattribute.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/getattribute.jsp 2006-08-17 22:41:01 UTC (rev 56042)
+++ trunk/testsuite/src/resources/cluster/http/getattribute.jsp 2006-08-17 22:54:55 UTC (rev 56043)
@@ -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: trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp 2006-08-17 22:41:01 UTC (rev 56042)
+++ trunk/testsuite/src/resources/cluster/http/http-cross-ctx-first/getAttribute.jsp 2006-08-17 22:54:55 UTC (rev 56043)
@@ -3,8 +3,11 @@
import="org.jboss.test.cluster.web.Person"
%>
<%
- String name = ((Person)session.getAttribute("TEST_PERSON")).getName();
- response.setHeader("FIRST", name);
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
+
+ String name = ((Person)session.getAttribute("TEST_PERSON")).getName();
+ response.setHeader("FIRST", name);
ServletContext ctx = application.getContext("/http-cross-ctx-second");
RequestDispatcher disp = ctx.getRequestDispatcher("/getAttribute.jsp");
Modified: trunk/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp 2006-08-17 22:41:01 UTC (rev 56042)
+++ trunk/testsuite/src/resources/cluster/http/http-field/getAttribute.jsp 2006-08-17 22:54:55 UTC (rev 56043)
@@ -6,6 +6,9 @@
%>
<%
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
+
Person joe = (Person)session.getAttribute("TEST_PERSON");
Address addr = (Address)joe.getAddress();
Modified: trunk/testsuite/src/resources/cluster/http/http-field-jdk5/getAttribute.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-field-jdk5/getAttribute.jsp 2006-08-17 22:41:01 UTC (rev 56042)
+++ trunk/testsuite/src/resources/cluster/http/http-field-jdk5/getAttribute.jsp 2006-08-17 22:54:55 UTC (rev 56043)
@@ -6,6 +6,9 @@
%>
<%
+ String isNew = session.isNew() ? "true" : "false";
+ response.setHeader("X-SessionIsNew", isNew);
+
Person joe = (Person)session.getAttribute("TEST_PERSON");
Address addr = (Address)joe.getAddress();
Modified: trunk/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp
===================================================================
--- trunk/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp 2006-08-17 22:41:01 UTC (rev 56042)
+++ trunk/testsuite/src/resources/cluster/http/http-scoped/getAttribute.jsp 2006-08-17 22:54:55 UTC (rev 56043)
@@ -2,5 +2,8 @@
import="java.util.*"
import="org.jboss.test.cluster.web.Person"
%>
-
+<%
+ 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