Browse Source

LLClient: Fix assertion on windows

In windows the exception message is ever so slightly differant than in
Linux and OSX. That is fine. We'll just catch either.
Nik Everett 7 years ago
parent
commit
045f76d67f

+ 4 - 1
client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java

@@ -42,7 +42,9 @@ 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;
 
@@ -214,7 +216,8 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase {
                     restClient.performRequest(request);
                     fail("expected to fail to connect");
                 } catch (ConnectException e) {
-                    assertEquals("Connection refused", e.getMessage());
+                    // This is different in windows and linux but this matches both.
+                    assertThat(e.getMessage(), startsWith("Connection refused"));
                 }
             } else {
                 Response response = restClient.performRequest(request);