blob: 8551d8eeeab15b1a70e39d0dfb3427507d75d69c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
package com.vaadin.tests.push;
import org.junit.Test;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTestWithProxy;
import java.io.IOException;
public abstract class ReconnectTest extends MultiBrowserTestWithProxy {
@Override
public void setup() throws Exception {
super.setup();
setDebug(true);
openTestURL();
openDebugLogTab();
startTimer();
waitUntilServerCounterChanges();
testBench().disableWaitForVaadin();
}
@Test
public void messageIsQueuedOnDisconnect() throws IOException {
disconnectProxy();
clickButtonAndWaitForTwoReconnectAttempts();
connectAndVerifyConnectionEstablished();
waitUntilClientCounterChanges(1);
}
@Test
public void messageIsNotSentBeforeConnectionIsEstablished()
throws IOException, InterruptedException {
disconnectProxy();
waitForNextReconnectionAttempt();
clickButtonAndWaitForTwoReconnectAttempts();
connectAndVerifyConnectionEstablished();
waitUntilClientCounterChanges(1);
}
private void clickButtonAndWaitForTwoReconnectAttempts() {
clickClientButton();
// Reconnection attempt is where pending messages can
// falsely be sent to server.
waitForNextReconnectionAttempt();
// Waiting for the second reconnection attempt makes sure that the
// first attempt has been completed or aborted.
waitForNextReconnectionAttempt();
}
private void clickClientButton() {
getIncrementClientCounterButton().click();
}
private void waitForNextReconnectionAttempt() {
clearDebugMessages();
waitForDebugMessage("Reopening push connection");
}
private void connectAndVerifyConnectionEstablished() throws IOException {
connectProxy();
waitUntilServerCounterChanges();
}
private WebElement getIncrementClientCounterButton() {
return BasicPushTest.getIncrementButton(this);
}
private void waitUntilServerCounterChanges() {
final int counter = BasicPushTest.getServerCounter(this);
waitUntil(input -> {
try {
return BasicPushTest
.getServerCounter(ReconnectTest.this) > counter;
} catch (NoSuchElementException e) {
return false;
}
}, 30);
}
private void waitUntilClientCounterChanges(final int expectedValue) {
waitUntil(
input -> BasicPushTest
.getClientCounter(ReconnectTest.this) == expectedValue,
5);
}
private void startTimer() {
BasicPushTest.getServerCounterStartButton(this).click();
}
}
|