Fix client test to not care about complete error response message
This commit is contained in:
parent
365d33efe3
commit
91cd6f35ce
|
@ -19,6 +19,9 @@
|
|||
|
||||
package org.elasticsearch.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.client.ResponseException;
|
||||
|
@ -27,9 +30,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
/**
|
||||
|
@ -48,14 +49,12 @@ public class DetailedErrorsDisabledIT extends HttpSmokeTestCase {
|
|||
}
|
||||
|
||||
public void testThatErrorTraceParamReturns400() throws IOException {
|
||||
try {
|
||||
getRestClient().performRequest("DELETE", "/", Collections.singletonMap("error_trace", "true"));
|
||||
fail("request should have failed");
|
||||
} catch(ResponseException e) {
|
||||
Response response = e.getResponse();
|
||||
assertThat(response.getHeader("Content-Type"), is("application/json; charset=UTF-8"));
|
||||
assertThat(EntityUtils.toString(e.getResponse().getEntity()), is("{\"error\":\"error traces in responses are disabled.\"}"));
|
||||
assertThat(response.getStatusLine().getStatusCode(), is(400));
|
||||
}
|
||||
ResponseException e = expectThrows(ResponseException.class, () ->
|
||||
getRestClient().performRequest("DELETE", "/", Collections.singletonMap("error_trace", "true")));
|
||||
|
||||
Response response = e.getResponse();
|
||||
assertThat(response.getHeader("Content-Type"), is("application/json; charset=UTF-8"));
|
||||
assertThat(EntityUtils.toString(e.getResponse().getEntity()), containsString("\"error\":\"error traces in responses are disabled.\""));
|
||||
assertThat(response.getStatusLine().getStatusCode(), is(400));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue