@@ -256,35 +256,51 @@ public void testGetWithBody() throws IOException {
256256
257257 public void testEncodeParams () throws IOException {
258258 {
259- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "this/is/the/routing" ));
259+ Request request = new Request ("PUT" , "/200" );
260+ request .addParameter ("routing" , "this/is/the/routing" );
261+ Response response = restClient .performRequest (request );
260262 assertEquals (pathPrefix + "/200?routing=this%2Fis%2Fthe%2Frouting" , response .getRequestLine ().getUri ());
261263 }
262264 {
263- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "this|is|the|routing" ));
265+ Request request = new Request ("PUT" , "/200" );
266+ request .addParameter ("routing" , "this|is|the|routing" );
267+ Response response = restClient .performRequest (request );
264268 assertEquals (pathPrefix + "/200?routing=this%7Cis%7Cthe%7Crouting" , response .getRequestLine ().getUri ());
265269 }
266270 {
267- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "routing#1" ));
271+ Request request = new Request ("PUT" , "/200" );
272+ request .addParameter ("routing" , "routing#1" );
273+ Response response = restClient .performRequest (request );
268274 assertEquals (pathPrefix + "/200?routing=routing%231" , response .getRequestLine ().getUri ());
269275 }
270276 {
271- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "中文" ));
277+ Request request = new Request ("PUT" , "/200" );
278+ request .addParameter ("routing" , "中文" );
279+ Response response = restClient .performRequest (request );
272280 assertEquals (pathPrefix + "/200?routing=%E4%B8%AD%E6%96%87" , response .getRequestLine ().getUri ());
273281 }
274282 {
275- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "foo bar" ));
283+ Request request = new Request ("PUT" , "/200" );
284+ request .addParameter ("routing" , "foo bar" );
285+ Response response = restClient .performRequest (request );
276286 assertEquals (pathPrefix + "/200?routing=foo+bar" , response .getRequestLine ().getUri ());
277287 }
278288 {
279- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "foo+bar" ));
289+ Request request = new Request ("PUT" , "/200" );
290+ request .addParameter ("routing" , "foo+bar" );
291+ Response response = restClient .performRequest (request );
280292 assertEquals (pathPrefix + "/200?routing=foo%2Bbar" , response .getRequestLine ().getUri ());
281293 }
282294 {
283- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "foo/bar" ));
295+ Request request = new Request ("PUT" , "/200" );
296+ request .addParameter ("routing" , "foo/bar" );
297+ Response response = restClient .performRequest (request );
284298 assertEquals (pathPrefix + "/200?routing=foo%2Fbar" , response .getRequestLine ().getUri ());
285299 }
286300 {
287- Response response = restClient .performRequest ("PUT" , "/200" , Collections .singletonMap ("routing" , "foo^bar" ));
301+ Request request = new Request ("PUT" , "/200" );
302+ request .addParameter ("routing" , "foo^bar" );
303+ Response response = restClient .performRequest (request );
288304 assertEquals (pathPrefix + "/200?routing=foo%5Ebar" , response .getRequestLine ().getUri ());
289305 }
290306 }
@@ -341,14 +357,14 @@ public void testAuthCredentialsAreNotClearedOnAuthChallenge() throws IOException
341357 public void testUrlWithoutLeadingSlash () throws Exception {
342358 if (pathPrefix .length () == 0 ) {
343359 try {
344- restClient .performRequest ("GET" , "200" );
360+ restClient .performRequest (new Request ( "GET" , "200" ) );
345361 fail ("request should have failed" );
346362 } catch (ResponseException e ) {
347363 assertEquals (404 , e .getResponse ().getStatusLine ().getStatusCode ());
348364 }
349365 } else {
350366 {
351- Response response = restClient .performRequest ("GET" , "200" );
367+ Response response = restClient .performRequest (new Request ( "GET" , "200" ) );
352368 //a trailing slash gets automatically added if a pathPrefix is configured
353369 assertEquals (200 , response .getStatusLine ().getStatusCode ());
354370 }
@@ -357,7 +373,7 @@ public void testUrlWithoutLeadingSlash() throws Exception {
357373 try (RestClient restClient = RestClient .builder (
358374 new HttpHost (httpServer .getAddress ().getHostString (), httpServer .getAddress ().getPort ()))
359375 .setPathPrefix (pathPrefix .substring (1 )).build ()) {
360- Response response = restClient .performRequest ("GET" , "200" );
376+ Response response = restClient .performRequest (new Request ( "GET" , "200" ) );
361377 //a trailing slash gets automatically added if a pathPrefix is configured
362378 assertEquals (200 , response .getStatusLine ().getStatusCode ());
363379 }
0 commit comments