Skip to content

Commit 2f3ee9c

Browse files
committed
More Java 8 in tests
1 parent 2494e69 commit 2f3ee9c

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java

+3-13
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static org.junit.Assert.assertNotNull;
2323
import static org.junit.Assert.assertSame;
2424
import static org.junit.Assert.assertThat;
25-
import static org.junit.Assert.fail;
2625
import static org.mockito.Matchers.any;
2726
import static org.mockito.Mockito.mock;
2827
import static org.mockito.Mockito.when;
@@ -90,12 +89,9 @@ public void shouldThrowAnExceptionIfTheTimerRunsOut() {
9089
TickingClock clock = new TickingClock(200);
9190
WebDriverWait wait = new WebDriverWait(mockDriver, clock, clock, 1, 200);
9291

93-
try {
94-
wait.until(new FalseExpectation());
95-
fail();
96-
} catch (TimeoutException e) {
97-
// this is expected
98-
}
92+
Throwable ex = catchThrowable(() -> wait.until((d) -> false));
93+
assertNotNull(ex);
94+
assertThat(ex, instanceOf(TimeoutException.class));
9995
}
10096

10197
@SuppressWarnings("unchecked")
@@ -137,10 +133,4 @@ public void shouldSilentlyCaptureNoSuchWindowExceptions() {
137133
Wait<WebDriver> wait = new WebDriverWait(mockDriver, clock, clock, 5, 500);
138134
wait.until(condition);
139135
}
140-
141-
private static class FalseExpectation implements ExpectedCondition<Boolean> {
142-
public Boolean apply(WebDriver driver) {
143-
return false;
144-
}
145-
}
146136
}

0 commit comments

Comments
 (0)