You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2020/05/27 16:16:01 UTC
[juneau] branch master updated: Move usage of MockRest to
MockRestClient.
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 0cc4a63 Move usage of MockRest to MockRestClient.
0cc4a63 is described below
commit 0cc4a63292f8a3c402f58372cbf77293ab124043
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Wed May 27 12:15:45 2020 -0400
Move usage of MockRest to MockRestClient.
---
.../juneau/html/HtmlStrippedDocSerializer.java | 7 +
.../org/apache/juneau/rest/client2/RestClient.java | 61 +++
.../juneau/rest/client2/RestClientBuilder.java | 4 +-
.../apache/juneau/rest/client2/RestRequest.java | 485 +++++++++++++++++++++
.../juneau/rest/annotation/HtmlDocAsideTest.java | 4 +-
.../rest/annotation/HtmlDocConfigAsideTest.java | 4 +-
.../rest/annotation/HtmlDocConfigFooterTest.java | 4 +-
.../rest/annotation/HtmlDocConfigHeaderTest.java | 4 +-
.../rest/annotation/HtmlDocConfigNavTest.java | 4 +-
.../rest/annotation/HtmlDocConfigNavlinksTest.java | 4 +-
.../rest/annotation/HtmlDocConfigScriptTest.java | 4 +-
.../rest/annotation/HtmlDocConfigStyleTest.java | 4 +-
.../juneau/rest/annotation/HtmlDocFooterTest.java | 4 +-
.../juneau/rest/annotation/HtmlDocHeaderTest.java | 4 +-
.../juneau/rest/annotation/HtmlDocNavTest.java | 4 +-
.../rest/annotation/HtmlDocNavlinksTest.java | 4 +-
.../juneau/rest/annotation/HtmlDocScriptTest.java | 4 +-
.../juneau/rest/annotation/HtmlDocStyleTest.java | 4 +-
.../annotation/ResponseHeaderAnnotationTest.java | 8 +-
.../annotation/ResponseStatusAnnotationTest.java | 6 +-
.../juneau/rest/annotation/RestMethodBpiTest.java | 14 +-
.../rest/annotation/RestMethodGuardsTest.java | 14 +-
.../rest/annotation/RestMethodMatchersTest.java | 2 +-
.../juneau/rest/annotation/RestMethodPathTest.java | 4 +-
.../rest/annotation/RestResourceLoggingTest.java | 48 +-
.../rest/annotation/RestResourceMessagesTest.java | 4 +-
.../rest/annotation/RestResourcePathTest.java | 2 +-
.../annotation/RestResourcePropertiesTest.java | 2 +-
.../annotation/RestResourceSerializersTest.java | 11 +-
.../annotation/RestResourceStaticFilesTest.java | 24 +-
.../juneau/rest/annotation/RestResourceTest.java | 106 ++---
31 files changed, 713 insertions(+), 145 deletions(-)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java
index 29146f6..f9c50b8 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java
@@ -36,6 +36,13 @@ import org.apache.juneau.serializer.*;
public class HtmlStrippedDocSerializer extends HtmlSerializer {
//-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
+ /** Default serializer, all default settings. */
+ public static final HtmlStrippedDocSerializer DEFAULT = new HtmlStrippedDocSerializer(PropertyStore.DEFAULT);
+
+ //-------------------------------------------------------------------------------------------------------------------
// Configurable properties
//-------------------------------------------------------------------------------------------------------------------
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 f7c509f..30dc7b8 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
@@ -1850,6 +1850,7 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
final Level logRequestsLevel;
private final boolean logToConsole;
private StackTraceElement[] closedStack;
+ private static final ConcurrentHashMap<Class<?>,Context> requestContexts = new ConcurrentHashMap<>();
// These are read directly by RestCall.
final SerializerGroup serializers;
@@ -2263,6 +2264,28 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
}
/**
+ * Perform a <c>HEAD</c> request against the specified URL.
+ *
+ * @param url
+ * The URL of the remote REST resource.
+ * Can be any of the following types:
+ * <ul class='spaced-list'>
+ * <li class='jc'>{@link URIBuilder}
+ * <li class='jc'>{@link URI}
+ * <li class='jc'>{@link URL}
+ * <li class='jc'>{@link String}
+ * <li class='jc'>{@link Object} - Converted to <c>String</c> using <c>toString()</c>
+ * </ul>
+ * @return
+ * A {@link RestRequest} object that can be further tailored before executing the request and getting the response
+ * as a parsed object.
+ * @throws RestCallException If any authentication errors occurred.
+ */
+ public RestRequest head(Object url) throws RestCallException {
+ return request("HEAD", url, false);
+ }
+
+ /**
* Perform a <c>POST</c> request with a content type of <c>application/x-www-form-urlencoded</c>
* against the specified URL.
*
@@ -2586,6 +2609,34 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
/**
* Perform a generic REST call.
*
+ * @param method The HTTP method.
+ * @param url
+ * The URL of the remote REST resource.
+ * Can be any of the following types:
+ * <ul class='spaced-list'>
+ * <li class='jc'>{@link URIBuilder}
+ * <li class='jc'>{@link URI}
+ * <li class='jc'>{@link URL}
+ * <li class='jc'>{@link String}
+ * <li class='jc'>{@link Object} - Converted to <c>String</c> using <c>toString()</c>
+ * </ul>
+ * @return
+ * A {@link RestRequest} object that can be further tailored before executing the request and getting the response
+ * as a parsed object.
+ * @throws RestCallException If any authentication errors occurred.
+ */
+ public RestRequest request(HttpMethod method, Object url) throws RestCallException {
+ RestRequest rc = request(method.name(), url, method.hasContent());
+ return rc;
+ }
+
+ /**
+ * Perform a generic REST call.
+ *
+ * <p>
+ * Typically you're going to use {@link #request(HttpMethod, Object)} or {@link #request(HttpMethod, Object, Object)},
+ * but this method is provided to allow you to perform non-standard HTTP methods (e.g. HTTP FOO).
+ *
* @param method The method name (e.g. <js>"GET"</js>, <js>"OPTIONS"</js>).
* @param url
* The URL of the remote REST resource.
@@ -3382,6 +3433,16 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
return l.size() == 1 ? l.get(0) : null;
}
+ @SuppressWarnings("unchecked")
+ <T extends Context> T getInstance(Class<T> c) {
+ Context o = requestContexts.get(c);
+ if (o == null) {
+ o = ContextCache.INSTANCE.create(c, getPropertyStore());
+ requestContexts.put(c, o);
+ }
+ return (T)o;
+ }
+
@Override /* Context */
public OMap toMap() {
return super.toMap()
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 58fcfb2..78743b5 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
@@ -322,7 +322,7 @@ public class RestClientBuilder extends BeanContextBuilder {
* POJOs are converted to fully renderable HTML pages.
*
* <p>
- * {@link HtmlSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * {@link HtmlDocSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
* <ul>
* <li>The serializer can be configured using any of the serializer property setters (e.g. {@link #sortCollections()}),
* bean context property setters (e.g. {@link #swaps(Object...)}), or generic property setters (e.g. {@link #set(String, Object)}) defined on this builder class.
@@ -368,7 +368,7 @@ public class RestClientBuilder extends BeanContextBuilder {
* Same as {@link #htmlDoc()} but without the header and body tags and page title and description.
*
* <p>
- * {@link HtmlSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * {@link HtmlStrippedDocSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
* <ul>
* <li>The serializer can be configured using any of the serializer property setters (e.g. {@link #sortCollections()}),
* bean context property setters (e.g. {@link #swaps(Object...)}), or generic property setters (e.g. {@link #set(String, Object)}) defined on this builder class.
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 c37bf77..a581708 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
@@ -35,13 +35,20 @@ import org.apache.http.params.*;
import org.apache.http.protocol.*;
import org.apache.juneau.*;
import org.apache.juneau.collections.*;
+import org.apache.juneau.html.*;
import org.apache.juneau.http.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.msgpack.*;
import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.xml.*;
/**
* Represents a request to a remote REST resource.
@@ -99,12 +106,444 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
//------------------------------------------------------------------------------------------------------------------
/**
+ * Convenience method for specifying JSON as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * {@link JsonSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link JsonParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"application/json"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"application/json"</js> unless overridden
+ * {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(JsonSerializer.<jk>class</jk>).parser(JsonParser.<jk>class</jk>)</c>.
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest json() {
+ return serializer(JsonSerializer.DEFAULT).parser(JsonParser.DEFAULT);
+ }
+
+ /**
+ * Convenience method for specifying Simplified JSON as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * Simplified JSON is typically useful for automated tests because you can do simple string comparison of results
+ * without having to escape lots of quotes.
+ *
+ * <p>
+ * {@link SimpleJsonSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link JsonParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"application/json"</js> unless overridden
+ * by {@link #header(String,Object)} or {@link #accept(Object)}, or per-request via {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"application/json+simple"</js> unless overridden
+ * by {@link #header(String,Object)} or {@link #contentType(Object)}, or per-request via {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Can be combined with other marshaller setters such as {@link #xml()} to provide support for multiple languages.
+ * <ul>
+ * <li>When multiple languages are supported, the <c>Accept</c> and <c>Content-Type</c> headers control which marshallers are used, or uses the
+ * last-enabled language if the headers are not set.
+ * </ul>
+ * <p>
+ * Identical to calling <c>serializer(SimpleJsonSerializer.<jk>class</jk>).parser(JsonParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses Simplified JSON marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().simpleJson().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest simpleJson() {
+ return serializer(SimpleJsonSerializer.class).parser(SimpleJsonParser.class);
+ }
+
+ /**
+ * Convenience method for specifying XML as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * {@link XmlSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link XmlParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/xml"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/xml"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(XmlSerializer.<jk>class</jk>).parser(XmlParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses XML marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().xml().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest xml() {
+ return serializer(XmlSerializer.class).parser(XmlParser.class);
+ }
+
+ /**
+ * Convenience method for specifying HTML as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * POJOs are converted to HTML without any sort of doc wrappers.
+ *
+ * <p>
+ * {@link HtmlSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link HtmlParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/html"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/html"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(HtmlSerializer.<jk>class</jk>).parser(HtmlParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses HTML marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().html().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest html() {
+ return serializer(HtmlSerializer.class).parser(HtmlParser.class);
+ }
+
+ /**
+ * Convenience method for specifying HTML DOC as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * POJOs are converted to fully renderable HTML pages.
+ *
+ * <p>
+ * {@link HtmlDocSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link HtmlParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/html"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/html"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(HtmlDocSerializer.<jk>class</jk>).parser(HtmlParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses HTML Doc marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().htmlDoc().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest htmlDoc() {
+ return serializer(HtmlDocSerializer.class).parser(HtmlParser.class);
+ }
+
+ /**
+ * Convenience method for specifying Stripped HTML DOC as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * Same as {@link #htmlDoc()} but without the header and body tags and page title and description.
+ *
+ * <p>
+ * {@link HtmlStrippedDocSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link HtmlParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/html+stripped"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/html+stripped"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(HtmlStrippedDocSerializer.<jk>class</jk>).parser(HtmlParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses HTML Stripped Doc marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().htmlStrippedDoc().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest htmlStrippedDoc() {
+ return serializer(HtmlStrippedDocSerializer.class).parser(HtmlParser.class);
+ }
+
+ /**
+ * Convenience method for specifying Plain Text as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * Plain text marshalling typically only works on simple POJOs that can be converted to and from strings using
+ * swaps, swap methods, etc...
+ *
+ * <p>
+ * {@link PlainTextSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link PlainTextParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/plain"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/plain"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(PlainTextSerializer.<jk>class</jk>).parser(PlainTextParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses Plain Text marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().plainText().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest plainText() {
+ return serializer(PlainTextSerializer.class).parser(PlainTextParser.class);
+ }
+
+ /**
+ * Convenience method for specifying MessagePack as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * MessagePack is a binary equivalent to JSON that takes up considerably less space than JSON.
+ *
+ * <p>
+ * {@link MsgPackSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link MsgPackParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"octal/msgpack"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"octal/msgpack"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(MsgPackSerializer.<jk>class</jk>).parser(MsgPackParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses MessagePack marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().msgPack().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest msgPack() {
+ return serializer(MsgPackSerializer.class).parser(MsgPackParser.class);
+ }
+
+ /**
+ * Convenience method for specifying UON as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * UON is Url-Encoding Object notation that is equivalent to JSON but suitable for transmission as URL-encoded
+ * query and form post values.
+ *
+ * <p>
+ * {@link UonSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * {@link UonParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/uon"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/uon"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(UonSerializer.<jk>class</jk>).parser(UonParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses UON marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().uon().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest uon() {
+ return serializer(UonSerializer.class).parser(UonParser.class);
+ }
+
+ /**
+ * Convenience method for specifying URL-Encoding as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * {@link UrlEncodingSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * <li>This serializer is NOT used when using the {@link RestRequest#formData(String, Object)} (and related) methods for constructing
+ * the request body. Instead, the part serializer specified via {@link RestClientBuilder#partSerializer(Class)} is used.
+ * </ul>
+ * <p>
+ * {@link UrlEncodingParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"application/x-www-form-urlencoded"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"application/x-www-form-urlencoded"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(UrlEncodingSerializer.<jk>class</jk>).parser(UrlEncodingParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses URL-Encoded marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().urlEnc().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest urlEnc() {
+ return serializer(UrlEncodingSerializer.class).parser(UrlEncodingParser.class);
+ }
+
+ /**
+ * Convenience method for specifying OpenAPI as the marshalling transmission media type for this request only.
+ *
+ * <p>
+ * OpenAPI is a language that allows serialization to formats that use {@link HttpPartSchema} objects to describe their structure.
+ *
+ * <p>
+ * {@link OpenApiSerializer} will be used to serialize POJOs to request bodies unless overridden per request via {@link RestRequest#serializer(Serializer)}.
+ * <ul>
+ * <li>The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * <li>Typically the {@link RestRequest#body(Object, HttpPartSchema)} method will be used to specify the body of the request with the
+ * schema describing it's structure.
+ * </ul>
+ * <p>
+ * {@link OpenApiParser} will be used to parse POJOs from response bodies unless overridden per request via {@link RestRequest#parser(Parser)}.
+ * <ul>
+ * <li>The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ * <li>Typically the {@link RestResponseBody#schema(HttpPartSchema)} method will be used to specify the structure of the response body.
+ * </ul>
+ * <p>
+ * <c>Accept</c> request header will be set to <js>"text/openapi"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#accept(Object)}.
+ * <p>
+ * <c>Content-Type</c> request header will be set to <js>"text/openapi"</js> unless overridden
+ * by {@link RestRequest#header(String,Object)} or {@link RestRequest#contentType(Object)}.
+ * <p>
+ * Identical to calling <c>serializer(OpenApiSerializer.<jk>class</jk>).parser(OpenApiParser.<jk>class</jk>)</c>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Construct a client that uses OpenAPI marshalling.</jc>
+ * RestClient c = RestClient.<jsm>create</jsm>().openApi().build();
+ * </p>
+ *
+ * @return This object (for method chaining).
+ */
+ public RestRequest openApi() {
+ return serializer(OpenApiSerializer.class).parser(OpenApiParser.class);
+ }
+
+ /**
* Specifies the serializer to use on the request body.
*
* <p>
* Overrides the serializers specified on the {@link RestClient}.
*
* <p>
+ * The serializer is not modified by an of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ *
+ * <p>
* If the <c>Content-Type</c> header is not set on the request, it will be set to the media type of this serializer.
*
* @param serializer The serializer used to serialize POJOs to the body of the HTTP request.
@@ -116,12 +555,37 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
}
/**
+ * Specifies the serializer to use on the request body.
+ *
+ * <p>
+ * Overrides the serializers specified on the {@link RestClient}.
+ *
+ * <p>
+ * The serializer can be configured using any of the serializer property setters (e.g. {@link RestClientBuilder#sortCollections()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ *
+ * <p>
+ * If the <c>Content-Type</c> header is not set on the request, it will be set to the media type of this serializer.
+ *
+ * @param serializer The serializer used to serialize POJOs to the body of the HTTP request.
+ * @return This object (for method chaining).
+ */
+ public RestRequest serializer(Class<? extends Serializer> serializer) {
+ this.serializer = client.getInstance(serializer);
+ return this;
+ }
+
+ /**
* Specifies the parser to use on the response body.
*
* <p>
* Overrides the parsers specified on the {@link RestClient}.
*
* <p>
+ * The parser is not modified by any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ *
+ * <p>
* If the <c>Accept</c> header is not set on the request, it will be set to the media type of this parser.
*
* @param parser The parser used to parse POJOs from the body of the HTTP response.
@@ -133,6 +597,27 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
}
/**
+ * Specifies the parser to use on the response body.
+ *
+ * <p>
+ * Overrides the parsers specified on the {@link RestClient}.
+ *
+ * <p>
+ * The parser can be configured using any of the parser property setters (e.g. {@link RestClientBuilder#strict()}),
+ * bean context property setters (e.g. {@link RestClientBuilder#swaps(Object...)}), or generic property setters (e.g. {@link RestClientBuilder#set(String, Object)}) defined on this builder class.
+ *
+ * <p>
+ * If the <c>Accept</c> header is not set on the request, it will be set to the media type of this parser.
+ *
+ * @param parser The parser used to parse POJOs from the body of the HTTP response.
+ * @return This object (for method chaining).
+ */
+ public RestRequest parser(Class<? extends Parser> parser) {
+ this.parser = client.getInstance(parser);
+ return this;
+ }
+
+ /**
* Allows you to override what status codes are considered error codes that would result in a {@link RestCallException}.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocAsideTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocAsideTest.java
index 1adf127..7903fbc 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocAsideTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocAsideTest.java
@@ -49,7 +49,7 @@ public class HtmlDocAsideTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -99,7 +99,7 @@ public class HtmlDocAsideTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigAsideTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigAsideTest.java
index fe96ec4..25a70fa 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigAsideTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigAsideTest.java
@@ -55,7 +55,7 @@ public class HtmlDocConfigAsideTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -110,7 +110,7 @@ public class HtmlDocConfigAsideTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigFooterTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigFooterTest.java
index 99e8046..2365478 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigFooterTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigFooterTest.java
@@ -55,7 +55,7 @@ public class HtmlDocConfigFooterTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -110,7 +110,7 @@ public class HtmlDocConfigFooterTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigHeaderTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigHeaderTest.java
index 07291e2..37dd887 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigHeaderTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigHeaderTest.java
@@ -55,7 +55,7 @@ public class HtmlDocConfigHeaderTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -110,7 +110,7 @@ public class HtmlDocConfigHeaderTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavTest.java
index bb1cb8b..466f151 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavTest.java
@@ -55,7 +55,7 @@ public class HtmlDocConfigNavTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -110,7 +110,7 @@ public class HtmlDocConfigNavTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavlinksTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavlinksTest.java
index 4dfe28d..d0c5eb6 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavlinksTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigNavlinksTest.java
@@ -86,7 +86,7 @@ public class HtmlDocConfigNavlinksTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -195,7 +195,7 @@ public class HtmlDocConfigNavlinksTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigScriptTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigScriptTest.java
index 6369851..db0ed23 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigScriptTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigScriptTest.java
@@ -55,7 +55,7 @@ public class HtmlDocConfigScriptTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -110,7 +110,7 @@ public class HtmlDocConfigScriptTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigStyleTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigStyleTest.java
index ed0c8b4..b0339ce 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigStyleTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocConfigStyleTest.java
@@ -55,7 +55,7 @@ public class HtmlDocConfigStyleTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -110,7 +110,7 @@ public class HtmlDocConfigStyleTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocFooterTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocFooterTest.java
index 2df2c24..9574759 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocFooterTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocFooterTest.java
@@ -49,7 +49,7 @@ public class HtmlDocFooterTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -99,7 +99,7 @@ public class HtmlDocFooterTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocHeaderTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocHeaderTest.java
index 868e900..c2e7db8 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocHeaderTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocHeaderTest.java
@@ -49,7 +49,7 @@ public class HtmlDocHeaderTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -99,7 +99,7 @@ public class HtmlDocHeaderTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavTest.java
index ede4a5c..62a964f 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavTest.java
@@ -49,7 +49,7 @@ public class HtmlDocNavTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -99,7 +99,7 @@ public class HtmlDocNavTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavlinksTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavlinksTest.java
index 0fd5d1f..2ae0c97 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavlinksTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocNavlinksTest.java
@@ -74,7 +74,7 @@ public class HtmlDocNavlinksTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -172,7 +172,7 @@ public class HtmlDocNavlinksTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocScriptTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocScriptTest.java
index 1a14845..8278802 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocScriptTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocScriptTest.java
@@ -49,7 +49,7 @@ public class HtmlDocScriptTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -99,7 +99,7 @@ public class HtmlDocScriptTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocStyleTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocStyleTest.java
index 6f338c5..7288332 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocStyleTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/HtmlDocStyleTest.java
@@ -49,7 +49,7 @@ public class HtmlDocStyleTest {
return "OK";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -99,7 +99,7 @@ public class HtmlDocStyleTest {
return "OK";
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseHeaderAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseHeaderAnnotationTest.java
index a6de55e..c982b32 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseHeaderAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseHeaderAnnotationTest.java
@@ -51,27 +51,27 @@ public class ResponseHeaderAnnotationTest {
public String toString() {return "foo";}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_valueOnParameterPojo() throws Exception {
a.get("/a01")
.run()
- .assertStatus().is(200)
+ .assertStatusCode().is(200)
.assertHeader("Foo").is("foo");
}
@Test
public void a02_valueOnParameterString() throws Exception {
a.get("/a02")
.run()
- .assertStatus().is(200)
+ .assertStatusCode().is(200)
.assertHeader("Foo").is("foo");
}
@Test
public void a03_valueOnParameterOverrideName() throws Exception {
a.get("/a03")
.run()
- .assertStatus().is(200)
+ .assertStatusCode().is(200)
.assertHeader("Bar").is("foo");
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseStatusAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseStatusAnnotationTest.java
index 41d1905..683ebc6 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseStatusAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/ResponseStatusAnnotationTest.java
@@ -30,16 +30,16 @@ public class ResponseStatusAnnotationTest {
public static class A {
@RestMethod
public void a01(@ResponseStatus Value<Integer> status) {
- status.set(100);
+ status.set(202);
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
a.get("/a01")
.run()
- .assertStatus().is(100);
+ .assertStatusCode().is(202);
}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodBpiTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodBpiTest.java
index e913db2..a015d9b 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodBpiTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodBpiTest.java
@@ -57,7 +57,7 @@ public class RestMethodBpiTest {
return new MyBeanA().init();
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -144,7 +144,7 @@ public class RestMethodBpiTest {
return new MyBeanA().init();
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
@@ -230,7 +230,7 @@ public class RestMethodBpiTest {
return new MyBeanB().init();
}
}
- static MockRest c = MockRest.build(C.class);
+ static MockRestClient c = MockRestClient.build(C.class);
@Test
public void c01() throws Exception {
@@ -316,7 +316,7 @@ public class RestMethodBpiTest {
return new MyBeanB().init();
}
}
- static MockRest d = MockRest.build(D.class);
+ static MockRestClient d = MockRestClient.build(D.class);
@Test
public void d01() throws Exception {
@@ -384,7 +384,7 @@ public class RestMethodBpiTest {
return new MyBeanA().init();
}
}
- static MockRest e = MockRest.build(E.class);
+ static MockRestClient e = MockRestClient.build(E.class);
@Test
public void e01() throws Exception {
@@ -420,7 +420,7 @@ public class RestMethodBpiTest {
return new MyBeanA().init();
}
}
- static MockRest f = MockRest.build(F.class);
+ static MockRestClient f = MockRestClient.build(F.class);
@Test
public void f01() throws Exception {
@@ -469,7 +469,7 @@ public class RestMethodBpiTest {
return new MyBeanA().init();
}
}
- static MockRest g = MockRest.build(G.class);
+ static MockRestClient g = MockRestClient.build(G.class);
@Test
public void g01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodGuardsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodGuardsTest.java
index 456ae20..a90bacc 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodGuardsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodGuardsTest.java
@@ -48,7 +48,7 @@ public class RestMethodGuardsTest {
}
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_overlappingOneGuard() throws Exception {
@@ -56,24 +56,28 @@ public class RestMethodGuardsTest {
.run()
.assertBody().is("OK1");
a.get("/a01?noTrace=true")
+ .ignoreErrors()
.run()
- .assertStatus().is(403)
+ .assertStatusCode().is(403)
.assertBody().contains("Access denied by guard");
}
@Test
public void a02_overlappingTwoGuards() throws Exception {
a.get("/a02?noTrace=true")
+ .ignoreErrors()
.run()
- .assertStatus().is(403)
+ .assertStatusCode().is(403)
.assertBody().contains("Access denied by guard");
a.get("/a02?noTrace=true&t1=1")
+ .ignoreErrors()
.run()
- .assertStatus().is(403)
+ .assertStatusCode().is(403)
.assertBody().contains("Access denied by guard");
a.get("/a02?noTrace=true&t2=2")
+ .ignoreErrors()
.run()
- .assertStatus().is(403)
+ .assertStatusCode().is(403)
.assertBody().contains("Access denied by guard");
a.get("/a02?t1=1&t2=2")
.run()
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodMatchersTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodMatchersTest.java
index 1e9656c..41d25be 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodMatchersTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodMatchersTest.java
@@ -62,7 +62,7 @@ public class RestMethodMatchersTest {
}
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodPathTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodPathTest.java
index bb71eee..ce5dd36 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodPathTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestMethodPathTest.java
@@ -60,7 +60,7 @@ public class RestMethodPathTest {
return "h";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_overlappingPaths() throws Exception {
@@ -100,7 +100,7 @@ public class RestMethodPathTest {
return "b";
}
}
- static MockRest b2 = MockRest.build(B2.class);
+ static MockRestClient b2 = MockRestClient.build(B2.class);
@Test
public void b01_pathOverriddenByChild() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceLoggingTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceLoggingTest.java
index d31c4b9..b007ed5 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceLoggingTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceLoggingTest.java
@@ -44,7 +44,7 @@ public class RestResourceLoggingTest {
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_default() throws Exception {
@@ -107,9 +107,9 @@ public class RestResourceLoggingTest {
}
}
- static MockRest b1 = MockRest.build(B1.class);
- static MockRest b2 = MockRest.build(B2.class);
- static MockRest b3 = MockRest.build(B3.class);
+ static MockRestClient b1 = MockRestClient.build(B1.class);
+ static MockRestClient b2 = MockRestClient.build(B2.class);
+ static MockRestClient b3 = MockRestClient.build(B3.class);
@Test
public void b01_logging() throws Exception {
@@ -215,10 +215,10 @@ public class RestResourceLoggingTest {
}
}
- static MockRest c1 = MockRest.build(C1.class);
- static MockRest c2 = MockRest.build(C2.class);
- static MockRest c3 = MockRest.build(C3.class);
- static MockRest c4 = MockRest.build(C4.class);
+ static MockRestClient c1 = MockRestClient.build(C1.class);
+ static MockRestClient c2 = MockRestClient.build(C2.class);
+ static MockRestClient c3 = MockRestClient.build(C3.class);
+ static MockRestClient c4 = MockRestClient.build(C4.class);
@Test
public void c01_useStackTraceHashing() throws Exception {
@@ -321,9 +321,9 @@ public class RestResourceLoggingTest {
}
}
- static MockRest d1 = MockRest.build(D1.class);
- static MockRest d2 = MockRest.build(D2.class);
- static MockRest d3 = MockRest.build(D3.class);
+ static MockRestClient d1 = MockRestClient.build(D1.class);
+ static MockRestClient d2 = MockRestClient.build(D2.class);
+ static MockRestClient d3 = MockRestClient.build(D3.class);
@Test
public void d01_stackTraceHashingTimeout() throws Exception {
@@ -429,10 +429,10 @@ public class RestResourceLoggingTest {
}
}
- static MockRest e1 = MockRest.build(E1.class);
- static MockRest e2 = MockRest.build(E2.class);
- static MockRest e3 = MockRest.build(E3.class);
- static MockRest e4 = MockRest.build(E4.class);
+ static MockRestClient e1 = MockRestClient.build(E1.class);
+ static MockRestClient e2 = MockRestClient.build(E2.class);
+ static MockRestClient e3 = MockRestClient.build(E3.class);
+ static MockRestClient e4 = MockRestClient.build(E4.class);
@Test
public void e01_noTrace() throws Exception {
@@ -535,9 +535,9 @@ public class RestResourceLoggingTest {
}
}
- static MockRest f1 = MockRest.build(F1.class);
- static MockRest f2 = MockRest.build(F2.class);
- static MockRest f3 = MockRest.build(F3.class);
+ static MockRestClient f1 = MockRestClient.build(F1.class);
+ static MockRestClient f2 = MockRestClient.build(F2.class);
+ static MockRestClient f3 = MockRestClient.build(F3.class);
@Test
public void f01_rules() throws Exception {
@@ -629,8 +629,8 @@ public class RestResourceLoggingTest {
return string(req.getCallLoggerConfig().getRules());
}
}
- static MockRest g1 = MockRest.build(G1.class);
- static MockRest g2 = MockRest.build(G2.class);
+ static MockRestClient g1 = MockRestClient.build(G1.class);
+ static MockRestClient g2 = MockRestClient.build(G2.class);
@Test
public void g01_rules() throws Exception {
@@ -669,17 +669,19 @@ public class RestResourceLoggingTest {
}
}
- static MockRest MY_REST = MockRest.build(MyRestClass.class);
+ static MockRestClient MY_REST = MockRestClient.build(MyRestClass.class);
@Test
public void test() throws Exception {
MY_REST.post("/foo?foo=bar", "Foo")
+ .ignoreErrors()
.header("Foo", "bar")
.run()
- .assertStatus().is(500);
+ .assertStatusCode().is(500);
MY_REST.post("/foo?foo=bar", "Foo")
+ .ignoreErrors()
.header("Foo", "bar")
.run()
- .assertStatus().is(500);
+ .assertStatusCode().is(500);
}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java
index e1db343..60af1d3 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java
@@ -45,7 +45,7 @@ public class RestResourceMessagesTest {
return convertToMap(rb);
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
@@ -59,7 +59,7 @@ public class RestResourceMessagesTest {
@Rest(messages="RestResourceMessagesTest2")
public static class B extends A {}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePathTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePathTest.java
index f197e5f..d1b5dc4 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePathTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePathTest.java
@@ -49,7 +49,7 @@ public class RestResourcePathTest {
@Rest(path="/p2")
public static class A02 extends A02a {}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_nestedChildren() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePropertiesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePropertiesTest.java
index 40d4b4d..111235f 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePropertiesTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourcePropertiesTest.java
@@ -77,7 +77,7 @@ public class RestResourcePropertiesTest {
}
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceSerializersTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceSerializersTest.java
index 0e452a6..24957b5 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceSerializersTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceSerializersTest.java
@@ -117,7 +117,7 @@ public class RestResourceSerializersTest {
return "test406";
}
}
- static MockRest a = MockRest.build(A.class);
+ static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_serializerOnClass() throws Exception {
@@ -127,8 +127,9 @@ public class RestResourceSerializersTest {
.assertBody().is("text/a - test1");
a.get("/a01?noTrace=true")
.accept("text/b")
+ .ignoreErrors()
.run()
- .assertStatus().is(406)
+ .assertStatusCode().is(406)
.assertBody().contains(
"Unsupported media-type in request header 'Accept': 'text/b'",
"Supported media-types: ['text/a'"
@@ -138,8 +139,9 @@ public class RestResourceSerializersTest {
public void a02_serializerOnMethod() throws Exception {
a.get("/a02?noTrace=true")
.accept("text/a")
+ .ignoreErrors()
.run()
- .assertStatus().is(406)
+ .assertStatusCode().is(406)
.assertBody().contains(
"Unsupported media-type in request header 'Accept': 'text/a'",
"Supported media-types: ['text/b']"
@@ -171,8 +173,9 @@ public class RestResourceSerializersTest {
public void a05_validErrorResponse() throws Exception {
a.get("/a05?noTrace=true")
.accept("text/bad")
+ .ignoreErrors()
.run()
- .assertStatus().is(406)
+ .assertStatusCode().is(406)
.assertBody().contains(
"Unsupported media-type in request header 'Accept': 'text/bad'",
"Supported media-types: ['text/a"
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceStaticFilesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceStaticFilesTest.java
index 4c8443f..6e4e692 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceStaticFilesTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceStaticFilesTest.java
@@ -31,7 +31,7 @@ public class RestResourceStaticFilesTest {
return null;
}
}
- static MockRest a1 = MockRest.build(A1.class);
+ static MockRestClient a1 = MockRestClient.build(A1.class);
@Test
public void a01a() throws Exception {
@@ -45,11 +45,13 @@ public class RestResourceStaticFilesTest {
@Test
public void a01b_preventPathTraversals() throws Exception {
a1.get("/xdocs/xsubdocs/../test.txt?noTrace=true")
+ .ignoreErrors()
.run()
- .assertStatus().is(404);
+ .assertStatusCode().is(404);
a1.get("/xdocs/xsubdocs/%2E%2E/test.txt?noTrace=true")
+ .ignoreErrors()
.run()
- .assertStatus().is(404);
+ .assertStatusCode().is(404);
}
@Rest(staticFiles={"xdocs2:xdocs2:{Foo:'Bar',Baz:'Qux'},xdocs:xdocs"})
@@ -59,7 +61,7 @@ public class RestResourceStaticFilesTest {
return null;
}
}
- static MockRest a2 = MockRest.build(A1.class);
+ static MockRestClient a2 = MockRestClient.build(A1.class);
@Test
public void a02a() throws Exception {
@@ -73,11 +75,13 @@ public class RestResourceStaticFilesTest {
@Test
public void a02b_preventPathTraversals() throws Exception {
a1.get("/xdocs/xsubdocs/../test.txt?noTrace=true")
+ .ignoreErrors()
.run()
- .assertStatus().is(404);
+ .assertStatusCode().is(404);
a1.get("/xdocs/xsubdocs/%2E%2E/test.txt?noTrace=true")
+ .ignoreErrors()
.run()
- .assertStatus().is(404);
+ .assertStatusCode().is(404);
}
//------------------------------------------------------------------------------------------------------------------
@@ -91,7 +95,7 @@ public class RestResourceStaticFilesTest {
return null;
}
}
- static MockRest b = MockRest.build(B.class);
+ static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01() throws Exception {
@@ -122,8 +126,8 @@ public class RestResourceStaticFilesTest {
}
}
- static MockRest c1 = MockRest.build(C1.class);
- static MockRest c2 = MockRest.build(C2.class);
+ static MockRestClient c1 = MockRestClient.build(C1.class);
+ static MockRestClient c2 = MockRestClient.build(C2.class);
@Test
public void c01() throws Exception {
@@ -170,7 +174,7 @@ public class RestResourceStaticFilesTest {
}
}
- static MockRest d = MockRest.build(D.class);
+ static MockRestClient d = MockRestClient.build(D.class);
@Test
public void d01() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceTest.java
index 95bb416..7b36727 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceTest.java
@@ -13,6 +13,7 @@
package org.apache.juneau.rest.annotation;
import static org.junit.runners.MethodSorters.*;
+import static org.apache.juneau.http.HttpMethod.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.http.annotation.*;
@@ -47,10 +48,10 @@ public class RestResourceTest {
@Rest(allowBodyParam="true")
public static class A4 extends A2 {}
- static MockRest a1 = MockRest.build(A1.class);
- static MockRest a2 = MockRest.build(A2.class);
- static MockRest a3 = MockRest.build(A3.class);
- static MockRest a4 = MockRest.build(A4.class);
+ static MockRestClient a1 = MockRestClient.build(A1.class);
+ static MockRestClient a2 = MockRestClient.build(A2.class);
+ static MockRestClient a3 = MockRestClient.build(A3.class);
+ static MockRestClient a4 = MockRestClient.build(A4.class);
@Test
public void a01_allowBodyParam_true() throws Exception {
@@ -111,14 +112,14 @@ public class RestResourceTest {
@Rest(allowedHeaderParams="None")
public static class B8 extends B5 {}
- static MockRest b1 = MockRest.build(B1.class);
- static MockRest b2 = MockRest.build(B2.class);
- static MockRest b3 = MockRest.build(B3.class);
- static MockRest b4 = MockRest.build(B4.class);
- static MockRest b5 = MockRest.build(B5.class);
- static MockRest b6 = MockRest.build(B6.class);
- static MockRest b7 = MockRest.build(B7.class);
- static MockRest b8 = MockRest.build(B8.class);
+ static MockRestClient b1 = MockRestClient.build(B1.class);
+ static MockRestClient b2 = MockRestClient.build(B2.class);
+ static MockRestClient b3 = MockRestClient.build(B3.class);
+ static MockRestClient b4 = MockRestClient.build(B4.class);
+ static MockRestClient b5 = MockRestClient.build(B5.class);
+ static MockRestClient b6 = MockRestClient.build(B6.class);
+ static MockRestClient b7 = MockRestClient.build(B7.class);
+ static MockRestClient b8 = MockRestClient.build(B8.class);
@Test
public void b01_allowedHeaderParams_default() throws Exception {
@@ -219,14 +220,14 @@ public class RestResourceTest {
@Rest(allowedMethodHeaders="None")
public static class C8 extends C5 {}
- static MockRest c1 = MockRest.build(C1.class);
- static MockRest c2 = MockRest.build(C2.class);
- static MockRest c3 = MockRest.build(C3.class);
- static MockRest c4 = MockRest.build(C4.class);
- static MockRest c5 = MockRest.build(C5.class);
- static MockRest c6 = MockRest.build(C6.class);
- static MockRest c7 = MockRest.build(C7.class);
- static MockRest c8 = MockRest.build(C8.class);
+ static MockRestClient c1 = MockRestClient.build(C1.class);
+ static MockRestClient c2 = MockRestClient.build(C2.class);
+ static MockRestClient c3 = MockRestClient.build(C3.class);
+ static MockRestClient c4 = MockRestClient.build(C4.class);
+ static MockRestClient c5 = MockRestClient.build(C5.class);
+ static MockRestClient c6 = MockRestClient.build(C6.class);
+ static MockRestClient c7 = MockRestClient.build(C7.class);
+ static MockRestClient c8 = MockRestClient.build(C8.class);
@Test
public void c01_allowedMethodHeaders_default() throws Exception {
@@ -234,7 +235,7 @@ public class RestResourceTest {
c1.put("/", "").run().assertBody().is("PUT");
c1.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c1.put("/", "").header("X-Method", "GET").run().assertBody().is("PUT");
- c1.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("GET");
+ c1.request(GET,"/").header("X-Method","FOO").run().assertBody().is("GET");
}
@Test
@@ -243,7 +244,7 @@ public class RestResourceTest {
c2.put("/", "").run().assertBody().is("PUT");
c2.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c2.put("/", "").header("X-Method", "GET").run().assertBody().is("GET");
- c2.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("GET");
+ c2.request(GET,"/").header("X-Method","FOO").run().assertBody().is("GET");
}
@Test
@@ -252,7 +253,7 @@ public class RestResourceTest {
c3.put("/", "").run().assertBody().is("PUT");
c3.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c3.put("/", "").header("X-Method", "GET").run().assertBody().is("GET");
- c3.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("GET");
+ c3.request(GET,"/").header("X-Method","FOO").run().assertBody().is("GET");
}
@Test
@@ -261,7 +262,7 @@ public class RestResourceTest {
c4.put("/", "").run().assertBody().is("PUT");
c4.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c4.put("/", "").header("X-Method", "GET").run().assertBody().is("PUT");
- c4.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("FOO");
+ c4.request(GET,"/").header("X-Method","FOO").run().assertBody().is("FOO");
}
@Test
@@ -270,7 +271,7 @@ public class RestResourceTest {
c5.put("/", "").run().assertBody().is("PUT");
c5.get("/").header("X-Method", "PUT").run().assertBody().is("PUT");
c5.put("/", "").header("X-Method", "GET").run().assertBody().is("GET");
- c5.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("FOO");
+ c5.request(GET,"/").header("X-Method","FOO").run().assertBody().is("FOO");
}
@Test
@@ -279,7 +280,7 @@ public class RestResourceTest {
c6.put("/", "").run().assertBody().is("PUT");
c6.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c6.put("/", "").header("X-Method", "GET").run().assertBody().is("PUT");
- c6.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("GET");
+ c6.request(GET,"/").header("X-Method","FOO").run().assertBody().is("GET");
}
@Test
@@ -288,7 +289,7 @@ public class RestResourceTest {
c7.put("/", "").run().assertBody().is("PUT");
c7.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c7.put("/", "").header("X-Method", "GET").run().assertBody().is("PUT");
- c7.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("GET");
+ c7.request(GET,"/").header("X-Method","FOO").run().assertBody().is("GET");
}
@Test
@@ -297,7 +298,7 @@ public class RestResourceTest {
c8.put("/", "").run().assertBody().is("PUT");
c8.get("/").header("X-Method", "PUT").run().assertBody().is("GET");
c8.put("/", "").header("X-Method", "GET").run().assertBody().is("PUT");
- c8.request("GET","/",null,"").header("X-Method","FOO").run().assertBody().is("GET");
+ c8.request(GET,"/").header("X-Method","FOO").run().assertBody().is("GET");
}
@Test
@@ -327,6 +328,7 @@ public class RestResourceTest {
}
@RestMethod
public String head() {
+ // Note that HTTP client is going to ignore this body.
return "HEAD";
}
@RestMethod
@@ -363,117 +365,117 @@ public class RestResourceTest {
@Rest(allowedMethodParams="None")
public static class D8 extends D5 {}
- static MockRest d1 = MockRest.build(D1.class);
- static MockRest d2 = MockRest.build(D2.class);
- static MockRest d3 = MockRest.build(D3.class);
- static MockRest d4 = MockRest.build(D4.class);
- static MockRest d5 = MockRest.build(D5.class);
- static MockRest d6 = MockRest.build(D6.class);
- static MockRest d7 = MockRest.build(D7.class);
- static MockRest d8 = MockRest.build(D8.class);
+ static MockRestClient d1 = MockRestClient.build(D1.class);
+ static MockRestClient d2 = MockRestClient.build(D2.class);
+ static MockRestClient d3 = MockRestClient.build(D3.class);
+ static MockRestClient d4 = MockRestClient.build(D4.class);
+ static MockRestClient d5 = MockRestClient.build(D5.class);
+ static MockRestClient d6 = MockRestClient.build(D6.class);
+ static MockRestClient d7 = MockRestClient.build(D7.class);
+ static MockRestClient d8 = MockRestClient.build(D8.class);
@Test
public void d01_allowedMethodHeaders_default() throws Exception {
d1.get("/").run().assertBody().is("GET");
d1.put("/", "").run().assertBody().is("PUT");
- d1.head("/").run().assertBody().is("HEAD");
+ d1.head("/").run().assertBody().is("");
d1.options("/").run().assertBody().is("OPTIONS");
d1.get("/?method=PUT").run().assertBody().is("GET");
d1.put("/?method=GET", "").run().assertBody().is("PUT");
d1.get("/?method=HEAD").run().assertBody().is("HEAD");
d1.get("/?method=OPTIONS").run().assertBody().is("OPTIONS");
- d1.request("GET","/?method=FOO",null,"").run().assertBody().is("GET");
+ d1.request(GET,"/?method=FOO").run().assertBody().is("GET");
}
@Test
public void d02_allowedMethodParams_GET_only() throws Exception {
d2.get("/").run().assertBody().is("GET");
d2.put("/", "").run().assertBody().is("PUT");
- d2.head("/").run().assertBody().is("HEAD");
+ d2.head("/").run().assertBody().is("");
d2.options("/").run().assertBody().is("OPTIONS");
d2.get("/?method=PUT").run().assertBody().is("GET");
d2.put("/?method=GET", "").run().assertBody().is("GET");
d2.get("/?method=HEAD").run().assertBody().is("GET");
d2.get("/?method=OPTIONS").run().assertBody().is("GET");
- d2.request("GET","/?method=FOO",null,"").run().assertBody().is("GET");
+ d2.request(GET,"/?method=FOO").run().assertBody().is("GET");
}
@Test
public void d03_allowedMethodParams_GET_caseSensitivity() throws Exception {
d3.get("/").run().assertBody().is("GET");
d3.put("/", "").run().assertBody().is("PUT");
- d3.head("/").run().assertBody().is("HEAD");
+ d3.head("/").run().assertBody().is("");
d3.options("/").run().assertBody().is("OPTIONS");
d3.get("/?method=PUT").run().assertBody().is("GET");
d3.put("/?method=GET", "").run().assertBody().is("GET");
d3.get("/?method=HEAD").run().assertBody().is("GET");
d3.get("/?method=OPTIONS").run().assertBody().is("GET");
- d3.request("GET","/?method=FOO",null,"").run().assertBody().is("GET");
+ d3.request(GET,"/?method=FOO").run().assertBody().is("GET");
}
@Test
public void d04_allowedMethodParams_FOO_only() throws Exception {
d4.get("/").run().assertBody().is("GET");
d4.put("/", "").run().assertBody().is("PUT");
- d4.head("/").run().assertBody().is("HEAD");
+ d4.head("/").run().assertBody().is("");
d4.options("/").run().assertBody().is("OPTIONS");
d4.get("/?method=PUT").run().assertBody().is("GET");
d4.put("/?method=GET", "").run().assertBody().is("PUT");
d4.get("/?method=HEAD").run().assertBody().is("GET");
d4.get("/?method=OPTIONS").run().assertBody().is("GET");
- d4.request("GET","/?method=FOO",null,"").run().assertBody().is("FOO");
+ d4.request(GET,"/?method=FOO").run().assertBody().is("FOO");
}
@Test
public void d05_allowedMethodParams_allMethods() throws Exception {
d5.get("/").run().assertBody().is("GET");
d5.put("/", "").run().assertBody().is("PUT");
- d5.head("/").run().assertBody().is("HEAD");
+ d5.head("/").run().assertBody().is("");
d5.options("/").run().assertBody().is("OPTIONS");
d5.get("/?method=PUT").run().assertBody().is("PUT");
d5.put("/?method=GET", "").run().assertBody().is("GET");
d5.get("/?method=HEAD").run().assertBody().is("HEAD");
d5.get("/?method=OPTIONS").run().assertBody().is("OPTIONS");
- d5.request("GET","/?method=FOO",null,"").run().assertBody().is("FOO");
+ d5.request(GET,"/?method=FOO").run().assertBody().is("FOO");
}
@Test
public void d06_allowedMethodParams_none() throws Exception {
d6.get("/").run().assertBody().is("GET");
d6.put("/", "").run().assertBody().is("PUT");
- d6.head("/").run().assertBody().is("HEAD");
+ d6.head("/").run().assertBody().is("");
d6.options("/").run().assertBody().is("OPTIONS");
d6.get("/?method=PUT").run().assertBody().is("GET");
d6.put("/?method=GET", "").run().assertBody().is("PUT");
d6.get("/?method=HEAD").run().assertBody().is("GET");
d6.get("/?method=OPTIONS").run().assertBody().is("GET");
- d6.request("GET","/?method=FOO",null,"").run().assertBody().is("GET");
+ d6.request(GET,"/?method=FOO").run().assertBody().is("GET");
}
@Test
public void d07_allowedMethodParams_none_caseSensitivity() throws Exception {
d7.get("/").run().assertBody().is("GET");
d7.put("/", "").run().assertBody().is("PUT");
- d7.head("/").run().assertBody().is("HEAD");
+ d7.head("/").run().assertBody().is("");
d7.options("/").run().assertBody().is("OPTIONS");
d7.get("/?method=PUT").run().assertBody().is("GET");
d7.put("/?method=GET", "").run().assertBody().is("PUT");
d7.get("/?method=HEAD").run().assertBody().is("GET");
d7.get("/?method=OPTIONS").run().assertBody().is("GET");
- d7.request("GET","/?method=FOO",null,"").run().assertBody().is("GET");
+ d7.request(GET,"/?method=FOO").run().assertBody().is("GET");
}
@Test
public void d08_allowedMethodParams_none_overridingParent() throws Exception {
d8.get("/").run().assertBody().is("GET");
d8.put("/", "").run().assertBody().is("PUT");
- d8.head("/").run().assertBody().is("HEAD");
+ d8.head("/").run().assertBody().is("");
d8.options("/").run().assertBody().is("OPTIONS");
d8.get("/?method=PUT").run().assertBody().is("GET");
d8.put("/?method=GET", "").run().assertBody().is("PUT");
d8.get("/?method=HEAD").run().assertBody().is("GET");
d8.get("/?method=OPTIONS").run().assertBody().is("GET");
- d8.request("GET","/?method=FOO",null,"").run().assertBody().is("GET");
+ d8.request(GET,"/?method=FOO").run().assertBody().is("GET");
}
@Test