]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make sleep in tests throw RuntimeException to avoid try catches
authorArtur Signell <artur@vaadin.com>
Fri, 9 Sep 2016 11:54:43 +0000 (14:54 +0300)
committerArtur Signell <artur@vaadin.com>
Fri, 9 Sep 2016 11:57:26 +0000 (14:57 +0300)
Change-Id: I7ef3cca8271ae9f725d8530793543253c216e6bc

uitest-common/src/main/java/com/vaadin/tests/tb3/AbstractTB3Test.java
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java
uitest/src/test/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListenerTest.java
uitest/src/test/java/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java
uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java
uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java
uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java

index dbfda17bfdd91fe4123ee9a093223283058e9da8..4985bc7e93c218e49bc5633729f775d154ba317e 100644 (file)
@@ -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
index 4483c27240982c39d91c93012404f31491a951fd..6adb68f933f976c48b669b0a07a4ea3a63d3f58a 100644 (file)
@@ -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"));
     }
index 756a55f3c59379d57c0e571c5f4ef5d74b4b6387..45f3828dd1fb465c537f9384b8e124684fef364f 100644 (file)
@@ -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"));
index 807c097c1630a737cdf320a393f133c81a35b1c4..ab4aeabaa21d6736c2bfb467b059857a45dda7d5 100644 (file)
@@ -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<WebElement> cellsOfFirstColumn = getCellsOfFirstColumn();
         WebElement first = cellsOfFirstColumn.get(0);
index 50136759c1670cad2858b12d040d5ba2993ba947..b01a9ded14f3c816a260b26e27c9f3e9fe92c682 100644 (file)
@@ -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);
     }
 
 }
index 1b8d0022368a2d04db8c5b444ccae57b158bff53..74af445b3cd3dac91a4d9621607fc7e1d758c2c8 100644 (file)
@@ -48,10 +48,6 @@ public class AppResource404Test extends MultiBrowserTest {
 
     protected void disableWaitingAndWait() {
         testBench().disableWaitForVaadin();
-        try {
-            sleep(500);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
+        sleep(500);
     }
 }
index 3abcdf76b8c0711b9c03487e8c93adc28c8c81d3..51f281f6de460c23f18d3397f11bf2278e283121 100755 (executable)
@@ -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);