for (Cookie cookie: this.client.getState().getCookies())
{
System.out.println(cookie.getDomain() + "\t" + cookie.getName() + "\t" + cookie.getPath() + "\t" + cookie.getValue());
}
Cookie cookie = this.findCookie(0, COOKIE_NAME);
Assert.assertNotNull(cookie);
Assert.assertEquals("0", cookie.getValue());
// Subsequent request should return 404
Assert.assertEquals(404, new RequestTask(0, 0).call().intValue());
System.out.println("After request to shutdown server");
for (Cookie c: this.client.getState().getCookies())
{
System.out.println(c.getDomain() + "\t" + c.getName() + "\t" + c.getPath() + "\t" + c.getValue());
}
String server0 = this.getServers()[0];
String server1 = this.getServers()[1];
// Copy cookies from server[0] to server[1]
for (Cookie c: this.client.getState().getCookies())
{
String domain = c.getDomain();
if (InetAddress.getByName(domain).equals(InetAddress.getByName(server0)) && c.getName().equals("JSESSIONID"))
{
// TODO Replace this with JBossTestUtil.fixHostnameForURL(), when ready
boolean wrap = domain.startsWith("[") && !server1.startsWith("[");
StringBuilder builder = new StringBuilder();
if (wrap)
{
builder.append('[');
}
builder.append(server1);
if (wrap)
{
builder.append(']');
}
this.client.getState().addCookie(new Cookie(builder.toString(), c.getName(), c.getValue(), c.getPath(), c.getExpiryDate(), c.getSecure()));
}
}
System.out.println("After cookie copy to failover server");
for (Cookie c: this.client.getState().getCookies())
{
System.out.println(c.getDomain() + "\t" + c.getName() + "\t" + c.getPath() + "\t" + c.getValue());
}
Assert.assertEquals(200, new RequestTask(1, 0).call().intValue());
System.out.println("After request on new server");
for (Cookie c: this.client.getState().getCookies())
{
System.out.println(c.getDomain() + "\t" + c.getName() + "\t" + c.getPath() + "\t" + c.getValue());
}
// If old session had replicated successfully, cookie value should equal old sleep duration
cookie = this.findCookie(1, COOKIE_NAME);
Assert.assertNotNull(cookie);
Assert.assertEquals(String.valueOf(REQUEST_DURATION), cookie.getValue());
}