This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 17ccc1e  RestClient tests.
17ccc1e is described below

commit 17ccc1e319992b1a54af31b3d9c14f0f6d1cd78a
Author: JamesBognar <[email protected]>
AuthorDate: Sat Jul 4 13:08:47 2020 -0400

    RestClient tests.
---
 .../client2/RestClient_Config_RestClient_Test.java | 117 ++++++++++++++++++---
 .../ext/BasicHttpRequestRetryHandler_Test.java}    |  84 +++++++++------
 .../juneau/rest/client/AllowAllRedirects.java      |   2 -
 .../juneau/rest/client2/BasicRestCallHandler.java  |  12 +--
 .../juneau/rest/client2/RestCallHandler.java       |  62 ++++++-----
 .../org/apache/juneau/rest/client2/RestClient.java |  47 ++-------
 .../juneau/rest/client2/RestClientBuilder.java     |   9 +-
 .../apache/juneau/rest/client2/RestRequest.java    |   5 +-
 8 files changed, 197 insertions(+), 141 deletions(-)

diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Config_RestClient_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Config_RestClient_Test.java
index d03d566..c7463dc 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Config_RestClient_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Config_RestClient_Test.java
@@ -24,7 +24,6 @@ import java.util.logging.*;
 import org.apache.http.*;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.*;
-import org.apache.http.client.methods.*;
 import org.apache.http.impl.client.*;
 import org.apache.http.message.*;
 import org.apache.http.protocol.*;
@@ -99,10 +98,10 @@ public class RestClient_Config_RestClient_Test {
                        super(client);
                }
                @Override
-               public HttpResponse execute(HttpHost target, HttpRequestBase 
request, HttpContext context) throws ClientProtocolException, IOException {
+               public HttpResponse run(HttpHost target, HttpRequest request, 
HttpContext context) throws ClientProtocolException, IOException {
                        request.addHeader("Check","Foo");
                        request.addHeader("Foo","baz");
-                       return super.execute(target,request,context);
+                       return super.run(target,request,context);
                }
        }
 
@@ -110,11 +109,7 @@ public class RestClient_Config_RestClient_Test {
        public void a01_callHandler() throws Exception {
                RestCallHandler x = new RestCallHandler() {
                        @Override
-                       public HttpResponse execute(HttpHost target, 
HttpEntityEnclosingRequestBase request, HttpContext context) throws 
ClientProtocolException, IOException {
-                               return null;
-                       }
-                       @Override
-                       public HttpResponse execute(HttpHost target, 
HttpRequestBase request, HttpContext context) throws ClientProtocolException, 
IOException {
+                       public HttpResponse run(HttpHost target, HttpRequest 
request, HttpContext context) throws ClientProtocolException, IOException {
                                return new BasicHttpResponse(new 
BasicStatusLine(new ProtocolVersion("http",1,1),201,null));
                        }
                };
@@ -209,6 +204,72 @@ public class RestClient_Config_RestClient_Test {
                }
        }
 
+       public static class A5d extends BasicRestCallInterceptor {
+               @Override
+               public void onInit(RestRequest req) throws Exception {
+                       throw new RestCallException(null,null,"foo");
+               }
+       }
+
+       public static class A5e extends BasicRestCallInterceptor {
+               @Override
+               public void onInit(RestRequest req) throws Exception {
+               }
+               @Override
+               public void onConnect(RestRequest req, RestResponse res) throws 
Exception {
+                       throw new RestCallException(null,null,"foo");
+               }
+               @Override
+               public void onClose(RestRequest req, RestResponse res) throws 
Exception {
+               }
+       }
+
+       public static class A5f extends BasicRestCallInterceptor {
+               @Override
+               public void onInit(RestRequest req) throws Exception {
+               }
+               @Override
+               public void onConnect(RestRequest req, RestResponse res) throws 
Exception {
+               }
+               @Override
+               public void onClose(RestRequest req, RestResponse res) throws 
Exception {
+                       throw new RestCallException(null,null,"foo");
+               }
+       }
+
+       public static class A5g extends BasicRestCallInterceptor {
+               @Override
+               public void onInit(RestRequest req) throws Exception {
+                       throw new IOException("foo");
+               }
+       }
+
+       public static class A5h extends BasicRestCallInterceptor {
+               @Override
+               public void onInit(RestRequest req) throws Exception {
+               }
+               @Override
+               public void onConnect(RestRequest req, RestResponse res) throws 
Exception {
+                       throw new IOException("foo");
+               }
+               @Override
+               public void onClose(RestRequest req, RestResponse res) throws 
Exception {
+               }
+       }
+
+       public static class A5i extends BasicRestCallInterceptor {
+               @Override
+               public void onInit(RestRequest req) throws Exception {
+               }
+               @Override
+               public void onConnect(RestRequest req, RestResponse res) throws 
Exception {
+               }
+               @Override
+               public void onClose(RestRequest req, RestResponse res) throws 
Exception {
+                       throw new IOException("foo");
+               }
+       }
+
        @Test
        public void a05_interceptors() throws Exception {
                
client().header("Foo","f1").interceptors(A5.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
@@ -219,15 +280,37 @@ public class RestClient_Config_RestClient_Test {
 
                
client().header("Foo","f1").build().get("/checkHeader").interceptors(new 
A5()).header("Check","foo").header("Foo","f3").run().assertBody().is("['f1','f2','f3']").assertHeader("Bar").is("b1");
                assertEquals(111,A5.x);
-               
assertThrown(()->client().header("Foo","f1").interceptors(A5a.class).build().get("/checkHeader")).is("foo");
-               
assertThrown(()->client().header("Foo","f1").interceptors(A5b.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).is("foo");
-               
assertThrown(()->client().header("Foo","f1").interceptors(A5c.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).is("foo");
-               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5a()).build().get("/checkHeader")).is("foo");
-               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5b()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).is("foo");
-               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5c()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).is("foo");
-               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 A5a())).is("foo");
-               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 A5b()).header("Check","foo").header("Foo","f3").run()).is("foo");
-               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 A5c()).header("Check","foo").header("Foo","f3").run().close()).is("foo");
+
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5a.class).build().get("/checkHeader")).isType(RuntimeException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5b.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).isType(RuntimeException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5c.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).isType(RuntimeException.class).is("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5a()).build().get("/checkHeader")).isType(RuntimeException.class).is("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5b()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).isType(RuntimeException.class).is("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5c()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).isType(RuntimeException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 A5a())).isType(RuntimeException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 
A5b()).header("Check","foo").header("Foo","f3").run()).isType(RuntimeException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 
A5c()).header("Check","foo").header("Foo","f3").run().close()).isType(RuntimeException.class).is("foo");
+
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5d.class).build().get("/checkHeader")).isType(RestCallException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5e.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).isType(RestCallException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5f.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).isType(RestCallException.class).is("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5d()).build().get("/checkHeader")).isType(RestCallException.class).is("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5e()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).isType(RestCallException.class).is("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5f()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).isType(RestCallException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 A5d())).isType(RestCallException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 
A5e()).header("Check","foo").header("Foo","f3").run()).isType(RestCallException.class).is("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 
A5f()).header("Check","foo").header("Foo","f3").run().close()).isType(RestCallException.class).is("foo");
+
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5g.class).build().get("/checkHeader")).isType(RestCallException.class).contains("foo");
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5h.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).isType(RestCallException.class).contains("foo");
+               
assertThrown(()->client().header("Foo","f1").interceptors(A5i.class).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).isType(RestCallException.class).contains("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5g()).build().get("/checkHeader")).isType(RestCallException.class).contains("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5h()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run()).isType(RestCallException.class).contains("foo");
+               assertThrown(()->client().header("Foo","f1").interceptors(new 
A5i()).build().get("/checkHeader").header("Check","foo").header("Foo","f3").run().close()).isType(RestCallException.class).contains("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 A5g())).isType(RestCallException.class).contains("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 
A5h()).header("Check","foo").header("Foo","f3").run()).isType(RestCallException.class).contains("foo");
+               
assertThrown(()->client().header("Foo","f1").build().get("/checkHeader").interceptors(new
 
A5i()).header("Check","foo").header("Foo","f3").run().close()).isType(RestCallException.class).contains("foo");
+
                
assertThrown(()->client().interceptors(String.class)).is("Invalid class of type 
'java.lang.String' passed to interceptors().");
                assertThrown(()->client().interceptors("")).is("Invalid object 
of type 'java.lang.String' passed to interceptors().");
                
client().interceptors((Object)null).header("Foo","f1").build().get("/checkHeader");
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/AllRedirectsStrategy.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/ext/BasicHttpRequestRetryHandler_Test.java
similarity index 59%
rename from 
juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/AllRedirectsStrategy.java
rename to 
juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/ext/BasicHttpRequestRetryHandler_Test.java
index ed6e749..c649916 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/AllRedirectsStrategy.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/ext/BasicHttpRequestRetryHandler_Test.java
@@ -1,32 +1,52 @@
-// 
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
-// * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              *
-// *                                                                           
                                              *
-// *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
-// *                                                                           
                                              *
-// * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
-// * specific language governing permissions and limitations under the 
License.                                              *
-// 
***************************************************************************************************************************
-package org.apache.juneau.rest.client2.ext;
-
-import org.apache.http.impl.client.*;
-
-/**
- * Redirect strategy that allows for redirects on any request type, not just 
<c>GET</c> or <c>HEAD</c>.
- *
- * <ul class='notes'>
- *     <li>
- *             This class is similar to 
<c>org.apache.http.impl.client.LaxRedirectStrategy</c>
- *             in Apache HttpClient 4.2, but also allows for redirects on 
<c>PUTs</c> and <c>DELETEs</c>.
- * </ul>
- */
-public class AllRedirectsStrategy extends DefaultRedirectStrategy {
-
-       @Override /* DefaultRedirectStrategy */
-       protected boolean isRedirectable(final String method) {
-               return true;
-       }
-}
+// 
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                
                                              *
+// *                                                                           
                                              *
+// *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
+// *                                                                           
                                              *
+// * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the 
License.                                              *
+// 
***************************************************************************************************************************
+package org.apache.juneau.rest.client2.ext;
+
+import static org.apache.juneau.assertions.Assertions.*;
+
+import java.io.*;
+import java.net.*;
+
+import org.apache.http.*;
+import org.apache.http.HttpResponse;
+import org.apache.http.protocol.*;
+import org.apache.juneau.http.response.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.mock2.*;
+import org.junit.*;
+
+public class BasicHttpRequestRetryHandler_Test {
+
+       @Rest
+       public static class A extends BasicRest {
+               @RestMethod
+               public Ok get() {
+                       return Ok.OK;
+               }
+       }
+
+       public static class A1 extends HttpRequestExecutor {
+               @Override
+               public HttpResponse execute(HttpRequest request, 
HttpClientConnection conn, HttpContext context) throws IOException, 
HttpException {
+                       throw new UnknownHostException("foo");
+               }
+       }
+
+       @Test
+       public void a01_basic() throws Exception {
+               RestClient x = MockRestClient.create(A.class).retryHandler(new 
BasicHttpRequestRetryHandler(1, 1, true)).requestExecutor(new A1()).build();
+               assertThrown(()->x.get().run()).contains("foo");
+       }
+}
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/AllowAllRedirects.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/AllowAllRedirects.java
index 29c79b1..ef25685 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/AllowAllRedirects.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/AllowAllRedirects.java
@@ -22,8 +22,6 @@ import org.apache.http.impl.client.*;
  *             This class is similar to 
<c>org.apache.http.impl.client.LaxRedirectStrategy</c>
  *             in Apache HttpClient 4.2, but also allows for redirects on 
<c>PUTs</c> and <c>DELETEs</c>.
  * </ul>
- *
- * @deprecated Use {@link 
org.apache.juneau.rest.client2.ext.AllRedirectsStrategy}
  */
 @Deprecated
 public class AllowAllRedirects extends DefaultRedirectStrategy {
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/BasicRestCallHandler.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/BasicRestCallHandler.java
index 301abc9..a775f0c 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/BasicRestCallHandler.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/BasicRestCallHandler.java
@@ -15,7 +15,6 @@ package org.apache.juneau.rest.client2;
 import java.io.*;
 
 import org.apache.http.*;
-import org.apache.http.client.*;
 import org.apache.http.client.methods.*;
 import org.apache.http.protocol.*;
 
@@ -37,13 +36,8 @@ public class BasicRestCallHandler implements RestCallHandler 
{
                this.client = client;
        }
 
-       @Override
-       public HttpResponse execute(HttpHost target, 
HttpEntityEnclosingRequestBase request, HttpContext context) throws 
ClientProtocolException, IOException {
-               return target == null ? client.execute(request, context) : 
client.execute(target, (HttpRequest)request, context);
-       }
-
-       @Override
-       public HttpResponse execute(HttpHost target, HttpRequestBase request, 
HttpContext context) throws ClientProtocolException, IOException {
-               return target == null ? client.execute(request, context) : 
client.execute(target, (HttpRequest)request, context);
+       @Override /* RestCallHandler */
+       public HttpResponse run(HttpHost target, HttpRequest request, 
HttpContext context) throws IOException {
+               return target == null ? client.execute((HttpUriRequest)request, 
context) : client.execute(target, request, context);
        }
 }
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallHandler.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallHandler.java
index 52372a3..9c94145 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallHandler.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallHandler.java
@@ -18,17 +18,44 @@ import org.apache.http.*;
 import org.apache.http.client.*;
 import org.apache.http.client.methods.*;
 import org.apache.http.protocol.*;
+import org.apache.juneau.*;
 
 /**
  * Interface that allows you to override the handling of HTTP requests.
  *
  * <p>
- * Providing this implementation is the equivalent to overriding the {@link 
RestClient#execute(HttpHost,HttpEntityEnclosingRequestBase,HttpContext)}
- * and {@link RestClient#execute(HttpHost,HttpRequestBase,HttpContext)} 
methods.
+ * Providing this implementation is the equivalent to overriding the {@link 
RestClient#execute(HttpHost,HttpRequest,HttpContext)}.
+ * <br>This can also be accomplished by providing your own {@link 
RestClientBuilder#connectionManager(org.apache.http.conn.HttpClientConnectionManager)}
+ * or subclassing {@link RestClient}, but this provides a simpler way of 
handling the requests yourself.
  *
  * <p>
- * This can also be accomplished by providing your own {@link 
RestClientBuilder#connectionManager(org.apache.http.conn.HttpClientConnectionManager)}
- * or subclassing {@link RestClient}, but this provides a simpler way of 
handling the requests yourself.
+ * The constructor on the implementation class can optionally take in any of 
the following parameters:
+ * <ul>
+ *     <li>{@link RestClient} - The client using this handler.
+ *     <li>{@link PropertyStore} - The properties used to initialize the 
client.
+ * </ul>
+ *
+ * <p>
+ * The {@link BasicRestCallHandler} shows an example of a simple pass-through 
handler.  Note that you must handle
+ * the case where {@link HttpHost} is null.
+ *
+ * <p class='bcode w800'>
+ *     <jk>public class</jk> BasicRestCallHandler <jk>implements</jk> 
RestCallHandler {
+ *
+ *             <jk>private final</jk> RestClient <jf>client</jf>;
+ *
+ *             <jk>public</jk> BasicRestCallHandler(RestClient client) {
+ *                     <jk>this</jk>.<jf>client</jf> = client;
+ *             }
+ *
+ *             <ja>@Override</ja>
+ *             <jk>public</jk> HttpResponse run(HttpHost target, HttpRequest 
request, HttpContext context) <jk>throws</jk> IOException {
+ *                     <jk>if</jk> (target == <jk>null</jk>)
+ *                             <jk>return</jk> 
<jf>client</jf>.execute((HttpUriRequest)request, context);
+ *                     <jk>return</jk> <jf>client</jf>.execute(target, 
request, context);
+ *             }
+ *     }
+ * </p>
  *
  * <ul class='seealso'>
  *     <li class='jf'>{@link RestClient#RESTCLIENT_callHandler}
@@ -39,28 +66,7 @@ import org.apache.http.protocol.*;
 public interface RestCallHandler {
 
        /**
-        * Execute the specified body request (e.g. POST/PUT).
-        *
-        * <p>
-        * Subclasses can override this method to provide specialized handling.
-        *
-        * @param target The target host for the request.
-        *      <br>Implementations may accept <jk>null</jk> if they can still 
determine a route, for example to a default
-        *              target or by inspecting the request.
-        * @param request The request to execute.
-        * @param context The context to use for the execution, or 
<jk>null</jk> to use the default context.
-        * @return
-        *      The response to the request.
-        *      <br>This is always a final response, never an intermediate 
response with an 1xx status code.
-        *      <br>Whether redirects or authentication challenges will be 
returned or handled automatically depends on the
-        *              implementation and configuration of this client.
-        * @throws IOException In case of a problem or the connection was 
aborted.
-        * @throws ClientProtocolException In case of an http protocol error.
-        */
-       HttpResponse execute(HttpHost target, HttpEntityEnclosingRequestBase 
request, HttpContext context) throws ClientProtocolException, IOException;
-
-       /**
-        * Execute the specified no-body request (e.g. GET/DELETE).
+        * Execute the specified request.
         *
         * <p>
         * Subclasses can override this method to provide specialized handling.
@@ -68,7 +74,7 @@ public interface RestCallHandler {
         * @param target The target host for the request.
         *      <br>Implementations may accept <jk>null</jk> if they can still 
determine a route, for example to a default
         *              target or by inspecting the request.
-        * @param request The request to execute.
+        * @param request The request to execute.  Must be an instance of 
{@link HttpUriRequest} if the target is <jk>null</jk>.
         * @param context The context to use for the execution, or 
<jk>null</jk> to use the default context.
         * @return
         *      The response to the request.
@@ -78,5 +84,5 @@ public interface RestCallHandler {
         * @throws IOException In case of a problem or the connection was 
aborted.
         * @throws ClientProtocolException In case of an http protocol error.
         */
-       HttpResponse execute(HttpHost target, HttpRequestBase request, 
HttpContext context) throws ClientProtocolException, IOException;
+       HttpResponse run(HttpHost target, HttpRequest request, HttpContext 
context) throws ClientProtocolException, IOException;
 }
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
index 2eb74ce..2007375 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClient.java
@@ -806,14 +806,13 @@ import org.apache.http.client.CookieStore;
  *     </ul>
  *     <li class='jic'>{@link RestCallHandler}
  *     <ul>
- *             <li class='jm'><c>{@link 
RestCallHandler#execute(HttpHost,HttpEntityEnclosingRequestBase,HttpContext) 
execute(HttpHost,HttpEntityEnclosingRequestBase,HttpContext)} <jk>returns</jk> 
HttpResponse</c>
- *             <li class='jm'><c>{@link 
RestCallHandler#execute(HttpHost,HttpRequestBase,HttpContext) 
execute(HttpHost,HttpRequestBase,HttpContext)} <jk>returns</jk> HttpResponse</c>
+ *             <li class='jm'><c>{@link 
RestCallHandler#run(HttpHost,HttpRequest,HttpContext) 
run(HttpHost,HttpRequest,HttpContext)} <jk>returns</jk> HttpResponse</c>
  *     </ul>
  * </ul>
  *
  * <p class='w900'>
  * Note that there are other ways of accomplishing this such as extending the 
{@link RestClient} class and overriding
- * the {@link #execute(HttpHost,HttpEntityEnclosingRequestBase,HttpContext)} 
and {@link #execute(HttpHost,HttpRequestBase,HttpContext)}
+ * the {@link #run(HttpHost,HttpRequest,HttpContext)} method
  * or by defining your own {@link HttpRequestExecutor}.  Using this interface 
is often simpler though.
  *
  *
@@ -2068,7 +2067,7 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable, Re
        }
 
        /**
-        * Execute the specified no-body request (e.g. GET/DELETE).
+        * Entrypoint for executing all requests and returning a response.
         *
         * <p>
         * Subclasses can override this method to provide specialized handling.
@@ -2096,41 +2095,8 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable, Re
         * @throws ClientProtocolException In case of an http protocol error.
         */
        @Override /* RestCallHandler */
-       public HttpResponse execute(HttpHost target, HttpRequestBase request, 
HttpContext context) throws ClientProtocolException, IOException {
-               return callHandler.execute(target, request, context);
-       }
-
-       /**
-        * Execute the specified body request (e.g. POST/PUT).
-        *
-        * <p>
-        * Subclasses can override this method to provide specialized handling.
-        *
-        * <p>
-        * The behavior of this method can also be modified by specifying a 
different {@link RestCallHandler}.
-        *
-        * <ul class='seealso'>
-        *      <li class='jf'>{@link RestClient#RESTCLIENT_callHandler}
-        *      <li class='jm'>{@link RestClientBuilder#callHandler(Class)}
-        *      <li class='jm'>{@link 
RestClientBuilder#callHandler(RestCallHandler)}
-        * </ul>
-        *
-        * @param target The target host for the request.
-        *      <br>Implementations may accept <jk>null</jk> if they can still 
determine a route, for example to a default
-        *              target or by inspecting the request.
-        * @param request The request to execute.
-        * @param context The context to use for the execution, or 
<jk>null</jk> to use the default context.
-        * @return
-        *      The response to the request.
-        *      <br>This is always a final response, never an intermediate 
response with an 1xx status code.
-        *      <br>Whether redirects or authentication challenges will be 
returned or handled automatically depends on the
-        *              implementation and configuration of this client.
-        * @throws IOException In case of a problem or the connection was 
aborted.
-        * @throws ClientProtocolException In case of an http protocol error.
-        */
-       @Override /* RestCallHandler */
-       public HttpResponse execute(HttpHost target, 
HttpEntityEnclosingRequestBase request, HttpContext context) throws 
ClientProtocolException, IOException {
-               return callHandler.execute(target, request, context);
+       public HttpResponse run(HttpHost target, HttpRequest request, 
HttpContext context) throws ClientProtocolException, IOException {
+               return callHandler.run(target, request, context);
        }
 
        /**
@@ -3508,8 +3474,7 @@ public class RestClient extends BeanContext implements 
HttpClient, Closeable, Re
         *
         * <ul class='notes'>
         *      <li>This method gets passed on directly to the underlying 
{@link HttpClient} class.
-        *      <li>The {@link 
#execute(HttpHost,HttpEntityEnclosingRequestBase,HttpContext)} and
-        *              {@link #execute(HttpHost,HttpRequestBase,HttpContext)} 
methods have been provided as wrappers around this method.
+        *      <li>The {@link #run(HttpHost,HttpRequest,HttpContext)} method 
has been provided as a wrapper around this method.
         *              Subclasses can override these methods for handling 
requests with and without bodies separately.
         *      <li>The {@link RestCallHandler} interface can also be 
implemented to intercept this method.
         * </ul>
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
index 6304a21..d184eb4 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestClientBuilder.java
@@ -65,7 +65,6 @@ import org.apache.juneau.parser.*;
 import org.apache.juneau.parser.ParseException;
 import org.apache.juneau.plaintext.*;
 import org.apache.juneau.reflect.*;
-import org.apache.juneau.rest.client2.ext.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.svl.*;
 import org.apache.juneau.uon.*;
@@ -714,12 +713,6 @@ public class RestClientBuilder extends BeanContextBuilder {
         * Subclasses can override this method to provide their own client 
builder.
         * The builder can also be specified using the {@link 
#httpClientBuilder(HttpClientBuilder)} method.
         *
-        * <p>
-        * The predefined method returns an {@link HttpClientBuilder} with the 
following settings:
-        * <ul>
-        *      <li>{@link AllRedirectsStrategy All redirect strategy}.
-        * </ul>
-        *
         * <h5 class='section'>Example:</h5>
         * <p class='bcode w800'>
         *      <jc>// A RestClientBuilder that provides it's own customized 
HttpClientBuilder.</jc>
@@ -737,7 +730,7 @@ public class RestClientBuilder extends BeanContextBuilder {
         * @return The HTTP client builder to use to create the HTTP client.
         */
        protected HttpClientBuilder createHttpClientBuilder() {
-               return HttpClientBuilder.create().setRedirectStrategy(new 
AllRedirectsStrategy());
+               return HttpClientBuilder.create();
        }
 
        /**
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
index 7c71a47..5bb2e39 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestRequest.java
@@ -2867,10 +2867,7 @@ public class RestRequest extends BeanSession implements 
HttpUriRequest, Configur
                        }
 
                        try {
-                               if (request2 != null)
-                                       response = client.createResponse(this, 
client.execute(target, request2, context), parser);
-                               else
-                                       response = client.createResponse(this, 
client.execute(target, this.request, context), parser);
+                               response = client.createResponse(this, 
client.run(target, request2 != null ? request2 : this.request, context), 
parser);
                        } catch (Exception e) {
                                throw e;
                        }

Reply via email to