if (k.getName().equalsIgnoreCase("JSESSIONID"))
sessionID = k.getValue();
}
getLog().debug("Saw JSESSIONID=" + sessionID);
// Submit the login form
PostMethod formPost = new PostMethod(baseURLNoAuth + "custom-principal/j_security_check");
formPost.addRequestHeader("Referer", baseURLNoAuth + "custom-principal/login.jsp");
formPost.addParameter("j_username", this.username);
formPost.addParameter("j_password", new String(password));
responseCode = httpConn.executeMethod(formPost.getHostConfiguration(), formPost, state);
String loginResult = formPost.getResponseBodyAsString();
if( loginResult.indexOf("Encountered a login error") > 0 )
fail("Login Failed");
String response = formPost.getStatusText();
log.debug("responseCode="+responseCode+", response="+response);
assertTrue("Saw HTTP_MOVED_TEMP", responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
// Follow the redirect to the index.jsp
Header location = formPost.getResponseHeader("Location");
String indexURI = location.getValue();
GetMethod war1Index = new GetMethod(indexURI);
responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
war1Index, state);
response = war1Index.getStatusText();