public abstract class PushLargeData extends AbstractTestUIWithLog {
+ // 1MB
+ static final int DEFAULT_SIZE_BYTES = 1000 * 1000;
+
+ // Every other second
+ static final int DEFAULT_DELAY_MS = 2000;
+
+ // 20 MB is enough for streaming to reconnect
+ static final int DEFAULT_DATA_TO_PUSH = 20 * 1000 * 1000;
+
+ static final int DEFAULT_DURATION_MS = DEFAULT_DATA_TO_PUSH
+ / DEFAULT_SIZE_BYTES * DEFAULT_DELAY_MS;
+
private Label dataLabel = new Label();
private final ExecutorService executor = Executors
final TextField duration = new TextField("Duration (ms)");
duration.setConverter(Integer.class);
- dataSize.setValue((1000 * 1000) + "");
- interval.setValue(2000 + "");
- duration.setValue(40 * 1000 + "");
+ dataSize.setValue(DEFAULT_SIZE_BYTES + "");
+ interval.setValue(DEFAULT_DELAY_MS + "");
+ duration.setValue(DEFAULT_DURATION_MS + "");
addComponent(dataSize);
addComponent(interval);
*/
package com.vaadin.tests.push;
+import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+@Push(transport = Transport.STREAMING)
public class PushLargeDataStreaming extends PushLargeData {
@Override
protected void setup(VaadinRequest request) {
super.setup(request);
getPushConfiguration().setTransport(Transport.STREAMING);
- getPushConfiguration().setFallbackTransport(Transport.STREAMING);
+ getPushConfiguration().setParameter(
+ PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
}
}
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
-import com.vaadin.tests.tb3.WebsocketTest;
+import com.vaadin.tests.tb3.MultiBrowserTest;
-public class PushLargeDataStreamingTest extends WebsocketTest {
+public class PushLargeDataStreamingTest extends MultiBrowserTest {
@Test
- public void testWebsocketLargeData() {
+ public void testStreamingLargeData() {
openTestURL();
// Without this there is a large chance that we will wait for all pushes
}
private void push() {
+ // Wait for startButton to be present
+ waitForElementToBePresent(vaadinLocatorById("startButton"));
+
String logRow0Id = "Log_row_0";
By logRow0 = vaadinLocatorById(logRow0Id);
vaadinElementById("startButton").click();
- waitUntil(ExpectedConditions.not(ExpectedConditions
- .textToBePresentInElement(logRow0, "Push complete")));
+ // Wait for push to start
+ waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
+ "Package "));
- // Pushes each 2000ms for 40s
- sleep(40000);
+ // Wait for until push should be done
+ sleep(PushLargeData.DEFAULT_DURATION_MS);
+ // Wait until push is actually done
waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
"Push complete"));
}
+
}
import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
-@Push
+@Push(transport = Transport.WEBSOCKET)
public class PushLargeDataWebsocket extends PushLargeData {
@Override
protected void setup(VaadinRequest request) {
super.setup(request);
- getPushConfiguration().setTransport(Transport.WEBSOCKET);
- getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+ getPushConfiguration().setParameter(
+ PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
}
}
}
private void push() {
+ // Wait for startButton to be present
+ waitForElementToBePresent(vaadinLocatorById("startButton"));
+
String logRow0Id = "Log_row_0";
By logRow0 = vaadinLocatorById(logRow0Id);
- testBench(driver).waitForVaadin();
vaadinElementById("startButton").click();
- waitUntil(ExpectedConditions.not(ExpectedConditions
- .textToBePresentInElement(logRow0, "Push complete")));
+ // Wait for push to start
+ waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
+ "Package"));
- // Pushes each 2000ms for 40s
- sleep(40000);
+ // Wait for until push should be done
+ sleep(PushLargeData.DEFAULT_DURATION_MS);
+ // Wait until push is actually done
waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
"Push complete"));
}
new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition));
}
+ protected void waitForElementToBePresent(By by) {
+ waitUntil(ExpectedConditions.not(ExpectedConditions
+ .invisibilityOfElementLocated(by)));
+ }
+
/**
* For tests extending {@link AbstractTestUIWithLog}, returns the element
* for the Nth log row