[TEST] create standard RestClient at first request and reuse it

A RestClient instance is now created whenever EsIntegTestCase#getRestClient is invoked for the first time. It is then kept until the cluster is cleared (depending on the cluster scope of the test).

Renamed other two restClient methods to createRestClient, as that instance needs to be closed and managed in the tests.
This commit is contained in:
javanna 2016-06-03 18:08:37 +02:00 committed by Luca Cavanna
parent 23a94bb974
commit c48b7a7a97
1 changed files with 2 additions and 1 deletions

View File

@ -219,7 +219,8 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase {
restController.registerRelevantHeaders(relevantHeaderName); restController.registerRelevantHeaders(relevantHeaderName);
} }
try (ElasticsearchResponse response = getRestClient().performRequest("GET", "/" + queryIndex + "/_search", Collections.emptyMap(), null, try (ElasticsearchResponse response = getRestClient().performRequest(
"GET", "/" + queryIndex + "/_search", Collections.emptyMap(), null,
new BasicHeader(randomHeaderKey, randomHeaderValue), new BasicHeader(relevantHeaderName, randomHeaderValue))) { new BasicHeader(randomHeaderKey, randomHeaderValue), new BasicHeader(relevantHeaderName, randomHeaderValue))) {
assertThat(response, hasStatus(OK)); assertThat(response, hasStatus(OK));
List<RequestAndHeaders> searchRequests = getRequests(SearchRequest.class); List<RequestAndHeaders> searchRequests = getRequests(SearchRequest.class);