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
This commit is contained in:
Nik Everett 2018-06-21 13:24:39 -04:00
parent bd06563e78
commit 6f3e97f2b7
1 changed files with 4 additions and 4 deletions

View File

@ -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);