From 4ee640120878974fedff271691700cad3d198547 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 9 Sep 2016 14:54:43 +0300 Subject: [PATCH] Make sleep in tests throw RuntimeException to avoid try catches Change-Id: I7ef3cca8271ae9f725d8530793543253c216e6bc --- .../main/java/com/vaadin/tests/tb3/AbstractTB3Test.java | 9 ++++++--- .../ComboBoxSelectingWithNewItemsAllowedTest.java | 5 +---- .../panel/PanelRemoveShortcutListenerTest.java | 5 +---- .../ExpandingContainerVisibleRowRaceConditionTest.java | 9 --------- .../tests/components/window/ModalWindowFocusTest.java | 5 +---- .../vaadin/tests/requesthandlers/AppResource404Test.java | 6 +----- .../com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java | 5 +---- 7 files changed, 11 insertions(+), 33 deletions(-) diff --git a/uitest-common/src/main/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest-common/src/main/java/com/vaadin/tests/tb3/AbstractTB3Test.java index dbfda17bfd..4985bc7e93 100644 --- a/uitest-common/src/main/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest-common/src/main/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -786,12 +786,15 @@ public abstract class AbstractTB3Test extends ParallelTest { * * @param timeoutMillis * Number of ms to wait - * @throws InterruptedException */ - protected void sleep(int timeoutMillis) throws InterruptedException { + protected void sleep(int timeoutMillis) { while (timeoutMillis > 0) { int d = Math.min(BROWSER_TIMEOUT_IN_MS, timeoutMillis); - Thread.sleep(d); + try { + Thread.sleep(d); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } timeoutMillis -= d; // Do something to keep the connection alive diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java index 4483c27240..6adb68f933 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java @@ -267,10 +267,7 @@ public class ComboBoxSelectingWithNewItemsAllowedTest extends MultiBrowserTest { private void assertInitialItemCount() { // wait for a bit in case the count is updating - try { - sleep(1000); - } catch (InterruptedException ignore) { - } + sleep(1000); assertThat("Wrong initial item count.", labelElement.getText(), is("2600")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListenerTest.java b/uitest/src/test/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListenerTest.java index 756a55f3c5..45f3828dd1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListenerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListenerTest.java @@ -81,10 +81,7 @@ public class PanelRemoveShortcutListenerTest extends MultiBrowserTest { attemptShortcut("A on"); // add a bit more delay to make sure the caption doesn't change later - try { - sleep(2000); - } catch (InterruptedException ignore) { - } + sleep(2000); assertThat(panel.findElement(By.className("v-panel-caption")) .findElement(By.tagName("span")).getText(), is("A on")); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java index 807c097c16..ab4aeabaa2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java @@ -49,15 +49,6 @@ public class ExpandingContainerVisibleRowRaceConditionTest assertScrollPositionIsNotVisible(); } - @Override - protected void sleep(int milliseconds) { - try { - super.sleep(milliseconds); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - private void assertFirstRowIdIs(String expected) { List cellsOfFirstColumn = getCellsOfFirstColumn(); WebElement first = cellsOfFirstColumn.get(0); diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java index 50136759c1..b01a9ded14 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java @@ -93,10 +93,7 @@ public class ModalWindowFocusTest extends MultiBrowserTest { private void pressEscAndWait() { new Actions(driver).sendKeys(Keys.ESCAPE).build().perform(); - try { - sleep(100); - } catch (InterruptedException e) { - } + sleep(100); } } diff --git a/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java b/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java index 1b8d002236..74af445b3c 100644 --- a/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java +++ b/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java @@ -48,10 +48,6 @@ public class AppResource404Test extends MultiBrowserTest { protected void disableWaitingAndWait() { testBench().disableWaitForVaadin(); - try { - sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } + sleep(500); } } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java b/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java index 3abcdf76b8..51f281f6de 100755 --- a/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java @@ -87,10 +87,7 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { createProxy(getProxyPort()); break; } catch (JSchException e) { - try { - sleep(500); - } catch (InterruptedException e1) { - } + sleep(500); if (i == 9) { throw new RuntimeException( "All 10 attempts to connect a proxy failed", e); -- 2.39.5