|
23 | 23 | import org.apache.http.HttpHost; |
24 | 24 | import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; |
25 | 25 |
|
| 26 | +import java.net.URI; |
| 27 | +import java.util.Collections; |
| 28 | + |
26 | 29 | import static org.junit.Assert.assertEquals; |
27 | 30 | import static org.junit.Assert.fail; |
28 | 31 | import static org.mockito.Mockito.mock; |
@@ -77,6 +80,22 @@ public void testPerformAsyncWithWrongEndpoint() throws Exception { |
77 | 80 | } |
78 | 81 | } |
79 | 82 |
|
| 83 | + public void testBuildUriLeavesPathUntouched() { |
| 84 | + { |
| 85 | + URI uri = RestClient.buildUri("/foo$bar", "/index/type/id", Collections.<String, String>emptyMap()); |
| 86 | + assertEquals("/foo$bar/index/type/id", uri.getPath()); |
| 87 | + } |
| 88 | + { |
| 89 | + URI uri = RestClient.buildUri(null, "/foo$bar/ty/pe/i/d", Collections.<String, String>emptyMap()); |
| 90 | + assertEquals("/foo$bar/ty/pe/i/d", uri.getPath()); |
| 91 | + } |
| 92 | + { |
| 93 | + URI uri = RestClient.buildUri(null, "/index/type/id", Collections.singletonMap("foo$bar", "x/y/z")); |
| 94 | + assertEquals("/index/type/id", uri.getPath()); |
| 95 | + assertEquals("foo$bar=x/y/z", uri.getQuery()); |
| 96 | + } |
| 97 | + } |
| 98 | + |
80 | 99 | private static RestClient createRestClient() { |
81 | 100 | HttpHost[] hosts = new HttpHost[]{new HttpHost("localhost", 9200)}; |
82 | 101 | return new RestClient(mock(CloseableHttpAsyncClient.class), randomLongBetween(1_000, 30_000), new Header[]{}, hosts, null, null); |
|
0 commit comments