|
17 | 17 |
|
18 | 18 | package org.openqa.selenium.grid.node; |
19 | 19 |
|
| 20 | +import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; |
20 | 21 | import static org.junit.jupiter.api.Assertions.assertEquals; |
21 | | -import static org.junit.jupiter.api.Assertions.assertThrows; |
22 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
23 | 22 | import static org.mockito.Mockito.*; |
| 23 | +import static org.openqa.selenium.remote.http.Contents.asJson; |
24 | 24 |
|
| 25 | +import com.google.common.collect.ImmutableMap; |
25 | 26 | import java.util.UUID; |
26 | 27 | import org.junit.jupiter.api.BeforeEach; |
27 | 28 | import org.junit.jupiter.api.Test; |
28 | | -import org.openqa.selenium.NoSuchSessionException; |
29 | 29 | import org.openqa.selenium.grid.data.NodeId; |
30 | 30 | import org.openqa.selenium.remote.SessionId; |
31 | 31 | import org.openqa.selenium.remote.http.HttpRequest; |
@@ -66,11 +66,15 @@ void testExecuteWithInvalidSessionOwner() { |
66 | 66 | SessionId sessionId = new SessionId("5678"); |
67 | 67 | when(mockNode.isSessionOwner(sessionId)).thenReturn(false); |
68 | 68 |
|
69 | | - NoSuchSessionException exception = |
70 | | - assertThrows(NoSuchSessionException.class, () -> command.execute(mockRequest)); |
71 | | - assertTrue( |
72 | | - exception |
73 | | - .getMessage() |
74 | | - .startsWith(String.format("Session not found in node %s", mockNode.getId()))); |
| 69 | + HttpResponse actualResponse = command.execute(mockRequest); |
| 70 | + HttpResponse expectResponse = |
| 71 | + new HttpResponse() |
| 72 | + .setStatus(HTTP_INTERNAL_ERROR) |
| 73 | + .setContent( |
| 74 | + asJson( |
| 75 | + ImmutableMap.of( |
| 76 | + "error", String.format("Session not found in node %s", mockNode.getId())))); |
| 77 | + assertEquals(expectResponse.getStatus(), actualResponse.getStatus()); |
| 78 | + assertEquals(expectResponse.getContentEncoding(), actualResponse.getContentEncoding()); |
75 | 79 | } |
76 | 80 | } |
0 commit comments