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 e68e863  RestClient tests
e68e863 is described below

commit e68e863d0c3e025354afe6826e88f58a4cb5d0ed
Author: JamesBognar <[email protected]>
AuthorDate: Wed Jul 1 19:55:43 2020 -0400

    RestClient tests
---
 .../org/apache/juneau/http/header/BasicHeader.java |  21 +-
 .../juneau/http/header/BasicIntegerHeader.java     |   2 +-
 .../apache/juneau/http/header/BasicLongHeader.java |   2 +-
 .../juneau/http/header/BasicStringHeader.java      |   2 +-
 .../client2/Remote_FormDataAnnotation_Test.java    |   2 +
 .../rest/client2/Remote_HeaderAnnotation_Test.java |   2 +
 .../rest/client2/Remote_PathAnnotation_Test.java   |   2 +
 .../rest/client2/Remote_QueryAnnotation_Test.java  |   2 +
 .../rest/client2/RestClient_BasicCalls_Test.java   |   9 +
 .../client2/RestClient_Response_Body_Test.java     |  70 ++++++
 .../client2/RestClient_Response_Headers_Test.java  | 234 +++++++++++++++++++++
 .../juneau/rest/client2/RestClient_Test.java       |  23 +-
 .../org/apache/juneau/rest/client/RestClient.java  |   8 +-
 .../juneau/rest/client/remote/RemoteMeta.java      |  14 --
 .../juneau/rest/client/remote/RemoteMethodArg.java |  21 +-
 .../rest/client/remote/RemoteMethodBeanArg.java    |  16 +-
 .../rest/client/remote/RemoteMethodBeanReturn.java |  55 -----
 .../rest/client/remote/RemoteMethodMeta.java       |   2 +-
 .../juneau/rest/client2/RestCallException.java     |  21 --
 .../apache/juneau/rest/client2/RestResponse.java   |   2 +-
 .../juneau/rest/client2/RestResponseHeader.java    |  19 +-
 21 files changed, 374 insertions(+), 155 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicHeader.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicHeader.java
index 4649653..b93158b 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicHeader.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicHeader.java
@@ -21,6 +21,7 @@ import org.apache.http.*;
 import org.apache.http.message.*;
 import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
+import org.apache.juneau.assertions.*;
 import org.apache.juneau.http.*;
 import org.apache.juneau.http.header.BasicHeader;
 import org.apache.juneau.internal.*;
@@ -181,18 +182,26 @@ public class BasicHeader implements Header, Cloneable, 
Serializable {
         * @param compare The value to compare against.
         * @return <jk>true</jk> if the specified value is the same.
         */
-       public boolean eqIC(String compare) {
+       protected boolean eqIC(String compare) {
                return getValue().equalsIgnoreCase(compare);
        }
 
        /**
-        * Returns <jk>true</jk> if the specified value is the same using 
{@link String#equals(Object)}.
+        * Provides an object for performing assertions against the name of 
this header.
         *
-        * @param compare The value to compare against.
-        * @return <jk>true</jk> if the specified value is the same.
+        * @return An object for performing assertions against the name of this 
header.
+        */
+       public FluentStringAssertion<BasicHeader> assertName() {
+               return new FluentStringAssertion<>(getName(), this);
+       }
+
+       /**
+        * Provides an object for performing assertions against the value of 
this header.
+        *
+        * @return An object for performing assertions against the value of 
this header.
         */
-       public boolean eq(String compare) {
-               return getValue().equals(compare);
+       public FluentStringAssertion<BasicHeader> assertValue() {
+               return new FluentStringAssertion<>(getValue(), this);
        }
 
        /**
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
index 7bfab3e..fc730aa 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicIntegerHeader.java
@@ -132,7 +132,7 @@ public class BasicIntegerHeader extends BasicHeader {
         * @return A new fluent assertion object.
         * @throws AssertionError If assertion failed.
         */
-       public FluentIntegerAssertion<BasicIntegerHeader> assertThat() {
+       public FluentIntegerAssertion<BasicIntegerHeader> assertInteger() {
                return new FluentIntegerAssertion<>(asInt(), this);
        }
 
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
index d548d3a..586d1b8 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicLongHeader.java
@@ -132,7 +132,7 @@ public class BasicLongHeader extends BasicHeader {
         * @return A new fluent assertion object.
         * @throws AssertionError If assertion failed.
         */
-       public FluentLongAssertion<BasicLongHeader> assertThat() {
+       public FluentLongAssertion<BasicLongHeader> assertLong() {
                return new FluentLongAssertion<>(getParsedValue(), this);
        }
 
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicStringHeader.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicStringHeader.java
index 6ff4855..29f4fd6 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicStringHeader.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/header/BasicStringHeader.java
@@ -109,7 +109,7 @@ public class BasicStringHeader extends BasicHeader {
         * @return A new fluent assertion object.
         * @throws AssertionError If assertion failed.
         */
-       public FluentStringAssertion<BasicStringHeader> assertThat() {
+       public FluentStringAssertion<BasicStringHeader> assertString() {
                return new FluentStringAssertion<>(getValue(), this);
        }
 
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_FormDataAnnotation_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_FormDataAnnotation_Test.java
index cefd38b..93e227c 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_FormDataAnnotation_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_FormDataAnnotation_Test.java
@@ -101,6 +101,7 @@ public class Remote_FormDataAnnotation_Test {
                @RemoteMethod(path="a") String postX23(@FormData InputStream b);
                @RemoteMethod(path="a") String postX24(@FormData Reader b);
                @RemoteMethod(path="a") String postX25(@FormData Bean2 b);
+               @RemoteMethod(path="a") String postX26(@FormData 
List<NameValuePair> b);
        }
 
        @Test
@@ -132,6 +133,7 @@ public class Remote_FormDataAnnotation_Test {
                assertEquals("{foo:'bar'}",x.postX23(new 
ByteArrayInputStream("foo=bar".getBytes())));
                assertEquals("{foo:'bar'}",x.postX24(new 
StringReader("foo=bar")));
                assertEquals("{f:'1'}",x.postX25(Bean2.create()));
+               
assertEquals("{foo:'bar'}",x.postX26(AList.of(pair("foo","bar"))));
        }
 
        
//-----------------------------------------------------------------------------------------------------------------
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_HeaderAnnotation_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_HeaderAnnotation_Test.java
index 7bc8337..412348c 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_HeaderAnnotation_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_HeaderAnnotation_Test.java
@@ -82,6 +82,7 @@ public class Remote_HeaderAnnotation_Test {
                @RemoteMethod(path="a") String getX17(@Header 
org.apache.http.Header b);
                @RemoteMethod(path="a") String getX18(@Header 
org.apache.http.Header[] b);
                @RemoteMethod(path="a") String getX19(@Header String b);
+               @RemoteMethod(path="a") String getX20(@Header 
List<org.apache.http.Header> b);
        }
 
        @Test
@@ -107,6 +108,7 @@ public class Remote_HeaderAnnotation_Test {
                assertEquals("{foo:'bar'}",x.getX18(new 
org.apache.http.Header[]{header("foo","bar")}));
                assertThrown(()->x.getX19("Foo")).contains("Invalid value 
type");
                assertEquals("{}",x.getX19(null));
+               
assertEquals("{foo:'bar'}",x.getX20(AList.of(header("foo","bar"))));
        }
 
        
//-----------------------------------------------------------------------------------------------------------------
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_PathAnnotation_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_PathAnnotation_Test.java
index f3757b6..857a806 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_PathAnnotation_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_PathAnnotation_Test.java
@@ -82,6 +82,7 @@ public class Remote_PathAnnotation_Test {
                @RemoteMethod(path="a/{x}") String getX19(@Path NameValuePair 
b);
                @RemoteMethod(path="a/{x}") String getX20(@Path NameValuePair[] 
b);
                @RemoteMethod(path="a/{x}") String getX21(@Path String b);
+               @RemoteMethod(path="a/{x}") String getX22(@Path 
List<NameValuePair> b);
        }
 
        @Test
@@ -109,6 +110,7 @@ public class Remote_PathAnnotation_Test {
                assertEquals("bar",x.getX20(new 
NameValuePair[]{pair("x","bar")}));
                assertEquals("{x}",x.getX20(null));
                assertThrown(()->x.getX21("foo")).contains("Invalid value type 
for path arg 'null': java.lang.String");
+               assertEquals("bar",x.getX22(AList.of(pair("x","bar"))));
        }
 
        
//-----------------------------------------------------------------------------------------------------------------
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_QueryAnnotation_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_QueryAnnotation_Test.java
index aac3729..204aaa3 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_QueryAnnotation_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/Remote_QueryAnnotation_Test.java
@@ -88,6 +88,7 @@ public class Remote_QueryAnnotation_Test {
                @RemoteMethod(path="a") String getX22(@Query NameValuePair[] b);
                @RemoteMethod(path="a") String getX23(@Query 
BasicNameValuePair[] b);
                @RemoteMethod(path="a") String getX24(@Query String b);
+               @RemoteMethod(path="a") String getX25(@Query 
List<NameValuePair> b);
        }
 
        @Test
@@ -118,6 +119,7 @@ public class Remote_QueryAnnotation_Test {
                
assertEquals("{foo:'bar'}",x.getX23(pairs("foo","bar").toArray(new 
BasicNameValuePair[0])));
                assertEquals("{foo:'bar'}",x.getX24("foo=bar"));
                assertEquals("{}",x.getX24(null));
+               
assertEquals("{foo:'bar'}",x.getX25(AList.of(pair("foo","bar"))));
        }
 
        
//-----------------------------------------------------------------------------------------------------------------
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_BasicCalls_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_BasicCalls_Test.java
index 1badc57..bd6d582 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_BasicCalls_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_BasicCalls_Test.java
@@ -331,6 +331,15 @@ public class RestClient_BasicCalls_Test {
                        
client().header("Check","Content-Type").accept("application/json+simple").build().formPost("/checkHeader",bodies.get(i)).run().assertBody().msg("Body
 {0} failed",i).matchesSimple("['application/x-www-form-urlencoded*']");
                        
client().build().formPost("/bean",bodies.get(i)).accept("application/json+simple").run().assertBody().msg("Body
 {0} failed","#"+i).is("{f:1}");
                }
+
+               StreamResourceBuilder sr = new StreamResourceBuilder() {
+                       @Override
+                       public StreamResource build() throws IOException {
+                               throw new IOException("Foo");
+                       }
+               };
+
+               
assertThrown(()->client().build().formPost("/bean",sr)).contains("Foo");
        }
 
        @Test
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
new file mode 100644
index 0000000..85c6c1c
--- /dev/null
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Body_Test.java
@@ -0,0 +1,70 @@
+// 
***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.io.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.mock2.*;
+import org.apache.juneau.xml.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class RestClient_Response_Body_Test {
+
+       public static class ABean {
+               public int f;
+               static ABean get() {
+                       ABean x = new ABean();
+                       x.f = 1;
+                       return x;
+               }
+       }
+
+       private static ABean bean = ABean.get();
+
+       @Rest
+       public static class A extends BasicRest {
+               @RestMethod
+               public InputStream postEcho(InputStream is) {
+                       return is;
+               }
+       }
+
+       @Test
+       public void a01_basic() throws Exception {
+               
client().build().post("/echo",bean).run().assertBody(ABean.class).json().is("{f:1}");
+       }
+
+       @Test
+       public void a02_overrideParser() throws Exception {
+               RestClient x = client().build();
+               ABean b = 
x.post("/echo",bean).run().getBody().parser(JsonParser.DEFAULT).as(ABean.class);
+               assertObject(b).json().is("{f:1}");
+               
assertThrown(()->x.post("/echo",bean).run().getBody().parser(XmlParser.DEFAULT).as(ABean.class)).contains("ParseError
 at [row,col]:[1,1]");
+               
assertThrown(()->x.post("/echo",bean).run().getBody().parser(XmlParser.DEFAULT).assertObject(ABean.class)).contains("ParseError
 at [row,col]:[1,1]");
+       }
+
+       
//------------------------------------------------------------------------------------------------------------------
+       // Helper methods.
+       
//------------------------------------------------------------------------------------------------------------------
+
+       private static RestClientBuilder client() {
+               return MockRestClient.create(A.class).simpleJson();
+       }
+}
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Headers_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Headers_Test.java
new file mode 100644
index 0000000..3c6c2f6
--- /dev/null
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Response_Headers_Test.java
@@ -0,0 +1,234 @@
+// 
***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.assertions.Assertions.*;
+import static org.junit.Assert.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.util.*;
+import java.util.regex.*;
+
+import org.apache.http.*;
+import org.apache.juneau.*;
+import org.apache.juneau.http.header.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.mock2.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class RestClient_Response_Headers_Test {
+
+       @Rest
+       public static class A extends BasicRest {
+               @RestMethod
+               public String getEcho(org.apache.juneau.rest.RestRequest req, 
org.apache.juneau.rest.RestResponse res) {
+                       String c = req.getHeader("Check");
+                       String[] h = req.getHeaders().get(c);
+                       if (h != null)
+                               for (String hh : h)
+                                       res.addHeader(c, hh);
+                       return "ok";
+               }
+       }
+
+       private static final Calendar CALENDAR = new 
GregorianCalendar(TimeZone.getTimeZone("Z"));
+       static {
+               CALENDAR.set(2000,11,31,12,34,56);
+       }
+
+       @Test
+       public void a01_exists() throws Exception {
+               
assertFalse(checkFooClient().build().get("/echo").run().getHeader("Foo").exists());
+               
assertTrue(checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").exists());
+       }
+
+       public static class A2 extends BasicHeader {
+               private static final long serialVersionUID = 1L;
+
+               private A2(String name, Object value) {
+                       super(name, value);  // Never called.
+               }
+       }
+
+       @Test
+       public void a02_asHeader() throws Exception {
+               Header h = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asHeader(BasicStringHeader.class).assertName().is("Foo").assertValue().is("bar");
+               assertTrue(h instanceof BasicStringHeader);
+
+               h = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asHeader(ETag.class).assertName().is("ETag").assertValue().is("bar");
+               assertTrue(h instanceof ETag);
+
+               
assertThrown(()->checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asHeader(Age.class)).contains("NumberFormatException");
+               
assertThrown(()->checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asHeader(A2.class)).contains("Could
 not determine a method to construct type");
+
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asCsvArrayHeader().assertName().is("Foo").assertValue().is("bar");
+               
checkFooClient().build().get("/echo").header("Foo","*").run().getHeader("Foo").asEntityValidatorArrayHeader().assertName().is("Foo").assertValue().is("*");
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asRangeArrayHeader().assertName().is("Foo").assertValue().is("bar");
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asStringHeader().assertName().is("Foo").assertValue().is("bar");
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asUriHeader().assertName().is("Foo").assertValue().is("bar");
+       }
+
+       @Test
+       public void a03_asString() throws Exception {
+               String s = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asString();
+               assertEquals("bar", s);
+
+               Mutable<String> m = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asString(m);
+               assertEquals("bar", m.get());
+
+               Optional<String> o = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asOptionalString();
+               assertEquals("bar", o.get());
+               o = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Bar").asOptionalString();
+               assertFalse(o.isPresent());
+
+               s = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asStringOrElse("baz");
+               assertEquals("bar", s);
+               s = 
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Bar").asStringOrElse("baz");
+               assertEquals("baz", s);
+
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").asStringOrElse(m,"baz");
+               assertEquals("bar", m.get());
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Bar").asStringOrElse(m,"baz");
+               assertEquals("baz", m.get());
+       }
+
+       @Test
+       public void a04_asType() throws Exception {
+               Integer i = 
checkFooClient().build().get("/echo").header("Foo","123").run().getHeader("Foo").as(Integer.class);
+               assertEquals(123, i.intValue());
+
+               Mutable<Integer> m1 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","123").run().getHeader("Foo").as(m1,Integer.class);
+               assertEquals(123, m1.get().intValue());
+
+               List<Integer> l = 
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Foo").as(LinkedList.class,Integer.class);
+               assertObject(l).json().is("[1,2]");
+
+               Mutable<Integer> m2 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Foo").as(m2,LinkedList.class,Integer.class);
+               assertObject(m2.get()).json().is("[1,2]");
+
+               ClassMeta<LinkedList<Integer>> cm1 = 
BeanContext.DEFAULT.getClassMeta(LinkedList.class, Integer.class);
+               ClassMeta<Integer> cm2 = 
BeanContext.DEFAULT.getClassMeta(Integer.class);
+
+               l = 
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Foo").as(cm1);
+               assertObject(l).json().is("[1,2]");
+
+               Mutable<LinkedList<Integer>> m3 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Foo").as(m3,cm1);
+               assertObject(m3.get()).json().is("[1,2]");
+
+               
assertThrown(()->checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Foo").as(m2,cm1)).contains("Invalid
 number");
+
+               Optional<List<Integer>> o1 = 
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Foo").asOptional(LinkedList.class,Integer.class);
+               assertObject(o1.get()).json().is("[1,2]");
+               o1 = 
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Bar").asOptional(LinkedList.class,Integer.class);
+               assertFalse(o1.isPresent());
+
+               Mutable<Optional<List<Integer>>> m4 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Foo").asOptional(m4,LinkedList.class,Integer.class);
+               assertObject(m4.get().get()).json().is("[1,2]");
+               
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Bar").asOptional(m4,LinkedList.class,Integer.class);
+               assertFalse(m4.get().isPresent());
+
+               Optional<Integer> o2 = 
checkFooClient().build().get("/echo").header("Foo","1").run().getHeader("Foo").asOptional(Integer.class);
+               assertEquals(1, o2.get().intValue());
+               o2 = 
checkFooClient().build().get("/echo").header("Foo","1").run().getHeader("Bar").asOptional(Integer.class);
+               assertFalse(o2.isPresent());
+
+               o2 = 
checkFooClient().build().get("/echo").header("Foo","1").run().getHeader("Foo").asOptional(cm2);
+               assertEquals(1, o2.get().intValue());
+               o2 = 
checkFooClient().build().get("/echo").header("Foo","1").run().getHeader("Bar").asOptional(cm2);
+               assertFalse(o2.isPresent());
+
+               Mutable<Optional<Integer>> m5 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","1").run().getHeader("Foo").asOptional(m5,Integer.class);
+               assertEquals(1, m5.get().get().intValue());
+               
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Bar").asOptional(m5,Integer.class);
+               assertFalse(m5.get().isPresent());
+
+               m5 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","1").run().getHeader("Foo").asOptional(m5,cm2);
+               assertEquals(1, m5.get().get().intValue());
+               
checkFooClient().build().get("/echo").header("Foo","1,2").run().getHeader("Bar").asOptional(m5,cm2);
+               assertFalse(m5.get().isPresent());
+
+               
assertTrue(checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Foo").asMatcher("foo").matches());
+               
assertFalse(checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Bar").asMatcher("foo").matches());
+               
assertTrue(checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Foo").asMatcher("FOO",Pattern.CASE_INSENSITIVE).matches());
+               
assertFalse(checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Bar").asMatcher("FOO",Pattern.CASE_INSENSITIVE).matches());
+
+               Mutable<Matcher> m6 = Mutable.create();
+               
checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Foo").asMatcher(m6,"foo");
+               assertTrue(m6.get().matches());
+               
checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Bar").asMatcher(m6,"foo");
+               assertFalse(m6.get().matches());
+               
checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Foo").asMatcher(m6,"FOO",Pattern.CASE_INSENSITIVE);
+               assertTrue(m6.get().matches());
+               
checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Bar").asMatcher(m6,"FOO",Pattern.CASE_INSENSITIVE);
+               assertFalse(m6.get().matches());
+               
checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Foo").asMatcher(m6,Pattern.compile("FOO",Pattern.CASE_INSENSITIVE));
+               assertTrue(m6.get().matches());
+               
checkFooClient().build().get("/echo").header("Foo","foo").run().getHeader("Bar").asMatcher(m6,Pattern.compile("FOO",Pattern.CASE_INSENSITIVE));
+               assertFalse(m6.get().matches());
+       }
+
+       @Test
+       public void a05_toResponse() throws Exception {
+               RestResponse r = 
checkFooClient().build().get("/echo").header("Foo","123").run();
+               assertTrue(r == r.getHeader("Foo").toResponse());
+       }
+
+       
//------------------------------------------------------------------------------------------------------------------
+       // Assertions.
+       
//------------------------------------------------------------------------------------------------------------------
+
+       @Test
+       public void b01_assertions() throws Exception {
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Foo").assertString().is("bar");
+               
checkFooClient().build().get("/echo").header("Foo","bar").run().getHeader("Bar").assertString().doesNotExist();
+               
checkFooClient().build().get("/echo").header("Foo","123").run().getHeader("Foo").assertInteger().is(123);
+               
checkFooClient().build().get("/echo").header("Foo","123").run().getHeader("Bar").assertInteger().doesNotExist();
+               
checkFooClient().build().get("/echo").header("Foo","123").run().getHeader("Foo").assertLong().is(123l);
+               
checkFooClient().build().get("/echo").header("Foo","123").run().getHeader("Bar").assertLong().doesNotExist();
+               
checkFooClient().build().get("/echo").header(BasicDateHeader.of("Foo",CALENDAR)).run().getHeader("Foo").assertDate().exists();
+               
checkFooClient().build().get("/echo").header(BasicDateHeader.of("Foo",CALENDAR)).run().getHeader("Bar").assertDate().doesNotExist();
+       }
+
+       
//------------------------------------------------------------------------------------------------------------------
+       // Header methods.
+       
//------------------------------------------------------------------------------------------------------------------
+
+       @Test
+       public void c01_getElements() throws Exception {
+               HeaderElement[] e = 
checkFooClient().build().get("/echo").header("Foo","bar=baz;qux=quux").run().getHeader("Foo").getElements();
+               assertEquals("bar", e[0].getName());
+               assertEquals("baz", e[0].getValue());
+               assertEquals("quux", e[0].getParameterByName("qux").getValue());
+
+               e = 
checkFooClient().build().get("/echo").header("Foo","bar=baz;qux=quux").run().getHeader("Bar").getElements();
+               assertEquals(0, e.length);
+       }
+
+       
//------------------------------------------------------------------------------------------------------------------
+       // Helper methods.
+       
//------------------------------------------------------------------------------------------------------------------
+
+       private static RestClientBuilder checkFooClient() {
+               return 
MockRestClient.create(A.class).simpleJson().header("Check","Foo");
+       }
+}
diff --git 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Test.java
 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Test.java
index 6f77be7..1f2018a 100644
--- 
a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Test.java
+++ 
b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/RestClient_Test.java
@@ -24,10 +24,12 @@ import org.apache.http.*;
 import org.apache.http.HttpException;
 import org.apache.http.HttpResponse;
 import org.apache.http.auth.*;
+import org.apache.http.client.*;
 import org.apache.http.client.config.*;
 import org.apache.http.client.methods.*;
 import org.apache.http.concurrent.*;
 import org.apache.http.impl.client.*;
+import org.apache.http.message.*;
 import org.apache.http.params.*;
 import org.apache.http.protocol.*;
 import org.apache.juneau.*;
@@ -36,6 +38,7 @@ import org.apache.juneau.http.*;
 import org.apache.juneau.http.exception.*;
 import org.apache.juneau.http.header.*;
 import org.apache.juneau.internal.*;
+import org.apache.juneau.parser.*;
 import org.apache.juneau.reflect.*;
 import org.apache.juneau.rest.*;
 import org.apache.juneau.rest.annotation.*;
@@ -127,25 +130,35 @@ public class RestClient_Test {
        }
 
        
//------------------------------------------------------------------------------------------------------------------
-       // Logging
+       // Overridden methods
        
//------------------------------------------------------------------------------------------------------------------
 
        public static class B4 extends RestClient {
-               private static boolean METHOD_CALLED;
+               private static boolean CREATE_REQUEST_CALLED, 
CREATE_RESPONSE_CALLED;
                public B4(PropertyStore ps) {
                        super(ps);
                }
                @Override
                protected RestRequest createRequest(java.net.URI uri, String 
method, boolean hasBody) throws RestCallException {
-                       METHOD_CALLED = true;
+                       CREATE_REQUEST_CALLED = true;
                        return super.createRequest(uri, method, hasBody);
                }
+               @Override
+               protected RestResponse createResponse(RestRequest req, 
HttpResponse httpResponse, Parser parser) throws RestCallException {
+                       CREATE_RESPONSE_CALLED = true;
+                       return super.createResponse(req, httpResponse, parser);
+               }
+               @Override /* HttpClient */
+               public HttpResponse execute(HttpUriRequest request, HttpContext 
context) throws IOException, ClientProtocolException {
+                       return new BasicHttpResponse(new 
ProtocolVersion("http",1,1),200,null);
+               }
        }
 
        @Test
        public void b04_restClient_overrideCreateRequest() throws Exception {
-               RestClient.create().simpleJson().build(B4.class).get("foo");
-               assertTrue(B4.METHOD_CALLED);
+               
RestClient.create().simpleJson().build(B4.class).get("foo").run();
+               assertTrue(B4.CREATE_REQUEST_CALLED);
+               assertTrue(B4.CREATE_RESPONSE_CALLED);
        }
 
        
//------------------------------------------------------------------------------------------------------------------
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 4b1ba6e..507554f 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -1221,16 +1221,16 @@ public class RestClient extends BeanContext implements 
Closeable {
                                                        
rc.serializer(serializer).parser(parser);
 
                                                        for (RemoteMethodArg a 
: rmm.getPathArgs())
-                                                               
rc.path(a.getName(), args[a.getIndex()], a.getSerializer(s), a.getSchema());
+                                                               
rc.path(a.getName(), args[a.getIndex()], s, a.getSchema());
 
                                                        for (RemoteMethodArg a 
: rmm.getQueryArgs())
-                                                               
rc.query(a.getName(), args[a.getIndex()], a.isSkipIfEmpty(), 
a.getSerializer(s), a.getSchema());
+                                                               
rc.query(a.getName(), args[a.getIndex()], a.isSkipIfEmpty(), s, a.getSchema());
 
                                                        for (RemoteMethodArg a 
: rmm.getFormDataArgs())
-                                                               
rc.formData(a.getName(), args[a.getIndex()], a.isSkipIfEmpty(), 
a.getSerializer(s), a.getSchema());
+                                                               
rc.formData(a.getName(), args[a.getIndex()], a.isSkipIfEmpty(), s, 
a.getSchema());
 
                                                        for (RemoteMethodArg a 
: rmm.getHeaderArgs())
-                                                               
rc.header(a.getName(), args[a.getIndex()], a.isSkipIfEmpty(), 
a.getSerializer(s), a.getSchema());
+                                                               
rc.header(a.getName(), args[a.getIndex()], a.isSkipIfEmpty(), s, a.getSchema());
 
                                                        RemoteMethodArg ba = 
rmm.getBodyArg();
                                                        if (ba != null)
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
index d555cfb..d7d1cd8 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMeta.java
@@ -37,7 +37,6 @@ import org.apache.juneau.reflect.*;
 public class RemoteMeta {
 
        private final Map<Method,RemoteMethodMeta> methods;
-       private final String path;
        private final HeaderSupplier headerSupplier = HeaderSupplier.create();
 
        /**
@@ -78,7 +77,6 @@ public class RemoteMeta {
                                methods.put(m.inner(), new 
RemoteMethodMeta(path, m.inner(), false, "GET"));
 
                this.methods = methods.unmodifiable();
-               this.path = path;
        }
 
        /**
@@ -92,18 +90,6 @@ public class RemoteMeta {
        }
 
        /**
-        * Returns the HTTP path of this interface.
-        *
-        * @return
-        *      The HTTP path of this interface.
-        *      <br>Never <jk>null</jk>.
-        *      <br>Never has leading or trailing slashes.
-        */
-       public String getPath() {
-               return path;
-       }
-
-       /**
         * Returns the headers to set on all requests.
         *
         * @return The headers to set on all requests.
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
index ba91189..c279d0d 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
@@ -33,21 +33,15 @@ public final class RemoteMethodArg {
        private final HttpPartType partType;
        private final HttpPartSerializer serializer;
        private final HttpPartSchema schema;
-       private final String name;
-       private final boolean skipIfEmpty;
 
        RemoteMethodArg(int index, HttpPartType partType, HttpPartSchema 
schema) {
                this.index = index;
                this.partType = partType;
                this.serializer = createSerializer(partType, schema);
                this.schema = schema;
-               this.name = schema == null ? null : schema.getName();
-               this.skipIfEmpty = schema == null ? false : 
schema.isSkipIfEmpty();
        }
 
        private static HttpPartSerializer createSerializer(HttpPartType 
partType, HttpPartSchema schema) {
-               if (schema == null)
-                       return null;
                return castOrCreate(HttpPartSerializer.class, 
schema.getSerializer());
        }
 
@@ -57,7 +51,7 @@ public final class RemoteMethodArg {
         * @return The name of the HTTP part.
         */
        public String getName() {
-               return name;
+               return schema.getName();
        }
 
        /**
@@ -66,7 +60,7 @@ public final class RemoteMethodArg {
         * @return <jk>true</jk> if the <c>skipIfEmpty</c> flag was found in 
the schema.
         */
        public boolean isSkipIfEmpty() {
-               return skipIfEmpty;
+               return schema.isSkipIfEmpty();
        }
 
        /**
@@ -91,17 +85,6 @@ public final class RemoteMethodArg {
         * Returns the HTTP part serializer to use for serializing this part.
         *
         * @param _default The default serializer to use if the serializer was 
not defined via annotations.
-        * @return The HTTP part serializer, or <jk>null</jk> if not specified.
-        */
-       @Deprecated
-       public HttpPartSerializer getSerializer(HttpPartSerializer _default) {
-               return serializer == null ? _default : serializer;
-       }
-
-       /**
-        * Returns the HTTP part serializer to use for serializing this part.
-        *
-        * @param _default The default serializer to use if the serializer was 
not defined via annotations.
         * @return The HTTP part serializer, or the default if not specified.
         */
        public HttpPartSerializerSession 
getSerializer(HttpPartSerializerSession _default) {
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
index 2d64965..12b3578 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
@@ -12,10 +12,7 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.rest.client.remote;
 
-import static org.apache.juneau.internal.ClassUtils.*;
-
 import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.httppart.*;
 import org.apache.juneau.httppart.bean.*;
 
 /**
@@ -29,11 +26,9 @@ public final class RemoteMethodBeanArg {
 
        private final int index;
        private final RequestBeanMeta meta;
-       private final HttpPartSerializer serializer;
 
-       RemoteMethodBeanArg(int index, Class<? extends HttpPartSerializer> 
serializer, RequestBeanMeta meta) {
+       RemoteMethodBeanArg(int index, RequestBeanMeta meta) {
                this.index = index;
-               this.serializer = castOrCreate(HttpPartSerializer.class, 
serializer);
                this.meta = meta;
        }
 
@@ -47,15 +42,6 @@ public final class RemoteMethodBeanArg {
        }
 
        /**
-        * Returns the serializer to use for serializing parts on the request 
bean.
-        *
-        * @return The serializer to use for serializing parts on the request 
bean, or <jk>null</jk> if not defined.
-        */
-       public HttpPartSerializer getSerializer() {
-               return serializer;
-       }
-
-       /**
         * Returns metadata on the request bean.
         *
         * @return Metadata about the bean.
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanReturn.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanReturn.java
deleted file mode 100644
index cc93206..0000000
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanReturn.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// 
***************************************************************************************************************************
-// * 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.client.remote;
-
-import static org.apache.juneau.internal.ClassUtils.*;
-
-import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.httppart.bean.*;
-
-/**
- * Represents the metadata about an {@link Response}-annotated return type on 
a method on a REST proxy class.
- *
- * <ul class='seealso'>
- *     <li class='link'>{@doc juneau-rest-client.RestProxies}
- * </ul>
- */
-public final class RemoteMethodBeanReturn {
-
-       private final ResponseBeanMeta meta;
-       private final HttpPartParser parser;
-
-       RemoteMethodBeanReturn(Class<? extends HttpPartParser> parser, 
ResponseBeanMeta meta) {
-               this.parser = castOrCreate(HttpPartParser.class, parser);
-               this.meta = meta;
-       }
-
-       /**
-        * Returns the parser to use for parsing parts on the response bean.
-        *
-        * @return The parser to use for parsing parts on the response bean, or 
<jk>null</jk> if not defined.
-        */
-       public HttpPartParser getParser() {
-               return parser;
-       }
-
-       /**
-        * Returns metadata on the response bean.
-        *
-        * @return Metadata about the bean.
-        */
-       public ResponseBeanMeta getMeta() {
-               return meta;
-       }
-}
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
index 9b17cf3..57b440a 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
@@ -133,7 +133,7 @@ public class RemoteMethodMeta {
                                }
                                RequestBeanMeta rmba = 
RequestBeanMeta.create(mpi, PropertyStore.DEFAULT);
                                if (rmba != null) {
-                                       requestArgs.add(new 
RemoteMethodBeanArg(mpi.getIndex(), null, rmba));
+                                       requestArgs.add(new 
RemoteMethodBeanArg(mpi.getIndex(), rmba));
                                }
                        }
                }
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallException.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallException.java
index 79a454f..495a558 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallException.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestCallException.java
@@ -12,8 +12,6 @@
 // 
***************************************************************************************************************************
 package org.apache.juneau.rest.client2;
 
-import static org.apache.juneau.internal.IOUtils.*;
-
 import java.io.*;
 import java.net.*;
 import java.text.*;
@@ -21,7 +19,6 @@ import java.util.regex.*;
 
 import org.apache.http.*;
 import org.apache.http.client.*;
-import org.apache.http.util.*;
 import org.apache.juneau.internal.*;
 
 /**
@@ -91,16 +88,6 @@ public final class RestCallException extends HttpException {
        }
 
        /**
-        * Create an exception with a simple message and the status code and 
body of the specified response.
-        *
-        * @param msg The exception message.
-        * @param response The HTTP response object.
-        */
-       public RestCallException(String msg, HttpResponse response) {
-               super(clean(format("{0}\n{1}\nstatus=''{2}''\nResponse: \n{3}", 
msg, response.getStatusLine().getStatusCode(), readEntity(response))));
-       }
-
-       /**
         * Constructor.
         *
         * @param responseCode The response code.
@@ -262,12 +249,4 @@ public final class RestCallException extends HttpException 
{
 
                return sb.toString();
        }
-
-       private static String readEntity(HttpResponse response) {
-               try {
-                       return EntityUtils.toString(response.getEntity(), UTF8);
-               } catch (Exception e) {
-                       throw new RuntimeException(e);
-               }
-       }
 }
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponse.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponse.java
index cf2ca91..46ac27a 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponse.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponse.java
@@ -341,7 +341,7 @@ public class RestResponse implements HttpResponse {
         * @throws RestCallException If REST call failed.
         */
        public FluentIntegerAssertion<RestResponse> assertIntHeader(String 
name) throws RestCallException {
-               return getHeader(name).assertInt();
+               return getHeader(name).assertInteger();
        }
 
        /**
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseHeader.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseHeader.java
index e286ddb..5486d80 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseHeader.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseHeader.java
@@ -456,7 +456,7 @@ public class RestResponseHeader implements Header {
         * @throws RestCallException If a connection error occurred.
         */
        public Matcher asMatcher(Pattern pattern) throws RestCallException {
-               return pattern.matcher(asString());
+               return pattern.matcher(asStringOrElse(""));
        }
 
        /**
@@ -481,7 +481,7 @@ public class RestResponseHeader implements Header {
         * @throws RestCallException If a connection error occurred.
         */
        public RestResponse asMatcher(Mutable<Matcher> m, Pattern pattern) 
throws RestCallException {
-               m.set(pattern.matcher(asString()));
+               m.set(pattern.matcher(asStringOrElse("")));
                return response;
        }
 
@@ -530,7 +530,7 @@ public class RestResponseHeader implements Header {
         * @throws RestCallException If a connection error occurred.
         */
        public RestResponse asMatcher(Mutable<Matcher> m, String regex) throws 
RestCallException {
-               asMatcher(regex, 0);
+               m.set(asMatcher(regex, 0));
                return response;
        }
 
@@ -581,7 +581,7 @@ public class RestResponseHeader implements Header {
         * @throws RestCallException If a connection error occurred.
         */
        public RestResponse asMatcher(Mutable<Matcher> m, String regex, int 
flags) throws RestCallException {
-               asMatcher(Pattern.compile(regex, flags));
+               m.set(asMatcher(Pattern.compile(regex, flags)));
                return response;
        }
 
@@ -681,9 +681,8 @@ public class RestResponseHeader implements Header {
         * @return A new fluent assertion object.
         * @throws RestCallException If REST call failed.
         */
-       public FluentIntegerAssertion<RestResponse> assertInt() throws 
RestCallException {
-               BasicIntegerHeader h = asIntegerHeader();
-               return new FluentIntegerAssertion<>(h == null ? -1 : h.asInt(), 
response);
+       public FluentIntegerAssertion<RestResponse> assertInteger() throws 
RestCallException {
+               return new FluentIntegerAssertion<>(asIntegerHeader().asInt(), 
response);
        }
 
        /**
@@ -705,8 +704,7 @@ public class RestResponseHeader implements Header {
         * @throws RestCallException If REST call failed.
         */
        public FluentLongAssertion<RestResponse> assertLong() throws 
RestCallException {
-               BasicLongHeader h = asLongHeader();
-               return new FluentLongAssertion<>(h == null ? -1 : h.asLong(), 
response);
+               return new FluentLongAssertion<>(asLongHeader().asLong(), 
response);
        }
 
        /**
@@ -728,8 +726,7 @@ public class RestResponseHeader implements Header {
         * @throws RestCallException If REST call failed.
         */
        public FluentDateAssertion<RestResponse> assertDate() throws 
RestCallException {
-               BasicDateHeader h = asDateHeader();
-               return new FluentDateAssertion<>(h == null ? null : h.asDate(), 
response);
+               return new FluentDateAssertion<>(asDateHeader().asDate(), 
response);
        }
 
        
//------------------------------------------------------------------------------------------------------------------

Reply via email to