Skip to content

Commit 0110a90

Browse files
committed
Test: Skip assertion on windows
Windows doesn't provide consistent exception messages when it can't connect so skip the exception message assertion on windows. Closes #31457
1 parent 54a20d0 commit 0110a90

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
import static org.elasticsearch.client.RestClientTestUtil.getAllStatusCodes;
4343
import static org.elasticsearch.client.RestClientTestUtil.randomErrorNoRetryStatusCode;
4444
import static org.elasticsearch.client.RestClientTestUtil.randomOkStatusCode;
45-
import static org.hamcrest.Matchers.startsWith;
4645
import static org.junit.Assert.assertEquals;
47-
import static org.junit.Assert.assertThat;
4846
import static org.junit.Assert.assertTrue;
4947
import static org.junit.Assert.fail;
5048

@@ -216,8 +214,10 @@ public void testNodeSelector() throws IOException {
216214
restClient.performRequest(request);
217215
fail("expected to fail to connect");
218216
} catch (ConnectException e) {
219-
// This is different in windows and linux but this matches both.
220-
assertThat(e.getMessage(), startsWith("Connection refused"));
217+
// Windows isn't consistent here. Sometimes the message is even null!
218+
if (false == System.getProperty("os.name").startsWith("Windows")) {
219+
assertEquals("Connection refused", e.getMessage());
220+
}
221221
}
222222
} else {
223223
Response response = restClient.performRequest(request);

0 commit comments

Comments
 (0)