From 6f3e97f2b7536e9d092ba80cb71d4ff3f7557734 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 21 Jun 2018 13:24:39 -0400 Subject: [PATCH] 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 --- .../client/RestClientMultipleHostsIntegTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java b/client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java index d09741ea25b..7f5915fe352 100644 --- a/client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java +++ b/client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java @@ -42,9 +42,7 @@ import java.util.concurrent.TimeUnit; import static org.elasticsearch.client.RestClientTestUtil.getAllStatusCodes; import static org.elasticsearch.client.RestClientTestUtil.randomErrorNoRetryStatusCode; import static org.elasticsearch.client.RestClientTestUtil.randomOkStatusCode; -import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -216,8 +214,10 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase { restClient.performRequest(request); fail("expected to fail to connect"); } catch (ConnectException e) { - // This is different in windows and linux but this matches both. - assertThat(e.getMessage(), startsWith("Connection refused")); + // Windows isn't consistent here. Sometimes the message is even null! + if (false == System.getProperty("os.name").startsWith("Windows")) { + assertEquals("Connection refused", e.getMessage()); + } } } else { Response response = restClient.performRequest(request);