|
18 | 18 | package org.openqa.selenium.remote;
|
19 | 19 |
|
20 | 20 | import static org.junit.Assert.assertEquals;
|
21 |
| -import static org.junit.Assert.fail; |
| 21 | +import static org.junit.Assert.assertThat; |
22 | 22 | import static org.mockito.Mockito.verifyNoMoreInteractions;
|
23 | 23 | import static org.mockito.Mockito.when;
|
24 | 24 |
|
25 | 25 | import com.google.common.collect.ImmutableList;
|
26 | 26 | import com.google.common.collect.ImmutableMap;
|
27 | 27 |
|
| 28 | +import org.hamcrest.CoreMatchers; |
28 | 29 | import org.junit.Before;
|
29 | 30 | import org.junit.Test;
|
30 | 31 | import org.junit.runner.RunWith;
|
|
36 | 37 | import org.openqa.selenium.logging.LogEntries;
|
37 | 38 | import org.openqa.selenium.logging.LogEntry;
|
38 | 39 | import org.openqa.selenium.logging.LogType;
|
| 40 | +import org.openqa.selenium.testing.TestUtilities; |
39 | 41 |
|
40 | 42 | import java.util.ArrayList;
|
41 | 43 | import java.util.HashSet;
|
@@ -131,15 +133,13 @@ public void throwsOnBogusRemoteLogsResponse() {
|
131 | 133 | when(
|
132 | 134 | executeMethod
|
133 | 135 | .execute(DriverCommand.GET_LOG, ImmutableMap.of(RemoteLogs.TYPE_KEY, LogType.BROWSER)))
|
134 |
| - .thenReturn(new ImmutableMap.Builder() |
| 136 | + .thenReturn(new ImmutableMap.Builder<>() |
135 | 137 | .put("error", "unknown method")
|
136 | 138 | .put("message", "Command not found: POST /session/11037/log")
|
137 | 139 | .put("stacktrace", "").build());
|
138 |
| - try { |
139 |
| - remoteLogs.get(LogType.BROWSER); |
140 |
| - fail("Should have thrown WebDriverException"); |
141 |
| - } catch (WebDriverException expected) { |
142 |
| - } |
| 140 | + |
| 141 | + Throwable ex = TestUtilities.catchThrowable(() -> remoteLogs.get(LogType.BROWSER)); |
| 142 | + assertThat(ex, CoreMatchers.instanceOf(WebDriverException.class)); |
143 | 143 |
|
144 | 144 | verifyNoMoreInteractions(localLogs);
|
145 | 145 | }
|
|
0 commit comments