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/03/20 14:40:25 UTC
[juneau] branch master updated: JUNEAU-193
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 4df4423 JUNEAU-193
4df4423 is described below
commit 4df44235cd5594f0cf34a9b8f5a26a5df5c95919
Author: JamesBognar <ja...@apache.org>
AuthorDate: Fri Mar 20 10:40:09 2020 -0400
JUNEAU-193
RestClient should support all languages by default.
---
.../java/org/apache/juneau/parser/ParserGroup.java | 9 +
.../apache/juneau/serializer/SerializerGroup.java | 11 +
.../juneau/examples/rest/RootResourcesTest.java | 4 +-
.../rest/test/client/ThirdPartyProxyTest.java | 12 +-
.../juneau/rest/client2/BodyAnnotationTest.java | 6 +-
.../juneau/rest/client2/EndToEndInterfaceTest.java | 4 +-
.../org/apache/juneau/rest/client2/RestClient.java | 112 ++++--
.../juneau/rest/client2/RestClientBuilder.java | 170 ++++++++-
.../apache/juneau/rest/client2/RestRequest.java | 51 ++-
.../apache/juneau/rest/client2/RestResponse.java | 10 +-
.../juneau/rest/client2/RestResponseBody.java | 8 +-
.../rest/client2/ext/SerializedHttpEntity.java | 5 +-
.../org/apache/juneau/rest/mock2/MockRemote.java | 425 +++++++++++++++++++--
.../org/apache/juneau/rest/mock2/MockRest.java | 43 ++-
.../juneau/rest/BeanContextPropertiesTest.java | 2 +-
.../java/org/apache/juneau/rest/DebugModeTest.java | 18 +-
.../test/java/org/apache/juneau/rest/NlsTest.java | 6 +-
.../java/org/apache/juneau/rest/PathsTest.java | 8 +-
.../org/apache/juneau/rest/RestParamsTest.java | 2 +-
.../org/apache/juneau/rest/StatusCodesTest.java | 2 +-
.../rest/annotation/RestMethodGuardsTest.java | 2 +-
.../rest/annotation/RestMethodMatchersTest.java | 2 +-
.../juneau/rest/annotation/RestMethodPathTest.java | 4 +-
.../rest/annotation/RestResourceLoggingTest.java | 42 +-
.../rest/annotation/RestResourceMessagesTest.java | 4 +-
.../rest/annotation/RestResourcePathTest.java | 2 +-
.../juneau/rest/annotation/RestResourceTest.java | 56 +--
.../rest/annotation2/BodyAnnotationTest.java | 8 +-
.../rest/annotation2/FormDataAnnotationTest.java | 6 +-
.../annotation2/HasFormDataAnnotationTest.java | 2 +-
.../rest/annotation2/HasQueryAnnotationTest.java | 2 +-
.../rest/annotation2/HeaderAnnotationTest.java | 2 +-
.../rest/annotation2/PathAnnotationTest.java | 20 +-
.../annotation2/PathRemainderAnnotationTest.java | 4 +-
.../rest/annotation2/QueryAnnotationTest.java | 8 +-
.../rest/annotation2/ResponseAnnotationTest.java | 10 +-
.../juneau/rest/annotation2/RestHookTest.java | 14 +-
.../rest/annotation2/RestMethodInheritTest.java | 6 +-
.../rest/annotation2/RestResourceParsersTest.java | 2 +-
.../juneau/rest/annotation2/RoleGuardTest.java | 76 ++--
.../apache/juneau/rest/exceptions/BasicTest.java | 8 +-
.../juneau/rest/headers/AcceptEncodingTest.java | 4 +-
.../org/apache/juneau/rest/headers/AcceptTest.java | 12 +-
.../juneau/rest/headers/ClientVersionTest.java | 4 +-
.../juneau/rest/headers/ContentEncodingTest.java | 4 +-
.../juneau/rest/headers/ContentTypeTest.java | 10 +-
.../apache/juneau/rest/headers/HeadersTest.java | 16 +-
.../apache/juneau/rest/responses/BasicTest.java | 6 +-
48 files changed, 939 insertions(+), 305 deletions(-)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
index 5ed717d..78275e4 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
@@ -216,4 +216,13 @@ public final class ParserGroup extends BeanContext {
public List<Parser> getParsers() {
return parsers;
}
+
+ /**
+ * Returns <jk>true</jk> if this group contains no parsers.
+ *
+ * @return <jk>true</jk> if this group contains no parsers.
+ */
+ public boolean isEmpty() {
+ return parsers.isEmpty();
+ }
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
index 6f4721e..cc93801 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
@@ -159,6 +159,8 @@ public final class SerializerGroup extends BeanTraverseContext {
* @return The serializer and media type that matched the accept header, or <jk>null</jk> if no match was made.
*/
public SerializerMatch getSerializerMatch(String acceptHeader) {
+ if (acceptHeader == null)
+ return null;
SerializerMatch sm = cache.get(acceptHeader);
if (sm != null)
return sm;
@@ -266,4 +268,13 @@ public final class SerializerGroup extends BeanTraverseContext {
public List<Serializer> getSerializers() {
return serializers;
}
+
+ /**
+ * Returns <jk>true</jk> if this group contains no serializers.
+ *
+ * @return <jk>true</jk> if this group contains no serializers.
+ */
+ public boolean isEmpty() {
+ return serializers.isEmpty();
+ }
}
diff --git a/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java b/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
index a0170bc..0706ac2 100644
--- a/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
+++ b/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
@@ -69,7 +69,7 @@ public class RootResourcesTest extends RestTestcase {
//====================================================================================================
@Test
public void testHtmlStripped() throws Exception {
- try (RestClient client = SamplesMicroservice.client().parser(HtmlParser.DEFAULT).accept("text/html+stripped").build()) {
+ try (RestClient client = SamplesMicroservice.client().parsers(HtmlParser.DEFAULT).accept("text/html+stripped").build()) {
ResourceDescription[] x = client.get("").run().getBody().as(ResourceDescription[].class);
assertEquals("helloWorld", x[0].getName());
@@ -87,7 +87,7 @@ public class RootResourcesTest extends RestTestcase {
//====================================================================================================
@Test
public void testJsonSchema() throws Exception {
- try (RestClient client = SamplesMicroservice.client().parser(JsonParser.DEFAULT).accept("text/json+schema").build()) {
+ try (RestClient client = SamplesMicroservice.client().parsers(JsonParser.DEFAULT).accept("text/json+schema").build()) {
ObjectMap m = client.get("").run().getBody().as(ObjectMap.class);
if (debug) System.err.println(m);
client.closeQuietly();
diff --git a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
index f8963b4..ab18467 100644
--- a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
+++ b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
@@ -79,7 +79,7 @@ public class ThirdPartyProxyTest extends RestTestcase {
public void a00_lotsOfSetInt3dArray() {
final AtomicLong time = new AtomicLong(System.currentTimeMillis());
final AtomicInteger iteration = new AtomicInteger(0);
- TimerTask timerTask = new TimerTask() {
+ TimerTask timerTask = new TimerTask() {
@Override
public void run() {
if (System.currentTimeMillis() - time.get() > 10000) {
@@ -92,10 +92,10 @@ public class ThirdPartyProxyTest extends RestTestcase {
}
}
}
- };
- // running timer task as daemon thread
- Timer timer = new Timer(true);
- timer.scheduleAtFixedRate(timerTask, 0, 10 * 1000);
+ };
+ // running timer task as daemon thread
+ Timer timer = new Timer(true);
+ timer.scheduleAtFixedRate(timerTask, 0, 10 * 1000);
for (int i = 0; i < 100000; i++) {
iteration.set(i);
String s = proxy.setInt3dArray(new int[][][]{{{i},null},null}, i);
@@ -103,7 +103,7 @@ public class ThirdPartyProxyTest extends RestTestcase {
System.err.println("response="+s);
time.set(System.currentTimeMillis());
}
- timer.cancel();
+ timer.cancel();
}
diff --git a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/BodyAnnotationTest.java b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/BodyAnnotationTest.java
index d5ad18b..daa57f4 100644
--- a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/BodyAnnotationTest.java
+++ b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/BodyAnnotationTest.java
@@ -130,7 +130,7 @@ public class BodyAnnotationTest {
String postA10(@Body NameValuePairs b);
}
- private static A01 a01 = MockRemote.create(A01.class, A.class).parser(null).build();
+ private static A01 a01 = MockRemote.create(A01.class, A.class).jsonSerializer().build();
@Test
public void a01_int() throws Exception {
@@ -254,7 +254,7 @@ public class BodyAnnotationTest {
String postB10(@Body NameValuePairs b);
}
- private static B01 b01 = MockRemote.create(B01.class, B.class).marshall(OpenApi.DEFAULT).contentType(null).build();
+ private static B01 b01 = MockRemote.create(B01.class, B.class).openApi().contentType(null).build();
@Test
public void b01_int() throws Exception {
@@ -379,7 +379,7 @@ public class BodyAnnotationTest {
String postC10(@Body NameValuePairs b);
}
- private static C01 c01 = MockRemote.create(C01.class, C.class).serializer(null).contentType("text/foo").build();
+ private static C01 c01 = MockRemote.create(C01.class, C.class).jsonParser().contentType("text/foo").build();
@Test
public void c01_int() throws Exception {
diff --git a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/EndToEndInterfaceTest.java b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/EndToEndInterfaceTest.java
index 9b44d1c..53306b0 100644
--- a/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/EndToEndInterfaceTest.java
+++ b/juneau-rest/juneau-rest-client-utest/src/test/java/org/apache/juneau/rest/client2/EndToEndInterfaceTest.java
@@ -134,7 +134,7 @@ public class EndToEndInterfaceTest {
}
}
- private static IB ib = MockRemote.build(IB.class, B.class);
+ private static IB ib = MockRemote.create(IB.class, B.class).json().build();
@Test
public void b01_combinedAnnotations_Body() throws Exception {
@@ -1451,7 +1451,7 @@ public class EndToEndInterfaceTest {
}
}
- private static IF ifa = MockRemote.build(IF.class, F.class);
+ private static IF ifa = MockRemote.create(IF.class, F.class).json().build();
@Test
public void fa01_badRequest() {
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 166db35..0b8edc0 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
@@ -1377,30 +1377,32 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
public static final String RESTCLIENT_leakDetection = PREFIX + "leakDetection.b";
/**
- * Configuration property: Parser.
+ * Configuration property: Parsers.
*
* <h5 class='section'>Property:</h5>
* <ul class='spaced-list'>
- * <li><b>ID:</b> {@link org.apache.juneau.rest.client2.RestClient#RESTCLIENT_parser RESTCLIENT_parser}
- * <li><b>Name:</b> <js>"RestClient.parser.o"</js>
+ * <li><b>ID:</b> {@link org.apache.juneau.rest.client2.RestClient#RESTCLIENT_parsers RESTCLIENT_parsers}
+ * <li><b>Name:</b> <js>"RestClient.parsers.lo"</js>
* <li><b>Data type:</b>
* <ul>
* <li><c>Class<? <jk>extends</jk> {@link org.apache.juneau.parser.Parser}></c>
* <li>{@link org.apache.juneau.parser.Parser}
* </ul>
- * <li><b>Default:</b> {@link org.apache.juneau.json.JsonParser};
+ * <li><b>Default:</b> No parsers.
* <li><b>Methods:</b>
* <ul>
* <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#parser(Class)}
* <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#parser(Parser)}
+ * <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#parsers(Class...)}
+ * <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#parsers(Parser...)}
* </ul>
* </ul>
*
* <h5 class='section'>Description:</h5>
* <p>
- * The parser to use for parsing POJOs in response bodies.
+ * The parsers to use for parsing POJOs in response bodies.
*/
- public static final String RESTCLIENT_parser = PREFIX + "parser.o";
+ public static final String RESTCLIENT_parsers = PREFIX + "parsers.lo";
/**
* Configuration property: Part parser.
@@ -1526,30 +1528,32 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
public static final String RESTCLIENT_rootUri = PREFIX + "rootUri.s";
/**
- * Configuration property: Serializer.
+ * Configuration property: Serializers.
*
* <h5 class='section'>Property:</h5>
* <ul class='spaced-list'>
- * <li><b>ID:</b> {@link org.apache.juneau.rest.client2.RestClient#RESTCLIENT_serializer RESTCLIENT_serializer}
- * <li><b>Name:</b> <js>"RestClient.serializer.o"</js>
+ * <li><b>ID:</b> {@link org.apache.juneau.rest.client2.RestClient#RESTCLIENT_serializers RESTCLIENT_serializers}
+ * <li><b>Name:</b> <js>"RestClient.serializers.lo"</js>
* <li><b>Data type:</b>
* <ul>
* <li><c>Class<? <jk>extends</jk> {@link org.apache.juneau.serializer.Serializer}></c>
* <li>{@link org.apache.juneau.serializer.Serializer}
* </ul>
- * <li><b>Default:</b> {@link org.apache.juneau.json.JsonSerializer};
+ * <li><b>Default:</b> No serializers.
* <li><b>Methods:</b>
* <ul>
* <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#serializer(Class)}
* <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#serializer(Serializer)}
+ * <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#serializers(Class...)}
+ * <li class='jm'>{@link org.apache.juneau.rest.client2.RestClientBuilder#serializers(Serializer...)}
* </ul>
* </ul>
*
* <h5 class='section'>Description:</h5>
* <p>
- * The serializer to use for serializing POJOs in request bodies.
+ * The serializers to use for serializing POJOs in request bodies.
*/
- public static final String RESTCLIENT_serializer = PREFIX + "serializer.o";
+ public static final String RESTCLIENT_serializers = PREFIX + "serializers.lo";
private static final Set<String> NO_BODY_METHODS = Collections.unmodifiableSet(ASet.<String>create("GET","HEAD","DELETE","CONNECT","OPTIONS","TRACE"));
@@ -1567,8 +1571,8 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
private StackTraceElement[] closedStack;
// These are read directly by RestCall.
- final Serializer serializer;
- final Parser parser;
+ final SerializerGroup serializers;
+ final ParserGroup parsers;
Predicate<Integer> errorCodes;
final RestCallInterceptor[] interceptors;
@@ -1640,23 +1644,25 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
this.rootUrl = StringUtils.nullIfEmpty(getStringProperty(RESTCLIENT_rootUri, "").replaceAll("\\/$", ""));
this.leakDetection = getBooleanProperty(RESTCLIENT_leakDetection, debug);
- Object o = getProperty(RESTCLIENT_serializer, Object.class, null);
- if (o instanceof Serializer) {
- this.serializer = ((Serializer)o).builder().apply(ps).build();
- } else if (o instanceof Class) {
- this.serializer = ContextCache.INSTANCE.create((Class<? extends Serializer>)o, ps);
- } else {
- this.serializer = null;
+ SerializerGroupBuilder sgb = SerializerGroup.create();
+ for (Object o : getArrayProperty(RESTCLIENT_serializers, Object.class)) {
+ if (o instanceof Serializer) {
+ sgb.append(((Serializer)o).builder().apply(ps).build());
+ } else if (o instanceof Class) {
+ sgb.append(ContextCache.INSTANCE.create((Class<? extends Serializer>)o, ps));
+ }
}
-
- o = getProperty(RESTCLIENT_parser, Object.class, null);
- if (o instanceof Parser) {
- this.parser = ((Parser)o).builder().apply(ps).build();
- } else if (o instanceof Class) {
- this.parser = ContextCache.INSTANCE.create((Class<? extends Parser>)o, ps);
- } else {
- this.parser = null;
+ this.serializers = sgb.build();
+
+ ParserGroupBuilder pgb = ParserGroup.create();
+ for (Object o : getArrayProperty(RESTCLIENT_parsers, Object.class)) {
+ if (o instanceof Parser) {
+ pgb.append(((Parser)o).builder().apply(ps).build());
+ } else if (o instanceof Class) {
+ pgb.append(ContextCache.INSTANCE.create((Class<? extends Parser>)o, ps));
+ }
}
+ this.parsers = pgb.build();
this.urlEncodingSerializer = new SerializerBuilder(ps).build(UrlEncodingSerializer.class);
this.partSerializer = getInstanceProperty(RESTCLIENT_partSerializer, HttpPartSerializer.class, OpenApiSerializer.class, ResourceResolver.FUZZY, ps);
@@ -2042,7 +2048,7 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
*/
public RestRequest formPost(Object url, Object body) throws RestCallException {
return request("POST", url, true)
- .body(body instanceof HttpEntity ? body : new SerializedHttpEntity(body, urlEncodingSerializer, null));
+ .body(body instanceof HttpEntity ? body : new SerializedHttpEntity(body, urlEncodingSerializer, null, null));
}
/**
@@ -2417,9 +2423,6 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
throw new RestCallException("Invalid type {0} for form-data.", o.getClass());
}
- if (parser != null && ! req.containsHeader("Accept"))
- req.setHeader("Accept", parser.getPrimaryMediaType().toString());
-
return req;
}
@@ -2508,7 +2511,7 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
* @return The new proxy interface.
*/
public <T> T getRemote(final Class<T> interfaceClass, final Object restUrl) {
- return getRemote(interfaceClass, restUrl, serializer, parser);
+ return getRemote(interfaceClass, restUrl, null, null);
}
/**
@@ -2560,6 +2563,7 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
RestRequest rc = request(httpMethod, url, hasContent(httpMethod));
rc.serializer(serializer);
+ rc.parser(parser);
for (RemoteMethodArg a : rmm.getPathArgs())
rc.path(a.getName(), args[a.getIndex()], a.getSerializer(s), a.getSchema());
@@ -2731,7 +2735,7 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
* @return The new proxy interface.
*/
public <T> T getRrpcInterface(final Class<T> interfaceClass, final Object restUrl) {
- return getRrpcInterface(interfaceClass, restUrl, serializer, parser);
+ return getRrpcInterface(interfaceClass, restUrl, null, null);
}
/**
@@ -3087,6 +3091,38 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
}
}
+ /*
+ * Returns the serializer that best matches the specified content type.
+ * If no match found or the content type is null, returns the first serializer in the list.
+ * Returns null if no serializers are defined.
+ */
+ Serializer getMatchingSerializer(String mediaType) {
+ if (serializers.isEmpty())
+ return null;
+ if (mediaType != null) {
+ Serializer s = serializers.getSerializer(mediaType);
+ if (s != null)
+ return s;
+ }
+ return serializers.getSerializers().get(0);
+ }
+
+ /*
+ * Returns the parser that best matches the specified content type.
+ * If no match found or the content type is null, returns the first parser in the list.
+ * Returns null if no parsers are defined.
+ */
+ Parser getMatchingParser(String mediaType) {
+ if (parsers.isEmpty())
+ return null;
+ if (mediaType != null) {
+ Parser p = parsers.getParser(mediaType);
+ if (p != null)
+ return p;
+ }
+ return parsers.getParsers().get(0);
+ }
+
@Override /* Context */
public ObjectMap toMap() {
return super.toMap()
@@ -3098,16 +3134,10 @@ public class RestClient extends BeanContext implements HttpClient, Closeable {
.append("headers", headers)
.append("interceptors", interceptors)
.append("keepHttpClientOpen", keepHttpClientOpen)
- .append("parser", parser)
.append("partParser", partParser)
.append("partSerializer", partSerializer)
.append("query", query)
.append("rootUri", rootUrl)
- .append("serializer", serializer)
);
}
-
- Parser getParser() {
- return parser;
- }
}
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 fd2e7be..1acda54 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
@@ -62,6 +62,7 @@ import org.apache.juneau.reflect.*;
import org.apache.juneau.rest.client2.ext.*;
import org.apache.juneau.rest.client2.logging.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.soap.*;
import org.apache.juneau.svl.*;
import org.apache.juneau.uon.*;
import org.apache.juneau.urlencoding.*;
@@ -118,6 +119,41 @@ public class RestClientBuilder extends BeanContextBuilder {
//------------------------------------------------------------------------------------------------------------------
/**
+ * Convenience method for specifying all available transmission types.
+ *
+ * @return This object (for method chaining).
+ */
+ public RestClientBuilder universal() {
+ return
+ serializers(
+ JsonSerializer.class,
+ SimpleJsonSerializer.class,
+ HtmlDocSerializer.class,
+ HtmlStrippedDocSerializer.class,
+ HtmlSchemaDocSerializer.class,
+ JsonSchemaSerializer.class,
+ XmlDocSerializer.class,
+ UonSerializer.class,
+ UrlEncodingSerializer.class,
+ OpenApiSerializer.class,
+ MsgPackSerializer.class,
+ SoapXmlSerializer.class,
+ PlainTextSerializer.class
+ )
+ .parsers(
+ JsonParser.class,
+ JsonParser.Simple.class,
+ XmlParser.class,
+ HtmlParser.class,
+ UonParser.class,
+ UrlEncodingParser.class,
+ OpenApiParser.class,
+ MsgPackParser.class,
+ PlainTextParser.class
+ );
+ }
+
+ /**
* Convenience method for specifying JSON as the transmission media type.
*
* <p>
@@ -1703,28 +1739,44 @@ public class RestClientBuilder extends BeanContextBuilder {
* Configuration property: Marshall
*
* <p>
- * Shortcut for specifying the {@link RestClient#RESTCLIENT_serializer} and {@link RestClient#RESTCLIENT_parser}
+ * Shortcut for specifying the {@link RestClient#RESTCLIENT_serializers} and {@link RestClient#RESTCLIENT_parsers}
* using the serializer and parser defined in a marshall.
*
* @param value The values to add to this setting.
* @return This object (for method chaining).
*/
public RestClientBuilder marshall(Marshall value) {
- if (value == null)
- serializer((Serializer)null).parser((Parser)null);
- else
+ if (value != null)
serializer(value.getSerializer()).parser(value.getParser());
return this;
}
/**
+ * Configuration property: Marshalls
+ *
+ * <p>
+ * Shortcut for specifying the {@link RestClient#RESTCLIENT_serializers} and {@link RestClient#RESTCLIENT_parsers}
+ * using the serializer and parser defined in a marshall.
+ *
+ * @param value The values to add to this setting.
+ * @return This object (for method chaining).
+ */
+ public RestClientBuilder marshalls(Marshall...value) {
+ for (Marshall m : value) {
+ if (m != null)
+ serializer(m.getSerializer()).parser(m.getParser());
+ }
+ return this;
+ }
+
+ /**
* Configuration property: Parser.
*
* <p>
- * The parser to use for parsing POJOs in response bodies.
+ * Shortcut for calling {@link #parsers(Class...)}.
*
* <ul class='seealso'>
- * <li class='jf'>{@link RestClient#RESTCLIENT_parser}
+ * <li class='jf'>{@link RestClient#RESTCLIENT_parsers}
* </ul>
*
* @param value
@@ -1733,17 +1785,17 @@ public class RestClientBuilder extends BeanContextBuilder {
* @return This object (for method chaining).
*/
public RestClientBuilder parser(Class<? extends Parser> value) {
- return set(RESTCLIENT_parser, value);
+ return parsers(value);
}
/**
* Configuration property: Parser.
*
* <p>
- * Same as {@link #parser(Parser)} except takes in a parser instance.
+ * Shortcut for calling {@link #parsers(Parser...)}.
*
* <ul class='seealso'>
- * <li class='jf'>{@link RestClient#RESTCLIENT_parser}
+ * <li class='jf'>{@link RestClient#RESTCLIENT_parsers}
* </ul>
*
* @param value
@@ -1752,7 +1804,50 @@ public class RestClientBuilder extends BeanContextBuilder {
* @return This object (for method chaining).
*/
public RestClientBuilder parser(Parser value) {
- return set(RESTCLIENT_parser, value);
+ return parsers(value);
+ }
+
+ /**
+ * Configuration property: Parsers.
+ *
+ * <p>
+ * Associates the specified {@link Parser Parsers} with the HTTP client.
+ *
+ * <p>
+ * The parser that best matches the <c>Accept</c> header will be used to parse the response body.
+ * <br>If no <c>Accept</c> header is specified, the first parser in the list will be used.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link RestClient#RESTCLIENT_parsers}
+ * </ul>
+ *
+ * @param value
+ * The new value for this setting.
+ * <br>The default value is {@link JsonParser#DEFAULT}.
+ * @return This object (for method chaining).
+ */
+ @SafeVarargs
+ public final RestClientBuilder parsers(Class<? extends Parser>...value) {
+ return addTo(RESTCLIENT_parsers, value);
+ }
+
+ /**
+ * Configuration property: Parsers.
+ *
+ * <p>
+ * Same as {@link #parsers(Class...)} except takes in a parser instance.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link RestClient#RESTCLIENT_parsers}
+ * </ul>
+ *
+ * @param value
+ * The new value for this setting.
+ * <br>The default value is {@link JsonParser#DEFAULT}.
+ * @return This object (for method chaining).
+ */
+ public RestClientBuilder parsers(Parser...value) {
+ return addTo(RESTCLIENT_parsers, value);
}
/**
@@ -1857,10 +1952,10 @@ public class RestClientBuilder extends BeanContextBuilder {
* Configuration property: Serializer.
*
* <p>
- * The serializer to use for serializing POJOs in request bodies.
+ * Shortcut for calling {@link #serializers(Class...)}.
*
* <ul class='seealso'>
- * <li class='jf'>{@link RestClient#RESTCLIENT_serializer}
+ * <li class='jf'>{@link RestClient#RESTCLIENT_serializers}
* </ul>
*
* @param value
@@ -1869,17 +1964,17 @@ public class RestClientBuilder extends BeanContextBuilder {
* @return This object (for method chaining).
*/
public RestClientBuilder serializer(Class<? extends Serializer> value) {
- return set(RESTCLIENT_serializer, value);
+ return serializers(value);
}
/**
* Configuration property: Serializer.
*
* <p>
- * Same as {@link #serializer(Class)} but takes in a serializer instance.
+ * Shortcut for calling {@link #serializers(Serializer...)}.
*
* <ul class='seealso'>
- * <li class='jf'>{@link RestClient#RESTCLIENT_serializer}
+ * <li class='jf'>{@link RestClient#RESTCLIENT_serializers}
* </ul>
*
* @param value
@@ -1888,7 +1983,50 @@ public class RestClientBuilder extends BeanContextBuilder {
* @return This object (for method chaining).
*/
public RestClientBuilder serializer(Serializer value) {
- return set(RESTCLIENT_serializer, value);
+ return serializers(value);
+ }
+
+ /**
+ * Configuration property: Serializers.
+ *
+ * <p>
+ * Associates the specified {@link Serializer Serializers} with the HTTP client.
+ *
+ * <p>
+ * The serializer that best matches the <c>Content-Type</c> header will be used to serialize the request body.
+ * <br>If no <c>Content-Type</c> header is specified, the first serializer in the list will be used.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link RestClient#RESTCLIENT_serializers}
+ * </ul>
+ *
+ * @param value
+ * The new value for this setting.
+ * <br>The default is {@link JsonSerializer}.
+ * @return This object (for method chaining).
+ */
+ @SafeVarargs
+ public final RestClientBuilder serializers(Class<? extends Serializer>...value) {
+ return addTo(RESTCLIENT_serializers, value);
+ }
+
+ /**
+ * Configuration property: Serializers.
+ *
+ * <p>
+ * Same as {@link #serializers(Class...)} but takes in serializer instances.
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link RestClient#RESTCLIENT_serializers}
+ * </ul>
+ *
+ * @param value
+ * The new value for this setting.
+ * <br>The default is {@link JsonSerializer}.
+ * @return This object (for method chaining).
+ */
+ public RestClientBuilder serializers(Serializer...value) {
+ return addTo(RESTCLIENT_serializers, value);
}
/**
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 c6fa0d3..d679656 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
@@ -38,6 +38,7 @@ import org.apache.juneau.http.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.oapi.*;
+import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.rest.client2.ext.NameValuePairs;
import org.apache.juneau.rest.client2.ext.SerializedNameValuePair;
@@ -71,6 +72,7 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
private Object input;
private boolean hasInput; // input() was called, even if it's setting 'null'.
private Serializer serializer;
+ private Parser parser;
private HttpPartSerializer partSerializer;
private HttpPartSchema requestBodySchema;
private URIBuilder uriBuilder;
@@ -93,7 +95,6 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
this.request = request;
interceptors(this.client.interceptors);
this.errorCodes = client.errorCodes;
- this.serializer = client.serializer;
this.partSerializer = client.getPartSerializer();
this.uriBuilder = new URIBuilder(uri);
}
@@ -103,10 +104,13 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
//------------------------------------------------------------------------------------------------------------------
/**
- * Specifies the serializer to use on this request body.
+ * Specifies the serializer to use on the request body.
*
* <p>
- * Overrides the serializer specified on the {@link RestClient}.
+ * Overrides the serializers specified on the {@link RestClient}.
+ *
+ * <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).
@@ -117,6 +121,23 @@ 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>
+ * 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(Parser parser) {
+ this.parser = parser;
+ return this;
+ }
+
+ /**
* Allows you to override what status codes are considered error codes that would result in a {@link RestCallException}.
*
* <p>
@@ -2175,6 +2196,24 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
request.setURI(uriBuilder.build());
+ // Pick the serializer if it hasn't been overridden.
+ Header h = getFirstHeader("Content-Type");
+ String contentType = h == null ? null : h.getValue();
+ Serializer serializer = this.serializer;
+ if (serializer == null)
+ serializer = client.getMatchingSerializer(contentType);
+ if (contentType == null && serializer != null)
+ contentType = serializer.getPrimaryMediaType().toString();
+
+ // Pick the parser if it hasn't been overridden.
+ h = getFirstHeader("Accept");
+ String accept = h == null ? null : h.getValue();
+ Parser parser = this.parser;
+ if (parser == null)
+ parser = client.getMatchingParser(accept);
+ if (accept == null && parser != null)
+ setHeader("Accept", parser.getPrimaryMediaType().toString());
+
if (hasInput || formData != null) {
if (hasInput && formData != null)
@@ -2207,7 +2246,7 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
entity = new InputStreamEntity(r.getContents(), getRequestContentType(ContentType.APPLICATION_OCTET_STREAM));
}
else if (serializer != null)
- entity = new SerializedHttpEntity(input, serializer, requestBodySchema);
+ entity = new SerializedHttpEntity(input, serializer, requestBodySchema, contentType);
else if (partSerializer != null)
entity = new StringEntity(partSerializer.serialize((HttpPartSchema)null, input), getRequestContentType(TEXT_PLAIN));
else
@@ -2218,9 +2257,9 @@ public final class RestRequest extends BeanSession implements HttpUriRequest, Co
try {
if (request2 != null)
- response = new RestResponse(client, this, client.execute(target, request2, context));
+ response = new RestResponse(client, this, client.execute(target, request2, context), parser);
else
- response = new RestResponse(client, this, client.execute(target, this.request, context));
+ response = new RestResponse(client, this, client.execute(target, this.request, context), parser);
} catch (Exception e) {
throw 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 3bf4399..fab5fd3 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
@@ -13,6 +13,7 @@
package org.apache.juneau.rest.client2;
import org.apache.juneau.internal.*;
+import org.apache.juneau.parser.*;
import static org.apache.juneau.httppart.HttpPartType.*;
@@ -45,6 +46,7 @@ public final class RestResponse implements HttpResponse {
private final RestClient client;
private final RestRequest request;
private final HttpResponse response;
+ private final Parser parser;
private HttpPartParser partParser;
private RestResponseBody responseBody;
private boolean isClosed;
@@ -54,12 +56,14 @@ public final class RestResponse implements HttpResponse {
* @param client The RestClient that created this response.
* @param request The REST request.
* @param response The HTTP response. Can be <jk>null</jk>.
+ * @param parser The overridden parser passed into {@link RestRequest#parser(Parser)}.
*/
- protected RestResponse(RestClient client, RestRequest request, HttpResponse response) {
+ protected RestResponse(RestClient client, RestRequest request, HttpResponse response, Parser parser) {
this.client = client;
this.request = request;
+ this.parser = parser;
this.response = response == null ? new BasicHttpResponse(null, 0, null) : response;
- this.responseBody = new RestResponseBody(client, request, this);
+ this.responseBody = new RestResponseBody(client, request, this, parser);
this.partParser = client.getPartParser();
}
@@ -370,7 +374,7 @@ public final class RestResponse implements HttpResponse {
@Override /* HttpResponse */
public void setEntity(HttpEntity entity) {
response.setEntity(entity);
- this.responseBody = new RestResponseBody(client, request, this);
+ this.responseBody = new RestResponseBody(client, request, this, parser);
}
/**
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
index f7c2a8f..6917d3a 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/RestResponseBody.java
@@ -107,12 +107,13 @@ public class RestResponseBody implements HttpEntity {
* @param client The client used to build this request.
* @param request The request object.
* @param response The response object.
+ * @param parser The parser to use to consume the body. Can be <jk>null</jk>.
*/
- public RestResponseBody(RestClient client, RestRequest request, RestResponse response) {
+ public RestResponseBody(RestClient client, RestRequest request, RestResponse response, Parser parser) {
this.client = client;
this.request = request;
this.response = response;
- this.parser = client.getParser();
+ this.parser = parser;
this.entity = ObjectUtils.firstNonNull(response.asHttpResponse().getEntity(), NULL_ENTITY);
}
@@ -773,6 +774,9 @@ public class RestResponseBody implements HttpEntity {
String ct = firstNonEmpty(response.getHeader("Content-Type").asStringOrElse("text/plain"));
+ if (parser == null)
+ parser = client.getMatchingParser(ct);
+
MediaType mt = MediaType.forString(ct);
if (parser == null || (mt.toString().equals("text/plain") && ! parser.canHandle(ct))) {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/SerializedHttpEntity.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/SerializedHttpEntity.java
index 03b703e..0fa9997 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/SerializedHttpEntity.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client2/ext/SerializedHttpEntity.java
@@ -38,13 +38,14 @@ public final class SerializedHttpEntity extends BasicHttpEntity {
* @param input The POJO to serialize. Can also be a {@link Reader} or {@link InputStream}.
* @param serializer The serializer to use to serialize this response.
* @param schema The optional schema information about the serialized part.
+ * @param contentType Override the content type defined on the serializer.
*/
- public SerializedHttpEntity(Object input, Serializer serializer, HttpPartSchema schema) {
+ public SerializedHttpEntity(Object input, Serializer serializer, HttpPartSchema schema, String contentType) {
this.output = input;
this.serializer = serializer;
this.schema = schema;
if (serializer != null && serializer.getResponseContentType() != null)
- setContentType(new BasicHeader("Content-Type", serializer.getResponseContentType().toString()));
+ setContentType(new BasicHeader("Content-Type", contentType != null ? contentType : serializer.getResponseContentType().toString()));
}
@Override /* BasicHttpEntity */
diff --git a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRemote.java b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRemote.java
index bb781ea..f0eb57f 100644
--- a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRemote.java
+++ b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRemote.java
@@ -16,11 +16,18 @@ import java.util.*;
import org.apache.juneau.json.*;
import org.apache.juneau.marshall.*;
+import org.apache.juneau.msgpack.*;
+import org.apache.juneau.oapi.*;
import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.html.*;
import org.apache.juneau.http.remote.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.xml.*;
/**
* Creates a mocked interface against a REST resource class to use for creating test remote resource interfaces.
@@ -34,7 +41,7 @@ import org.apache.juneau.serializer.*;
public class MockRemote<T> {
private MockRest.Builder mrb;
- private RestClientBuilder rcb = RestClient.create().json();
+ private RestClientBuilder rcb = RestClient.create();
private final Class<T> intf;
/**
@@ -265,92 +272,331 @@ public class MockRemote<T> {
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"application/json"</js>.
+ * Adds JSON support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"application/json"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> json() {
- marshall(Json.DEFAULT);
+ return jsonSerializer().jsonParser();
+ }
+
+ /**
+ * Adds JSON support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"application/json"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> jsonSerializer() {
+ serializer(JsonSerializer.class);
+ return this;
+ }
+
+ /**
+ * Adds JSON support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"application/json"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> jsonParser() {
+ parser(JsonParser.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"application/json+simple"</js>.
+ * Adds Simplified JSON support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"application/json+simple"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> simpleJson() {
- marshall(SimpleJson.DEFAULT);
+ return simpleJsonSerializer().jsonParser();
+ }
+
+ /**
+ * Adds Simplified JSON support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"application/json+simple"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> simpleJsonSerializer() {
+ serializer(SimpleJsonSerializer.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"text/xml"</js>.
+ * Adds XML support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"text/xml"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> xml() {
- marshall(Xml.DEFAULT);
+ return xmlSerializer().xmlParser();
+ }
+
+ /**
+ * Adds XML support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"text/xml"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> xmlSerializer() {
+ serializer(XmlSerializer.class);
+ return this;
+ }
+
+ /**
+ * Adds XML support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"text/xml"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> xmlParser() {
+ parser(XmlParser.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"text/html"</js>.
+ * Adds HTML support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"text/html"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> html() {
- marshall(Html.DEFAULT);
+ return htmlSerializer().htmlParser();
+ }
+
+ /**
+ * Adds HTML support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"text/html"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> htmlSerializer() {
+ serializer(HtmlSerializer.class);
+ return this;
+ }
+
+ /**
+ * Adds HTML support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"text/html"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> htmlParser() {
+ parser(HtmlParser.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"text/plain"</js>.
+ * Adds Plain-Text support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"text/plain"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> plainText() {
- marshall(PlainText.DEFAULT);
+ return plainTextSerializer().plainTextParser();
+ }
+
+ /**
+ * Adds Plain-Text support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"text/plain"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> plainTextSerializer() {
+ serializer(PlainTextSerializer.class);
+ return this;
+ }
+
+ /**
+ * Adds Plain-Text support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"text/plain"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> plainTextParser() {
+ parser(PlainTextParser.class);
+ return this;
+ }
+
+ /**
+ * Adds MessagePack support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"octal/msgpack"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> msgPack() {
+ return msgPackSerializer().msgPackParser();
+ }
+
+ /**
+ * Adds MessagePack support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"octal/msgpack"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> msgPackSerializer() {
+ serializer(MsgPackSerializer.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"octal/msgpack"</js>.
+ * Adds MessagePack support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"octal/msgpack"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
- public MockRemote<T> msgpack() {
- marshall(MsgPack.DEFAULT);
+ public MockRemote<T> msgPackParser() {
+ parser(MsgPackParser.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"text/uon"</js>.
+ * Adds UON support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"text/uon"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> uon() {
- marshall(Uon.DEFAULT);
+ return uonSerializer().uonParser();
+ }
+
+ /**
+ * Adds UON support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"text/uon"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> uonSerializer() {
+ serializer(UonSerializer.class);
+ return this;
+ }
+
+ /**
+ * Adds UON support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"text/uon"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> uonParser() {
+ parser(UonParser.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"application/x-www-form-urlencoded"</js>.
+ * Adds URL-Encoding support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"application/x-www-form-urlencoded"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
public MockRemote<T> urlEnc() {
- marshall(UrlEncoding.DEFAULT);
+ return urlEncSerializer().urlEncParser();
+ }
+
+ /**
+ * Adds URL-Encoding support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"application/x-www-form-urlencoded"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> urlEncSerializer() {
+ serializer(UrlEncodingSerializer.class);
+ return this;
+ }
+
+ /**
+ * Adds URL-Encoding support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"application/x-www-form-urlencoded"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> urlEncParser() {
+ parser(UrlEncodingParser.class);
+ return this;
+ }
+
+ /**
+ * Adds OpenAPI support for the request and response bodies.
+ *
+ * <p>
+ * <c>Accept</c> and <c>Content-Type</c> headers are set to <js>"text/openapi"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> openApi() {
+ return openApiSerializer().openApiParser();
+ }
+
+ /**
+ * Adds OpenAPI support for the request body only.
+ *
+ * <p>
+ * <c>Content-Type</c> header is set to <js>"text/openapi"</js> unless explicitly set.
+ *
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> openApiSerializer() {
+ serializer(OpenApiSerializer.class);
return this;
}
/**
- * Convenience method for setting <c>Accept</c> and <c>Content-Type</c> headers to <js>"text/openapi"</js>.
+ * Adds OpenAPI support for the response body only.
+ *
+ * <p>
+ * <c>Accept</c> header is set to <js>"text/openapi"</js> unless explicitly set.
*
* @return This object (for method chaining).
*/
- public MockRemote<T> openapi() {
- marshall(OpenApi.DEFAULT);
+ public MockRemote<T> openApiParser() {
+ parser(OpenApiParser.class);
return this;
}
@@ -369,36 +615,157 @@ public class MockRemote<T> {
public MockRemote<T> marshall(Marshall value) {
if (value != null)
serializer(value.getSerializer()).parser(value.getParser());
- else
- serializer(null).parser(null);
return this;
}
/**
- * Associates the specified {@link Serializer} with this client.
+ * Associates the specified {@link Marshall Marshalls} with this client.
+ *
+ * <p>
+ * This is shorthand for calling <c>serializer(x)</c> and <c>parser(x)</c> using the inner
+ * serializer and parser of the marshall object.
+ *
+ * @param values
+ * The marshalls to use for serializing and parsing HTTP bodies.
+ * <br>Can be <jk>null</jk> (will remote the existing serializer/parser).
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> marshalls(Marshall...values) {
+ rcb.marshalls(values);
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Serializer} with the HTTP client.
+ *
+ * <p>
+ * If the <c>Content-Type</c> header is not specified, it will be set to the media type of this serializer.
*
* @param value
* The serializer to use for serializing HTTP bodies.
- * <br>Can be <jk>null</jk> (will remote the existing serializer).
+ * <br>Can be <jk>null</jk>.
* @return This object (for method chaining).
*/
public MockRemote<T> serializer(Serializer value) {
rcb.serializer(value);
- contentType(value == null ? null : value.getPrimaryMediaType().toString());
return this;
}
/**
- * Associates the specified {@link Parser} with this client.
+ * Associates the specified {@link Serializer} with the HTTP client.
+ *
+ * <p>
+ * If the <c>Content-Type</c> header is not specified, it will be set to the media type of this serializer.
+ *
+ * @param value
+ * The serializer to use for serializing HTTP bodies.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> serializer(Class<? extends Serializer> value) {
+ rcb.serializer(value);
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Serializer Serializers} with the HTTP client.
+ *
+ * <p>
+ * The serializer that best matches the <c>Content-Type</c> header will be used to serialize the request body.
+ * <br>If no <c>Content-Type</c> header is specified, the first serializer in the list will be used.
+ *
+ * @param values
+ * The serializer to use for serializing HTTP bodies.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> serializers(Serializer...values) {
+ rcb.serializers(values);
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Serializer Serializers} with the HTTP client.
+ *
+ * <p>
+ * The serializer that best matches the <c>Content-Type</c> header will be used to serialize the request body.
+ * <br>If no <c>Content-Type</c> header is specified, the first serializer in the list will be used.
+ *
+ * @param values
+ * The serializer to use for serializing HTTP bodies.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ @SafeVarargs
+ public final MockRemote<T> serializers(Class<? extends Serializer>...values) {
+ rcb.serializers(values);
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Parser} with the HTTP client.
+ *
+ * <p>
+ * If the <c>Accept</c> header is not specified, it will be set to the media type of this parser.
*
* @param value
* The parser to use for parsing HTTP bodies.
- * <br>Can be <jk>null</jk> (will remote the existing parser).
+ * <br>Can be <jk>null</jk>.
* @return This object (for method chaining).
*/
public MockRemote<T> parser(Parser value) {
rcb.parser(value);
- accept(value == null ? null : value.getPrimaryMediaType().toString());
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Parser} with the HTTP client.
+ *
+ * <p>
+ * If the <c>Accept</c> header is not specified, it will be set to the media type of this parser.
+ *
+ * @param value
+ * The parser to use for parsing HTTP bodies.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> parser(Class<? extends Parser> value) {
+ rcb.parser(value);
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Parser Parsers} with the HTTP client.
+ *
+ * <p>
+ * The parser that best matches the <c>Accept</c> header will be used to parse the response body.
+ * <br>If no <c>Accept</c> header is specified, the first parser in the list will be used.
+ *
+ * @param values
+ * The parsers to use for parsing HTTP bodies.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ public MockRemote<T> parsers(Parser...values) {
+ rcb.parsers(values);
+ return this;
+ }
+
+ /**
+ * Associates the specified {@link Parser Parsers} with the HTTP client.
+ *
+ * <p>
+ * The parser that best matches the <c>Accept</c> header will be used to parse the response body.
+ * <br>If no <c>Accept</c> header is specified, the first parser in the list will be used.
+ *
+ * @param values
+ * The parsers to use for parsing HTTP bodies.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ @SafeVarargs
+ public final MockRemote<T> parsers(Class<? extends Parser>...values) {
+ rcb.parsers(values);
return this;
}
}
diff --git a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRest.java b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRest.java
index dfdb118..b006267 100644
--- a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRest.java
+++ b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock2/MockRest.java
@@ -50,6 +50,8 @@ import org.apache.juneau.serializer.*;
* <jk>public void</jk> testEcho() <jk>throws</jk> Exception {
* MockRest
* .<jsm>create</jsm>(MyRest.<jk>class</jk>)
+ * .json()
+ * .build()
* .put(<js>"/String"</js>, <js>"'foo'"</js>)
* .execute()
* .assertStatus(200)
@@ -131,13 +133,12 @@ public class MockRest implements MockHttpConnection {
* Convenience method for creating a MockRest over the specified REST implementation bean or bean class.
*
* <p>
- * <c>Accept</c> header is set to <c>"application/json+simple"</c> by default.
- * <c>Content-Type</c> header is set to <c>"application/json"</c> by default.
+ * <c>Accept</c> and <c>Content-Type</c> headers are not added to the request.
*
* <p>
* Equivalent to calling:
* <p class='bpcode w800'>
- * MockRest.create(impl, SimpleJson.<jsf>DEFAULT</jsf>).build();
+ * MockRest.create(impl, <jk>null</jk>, <jk>null</jk>).build();
* </p>
*
* @param impl
@@ -146,7 +147,7 @@ public class MockRest implements MockHttpConnection {
* @return A new {@link MockRest} object.
*/
public static MockRest build(Object impl) {
- return build(impl, SimpleJson.DEFAULT);
+ return build(impl, null, null);
}
/**
@@ -183,12 +184,12 @@ public class MockRest implements MockHttpConnection {
* <c>Accept</c> and <c>Content-Type</c> headers are set to the primary media types on the specified serializer and parser.
*
* <p>
- * Note that the marshall itself is not involved in any serialization or parsing.
+ * Note that the serializer and parsers are not involved in any serialization or parsing.
*
* <p>
* Equivalent to calling:
* <p class='bpcode w800'>
- * MockRest.create(impl, SimpleJson.<jsf>DEFAULT</jsf>).serializer(s).parser(p).build();
+ * MockRest.create(impl).serializer(s).parser(p).build();
* </p>
*
* @param impl
@@ -207,6 +208,36 @@ public class MockRest implements MockHttpConnection {
}
/**
+ * Shortcut builder.
+ *
+ * <p>
+ * Shortcut for calling <c>create(impl).json().build()</c>.
+ *
+ * @param impl
+ * The REST bean or bean class annotated with {@link Rest @Rest}.
+ * <br>If a class, it must have a no-arg constructor.
+ * @return A new {@link MockRest} object.
+ */
+ public static MockRest buildJson(Object impl) {
+ return create(impl).json().build();
+ }
+
+ /**
+ * Shortcut builder.
+ *
+ * <p>
+ * Shortcut for calling <c>create(impl).simpleJson().build()</c>.
+ *
+ * @param impl
+ * The REST bean or bean class annotated with {@link Rest @Rest}.
+ * <br>If a class, it must have a no-arg constructor.
+ * @return A new {@link MockRest} object.
+ */
+ public static MockRest buildSimpleJson(Object impl) {
+ return create(impl).simpleJson().build();
+ }
+
+ /**
* Builder class.
*/
public static class Builder {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java
index f412c6d..758da36 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java
@@ -48,7 +48,7 @@ public class BeanContextPropertiesTest {
return "d1="+df.swap(session, d1)+",d2="+df.swap(session, d2)+",d3="+df.swap(session, d3)+"";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_testClassTransforms() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java
index 41bed60..97f7aaa 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java
@@ -113,7 +113,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest a1 = MockRest.build(A1.class);
+ static MockRest a1 = MockRest.buildSimpleJson(A1.class);
static MockRest a1d = MockRest.create(A1.class).simpleJson().header("X-Debug", true).build();
@Test
@@ -188,7 +188,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest a1a = MockRest.build(A1a.class);
+ static MockRest a1a = MockRest.buildSimpleJson(A1a.class);
static MockRest a1ad = MockRest.create(A1a.class).simpleJson().header("X-Debug", true).build();
@Test
@@ -267,7 +267,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest a2 = MockRest.build(A2.class);
+ static MockRest a2 = MockRest.buildSimpleJson(A2.class);
static MockRest a2d = MockRest.create(A2.class).simpleJson().header("X-Debug", true).build();
@Test
@@ -346,7 +346,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest a3 = MockRest.build(A3.class);
+ static MockRest a3 = MockRest.buildSimpleJson(A3.class);
static MockRest a3d = MockRest.create(A3.class).simpleJson().header("X-Debug", true).build();
@Test
@@ -425,7 +425,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest a4 = MockRest.build(A4.class);
+ static MockRest a4 = MockRest.buildSimpleJson(A4.class);
static MockRest a4d = MockRest.create(A4.class).simpleJson().header("X-Debug", true).build();
@Test
@@ -486,7 +486,7 @@ public class DebugModeTest {
LOGGER.log(config, req, res);
}
}
- static MockRest b1 = MockRest.build(B1.class);
+ static MockRest b1 = MockRest.buildSimpleJson(B1.class);
@Test
public void b01_debugDefault() throws Exception {
@@ -512,7 +512,7 @@ public class DebugModeTest {
LOGGER.log(config, req, res);
}
}
- static MockRest b2 = MockRest.build(B2.class);
+ static MockRest b2 = MockRest.buildSimpleJson(B2.class);
@Test
public void b02_debugDefault() throws Exception {
@@ -700,7 +700,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest c1 = MockRest.build(C1.class);
+ static MockRest c1 = MockRest.buildSimpleJson(C1.class);
static MockRest c1d = MockRest.create(C1.class).simpleJson().header("X-Debug", true).build();
@Test
@@ -1034,7 +1034,7 @@ public class DebugModeTest {
return req.isDebug();
}
}
- static MockRest c2 = MockRest.build(C2.class);
+ static MockRest c2 = MockRest.buildSimpleJson(C2.class);
static MockRest c2d = MockRest.create(C2.class).simpleJson().header("X-Debug", true).build();
@Test
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java
index 3d8b1e7..ba85941 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java
@@ -50,7 +50,7 @@ public class NlsTest {
return null;
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
public static class A01 extends WriterSerializer {
public A01(PropertyStore ps) {
@@ -89,7 +89,7 @@ public class NlsTest {
return req.getSwagger();
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_optionsPageWithoutNls() throws Exception {
@@ -108,7 +108,7 @@ public class NlsTest {
return req.getMessage("bad", 1, 2, 3);
}
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01_missingResourceBundle() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java
index 26346b1..68833af 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java
@@ -56,7 +56,7 @@ public class PathsTest {
return getPaths(req).append("pathRemainder2", r).append("method",1);
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01() throws Exception {
@@ -204,7 +204,7 @@ public class PathsTest {
return getPaths(req).append("pathRemainder2", r).append("method",2);
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01() throws Exception {
@@ -356,7 +356,7 @@ public class PathsTest {
return getPaths(req).append("pathRemainder2", r).append("method",3);
}
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01() throws Exception {
@@ -508,7 +508,7 @@ public class PathsTest {
return getPaths(req).append("pathRemainder2", r).append("method",4);
}
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.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/RestParamsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestParamsTest.java
index 297f99e..6febffb 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestParamsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestParamsTest.java
@@ -126,7 +126,7 @@ public class RestParamsTest {
return t != null;
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_ResourceBundle() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
index e783a5b..fc887ff 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
@@ -43,7 +43,7 @@ public class StatusCodesTest {
return new StringReader(b);
}
}
- private static MockRest a = MockRest.build(A.class, null);
+ private static MockRest a = MockRest.build(A.class);
@Test
public void a01a_OK() 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 2e8d6e3..9ab5257 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
@@ -51,7 +51,7 @@ public class RestMethodGuardsTest {
}
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_overlappingOneGuard() throws Exception {
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 64ceb8e..2b350f9 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
@@ -66,7 +66,7 @@ public class RestMethodMatchersTest {
}
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.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 4a89ea5..790f32f 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
@@ -64,7 +64,7 @@ public class RestMethodPathTest {
return "h";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_overlappingPaths() throws Exception {
@@ -104,7 +104,7 @@ public class RestMethodPathTest {
return "b";
}
}
- static MockRest b2 = MockRest.build(B2.class, null);
+ static MockRest b2 = MockRest.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 aede074..80265cc 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
@@ -47,7 +47,7 @@ public class RestResourceLoggingTest {
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_default() throws Exception {
@@ -110,9 +110,9 @@ public class RestResourceLoggingTest {
}
}
- static MockRest b1 = MockRest.build(B1.class, null);
- static MockRest b2 = MockRest.build(B2.class, null);
- static MockRest b3 = MockRest.build(B3.class, null);
+ static MockRest b1 = MockRest.build(B1.class);
+ static MockRest b2 = MockRest.build(B2.class);
+ static MockRest b3 = MockRest.build(B3.class);
@Test
public void b01_logging() throws Exception {
@@ -218,10 +218,10 @@ public class RestResourceLoggingTest {
}
}
- static MockRest c1 = MockRest.build(C1.class, null);
- static MockRest c2 = MockRest.build(C2.class, null);
- static MockRest c3 = MockRest.build(C3.class, null);
- static MockRest c4 = MockRest.build(C4.class, null);
+ 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);
@Test
public void c01_useStackTraceHashing() throws Exception {
@@ -324,9 +324,9 @@ public class RestResourceLoggingTest {
}
}
- static MockRest d1 = MockRest.build(D1.class, null);
- static MockRest d2 = MockRest.build(D2.class, null);
- static MockRest d3 = MockRest.build(D3.class, null);
+ static MockRest d1 = MockRest.build(D1.class);
+ static MockRest d2 = MockRest.build(D2.class);
+ static MockRest d3 = MockRest.build(D3.class);
@Test
public void d01_stackTraceHashingTimeout() throws Exception {
@@ -432,10 +432,10 @@ public class RestResourceLoggingTest {
}
}
- static MockRest e1 = MockRest.build(E1.class, null);
- static MockRest e2 = MockRest.build(E2.class, null);
- static MockRest e3 = MockRest.build(E3.class, null);
- static MockRest e4 = MockRest.build(E4.class, null);
+ 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);
@Test
public void e01_noTrace() throws Exception {
@@ -538,9 +538,9 @@ public class RestResourceLoggingTest {
}
}
- static MockRest f1 = MockRest.build(F1.class, null);
- static MockRest f2 = MockRest.build(F2.class, null);
- static MockRest f3 = MockRest.build(F3.class, null);
+ static MockRest f1 = MockRest.build(F1.class);
+ static MockRest f2 = MockRest.build(F2.class);
+ static MockRest f3 = MockRest.build(F3.class);
@Test
public void f01_rules() throws Exception {
@@ -632,8 +632,8 @@ public class RestResourceLoggingTest {
return string(req.getCallLoggerConfig().getRules());
}
}
- static MockRest g1 = MockRest.build(G1.class, null);
- static MockRest g2 = MockRest.build(G2.class, null);
+ static MockRest g1 = MockRest.build(G1.class);
+ static MockRest g2 = MockRest.build(G2.class);
@Test
public void g01_rules() throws Exception {
@@ -672,7 +672,7 @@ public class RestResourceLoggingTest {
}
}
- static MockRest MY_REST = MockRest.build(MyRestClass.class, null);
+ static MockRest MY_REST = MockRest.build(MyRestClass.class);
@Test
public void test() throws Exception {
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 e0fd2e7..59d19ae 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
@@ -48,7 +48,7 @@ public class RestResourceMessagesTest {
return convertToMap(rb);
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01() throws Exception {
@@ -62,7 +62,7 @@ public class RestResourceMessagesTest {
@Rest(messages="RestResourceMessagesTest2")
public static class B extends A {}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.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 3089969..bbff5ae 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
@@ -53,7 +53,7 @@ public class RestResourcePathTest {
@Rest(path="/p2")
public static class A02 extends A02a {}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.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/RestResourceTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/RestResourceTest.java
index bd9c6ef..530efc8 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
@@ -50,10 +50,10 @@ public class RestResourceTest {
@Rest(allowBodyParam="true")
public static class A4 extends A2 {}
- static MockRest a1 = MockRest.build(A1.class, null);
- static MockRest a2 = MockRest.build(A2.class, null);
- static MockRest a3 = MockRest.build(A3.class, null);
- static MockRest a4 = MockRest.build(A4.class, null);
+ 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);
@Test
public void a01_allowBodyParam_true() throws Exception {
@@ -114,14 +114,14 @@ public class RestResourceTest {
@Rest(allowedHeaderParams="None")
public static class B8 extends B5 {}
- static MockRest b1 = MockRest.build(B1.class, null);
- static MockRest b2 = MockRest.build(B2.class, null);
- static MockRest b3 = MockRest.build(B3.class, null);
- static MockRest b4 = MockRest.build(B4.class, null);
- static MockRest b5 = MockRest.build(B5.class, null);
- static MockRest b6 = MockRest.build(B6.class, null);
- static MockRest b7 = MockRest.build(B7.class, null);
- static MockRest b8 = MockRest.build(B8.class, null);
+ 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);
@Test
public void b01_allowedHeaderParams_default() throws Exception {
@@ -222,14 +222,14 @@ public class RestResourceTest {
@Rest(allowedMethodHeaders="None")
public static class C8 extends C5 {}
- static MockRest c1 = MockRest.build(C1.class, null);
- static MockRest c2 = MockRest.build(C2.class, null);
- static MockRest c3 = MockRest.build(C3.class, null);
- static MockRest c4 = MockRest.build(C4.class, null);
- static MockRest c5 = MockRest.build(C5.class, null);
- static MockRest c6 = MockRest.build(C6.class, null);
- static MockRest c7 = MockRest.build(C7.class, null);
- static MockRest c8 = MockRest.build(C8.class, null);
+ 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);
@Test
public void c01_allowedMethodHeaders_default() throws Exception {
@@ -366,14 +366,14 @@ public class RestResourceTest {
@Rest(allowedMethodParams="None")
public static class D8 extends D5 {}
- static MockRest d1 = MockRest.build(D1.class, null);
- static MockRest d2 = MockRest.build(D2.class, null);
- static MockRest d3 = MockRest.build(D3.class, null);
- static MockRest d4 = MockRest.build(D4.class, null);
- static MockRest d5 = MockRest.build(D5.class, null);
- static MockRest d6 = MockRest.build(D6.class, null);
- static MockRest d7 = MockRest.build(D7.class, null);
- static MockRest d8 = MockRest.build(D8.class, null);
+ 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);
@Test
public void d01_allowedMethodHeaders_default() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/BodyAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/BodyAnnotationTest.java
index e6f56e1..e3e41a6 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/BodyAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/BodyAnnotationTest.java
@@ -131,7 +131,7 @@ public class BodyAnnotationTest {
@Override public String toString() { return s; }
}
}
- private static MockRest a = MockRest.build(A.class, null);
+ private static MockRest a = MockRest.build(A.class);
@Test
public void a01a_onParameter_String() throws Exception {
@@ -321,7 +321,7 @@ public class BodyAnnotationTest {
@Override public String toString() { return s; }
}
}
- private static MockRest b = MockRest.build(B.class, null);
+ private static MockRest b = MockRest.build(B.class);
@Test
public void b01a_onPojo_StringTransform() throws Exception {
@@ -540,7 +540,7 @@ public class BodyAnnotationTest {
@Override public String toString() { return s; }
}
}
- private static MockRest d = MockRest.build(D.class, null);
+ private static MockRest d = MockRest.build(D.class);
@Test
public void d01a_noMediaTypes_String() throws Exception {
@@ -908,7 +908,7 @@ public class BodyAnnotationTest {
return body;
}
}
- static MockRest j = MockRest.create(J.class).json().build();;
+ static MockRest j = MockRest.buildJson(J.class);
@Test
public void j01_optionalParam_integer() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/FormDataAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/FormDataAnnotationTest.java
index 8ae66af..2171fce 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/FormDataAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/FormDataAnnotationTest.java
@@ -48,7 +48,7 @@ public class FormDataAnnotationTest {
return "p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", String.class)+"],p2=["+p2+","+req.getFormData().getString("p2")+","+f.get("p2", int.class)+"]";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01() throws Exception {
@@ -83,7 +83,7 @@ public class FormDataAnnotationTest {
return "p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", String.class)+"]";
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01() throws Exception {
@@ -131,7 +131,7 @@ public class FormDataAnnotationTest {
.append("f3", f3);
}
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01_defaultFormData() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasFormDataAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasFormDataAnnotationTest.java
index c5646ed..2b2ec98 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasFormDataAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasFormDataAnnotationTest.java
@@ -38,7 +38,7 @@ public class HasFormDataAnnotationTest {
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_post() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasQueryAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasQueryAnnotationTest.java
index 57a4846..17c243a 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasQueryAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HasQueryAnnotationTest.java
@@ -44,7 +44,7 @@ public class HasQueryAnnotationTest {
return "p1=["+p1+","+q.containsKey("p1")+"],p2=["+p2+","+q.containsKey("p2")+"]";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_get() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HeaderAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HeaderAnnotationTest.java
index b8c4586..7e82931 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HeaderAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/HeaderAnnotationTest.java
@@ -60,7 +60,7 @@ public class HeaderAnnotationTest {
return f1;
}
}
- static MockRest a = MockRest.create(A.class).json().build();
+ static MockRest a = MockRest.buildJson(A.class);
@Test
public void a01_optionalParam_integer() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathAnnotationTest.java
index efbc375..dba6d1e 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathAnnotationTest.java
@@ -64,7 +64,7 @@ public class PathAnnotationTest {
return "GET /a "+foo+","+bar+",r="+remainder;
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a00_nonExistentPath() throws Exception {
@@ -140,7 +140,7 @@ public class PathAnnotationTest {
return String.valueOf(x);
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_int() throws Exception {
@@ -222,7 +222,7 @@ public class PathAnnotationTest {
return String.valueOf(x);
}
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01_Integer() throws Exception {
@@ -277,7 +277,7 @@ public class PathAnnotationTest {
return uuid;
}
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Test
public void d01_uuid() throws Exception {
@@ -312,7 +312,7 @@ public class PathAnnotationTest {
return new ObjectMap().append("m","numbers3").append("0", foo).append("1", bar);
}
}
- static MockRest e = MockRest.build(E.class, null);
+ static MockRest e = MockRest.build(E.class);
@Test
public void e01_normal1() throws Exception {
@@ -704,7 +704,7 @@ public class PathAnnotationTest {
return f1;
}
}
- static MockRest j = MockRest.create(J.class).json().build();
+ static MockRest j = MockRest.buildJson(J.class);
@Test
public void j01_optionalParam_integer() throws Exception {
@@ -1124,8 +1124,8 @@ public class PathAnnotationTest {
}
}
- static MockRest u1 = MockRest.build(U1.class, null);
- static MockRest u2 = MockRest.build(U2.class, null);
+ static MockRest u1 = MockRest.build(U1.class);
+ static MockRest u2 = MockRest.build(U2.class);
@Test
public void u01_nonRequiredPath() throws Exception {
@@ -1154,8 +1154,8 @@ public class PathAnnotationTest {
}
}
- static MockRest v1 = MockRest.build(V1.class, null);
- static MockRest v2 = MockRest.build(V2.class, null);
+ static MockRest v1 = MockRest.build(V1.class);
+ static MockRest v2 = MockRest.build(V2.class);
@Test
public void v01_multiplePaths() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathRemainderAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathRemainderAnnotationTest.java
index 0a61493..5ab895d 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathRemainderAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/PathRemainderAnnotationTest.java
@@ -43,7 +43,7 @@ public class PathRemainderAnnotationTest {
return remainder;
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_withoutRemainder() throws Exception {
@@ -84,7 +84,7 @@ public class PathRemainderAnnotationTest {
return f1;
}
}
- static MockRest b = MockRest.create(B.class).json().build();
+ static MockRest b = MockRest.buildJson(B.class);
@Test
public void b01_optionalParam_integer() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/QueryAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/QueryAnnotationTest.java
index fd9ff75..b605da0 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/QueryAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/QueryAnnotationTest.java
@@ -53,7 +53,7 @@ public class QueryAnnotationTest {
return "p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_get() throws Exception {
@@ -113,7 +113,7 @@ public class QueryAnnotationTest {
return "p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"]";
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_get1() throws Exception {
@@ -241,7 +241,7 @@ public class QueryAnnotationTest {
.append("f3", f3);
}
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Test
public void d01_defaultQuery() throws Exception {
@@ -293,7 +293,7 @@ public class QueryAnnotationTest {
return f1;
}
}
- static MockRest e = MockRest.create(E.class).json().build();
+ static MockRest e = MockRest.buildJson(E.class);
@Test
public void e01_optionalParam_integer() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/ResponseAnnotationTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/ResponseAnnotationTest.java
index ae4aa5b..8020795 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/ResponseAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/ResponseAnnotationTest.java
@@ -70,7 +70,7 @@ public class ResponseAnnotationTest {
public String toString() {return "foo";}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_codeOnClass() throws Exception {
@@ -123,7 +123,7 @@ public class ResponseAnnotationTest {
public String toString() {return "foo";}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_useOnMethod() throws Exception {
@@ -214,7 +214,7 @@ public class ResponseAnnotationTest {
}
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Test
public void d01_useOnMethod() throws Exception {
@@ -285,7 +285,7 @@ public class ResponseAnnotationTest {
public String toString() {return "foo";}
}
- static MockRest e = MockRest.build(E.class, null);
+ static MockRest e = MockRest.build(E.class);
@Test
public void e01_basic_onParameter() throws Exception {
@@ -337,7 +337,7 @@ public class ResponseAnnotationTest {
}
}
- static MockRest f = MockRest.build(F.class, null);
+ static MockRest f = MockRest.build(F.class);
static Swagger sf = getSwagger(F.class);
@Test
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestHookTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestHookTest.java
index ebeacc2..90bcdca 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestHookTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestHookTest.java
@@ -83,7 +83,7 @@ public class RestHookTest {
return req.getBody().asType(String.class);
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
public static class A01 extends ReaderParser {
public A01(PropertyStore ps) {
@@ -163,7 +163,7 @@ public class RestHookTest {
return null;
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
public static class B01 extends WriterSerializer {
public B01(PropertyStore ps) {
@@ -218,7 +218,7 @@ public class RestHookTest {
@Rest(children={C_Super.class,C_Sub.class})
public static class C {}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Rest(path="/super")
public static class C_Super {
@@ -293,7 +293,7 @@ public class RestHookTest {
//====================================================================================================
@Rest(children={D_Super.class,D_Sub.class})
public static class D {}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Rest(path="/super")
public static class D_Super {
@@ -391,7 +391,7 @@ public class RestHookTest {
}
)
public static class E {}
- static MockRest e = MockRest.build(E.class, null);
+ static MockRest e = MockRest.build(E.class);
@Rest(path="/super")
public static class E_Super {
@@ -506,7 +506,7 @@ public class RestHookTest {
.append("4", res.getHeader("start4-called"));
}
}
- static MockRest f = MockRest.build(F.class, null);
+ static MockRest f = MockRest.build(F.class);
public static class F_Parent {
private boolean start1Called;
@@ -557,7 +557,7 @@ public class RestHookTest {
.append("4", res.getHeader("pre4-called"));
}
}
- static MockRest g = MockRest.build(G.class, null);
+ static MockRest g = MockRest.build(G.class);
public static class G_Parent {
private boolean pre1Called;
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestMethodInheritTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestMethodInheritTest.java
index d7b745c..e2e88ae 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestMethodInheritTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestMethodInheritTest.java
@@ -154,7 +154,7 @@ public class RestMethodInheritTest {
return new ObjectList(res.getSupportedMediaTypes());
}
}
- static MockRest a = MockRest.build(A02.class, null);
+ static MockRest a = MockRest.build(A02.class);
@Test
public void a01_serializers_default() throws Exception {
@@ -197,7 +197,7 @@ public class RestMethodInheritTest {
return new ObjectList(req.getConsumes());
}
}
- static MockRest b = MockRest.build(B02.class, null);
+ static MockRest b = MockRest.build(B02.class);
@Test
public void b01_parsers_default() throws Exception {
@@ -307,7 +307,7 @@ public class RestMethodInheritTest {
return m;
}
}
- static MockRest e = MockRest.build(E02.class, null);
+ static MockRest e = MockRest.build(E02.class);
@Test
public void e01_properties_default() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourceParsersTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourceParsersTest.java
index 89cd016..00c68e1 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourceParsersTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourceParsersTest.java
@@ -128,7 +128,7 @@ public class RestResourceParsersTest {
return in;
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_parserOnClass() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RoleGuardTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RoleGuardTest.java
index 792ed90..b486846 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RoleGuardTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RoleGuardTest.java
@@ -35,7 +35,7 @@ public class RoleGuardTest {
return "OK";
}
}
- static MockRest a1 = MockRest.build(A1.class, null);
+ static MockRest a1 = MockRest.build(A1.class);
@Test
public void a01a_onClass_simple_pass() throws Exception {
@@ -62,7 +62,7 @@ public class RoleGuardTest {
return "OK";
}
}
- static MockRest a2 = MockRest.build(A2.class, null);
+ static MockRest a2 = MockRest.build(A2.class);
@Test
public void a02a_onMethod_simple_pass() throws Exception {
@@ -89,7 +89,7 @@ public class RoleGuardTest {
return "OK";
}
}
- static MockRest a3 = MockRest.build(A3.class, null);
+ static MockRest a3 = MockRest.build(A3.class);
@Test
public void a03a_onBoth_simple_pass() throws Exception {
@@ -128,7 +128,7 @@ public class RoleGuardTest {
}
}
- static MockRest a4 = MockRest.build(A4b.class, null);
+ static MockRest a4 = MockRest.build(A4b.class);
@Test
public void a04a_inheritence_simple_pass() throws Exception {
@@ -185,14 +185,14 @@ public class RoleGuardTest {
@Rest(roleGuard="foo || (bar && baz)")
public static class B1h extends B1 {}
- static MockRest b1a = MockRest.build(B1a.class, null);
- static MockRest b1b = MockRest.build(B1b.class, null);
- static MockRest b1c = MockRest.build(B1c.class, null);
- static MockRest b1d = MockRest.build(B1d.class, null);
- static MockRest b1e = MockRest.build(B1e.class, null);
- static MockRest b1f = MockRest.build(B1f.class, null);
- static MockRest b1g = MockRest.build(B1g.class, null);
- static MockRest b1h = MockRest.build(B1h.class, null);
+ static MockRest b1a = MockRest.build(B1a.class);
+ static MockRest b1b = MockRest.build(B1b.class);
+ static MockRest b1c = MockRest.build(B1c.class);
+ static MockRest b1d = MockRest.build(B1d.class);
+ static MockRest b1e = MockRest.build(B1e.class);
+ static MockRest b1f = MockRest.build(B1f.class);
+ static MockRest b1g = MockRest.build(B1g.class);
+ static MockRest b1h = MockRest.build(B1h.class);
@Test
public void b01a_orsWithComma_pass() throws Exception {
@@ -391,14 +391,14 @@ public class RoleGuardTest {
}
}
- static MockRest b2a = MockRest.build(B2a.class, null);
- static MockRest b2b = MockRest.build(B2b.class, null);
- static MockRest b2c = MockRest.build(B2c.class, null);
- static MockRest b2d = MockRest.build(B2d.class, null);
- static MockRest b2e = MockRest.build(B2e.class, null);
- static MockRest b2f = MockRest.build(B2f.class, null);
- static MockRest b2g = MockRest.build(B2g.class, null);
- static MockRest b2h = MockRest.build(B2h.class, null);
+ static MockRest b2a = MockRest.build(B2a.class);
+ static MockRest b2b = MockRest.build(B2b.class);
+ static MockRest b2c = MockRest.build(B2c.class);
+ static MockRest b2d = MockRest.build(B2d.class);
+ static MockRest b2e = MockRest.build(B2e.class);
+ static MockRest b2f = MockRest.build(B2f.class);
+ static MockRest b2g = MockRest.build(B2g.class);
+ static MockRest b2h = MockRest.build(B2h.class);
@Test
public void b02a_orsWithComma_pass() throws Exception {
@@ -565,14 +565,14 @@ public class RoleGuardTest {
@Rest(roleGuard="fo* || (*ar && *az)")
public static class C1h extends C1 {}
- static MockRest c1a = MockRest.build(C1a.class, null);
- static MockRest c1b = MockRest.build(C1b.class, null);
- static MockRest c1c = MockRest.build(C1c.class, null);
- static MockRest c1d = MockRest.build(C1d.class, null);
- static MockRest c1e = MockRest.build(C1e.class, null);
- static MockRest c1f = MockRest.build(C1f.class, null);
- static MockRest c1g = MockRest.build(C1g.class, null);
- static MockRest c1h = MockRest.build(C1h.class, null);
+ static MockRest c1a = MockRest.build(C1a.class);
+ static MockRest c1b = MockRest.build(C1b.class);
+ static MockRest c1c = MockRest.build(C1c.class);
+ static MockRest c1d = MockRest.build(C1d.class);
+ static MockRest c1e = MockRest.build(C1e.class);
+ static MockRest c1f = MockRest.build(C1f.class);
+ static MockRest c1g = MockRest.build(C1g.class);
+ static MockRest c1h = MockRest.build(C1h.class);
@Test
public void c01a_orPatternsWithComma_pass() throws Exception {
@@ -771,14 +771,14 @@ public class RoleGuardTest {
}
}
- static MockRest c2a = MockRest.build(C2a.class, null);
- static MockRest c2b = MockRest.build(C2b.class, null);
- static MockRest c2c = MockRest.build(C2c.class, null);
- static MockRest c2d = MockRest.build(C2d.class, null);
- static MockRest c2e = MockRest.build(C2e.class, null);
- static MockRest c2f = MockRest.build(C2f.class, null);
- static MockRest c2g = MockRest.build(C2g.class, null);
- static MockRest c2h = MockRest.build(C2h.class, null);
+ static MockRest c2a = MockRest.build(C2a.class);
+ static MockRest c2b = MockRest.build(C2b.class);
+ static MockRest c2c = MockRest.build(C2c.class);
+ static MockRest c2d = MockRest.build(C2d.class);
+ static MockRest c2e = MockRest.build(C2e.class);
+ static MockRest c2f = MockRest.build(C2f.class);
+ static MockRest c2g = MockRest.build(C2g.class);
+ static MockRest c2h = MockRest.build(C2h.class);
@Test
public void c02a_orPatternsWithComma_pass() throws Exception {
@@ -921,7 +921,7 @@ public class RoleGuardTest {
}
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Test
public void d01_patternsWithoutRoles_fail() throws Exception {
@@ -945,7 +945,7 @@ public class RoleGuardTest {
}
}
- static MockRest e = MockRest.build(E.class, null);
+ static MockRest e = MockRest.build(E.class);
@Test
public void e01_anyRole_pass() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java
index d5a8a53..1eef245 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java
@@ -70,7 +70,7 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates(); }
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_badRequest() throws Exception {
@@ -246,7 +246,7 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates("foo {0}", "bar"); }
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_badRequest() throws Exception {
@@ -424,7 +424,7 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates(t); }
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01_badRequest() throws Exception {
@@ -600,7 +600,7 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates(t, "foo {0}", "bar"); }
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Test
public void d01_badRequest() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
index 5e23957..0bb2b74 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
@@ -53,7 +53,7 @@ public class AcceptEncodingTest {
return "foo";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_noCompression() throws Exception {
@@ -124,7 +124,7 @@ public class AcceptEncodingTest {
return "foo";
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_withCompression_identity() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
index 5f3ba03..b275f79 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
@@ -71,7 +71,7 @@ public class AcceptTest {
return in;
}
}
- private static MockRest a = MockRest.build(A.class, null);
+ private static MockRest a = MockRest.build(A.class);
@Test
public void a01_defaultHeadersOnServletAnnotation_valid() throws Exception {
@@ -100,7 +100,7 @@ public class AcceptTest {
return in;
}
}
- private static MockRest b = MockRest.build(B.class, null);
+ private static MockRest b = MockRest.build(B.class);
@Test
public void b01_restMethodWithParsersSerializers_valid() throws Exception {
@@ -132,7 +132,7 @@ public class AcceptTest {
return in;
}
}
- private static MockRest c = MockRest.build(C.class, null);
+ private static MockRest c = MockRest.build(C.class);
@Test
public void c01_restMethodAddParsersSerializersInherit() throws Exception {
@@ -166,7 +166,7 @@ public class AcceptTest {
return in;
}
}
- private static MockRest d = MockRest.build(D.class, null);
+ private static MockRest d = MockRest.build(D.class);
@Test
public void d01_accept_valid() throws Exception {
@@ -204,7 +204,7 @@ public class AcceptTest {
return in;
}
}
- private static MockRest e = MockRest.build(E.class, null);
+ private static MockRest e = MockRest.build(E.class);
@Test
public void e01_restMethodParserSerializerAnnotations_valid() throws Exception {
@@ -242,7 +242,7 @@ public class AcceptTest {
return in;
}
}
- private static MockRest f = MockRest.build(F.class, null);
+ private static MockRest f = MockRest.build(F.class);
@Test
public void f01_restMethodAddParsersSerializersAnnotations_valid() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ClientVersionTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ClientVersionTest.java
index bceefb9..f265479 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ClientVersionTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ClientVersionTest.java
@@ -53,7 +53,7 @@ public class ClientVersionTest {
return "2";
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_defaultHeader() throws Exception {
@@ -96,7 +96,7 @@ public class ClientVersionTest {
return "2";
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_testCustomHeader() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java
index 7e73e3b..a8481eb 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java
@@ -51,7 +51,7 @@ public class ContentEncodingTest {
return in;
}
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_noCompression() throws Exception {
@@ -80,7 +80,7 @@ public class ContentEncodingTest {
return in;
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_withCompression_identity() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
index 95ea2b7..1daac40 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
@@ -73,7 +73,7 @@ public class ContentTypeTest {
return in;
}
}
- private static MockRest a = MockRest.build(A.class, null);
+ private static MockRest a = MockRest.build(A.class);
@Test
public void a01_defaultHeadersOnServletAnnotation_valid() throws Exception {
@@ -102,7 +102,7 @@ public class ContentTypeTest {
return in;
}
}
- private static MockRest b = MockRest.build(B.class, null);
+ private static MockRest b = MockRest.build(B.class);
@Test
public void b01_restMethodWithParsersSerializers_valid() throws Exception {
@@ -146,7 +146,7 @@ public class ContentTypeTest {
return in;
}
}
- private static MockRest c = MockRest.build(C.class, null);
+ private static MockRest c = MockRest.build(C.class);
@Test
public void c01_restMethodAddParsersSerializersInherit() throws Exception {
@@ -181,7 +181,7 @@ public class ContentTypeTest {
return in;
}
}
- private static MockRest e = MockRest.build(E.class, null);
+ private static MockRest e = MockRest.build(E.class);
@Test
public void e01_restMethodParserSerializerAnnotations_valid() throws Exception {
@@ -220,7 +220,7 @@ public class ContentTypeTest {
}
}
- private static MockRest f = MockRest.build(F.class, null);
+ private static MockRest f = MockRest.build(F.class);
@Test
public void f01_restMethodAddParsersSerializersAnnotations_valid() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java
index e30085d..d2adfb7 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java
@@ -421,7 +421,7 @@ public class HeadersTest {
return customHeader.toString();
}
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
public static class CustomHeaderParam extends RestMethodParam {
public CustomHeaderParam() {
@@ -467,7 +467,7 @@ public class HeadersTest {
.append("h3", headers.getString("H3"));
}
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01_reqHeaders_default() throws Exception {
@@ -496,7 +496,7 @@ public class HeadersTest {
.append("h3", headers.getString("h3"));
}
}
- static MockRest d = MockRest.build(D.class, null);
+ static MockRest d = MockRest.build(D.class);
@Test
public void d01_reqHeadersCaseInsensitive_default() throws Exception {
@@ -525,7 +525,7 @@ public class HeadersTest {
.append("h3", h3);
}
}
- static MockRest e = MockRest.build(E.class, null);
+ static MockRest e = MockRest.build(E.class);
@Test
public void e01_annotatedHeaders_default() throws Exception {
@@ -554,7 +554,7 @@ public class HeadersTest {
.append("h3", h3);
}
}
- static MockRest f = MockRest.build(F.class, null);
+ static MockRest f = MockRest.build(F.class);
@Test
public void f01_annotatedHeadersCaseInsensitive_default() throws Exception {
@@ -583,7 +583,7 @@ public class HeadersTest {
.append("h3", h3);
}
}
- static MockRest g = MockRest.build(G.class, null);
+ static MockRest g = MockRest.build(G.class);
@Test
public void g01_annotatedHeadersDefault_default() throws Exception {
@@ -608,7 +608,7 @@ public class HeadersTest {
.append("h3", h3);
}
}
- static MockRest gb = MockRest.build(GB.class, null);
+ static MockRest gb = MockRest.build(GB.class);
@Test
public void gb01_annotatedHeadersDefault_default() throws Exception {
@@ -637,7 +637,7 @@ public class HeadersTest {
.append("h3", h3);
}
}
- static MockRest h = MockRest.build(H.class, null);
+ static MockRest h = MockRest.build(H.class);
@Test
public void h01_annotatedAndDefaultHeaders_default() throws Exception {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/responses/BasicTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/responses/BasicTest.java
index 4ee3fa8..decf77d 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/responses/BasicTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/responses/BasicTest.java
@@ -60,7 +60,7 @@ public class BasicTest {
@RestMethod public UseProxy useProxy() { return new UseProxy(); }
}
- static MockRest a = MockRest.build(A.class, null);
+ static MockRest a = MockRest.build(A.class);
@Test
public void a01_accepted() throws Exception {
@@ -163,7 +163,7 @@ public class BasicTest {
@RestMethod public TemporaryRedirect temporaryRedirect() { return new TemporaryRedirect(URI.create("servlet:/foo")); }
}
- static MockRest b = MockRest.build(B.class, null);
+ static MockRest b = MockRest.build(B.class);
@Test
public void b01_movedPermanently() throws Exception {
@@ -212,7 +212,7 @@ public class BasicTest {
@RestMethod public UseProxy useProxy() { return new UseProxy("foo"); }
}
- static MockRest c = MockRest.build(C.class, null);
+ static MockRest c = MockRest.build(C.class);
@Test
public void c01_accepted() throws Exception {