/** Tests that the failing pages' notifications are removed nicely. */
@SecondsLong(42)
@TestType(Type.INTEGRATION)
public void testCleanerNotificationRemoval() throws Exception {
WebClient c1 = new WebClient();
WebClient c2 = new WebClient();
String requestId1 = ((HtmlPage) c1.getPage(TEST_URL)).getElementById("requestId").getAttribute("value");
String requestId2 = ((HtmlPage) c2.getPage(TEST_URL)).getElementById("requestId").getAttribute("value");
System.out.println("Pages got");
c1.closeAllWindows();
c2.closeAllWindows();
System.out.println("Windows closed");
if (c1.getPage(TEST_URL_PREFIX + "/pushnotifications/?requestId=" + requestId1).getWebResponse().getContentAsString().startsWith("SUCCESS") == false) {
throw new Exception("There should be a notification!");
}
System.out.println("Notifications working");
for (int i = 0; i < 21; i++) {
Thread.sleep(2000);
System.out.println("Sending keepalive:" + i);
if (c1.getPage(TEST_URL_PREFIX + "/keepalive/?requestId=" + requestId1).getWebResponse().getContentAsString().startsWith("SUCCESS") == false) {
throw new Exception("Keepalive should be successful!");
}
}
System.out.println("All keepalives sent");
for (int i = 0; i < 20; i++) {
System.out.println("Getting notification:" + i);
if (new String(Base64.decodeStandard(c1.getPage(TEST_URL_PREFIX + "/pushnotifications/?requestId=" + requestId1).getWebResponse().getContentAsString().split("[:]")[1])).compareTo(requestId1) != 0) {
throw new Exception("Only the first page should have notifications!");
}
}
c1.getPage(TEST_URL_PREFIX + "/leaving/?requestId=" + requestId1);
c2.getPage(TEST_URL_PREFIX + "/leaving/?requestId=" + requestId2);
}