|
23 | 23 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
24 | 24 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
25 | 25 | import static org.assertj.core.api.InstanceOfAssertFactories.MAP; |
26 | | -import static org.junit.jupiter.api.Assertions.assertThrows; |
27 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
28 | 26 | import static org.openqa.selenium.json.Json.MAP_TYPE; |
29 | 27 | import static org.openqa.selenium.remote.http.Contents.string; |
30 | 28 | import static org.openqa.selenium.remote.http.HttpMethod.DELETE; |
@@ -402,20 +400,14 @@ void shouldOnlyRespondToWebDriverCommandsForSessionsTheNodeOwns() { |
402 | 400 | assertThat(node2.matches(req2)).isTrue(); |
403 | 401 |
|
404 | 402 | // Assert that should not respond to commands for sessions Node 1 does not own |
405 | | - NoSuchSessionException exception = |
406 | | - assertThrows(NoSuchSessionException.class, () -> node.execute(req2)); |
407 | | - assertTrue( |
408 | | - exception |
409 | | - .getMessage() |
410 | | - .startsWith(String.format("Cannot find session with id: %s", session2.getId()))); |
| 403 | + HttpResponse res1 = node.execute(req2); |
| 404 | + assertThat(res1.getStatus()).isEqualTo(404); |
| 405 | + assertThat(Contents.string(res1)).contains("invalid session id"); |
411 | 406 |
|
412 | 407 | // Assert that should not respond to commands for sessions Node 2 does not own |
413 | | - NoSuchSessionException exception2 = |
414 | | - assertThrows(NoSuchSessionException.class, () -> node2.execute(req)); |
415 | | - assertTrue( |
416 | | - exception2 |
417 | | - .getMessage() |
418 | | - .startsWith(String.format("Cannot find session with id: %s", session.getId()))); |
| 408 | + HttpResponse res2 = node2.execute(req); |
| 409 | + assertThat(res2.getStatus()).isEqualTo(404); |
| 410 | + assertThat(Contents.string(res2)).contains("invalid session id"); |
419 | 411 | } |
420 | 412 |
|
421 | 413 | @Test |
|
0 commit comments