public void badtestFormAuthFailover() throws Exception
{
log.info("+++ testFormAuthFailover");
// Start by accessing the war's protected url
HttpClient client = new HttpClient();
String body = makeGet(client, baseURL0_ + protectedUrl_);
if( body.indexOf("j_security_check") < 0 )
fail("get of "+protectedUrl_+" not redirected to login page");
HttpState state = client.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(baseURL0_ + securityCheckUrl_);
formPost.addRequestHeader("Referer", baseURL0_ + loginFormUrl_);
formPost.addParameter("j_username", "admin");
formPost.addParameter("j_password", "admin");
int responseCode = client.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);