diff --git a/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java b/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java index 2f95fe20232..6b4fdee47c6 100644 --- a/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java +++ b/core/src/test/java/org/elasticsearch/plugins/ResponseHeaderPluginIT.java @@ -30,9 +30,6 @@ import org.elasticsearch.test.ESIntegTestCase.Scope; import java.util.Collection; import java.util.Collections; -import static org.elasticsearch.rest.RestStatus.OK; -import static org.elasticsearch.rest.RestStatus.UNAUTHORIZED; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus; import static org.hamcrest.Matchers.equalTo; /** @@ -60,13 +57,13 @@ public class ResponseHeaderPluginIT extends ESIntegTestCase { fail("request should have failed"); } catch(ElasticsearchResponseException e) { ElasticsearchResponse response = e.getElasticsearchResponse(); - assertThat(response, hasStatus(UNAUTHORIZED)); + assertThat(response.getStatusLine().getStatusCode(), equalTo(401)); assertThat(response.getHeader("Secret"), equalTo("required")); } try (ElasticsearchResponse authResponse = getRestClient().performRequest("GET", "/_protected", Collections.emptyMap(), null, new BasicHeader("Secret", "password"))) { - assertThat(authResponse, hasStatus(OK)); + assertThat(authResponse.getStatusLine().getStatusCode(), equalTo(200)); assertThat(authResponse.getHeader("Secret"), equalTo("granted")); } } diff --git a/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java b/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java index 6dd6114ce79..9d25414f4d8 100644 --- a/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java +++ b/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java @@ -63,12 +63,11 @@ import java.util.concurrent.CopyOnWriteArrayList; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.rest.RestStatus.OK; import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasStatus; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; @@ -222,7 +221,7 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase { try (ElasticsearchResponse response = getRestClient().performRequest( "GET", "/" + queryIndex + "/_search", Collections.emptyMap(), null, new BasicHeader(randomHeaderKey, randomHeaderValue), new BasicHeader(relevantHeaderName, randomHeaderValue))) { - assertThat(response, hasStatus(OK)); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); List searchRequests = getRequests(SearchRequest.class); assertThat(searchRequests, hasSize(greaterThan(0))); for (RequestAndHeaders requestAndHeaders : searchRequests) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java index 0fe65ccf752..51d15e019a4 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java @@ -42,7 +42,6 @@ import org.elasticsearch.action.search.ShardSearchFailure; import org.elasticsearch.action.support.broadcast.BroadcastResponse; import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.client.ElasticsearchResponse; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; @@ -486,10 +485,6 @@ public class ElasticsearchAssertions { return new ElasticsearchMatchers.SearchHitHasScoreMatcher(score); } - public static Matcher hasStatus(RestStatus restStatus) { - return new ElasticsearchMatchers.ElasticsearchResponseHasStatusMatcher(restStatus); - } - public static T assertBooleanSubQuery(Query query, Class subqueryType, int i) { assertThat(query, instanceOf(BooleanQuery.class)); BooleanQuery q = (BooleanQuery) query; diff --git a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java index c40e434a5a7..f49cc3bd39e 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java +++ b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.test.hamcrest; -import org.elasticsearch.client.ElasticsearchResponse; -import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.SearchHit; import org.hamcrest.Description; import org.hamcrest.TypeSafeMatcher; @@ -117,28 +115,4 @@ public class ElasticsearchMatchers { description.appendText("searchHit score should be ").appendValue(score); } } - - public static class ElasticsearchResponseHasStatusMatcher extends TypeSafeMatcher { - - private RestStatus restStatus; - - public ElasticsearchResponseHasStatusMatcher(RestStatus restStatus) { - this.restStatus = restStatus; - } - - @Override - protected boolean matchesSafely(ElasticsearchResponse response) { - return response.getStatusLine().getStatusCode() == restStatus.getStatus(); - } - - @Override - public void describeMismatchSafely(final ElasticsearchResponse response, final Description mismatchDescription) { - mismatchDescription.appendText(" was ").appendValue(response.getStatusLine().getStatusCode()); - } - - @Override - public void describeTo(final Description description) { - description.appendText("Elasticsearch response status code should be ").appendValue(restStatus.getStatus()); - } - } }