diff options
author | Artur Signell <artur@vaadin.com> | 2013-10-31 21:35:25 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-11-01 09:03:36 +0000 |
commit | 7615fd1d1b248a612aa796f7621321040a795a55 (patch) | |
tree | ab28eea42bb0881f10975e0126ecf7c5ce95a0a0 /uitest/src/com/vaadin/tests | |
parent | c21a6848a2b7327eb0377b44b2479f03fecaf23e (diff) | |
download | vaadin-framework-7615fd1d1b248a612aa796f7621321040a795a55.tar.gz vaadin-framework-7615fd1d1b248a612aa796f7621321040a795a55.zip |
Made test more stable and added Firefox reconnect test (#12492)
Waits longer for push message as at least Firefox has some kind of built in back off for websocket reconnects
Change-Id: Iaab2e09e8364f0b6247b3b39c19be439a4995800
Diffstat (limited to 'uitest/src/com/vaadin/tests')
3 files changed, 73 insertions, 13 deletions
diff --git a/uitest/src/com/vaadin/tests/push/PushReconnectTest.java b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java index 8f131a5051..76a0b547da 100644 --- a/uitest/src/com/vaadin/tests/push/PushReconnectTest.java +++ b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java @@ -38,6 +38,26 @@ public abstract class PushReconnectTest extends MultiBrowserTestWithProxy { } @Test + public void testUserActionWhileDisconnectedWithDelay() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Assert.assertEquals(0, getClientCounter()); + getIncrementClientCounterButton().click(); + // No change while disconnected + Assert.assertEquals(0, getClientCounter()); + // Firefox sends extra onopen calls after a while, which breaks + // everything + Thread.sleep(10000); + connectProxy(); + waitUntilServerCounterChanges(); + // The change should have appeared when reconnected + Assert.assertEquals(1, getClientCounter()); + } + + @Test public void testUserActionWhileDisconnected() throws Exception { setDebug(true); openTestURL(); @@ -110,9 +130,9 @@ public abstract class PushReconnectTest extends MultiBrowserTestWithProxy { waitUntilServerCounterChanges(); for (int i = 0; i < 50; i++) { disconnectProxy(); - Thread.sleep(50); + Thread.sleep(100); connectProxy(); - Thread.sleep(50); + Thread.sleep(100); } waitUntilServerCounterChanges(); waitUntilServerCounterChanges(); @@ -134,7 +154,7 @@ public abstract class PushReconnectTest extends MultiBrowserTestWithProxy { public Boolean apply(WebDriver input) { return BasicPushTest.getServerCounter(PushReconnectTest.this) > counter; } - }); + }, 30); } private void startTimer() { diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 44cf069402..e6acad780f 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -306,18 +306,31 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } /** - * Waits a short while for the given condition to become true. Use e.g. as + * Waits up to 10s for the given condition to become true. Use e.g. as * {@link #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))} * * @param condition * the condition to wait for to become true */ protected void waitUntil(ExpectedCondition<Boolean> condition) { - new WebDriverWait(driver, 10).until(condition); + waitUntil(condition, 10); } /** - * Waits a short while for the given condition to become false. Use e.g. as + * Waits the given number of seconds for the given condition to become true. + * Use e.g. as {@link + * #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))} + * + * @param condition + * the condition to wait for to become true + */ + protected void waitUntil(ExpectedCondition<Boolean> condition, + long timeoutInSeconds) { + new WebDriverWait(driver, timeoutInSeconds).until(condition); + } + + /** + * Waits up to 10s for the given condition to become false. Use e.g. as * {@link #waitUntilNot(ExpectedConditions.textToBePresentInElement(by, * text))} * @@ -325,7 +338,20 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * the condition to wait for to become false */ protected void waitUntilNot(ExpectedCondition<Boolean> condition) { - new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition)); + waitUntilNot(condition, 10); + } + + /** + * Waits the given number of seconds for the given condition to become + * false. Use e.g. as {@link + * #waitUntilNot(ExpectedConditions.textToBePresentInElement(by, text))} + * + * @param condition + * the condition to wait for to become false + */ + protected void waitUntilNot(ExpectedCondition<Boolean> condition, + long timeoutInSeconds) { + waitUntil(ExpectedConditions.not(condition), timeoutInSeconds); } protected void waitForElementToBePresent(By by) { diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java index d3488a98c4..0bb76889a0 100755 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.tb3; +import java.io.File; import java.util.concurrent.atomic.AtomicInteger; import org.junit.After; @@ -29,6 +30,11 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { private static AtomicInteger availablePort = new AtomicInteger(2000); private Session proxySession; private Integer proxyPort = null; + private JSch jsch; + private static String sshDir = System.getProperty("user.home") + "/.ssh/"; + private String[] publicKeys = new String[] { + System.getProperty("sshkey.file"), sshDir + "id_rsa", + sshDir + "id_dsa", sshDir + "id_rsa2" }; @Before public void setupInitialProxy() throws JSchException { @@ -71,13 +77,21 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { } private void createProxy(int proxyPort) throws JSchException { - JSch j = new JSch(); - String keyFile = System.getProperty("sshkey.file"); - if (keyFile == null) { - keyFile = "~/.ssh/id_rsa"; + if (jsch == null) { + jsch = new JSch(); + + String keyFile = null; + for (String publicKey : publicKeys) { + if (publicKey != null) { + if (new File(publicKey).exists()) { + keyFile = publicKey; + break; + } + } + } + jsch.addIdentity(keyFile); } - j.addIdentity(keyFile); - proxySession = j.getSession("localhost"); + proxySession = jsch.getSession("localhost"); proxySession.setConfig("StrictHostKeyChecking", "no"); proxySession.setPortForwardingL("0.0.0.0", proxyPort, super.getDeploymentHostname(), super.getDeploymentPort()); |