|
@@ -23,6 +23,9 @@ import org.apache.http.Header;
|
|
|
import org.apache.http.HttpHost;
|
|
|
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
|
|
|
|
|
+import java.net.URI;
|
|
|
+import java.util.Collections;
|
|
|
+
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.fail;
|
|
|
import static org.mockito.Mockito.mock;
|
|
@@ -77,6 +80,22 @@ public class RestClientTests extends RestClientTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void testBuildUriLeavesPathUntouched() {
|
|
|
+ {
|
|
|
+ URI uri = RestClient.buildUri("/foo$bar", "/index/type/id", Collections.<String, String>emptyMap());
|
|
|
+ assertEquals("/foo$bar/index/type/id", uri.getPath());
|
|
|
+ }
|
|
|
+ {
|
|
|
+ URI uri = RestClient.buildUri(null, "/foo$bar/ty/pe/i/d", Collections.<String, String>emptyMap());
|
|
|
+ assertEquals("/foo$bar/ty/pe/i/d", uri.getPath());
|
|
|
+ }
|
|
|
+ {
|
|
|
+ URI uri = RestClient.buildUri(null, "/index/type/id", Collections.singletonMap("foo$bar", "x/y/z"));
|
|
|
+ assertEquals("/index/type/id", uri.getPath());
|
|
|
+ assertEquals("foo$bar=x/y/z", uri.getQuery());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static RestClient createRestClient() {
|
|
|
HttpHost[] hosts = new HttpHost[]{new HttpHost("localhost", 9200)};
|
|
|
return new RestClient(mock(CloseableHttpAsyncClient.class), randomLongBetween(1_000, 30_000), new Header[]{}, hosts, null, null);
|