[Jboss-cvs] JBossAS SVN: r55443 - trunk/testsuite/src/main/org/jboss/test/web/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 9 12:32:04 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-09 12:32:02 -0400 (Wed, 09 Aug 2006)
New Revision: 55443
Modified:
trunk/testsuite/src/main/org/jboss/test/web/test/ClusteredSingleSignOnUnitTestCase.java
Log:
Make deployment tracking fields static
Modified: trunk/testsuite/src/main/org/jboss/test/web/test/ClusteredSingleSignOnUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/ClusteredSingleSignOnUnitTestCase.java 2006-08-09 16:30:35 UTC (rev 55442)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/ClusteredSingleSignOnUnitTestCase.java 2006-08-09 16:32:02 UTC (rev 55443)
@@ -46,8 +46,11 @@
public class ClusteredSingleSignOnUnitTestCase
extends JBossClusteredTestCase
{
- private boolean deployed0 = true;
- private boolean deployed1 = true;
+ // NOTE: these variables must be static as apparently a separate instance
+ // of this class is created for each test
+ private static boolean deployed0 = true;
+ private static boolean deployed1 = true;
+
private RMIAdaptor[] adaptors = null;
public ClusteredSingleSignOnUnitTestCase(String name)
@@ -80,106 +83,7 @@
deployed1 = true;
}
}
-
- /** Test single sign-on across two web apps using form based auth
- *
- * @throws Exception
- */
- public void testFormAuthSingleSignOn() throws Exception
- {
- log.info("+++ testFormAuthSingleSignOn");
- String[] httpURLs = super.getHttpURLs();
-
- String serverA = httpURLs[0];
- String serverB = httpURLs[1];
- log.info(System.getProperties());
- log.info("serverA: "+serverA);
- log.info("serverB: "+serverB);
- SSOBaseCase.executeFormAuthSingleSignOnTest(serverA, serverB, getLog());
- }
- /**
- * Tests that use of transactions in ClusteredSSO does not interfere
- * with session expiration thread. See JBAS-2212.
- *
- * @throws Exception
- */
- public void testSessionExpiration()
- throws Exception
- {
- log.info("+++ testSessionExpiration");
- String[] httpURLs = super.getHttpURLs();
-
- String serverA = httpURLs[0];
- log.info(System.getProperties());
- log.info("serverA: "+serverA);
-
- // Start by accessing the secured index.html of war1
- HttpClient httpConn = new HttpClient();
- GetMethod indexGet = new GetMethod(serverA+"/war3/index.jsp");
- int responseCode = httpConn.executeMethod(indexGet);
- String body = indexGet.getResponseBodyAsString();
- assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
- assertTrue("Redirected to login page", body.indexOf("j_security_check") > 0 );
-
- HttpState state = httpConn.getState();
- Cookie[] cookies = state.getCookies();
- String sessionID = null;
- for(int c = 0; c < cookies.length; c ++)
- {
- Cookie k = cookies[c];
- if( k.getName().equalsIgnoreCase("JSESSIONID") )
- sessionID = k.getValue();
- }
- log.debug("Saw JSESSIONID="+sessionID);
-
- // Submit the login form
- PostMethod formPost = new PostMethod(serverA+"/war3/j_security_check");
- formPost.addRequestHeader("Referer", serverA+"/war3/login.html");
- formPost.addParameter("j_username", "jduke");
- formPost.addParameter("j_password", "theduke");
- responseCode = httpConn.executeMethod(formPost.getHostConfiguration(),
- formPost, state);
- String response = formPost.getStatusText();
- log.debug("responseCode="+responseCode+", response="+response);
- assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
- responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
-
- // Follow the redirect to the index.html page
- Header location = formPost.getResponseHeader("Location");
- String indexURI = location.getValue();
- GetMethod war1Index = new GetMethod(indexURI);
- responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
- war1Index, state);
- assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
- body = war1Index.getResponseBodyAsString();
- if( body.indexOf("j_security_check") > 0 )
- fail("get of "+indexURI+" redirected to login page");
-
- // Wait more than 65 secs to let session time out
- // 5 secs for the session timeout, 2 * 30 secs for the processor thread
- // TODO for some reason it takes 1 min for processExpires to run ???
- // (not an sso issue -- a tomcat issue)
- try {
- Thread.sleep(65500);
- }
- catch (InterruptedException ie)
- {
- log.debug("Interrupted while waiting for session expiration");
- }
-
- // Try accessing war1 again
- war1Index = new GetMethod(serverA+"/war3/index.jsp");
- responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
- war1Index, state);
- assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
- body = war1Index.getResponseBodyAsString();
- log.debug("body: " + body);
- if( body.indexOf("j_security_check") < 0 )
- fail("get of /war1/index.html not redirected to login page");
-
- }
-
/**
* Tests that undeploying a webapp on one server doesn't kill an sso
* that also has a session from another webapp associated with it.
@@ -309,4 +213,103 @@
fail("get of /war1/index.html redirected to login page");
}
+
+ /** Test single sign-on across two web apps using form based auth
+ *
+ * @throws Exception
+ */
+ public void testFormAuthSingleSignOn() throws Exception
+ {
+ log.info("+++ testFormAuthSingleSignOn");
+ String[] httpURLs = super.getHttpURLs();
+
+ String serverA = httpURLs[0];
+ String serverB = httpURLs[1];
+ log.info(System.getProperties());
+ log.info("serverA: "+serverA);
+ log.info("serverB: "+serverB);
+ SSOBaseCase.executeFormAuthSingleSignOnTest(serverA, serverB, getLog());
+ }
+
+ /**
+ * Tests that use of transactions in ClusteredSSO does not interfere
+ * with session expiration thread. See JBAS-2212.
+ *
+ * @throws Exception
+ */
+ public void testSessionExpiration()
+ throws Exception
+ {
+ log.info("+++ testSessionExpiration");
+ String[] httpURLs = super.getHttpURLs();
+
+ String serverA = httpURLs[0];
+ log.info(System.getProperties());
+ log.info("serverA: "+serverA);
+
+ // Start by accessing the secured index.html of war1
+ HttpClient httpConn = new HttpClient();
+ GetMethod indexGet = new GetMethod(serverA+"/war3/index.jsp");
+ int responseCode = httpConn.executeMethod(indexGet);
+ String body = indexGet.getResponseBodyAsString();
+ assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+ assertTrue("Redirected to login page", body.indexOf("j_security_check") > 0 );
+
+ HttpState state = httpConn.getState();
+ Cookie[] cookies = state.getCookies();
+ String sessionID = null;
+ for(int c = 0; c < cookies.length; c ++)
+ {
+ Cookie k = cookies[c];
+ if( k.getName().equalsIgnoreCase("JSESSIONID") )
+ sessionID = k.getValue();
+ }
+ log.debug("Saw JSESSIONID="+sessionID);
+
+ // Submit the login form
+ PostMethod formPost = new PostMethod(serverA+"/war3/j_security_check");
+ formPost.addRequestHeader("Referer", serverA+"/war3/login.html");
+ formPost.addParameter("j_username", "jduke");
+ formPost.addParameter("j_password", "theduke");
+ responseCode = httpConn.executeMethod(formPost.getHostConfiguration(),
+ formPost, state);
+ String response = formPost.getStatusText();
+ log.debug("responseCode="+responseCode+", response="+response);
+ assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
+ responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
+
+ // Follow the redirect to the index.html page
+ Header location = formPost.getResponseHeader("Location");
+ String indexURI = location.getValue();
+ GetMethod war1Index = new GetMethod(indexURI);
+ responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
+ war1Index, state);
+ assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+ body = war1Index.getResponseBodyAsString();
+ if( body.indexOf("j_security_check") > 0 )
+ fail("get of "+indexURI+" redirected to login page");
+
+ // Wait more than 65 secs to let session time out
+ // 5 secs for the session timeout, 2 * 30 secs for the processor thread
+ // TODO for some reason it takes 1 min for processExpires to run ???
+ // (not an sso issue -- a tomcat issue)
+ try {
+ Thread.sleep(65500);
+ }
+ catch (InterruptedException ie)
+ {
+ log.debug("Interrupted while waiting for session expiration");
+ }
+
+ // Try accessing war1 again
+ war1Index = new GetMethod(serverA+"/war3/index.jsp");
+ responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
+ war1Index, state);
+ assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+ body = war1Index.getResponseBodyAsString();
+ log.debug("body: " + body);
+ if( body.indexOf("j_security_check") < 0 )
+ fail("get of /war1/index.html not redirected to login page");
+
+ }
}
More information about the jboss-cvs-commits
mailing list