[jboss-cvs] JBossAS SVN: r96468 - in branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test: util/web and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 17 15:16:38 EST 2009
Author: rachmatowicz at jboss.com
Date: 2009-11-17 15:16:38 -0500 (Tue, 17 Nov 2009)
New Revision: 96468
Modified:
branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java
branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/util/web/HttpUtils.java
branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/RemoteClassloadingServiceUnitTestCase.java
branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java
Log:
Apply fixes for testsuite version of HttpUtils (JBPAPP-2997)
Modified: branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java 2009-11-17 19:23:42 UTC (rev 96467)
+++ branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/cluster/test/BaseTest.java 2009-11-17 20:16:38 UTC (rev 96468)
@@ -69,6 +69,12 @@
{
baseURL1_ = httpURLs[1];
}
+
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("servers_[0] = " + servers_[0]) ;
+ if (servers_.length > 1)
+ getLog().debug("servers_[1] = " + servers_[1]) ;
+ }
}
/**
@@ -238,11 +244,17 @@
protected void setCookieDomainToThisServer(HttpClient client, String server)
{
+ if (getLog().isDebugEnabled())
+ logClientCookies(client, server) ;
+
// Get the session cookie
Cookie sessionID = getSessionCookie(client, server);
// Reset the domain so that the cookie will be sent to server1
sessionID.setDomain(server);
client.getState().addCookie(sessionID);
+
+ if (getLog().isDebugEnabled())
+ logClientCookies(client, server) ;
}
protected String getSessionID(HttpClient client, String server)
@@ -284,4 +296,20 @@
return id;
}
}
+
+ private void logClientCookies(HttpClient client, String server) {
+ HttpState state = client.getState();
+ Cookie[] cookies = state.getCookies();
+ getLog().debug("Client side cookies for server: " + server) ;
+ for(int c = 0; c < cookies.length; c ++)
+ {
+ Cookie k = cookies[c];
+ getLog().debug("Cookie[" + c + "]: path: " + k.getPath()) ;
+ getLog().debug("Cookie[" + c + "]: path specified(by server)?: " + k.isPathAttributeSpecified()) ;
+ getLog().debug("Cookie[" + c + "]: domain: " + k.getDomain()) ;
+ getLog().debug("Cookie[" + c + "]: domain specified(by server)?: " + k.isDomainAttributeSpecified()) ;
+ getLog().debug("Cookie[" + c + "]: expiry: " + k.getExpiryDate()) ;
+ getLog().debug("Cookie[" + c + "]: external form: " + k.toExternalForm()) ;
+ }
+ }
}
Modified: branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/util/web/HttpUtils.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/util/web/HttpUtils.java 2009-11-17 19:23:42 UTC (rev 96467)
+++ branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/util/web/HttpUtils.java 2009-11-17 20:16:38 UTC (rev 96468)
@@ -45,8 +45,9 @@
public class HttpUtils
{
private static Logger log = Logger.getLogger(HttpUtils.class);
- private static String baseURL = "http://jduke:theduke@" + System.getProperty("jbosstest.server.host", "localhost") + ":" + Integer.getInteger("web.port", 8080) + "/";
- private static String baseURLNoAuth = "http://" + System.getProperty("jbosstest.server.host", "localhost") + ":" + Integer.getInteger("web.port", 8080) + "/";
+ private static String hostForURL = fixHostnameForURL(System.getProperty("jbosstest.server.host", "localhost")) ;
+ private static String baseURL = "http://jduke:theduke@" + hostForURL + ":" + Integer.getInteger("web.port", 8080) + "/";
+ private static String baseURLNoAuth = "http://" + hostForURL + ":" + Integer.getInteger("web.port", 8080) + "/";
public static final int GET = 1;
public static final int POST = 2;
@@ -62,8 +63,7 @@
}
public static String getBaseURL(String username, String password)
{
- String url = "http://"+username+":"+password+"@" + System.getProperty("jbosstest.server.host", "localhost") + ":"
- + Integer.getInteger("web.port", 8080) + "/";
+ String url = "http://"+username+":"+password+"@" + hostForURL + ":" + Integer.getInteger("web.port", 8080) + "/";
return url;
}
public static String getBaseURLNoAuth()
@@ -174,4 +174,18 @@
}
return request;
}
+
+ /*
+ * This method generates a hostname suitable for inclusion in URLs,
+ * taking into account required treatnment of IPv6 literals (RFC2732).
+ */
+ public static String fixHostnameForURL(String host) {
+ if (host == null)
+ return host ;
+
+ if (host.indexOf(":") != -1)
+ return "[" + host + "]" ;
+ else
+ return host ;
+ }
}
Modified: branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/RemoteClassloadingServiceUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/RemoteClassloadingServiceUnitTestCase.java 2009-11-17 19:23:42 UTC (rev 96467)
+++ branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/RemoteClassloadingServiceUnitTestCase.java 2009-11-17 20:16:38 UTC (rev 96468)
@@ -37,7 +37,7 @@
*/
public class RemoteClassloadingServiceUnitTestCase extends JBossTestCase
{
- static final String baseURL = "http://" + System.getProperty("jbosstest.server.host", "localhost") + ":8083/";
+ static final String baseURL = "http://" + HttpUtils.fixHostnameForURL(System.getProperty("jbosstest.server.host", "localhost")) + ":8083/";
public RemoteClassloadingServiceUnitTestCase(String name)
{
Modified: branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java 2009-11-17 19:23:42 UTC (rev 96467)
+++ branches/JBPAPP_4_2_0_GA_CP_IPV6/testsuite/src/main/org/jboss/test/web/test/WebIntegrationUnitTestCase.java 2009-11-17 20:16:38 UTC (rev 96468)
@@ -226,7 +226,8 @@
URL url = new URL(baseURL+"jbosstest/restricted/SecureServlet");
getLog().info("Accessing SecureServlet with valid login");
HttpUtils.accessURL(url);
- String baseURL2 = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL2 = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL2 = HttpUtils.getBaseURLNoAuth() ;
URL url2 = new URL(baseURL2+"jbosstest/restricted/UnsecureEJBServlet");
getLog().info("Accessing SecureServlet with no login");
HttpUtils.accessURL(url2, REALM, HttpURLConnection.HTTP_UNAUTHORIZED);
@@ -235,7 +236,8 @@
*/
public void testSecureServletWithBadPass() throws Exception
{
- String baseURL = "http://jduke:badpass@" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://jduke:badpass@" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURL("jduke", "badpass") ;
URL url = new URL(baseURL+"jbosstest/restricted/SecureServlet");
HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_UNAUTHORIZED);
}
@@ -243,7 +245,8 @@
*/
public void testSecureServletWithNoLogin() throws Exception
{
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
URL url = new URL(baseURL+"jbosstest/restricted/SecureServlet");
HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_UNAUTHORIZED);
}
@@ -251,7 +254,8 @@
*/
public void testNotJbosstest() throws Exception
{
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
URL url = new URL(baseURL+"jbosstest-not/unrestricted/SecureServlet");
HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
}
@@ -336,7 +340,8 @@
try
{
deploy("jbosstest-web2.ear");
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
URL url = new URL(baseURL+"jbosstest-not2/unrestricted/SecureServlet");
HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
}
@@ -369,7 +374,8 @@
try
{
deploy("good-web.war");
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
URL url = new URL(baseURL+"redeploy/index.html");
HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
getLog().debug(baseURL+"redeploy/index.html OK");
@@ -389,7 +395,8 @@
deploy("manifest-web.ear");
try
{
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
URL url = new URL(baseURL+"manifest/classpath.jsp");
HttpMethodBase request = HttpUtils.accessURL(url);
Header errors = request.getResponseHeader("X-Exception");
@@ -421,7 +428,8 @@
try
{
deploy("jbosstest-good.ear");
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
URL url = new URL(baseURL+"redeploy/index.html");
HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
getLog().debug(baseURL+"redeploy/index.html OK");
@@ -447,7 +455,8 @@
deploy("class-loading.war");
try
{
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
// Load a log4j class
URL url = new URL(baseURL+"class-loading/ClasspathServlet2?class=org.apache.log4j.net.SocketAppender");
HttpMethodBase request = HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
@@ -477,7 +486,8 @@
deploy("class-loading-ulr.war");
try
{
- String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ // String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/';
+ String baseURL = HttpUtils.getBaseURLNoAuth() ;
// Load a log4j class
URL url = new URL(baseURL+"class-loading-ulr/ClasspathServlet2?class=org.apache.log4j.net.SocketAppender");
HttpMethodBase request = HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
More information about the jboss-cvs-commits
mailing list