@@ -256,35 +256,51 @@ public void testGetWithBody() throws IOException {
256
256
257
257
public void testEncodeParams () throws IOException {
258
258
{
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 );
260
262
assertEquals (pathPrefix + "/200?routing=this%2Fis%2Fthe%2Frouting" , response .getRequestLine ().getUri ());
261
263
}
262
264
{
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 );
264
268
assertEquals (pathPrefix + "/200?routing=this%7Cis%7Cthe%7Crouting" , response .getRequestLine ().getUri ());
265
269
}
266
270
{
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 );
268
274
assertEquals (pathPrefix + "/200?routing=routing%231" , response .getRequestLine ().getUri ());
269
275
}
270
276
{
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 );
272
280
assertEquals (pathPrefix + "/200?routing=%E4%B8%AD%E6%96%87" , response .getRequestLine ().getUri ());
273
281
}
274
282
{
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 );
276
286
assertEquals (pathPrefix + "/200?routing=foo+bar" , response .getRequestLine ().getUri ());
277
287
}
278
288
{
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 );
280
292
assertEquals (pathPrefix + "/200?routing=foo%2Bbar" , response .getRequestLine ().getUri ());
281
293
}
282
294
{
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 );
284
298
assertEquals (pathPrefix + "/200?routing=foo%2Fbar" , response .getRequestLine ().getUri ());
285
299
}
286
300
{
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 );
288
304
assertEquals (pathPrefix + "/200?routing=foo%5Ebar" , response .getRequestLine ().getUri ());
289
305
}
290
306
}
@@ -341,14 +357,14 @@ public void testAuthCredentialsAreNotClearedOnAuthChallenge() throws IOException
341
357
public void testUrlWithoutLeadingSlash () throws Exception {
342
358
if (pathPrefix .length () == 0 ) {
343
359
try {
344
- restClient .performRequest ("GET" , "200" );
360
+ restClient .performRequest (new Request ( "GET" , "200" ) );
345
361
fail ("request should have failed" );
346
362
} catch (ResponseException e ) {
347
363
assertEquals (404 , e .getResponse ().getStatusLine ().getStatusCode ());
348
364
}
349
365
} else {
350
366
{
351
- Response response = restClient .performRequest ("GET" , "200" );
367
+ Response response = restClient .performRequest (new Request ( "GET" , "200" ) );
352
368
//a trailing slash gets automatically added if a pathPrefix is configured
353
369
assertEquals (200 , response .getStatusLine ().getStatusCode ());
354
370
}
@@ -357,7 +373,7 @@ public void testUrlWithoutLeadingSlash() throws Exception {
357
373
try (RestClient restClient = RestClient .builder (
358
374
new HttpHost (httpServer .getAddress ().getHostString (), httpServer .getAddress ().getPort ()))
359
375
.setPathPrefix (pathPrefix .substring (1 )).build ()) {
360
- Response response = restClient .performRequest ("GET" , "200" );
376
+ Response response = restClient .performRequest (new Request ( "GET" , "200" ) );
361
377
//a trailing slash gets automatically added if a pathPrefix is configured
362
378
assertEquals (200 , response .getStatusLine ().getStatusCode ());
363
379
}
0 commit comments