|
@@ -207,36 +207,6 @@ public class RestClientIntegTests extends RestClientTestCase {
|
|
|
bodyTest("GET");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Ensure that pathPrefix works as expected even when the path does not exist.
|
|
|
- */
|
|
|
- public void testPathPrefixUnknownPath() throws IOException {
|
|
|
- // guarantee no other test setup collides with this one and lets it sneak through
|
|
|
- final String uniqueContextSuffix = "/testPathPrefixUnknownPath";
|
|
|
- final String pathPrefix = "dne/" + randomAsciiOfLengthBetween(1, 5) + "/";
|
|
|
- final int statusCode = randomStatusCode(getRandom());
|
|
|
-
|
|
|
- try (final RestClient client =
|
|
|
- RestClient.builder(new HttpHost(httpServer.getAddress().getHostString(), httpServer.getAddress().getPort()))
|
|
|
- .setPathPrefix((randomBoolean() ? "/" : "") + pathPrefix).build()) {
|
|
|
-
|
|
|
- for (final String method : getHttpMethods()) {
|
|
|
- Response esResponse;
|
|
|
- try {
|
|
|
- esResponse = client.performRequest(method, "/" + statusCode + uniqueContextSuffix);
|
|
|
- if ("HEAD".equals(method) == false) {
|
|
|
- fail("only HEAD requests should not throw an exception; 404 is expected");
|
|
|
- }
|
|
|
- } catch(ResponseException e) {
|
|
|
- esResponse = e.getResponse();
|
|
|
- }
|
|
|
-
|
|
|
- assertThat(esResponse.getRequestLine().getUri(), equalTo("/" + pathPrefix + statusCode + uniqueContextSuffix));
|
|
|
- assertThat(esResponse.getStatusLine().getStatusCode(), equalTo(404));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Ensure that pathPrefix works as expected.
|
|
|
*/
|