[Jboss-cvs] JBossAS SVN: r55051 - trunk/testsuite/src/main/org/jboss/test/cluster/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 2 17:18:51 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-02 17:18:51 -0400 (Wed, 02 Aug 2006)
New Revision: 55051
Added:
trunk/testsuite/src/main/org/jboss/test/cluster/test/CrossContextCallsTestCase.java
Log:
[JBAS-3318] Test for replication of all sessions in a cross-context request
Added: trunk/testsuite/src/main/org/jboss/test/cluster/test/CrossContextCallsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/test/CrossContextCallsTestCase.java 2006-08-02 21:18:29 UTC (rev 55050)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/test/CrossContextCallsTestCase.java 2006-08-02 21:18:51 UTC (rev 55051)
@@ -0,0 +1,142 @@
+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.HttpState;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.JBossClusteredTestCase;
+
+public class CrossContextCallsTestCase extends ScopedTestCase
+{
+
+ public CrossContextCallsTestCase(String name)
+ {
+ super(name);
+ warName_ = "/http-cross-ctx-first/";
+
+ concatenate();
+ }
+
+ public static Test suite() throws Exception
+ {
+ Test t1 = JBossClusteredTestCase.getDeploySetup(CrossContextCallsTestCase.class,
+ "http-cross-ctx.ear");
+ return t1;
+ }
+
+
+ /**
+ * Disabled; no-op.
+ */
+ public void testExcludeSecuritySubject() throws Exception
+ {
+ return;
+ }
+
+ /**
+ * Disabled; no-op.
+ */
+ public void testSessionBindingEvent() throws Exception
+ {
+ return;
+ }
+
+ protected String makeGet(HttpClient client, String url)
+ {
+ getLog().debug("makeGet(): 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);
+
+ String response = extractResponse(method);
+
+ // Release the connection.
+ // method.releaseConnection();
+
+ return response;
+ }
+
+ /**
+ * Makes a http call to the jsp that retrieves the attribute stored on the
+ * session. When the attribute values mathes with the one retrieved earlier,
+ * we have HttpSessionReplication.
+ * Makes use of commons-httpclient library of Apache
+ *
+ * @param client
+ * @param url
+ * @return session attribute
+ */
+ protected String makeGetWithState(HttpClient client, String url)
+ {
+ getLog().debug("makeGetWithState(): trying to get from url " +url);
+ GetMethod method = new GetMethod(url);
+ int responseCode = 0;
+ try
+ {
+ HttpState state = client.getState();
+ responseCode = client.executeMethod(method.getHostConfiguration(),
+ method, state);
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ fail("HttpClient executeMethod fails." +e.toString());
+ }
+ assertTrue("Get OK with url: " +url + " responseCode: " +responseCode,
+ responseCode == HttpURLConnection.HTTP_OK);
+
+ String response = extractResponse(method);
+
+ // Release the connection.
+ // method.releaseConnection();
+
+ return response;
+ }
+
+ private String extractResponse(GetMethod method)
+ {
+ Header header = method.getResponseHeader("FIRST");
+
+ assertNotNull("Received FIRST header", header);
+
+ String result = header.getValue();
+
+ assertNotNull("FIRST header not null", result);
+
+ header = method.getResponseHeader("SECOND");
+
+ assertNotNull("Received SECOND header", header);
+
+ String second = header.getValue();
+
+ assertNotNull("FIRST header not null", second);
+
+ result.concat(second);
+
+ // Read the response body.
+ byte[] responseBody = method.getResponseBody();
+ // Use caution: ensure correct character encoding and is not binary data
+ result.concat(new String(responseBody));
+
+ // Release the connection.
+ // method.releaseConnection();
+
+ return result;
+
+ }
+
+}
More information about the jboss-cvs-commits
mailing list