@SecondsLong(12)
@TestType(Type.ACCEPTANCE)
public void testConnectionSharing() throws Exception {
WebClient c = new WebClient();
WebWindow w1 = new TopLevelWindow("1", c);
WebWindow w2 = new TopLevelWindow("2", c);
c.setCurrentWindow(w1);
String requestId1 = ((HtmlPage) c.getPage(TEST_URL)).getElementById("requestId").getAttribute("value");
Thread.sleep(1000);
c.setCurrentWindow(w2);
String requestId2 = ((HtmlPage) c.getPage(TEST_URL)).getElementById("requestId").getAttribute("value");
Thread.sleep(500);
enableDebug(w1);
enableDebug(w2);
Thread.sleep(10000);
System.out.println(getLogForWindows(w1,w2));
int current = Integer.parseInt(((HtmlPage) w1.getEnclosedPage()).getElementById("content").getFirstChild().getFirstChild().getTextContent().trim());
if (current < 9 || current > 12) {
throw new Exception("The value is not in the expected interval:[9,12] for Window 1. The current value:" + current);
}
current = Integer.parseInt(((HtmlPage) w2.getEnclosedPage()).getElementById("content").getFirstChild().getFirstChild().getTextContent().trim());
if (current < 9 || current > 12) {
throw new Exception("The value is not in the expected interval:[9,12] for Window 2. The current value:" + current);
}
if (getLogForWindows(w2).contains("pushnotifications") || getLogForWindows(w1).contains("pushnotifications") == false) {
throw new Exception("Window 2 is making permanent requests or Window 1 don't");