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 2017/09/08 23:28:22 UTC
[29/33] incubator-juneau git commit: Microservice should be in it's
own group.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
new file mode 100644
index 0000000..2595768
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
@@ -0,0 +1,111 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import java.io.*;
+
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+public class GzipResource {
+
+ //================================================================================
+ // Encoder for "myencoding" encoding
+ //================================================================================
+ public static class MyEncoder extends GzipEncoder {
+ @Override /* Encoder */
+ public String[] getCodings() {
+ return new String[]{"mycoding"};
+ }
+ }
+
+ //====================================================================================================
+ // Test with no compression enabled.
+ //====================================================================================================
+ @RestResource(
+ path="/testGzipOff",
+ serializers=PlainTextSerializer.class,
+ parsers=PlainTextParser.class
+ )
+ public static class TestGzipOff extends RestServlet {
+ private static final long serialVersionUID = 1L;
+ @RestMethod(name="GET", path="/")
+ public String test1get() {
+ return "foo";
+ }
+ @RestMethod(name="PUT", path="/")
+ public String test1put(@Body String in) {
+ return in;
+ }
+ }
+
+ //====================================================================================================
+ // Test with compression enabled.
+ //====================================================================================================
+ @RestResource(
+ path="/testGzipOn",
+ serializers=PlainTextSerializer.class,
+ parsers=PlainTextParser.class,
+ encoders=MyEncoder.class
+ )
+ public static class TestGzipOn extends RestServlet {
+ private static final long serialVersionUID = 1L;
+ @RestMethod(name="GET", path="/")
+ public String test1() {
+ return "foo";
+ }
+ @RestMethod(name="PUT", path="/")
+ public String test1put(@Body String in) {
+ return in;
+ }
+ // This method bypasses the content type and encoding from
+ // the serializers and encoders when calling getOutputStream() directly.
+ @RestMethod(name="GET", path="/direct")
+ public void direct(RestResponse res) throws Exception {
+ res.setContentType("text/direct");
+ OutputStream os = res.getOutputStream();
+ os.write("test".getBytes());
+ os.flush();
+ }
+
+ // This method bypasses the content type and encoding from
+ // the serializers and encoders when calling getWriter() directly.
+ @RestMethod(name="GET", path="/direct2")
+ public void direct2(RestResponse res) throws Exception {
+ Writer w = res.getWriter();
+ w.append("test");
+ w.flush();
+ }
+
+ // This method uses getNegotiatedWriter() which should use GZip encoding.
+ @RestMethod(name="GET", path="/direct3")
+ public void direct3(RestResponse res) throws Exception {
+ Writer w = res.getNegotiatedWriter();
+ w.append("test");
+ w.flush();
+ }
+
+ // This method overrides the set of encoders at the method level and so shouldn't use GZip encoding.
+ @RestMethod(name="GET", path="/direct4", inheritEncoders=false)
+ public void direct4(RestResponse res) throws Exception {
+ Writer w = res.getNegotiatedWriter();
+ w.append("test");
+ w.flush();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
new file mode 100644
index 0000000..8af0fd3
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
@@ -0,0 +1,243 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testHeaders",
+ serializers=HeadersResource.PlainTextAnythingSerializer.class,
+ parsers=HeadersResource.PlainTextAnythingParser.class,
+ encoders=HeadersResource.IdentityAnythingEncoder.class,
+ paramResolvers=HeadersResource.CustomHeaderParam.class
+)
+public class HeadersResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // HTTP 1.1 headers
+ //====================================================================================================
+
+ @RestMethod(name="GET", path="/accept")
+ public String accept(Accept accept) {
+ return accept.toString();
+ }
+ @RestMethod(name="GET", path="/acceptCharset")
+ public String acceptCharset(AcceptCharset acceptCharset) {
+ return acceptCharset.toString();
+ }
+ @RestMethod(name="GET", path="/acceptEncoding")
+ public String acceptEncoding(AcceptEncoding acceptEncoding) {
+ return acceptEncoding.toString();
+ }
+ @RestMethod(name="GET", path="/acceptLanguage")
+ public String acceptLanguage(AcceptLanguage acceptLanguage) {
+ return acceptLanguage.toString();
+ }
+ @RestMethod(name="GET", path="/authorization")
+ public String authorization(Authorization authorization) {
+ return authorization.toString();
+ }
+ @RestMethod(name="GET", path="/cacheControl")
+ public String cacheControl(CacheControl cacheControl) {
+ return cacheControl.toString();
+ }
+ @RestMethod(name="GET", path="/connection")
+ public String connection(Connection connection) {
+ return connection.toString();
+ }
+ @RestMethod(name="GET", path="/contentLength")
+ public String contentLength(ContentLength contentLength) {
+ return contentLength.toString();
+ }
+ @RestMethod(name="GET", path="/contentType")
+ public String contentType(ContentType contentType) {
+ return contentType.toString();
+ }
+ @RestMethod(name="GET", path="/date")
+ public String date(org.apache.juneau.http.Date date) {
+ return date.toString();
+ }
+ @RestMethod(name="GET", path="/expect")
+ public String expect(Expect expect) {
+ return expect.toString();
+ }
+ @RestMethod(name="GET", path="/from")
+ public String from(From from) {
+ return from.toString();
+ }
+ @RestMethod(name="GET", path="/host")
+ public String host(Host host) {
+ return host.toString();
+ }
+ @RestMethod(name="GET", path="/ifMatch")
+ public String IfMatch(IfMatch ifMatch) {
+ return ifMatch.toString();
+ }
+ @RestMethod(name="GET", path="/ifModifiedSince")
+ public String ifModifiedSince(IfModifiedSince ifModifiedSince) {
+ return ifModifiedSince.toString();
+ }
+ @RestMethod(name="GET", path="/ifNoneMatch")
+ public String ifNoneMatch(IfNoneMatch ifNoneMatch) {
+ return ifNoneMatch.toString();
+ }
+ @RestMethod(name="GET", path="/ifRange")
+ public String ifRange(IfRange ifRange) {
+ return ifRange.toString();
+ }
+ @RestMethod(name="GET", path="/ifUnmodifiedSince")
+ public String ifUnmodifiedSince(IfUnmodifiedSince ifUnmodifiedSince) {
+ return ifUnmodifiedSince.toString();
+ }
+ @RestMethod(name="GET", path="/maxForwards")
+ public String maxForwards(MaxForwards maxForwards) {
+ return maxForwards.toString();
+ }
+ @RestMethod(name="GET", path="/pragma")
+ public String pragma(Pragma pragma) {
+ return pragma.toString();
+ }
+ @RestMethod(name="GET", path="/proxyAuthorization")
+ public String proxyAuthorization(ProxyAuthorization proxyAuthorization) {
+ return proxyAuthorization.toString();
+ }
+ @RestMethod(name="GET", path="/range")
+ public String range(Range range) {
+ return range.toString();
+ }
+ @RestMethod(name="GET", path="/referer")
+ public String referer(Referer referer) {
+ return referer.toString();
+ }
+ @RestMethod(name="GET", path="/te")
+ public String te(TE te) {
+ return te.toString();
+ }
+ @RestMethod(name="GET", path="/upgrade")
+ public String upgrade(Upgrade upgrade) {
+ return upgrade.toString();
+ }
+ @RestMethod(name="GET", path="/userAgent")
+ public String userAgent(UserAgent userAgent) {
+ return userAgent.toString();
+ }
+ @RestMethod(name="GET", path="/warning")
+ public String warning(Warning warning) {
+ return warning.toString();
+ }
+ @RestMethod(name="GET", path="/customHeader")
+ public String customHeader(CustomHeader customHeader) {
+ return customHeader.toString();
+ }
+
+ public static class CustomHeaderParam extends RestParam {
+ public CustomHeaderParam() {
+ super(RestParamType.HEADER, "Custom", CustomHeader.class);
+ }
+ @Override
+ public Object resolve(RestRequest req, RestResponse res) throws Exception {
+ return new CustomHeader(req.getHeader("Custom"));
+ }
+ }
+
+ public static class CustomHeader {
+ public String value;
+ public CustomHeader(String value) {
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ public static class PlainTextAnythingSerializer extends PlainTextSerializer {
+ public PlainTextAnythingSerializer(PropertyStore propertyStore) {
+ super(propertyStore, "text/plain", "*/*");
+ }
+ }
+
+ public static class PlainTextAnythingParser extends PlainTextParser {
+ public PlainTextAnythingParser(PropertyStore propertyStore) {
+ super(propertyStore, "*/*");
+ }
+ }
+
+ public static class IdentityAnythingEncoder extends IdentityEncoder {
+ @Override /* Encoder */
+ public String[] getCodings() {
+ return new String[]{"*"};
+ }
+ }
+
+ //====================================================================================================
+ // Default values.
+ //====================================================================================================
+
+ @RestMethod(name="GET", path="/defaultRequestHeaders", defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ public ObjectMap defaultRequestHeaders(RequestHeaders headers) {
+ return new ObjectMap()
+ .append("h1", headers.getString("H1"))
+ .append("h2", headers.getString("H2"))
+ .append("h3", headers.getString("H3"));
+ }
+
+ @RestMethod(name="GET", path="/defaultRequestHeadersCaseInsensitive", defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ public ObjectMap defaultRequestHeadersCaseInsensitive(RequestHeaders headers) {
+ return new ObjectMap()
+ .append("h1", headers.getString("h1"))
+ .append("h2", headers.getString("h2"))
+ .append("h3", headers.getString("h3"));
+ }
+
+ @RestMethod(name="GET", path="/annotatedHeaders")
+ public ObjectMap annotatedHeaders(@Header("H1") String h1, @Header("H2") String h2, @Header("H3") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+
+ @RestMethod(name="GET", path="/annotatedHeadersCaseInsensitive")
+ public ObjectMap annotatedHeadersCaseInsensitive(@Header("h1") String h1, @Header("h2") String h2, @Header("h3") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+
+ @RestMethod(name="GET", path="/annotatedHeadersDefault")
+ public ObjectMap annotatedHeadersDefault(@Header(value="h1",def="1") String h1, @Header(value="h2",def="2") String h2, @Header(value="h3",def="3") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+
+ @RestMethod(name="GET", path="/annotatedAndDefaultHeaders", defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ public ObjectMap annotatedAndDefaultHeaders(@Header(value="h1",def="4") String h1, @Header(value="h2",def="5") String h2, @Header(value="h3",def="6") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java
new file mode 100644
index 0000000..26e1b02
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java
@@ -0,0 +1,255 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * Validates inheritance on the @HtmlDoc.links() annotation.
+ */
+@RestResource(
+ path="/testHtmlDocLinks",
+ htmldoc=@HtmlDoc(
+ links={"links1a","links1b"}
+ ),
+ children={
+ HtmlDocLinksResource.HtmlDocLinksResource2.class
+ }
+)
+public class HtmlDocLinksResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test1")
+ public Object test1() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test2",
+ htmldoc=@HtmlDoc(
+ links={"links2a","links2b"}
+ )
+ )
+ public Object test2() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test3",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","links3a","links3b"}
+ )
+ )
+ public Object test3() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test4",
+ htmldoc=@HtmlDoc(
+ links={"links4a","INHERIT","links4b"}
+ )
+ )
+ public Object test4() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test5",
+ htmldoc=@HtmlDoc(
+ links={"links5a","links5b","INHERIT"}
+ )
+ )
+ public Object test5() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6a",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","[0]:links6a","[3]:links6b"}
+ )
+ )
+ public Object test6a() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6b",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links6a","[2]:links6b","INHERIT"}
+ )
+ )
+ public Object test6b() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6c",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links6a","[0]:links6b"}
+ )
+ )
+ public Object test6c() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6d",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","foo[0]:links6a","bar[3]:links6b"}
+ )
+ )
+ public Object test6d() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6e",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links6a","bar[2]:links6b","INHERIT"}
+ )
+ )
+ public Object test6e() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6f",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links6a","bar[0]:links6b"}
+ )
+ )
+ public Object test6f() {
+ return "OK";
+ }
+
+ @RestResource(
+ path="/testHtmlDocLinks2",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","links11a","links11b"}
+ )
+ )
+ public static class HtmlDocLinksResource2 extends HtmlDocLinksResource {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test11")
+ public Object test11() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test12",
+ htmldoc=@HtmlDoc(
+ links={"links12a","links12b"}
+ )
+ )
+ public Object test12() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test13",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","links13a","links13b"}
+ )
+ )
+ public Object test13() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test14",
+ htmldoc=@HtmlDoc(
+ links={"links14a","INHERIT","links14b"}
+ )
+ )
+ public Object test14() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test15",
+ htmldoc=@HtmlDoc(
+ links={"links15a","links15b","INHERIT"}
+ )
+ )
+ public Object test15() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16a",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","[0]:links16a","[3]:links16b"}
+ )
+ )
+ public Object test16a() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16b",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links16a","[2]:links16b","INHERIT"}
+ )
+ )
+ public Object test16b() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16c",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links16a","[0]:links16b"}
+ )
+ )
+ public Object test16c() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16d",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","foo[0]:links16a","bar[3]:links16b"}
+ )
+ )
+ public Object test16d() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16e",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links16a","bar[2]:links16b","INHERIT"}
+ )
+ )
+ public Object test16e() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16f",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links16a","bar[0]:links16b"}
+ )
+ )
+ public Object test16f() {
+ return "OK";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
new file mode 100644
index 0000000..45c398b
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
@@ -0,0 +1,186 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * Validates inheritance on the @HtmlDoc annotation.
+ */
+@RestResource(
+ path="/testHtmlDoc",
+ htmldoc=@HtmlDoc(
+ aside={"aside1a","aside1b","INHERIT"},
+ footer={"footer1a","footer1b"},
+ header={"header1a","header1b"},
+ nav={"nav1a","nav1b"},
+ script={"script1a","script1b"},
+ style={"style1a","style1b"},
+ stylesheet="stylesheet1"
+ ),
+ children={
+ HtmlDocResource.HtmlDocResource2.class
+ }
+)
+public class HtmlDocResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test1")
+ public Object test1() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test2",
+ htmldoc=@HtmlDoc(
+ aside={"aside2a","aside2b"},
+ footer={"footer2a","footer2b"},
+ header={"header2a","header2b"},
+ nav={"nav2a","nav2b"},
+ script={"script2a","script2b"},
+ style={"style2a","style2b"},
+ stylesheet="stylesheet2"
+ )
+ )
+ public Object test2() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test3",
+ htmldoc=@HtmlDoc(
+ aside={"INHERIT","aside3a","aside3b"},
+ footer={"INHERIT","footer3a","footer3b"},
+ header={"INHERIT","header3a","header3b"},
+ nav={"INHERIT","nav3a","nav3b"},
+ script={"INHERIT","script3a","script3b"},
+ style={"INHERIT","style3a","style3b"}
+ )
+ )
+ public Object test3() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test4",
+ htmldoc=@HtmlDoc(
+ aside={"aside4a","INHERIT","aside4b"},
+ footer={"footer4a","INHERIT","footer4b"},
+ header={"header4a","INHERIT","header4b"},
+ nav={"nav4a","INHERIT","nav4b"},
+ script={"script4a","INHERIT","script4b"},
+ style={"style4a","INHERIT","style4b"}
+ )
+ )
+ public Object test4() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test5",
+ htmldoc=@HtmlDoc(
+ aside={"aside5a","aside5b","INHERIT"},
+ footer={"footer5a","footer5b","INHERIT"},
+ header={"header5a","header5b","INHERIT"},
+ nav={"nav5a","nav5b","INHERIT"},
+ script={"script5a","script5b","INHERIT"},
+ style={"style5a","style5b","INHERIT"}
+ )
+ )
+ public Object test5() {
+ return "OK";
+ }
+
+ @RestResource(
+ path="/testHtmlDoc2",
+ htmldoc=@HtmlDoc(
+ aside={"INHERIT","aside11a","aside11b"},
+ footer={"footer11a","INHERIT","footer11b"},
+ header={"header11a","header11b","INHERIT"},
+ nav={"INHERIT","nav11a","nav11b"},
+ script={"script11a","script11b"},
+ style={"style11a","style11b"},
+ stylesheet="stylesheet11"
+ )
+ )
+ public static class HtmlDocResource2 extends HtmlDocResource {
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test11")
+ public Object test11() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test12",
+ htmldoc=@HtmlDoc(
+ aside={"aside12a","aside12b"},
+ footer={"footer12a","footer12b"},
+ header={"header12a","header12b"},
+ nav={"nav12a","nav12b"},
+ script={"script12a","script12b"},
+ style={"style12a","style12b"},
+ stylesheet="stylesheet12"
+ )
+ )
+ public Object test12() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test13",
+ htmldoc=@HtmlDoc(
+ aside={"INHERIT","aside13a","aside13b"},
+ footer={"INHERIT","footer13a","footer13b"},
+ header={"INHERIT","header13a","header13b"},
+ nav={"INHERIT","nav13a","nav13b"},
+ script={"INHERIT","script13a","script13b"},
+ style={"INHERIT","style13a","style13b"}
+ )
+ )
+ public Object test13() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test14",
+ htmldoc=@HtmlDoc(
+ aside={"aside14a","INHERIT","aside14b"},
+ footer={"footer14a","INHERIT","footer14b"},
+ header={"header14a","INHERIT","header14b"},
+ nav={"nav14a","INHERIT","nav14b"},
+ script={"script14a","INHERIT","script14b"},
+ style={"style14a","INHERIT","style14b"}
+ )
+ )
+ public Object test14() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test15",
+ htmldoc=@HtmlDoc(
+ aside={"aside15a","aside15b","INHERIT"},
+ footer={"footer15a","footer15b","INHERIT"},
+ header={"header15a","header15b","INHERIT"},
+ nav={"nav15a","nav15b","INHERIT"},
+ script={"script15a","script15b","INHERIT"},
+ style={"style15a","style15b","INHERIT"}
+ )
+ )
+ public Object test15() {
+ return "OK";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
new file mode 100644
index 0000000..72bb164
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
@@ -0,0 +1,328 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import static org.apache.juneau.rest.annotation.Inherit.*;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.annotation.Properties;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.transform.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testInheritance",
+ serializers={InheritanceResource.S1.class,InheritanceResource.S2.class},
+ parsers={InheritanceResource.P1.class,InheritanceResource.P2.class},
+ encoders={InheritanceResource.E1.class,InheritanceResource.E2.class},
+ pojoSwaps={InheritanceResource.F1Swap.class},
+ properties={@Property(name="p1",value="v1"), @Property(name="p2",value="v2")}
+)
+public class InheritanceResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @RestResource(
+ serializers={S3.class,S4.class},
+ parsers={P3.class,P4.class},
+ encoders={E3.class,E4.class},
+ pojoSwaps={F2Swap.class},
+ properties={@Property(name="p2",value="v2a"), @Property(name="p3",value="v3"), @Property(name="p4",value="v4")}
+ )
+ public static class Sub extends InheritanceResource {
+ private static final long serialVersionUID = 1L;
+ }
+
+ //====================================================================================================
+ // Test serializer inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceSerializers")
+ public static class TestSerializers extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['text/s3','text/s4','text/s1','text/s2']
+ @RestMethod(
+ name="GET",
+ path="/test1"
+ )
+ public Reader test1(RestResponse res) {
+ return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/s5']
+ @RestMethod(
+ name="GET",
+ path="/test2",
+ serializers=S5.class
+ )
+ public Reader test2(RestResponse res) {
+ return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/s5','text/s3','text/s4','text/s1','text/s2']
+ @RestMethod(
+ name="GET",
+ path="/test3",
+ serializers=S5.class,
+ serializersInherit=SERIALIZERS
+ )
+ public Reader test3(RestResponse res) {
+ return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
+ }
+ }
+
+ //====================================================================================================
+ // Test parser inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceParsers")
+ public static class TestParsers extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['text/p3','text/p4','text/p1','text/p2']
+ @RestMethod(
+ name="GET",
+ path="/test1"
+ )
+ public Reader test1(RestRequest req) {
+ return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/p5']
+ @RestMethod(
+ name="GET",
+ path="/test2",
+ parsers=P5.class
+ )
+ public Reader test2(RestRequest req) {
+ return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/p5','text/p3','text/p4','text/p1','text/p2']
+ @RestMethod(
+ name="GET",
+ path="/test3",
+ parsers=P5.class,
+ parsersInherit=PARSERS
+ )
+ public Reader test3(RestRequest req) {
+ return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
+ }
+ }
+
+ //====================================================================================================
+ // Test encoder inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceEncoders")
+ public static class TestEncoders extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['e3','e4','e1','e2','identity']
+ @RestMethod(name="GET", path="/test")
+ public Reader test(RestResponse res) throws RestServletException {
+ return new StringReader(new ObjectList(res.getSupportedEncodings()).toString());
+ }
+ }
+
+ //====================================================================================================
+ // Test filter inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceTransforms", serializers=JsonSerializer.Simple.class)
+ public static class TestTransforms extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['F1Swap','F2Swap','Foo3']
+ @RestMethod(name="GET", path="/test1")
+ public Object[] test1() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1Swap','F2Swap','F3Swap']
+ // Inherited serializer already has parent filters applied.
+ @RestMethod(name="GET", path="/test2", pojoSwaps=F3Swap.class)
+ public Object[] test2() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1Swap','F2Swap','F3Swap']
+ @RestMethod(name="GET", path="/test3", pojoSwaps=F3Swap.class, serializersInherit=TRANSFORMS)
+ public Object[] test3() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['Foo1','Foo2','F3Swap']
+ // Overriding serializer does not have parent filters applied.
+ @RestMethod(name="GET", path="/test4", serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class)
+ public Object[] test4() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1Swap','F2Swap','F3Swap']
+ // Overriding serializer does have parent filters applied.
+ @RestMethod(name="GET", path="/test5", serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class, serializersInherit=TRANSFORMS)
+ public Object[] test5() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+ }
+
+ //====================================================================================================
+ // Test properties inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceProperties", serializers=JsonSerializer.Simple.class)
+ public static class TestProperties extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}
+ @RestMethod(name="GET", path="/test1")
+ public ObjectMap test1(@Properties ObjectMap properties) {
+ return transform(properties);
+ }
+
+ // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'} when override is false.
+ // Should show {p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'} when override is true.
+ @RestMethod(name="GET", path="/test2",
+ properties={@Property(name="p4",value="v4a"), @Property(name="p5", value="v5")})
+ public ObjectMap test2(@Properties ObjectMap properties, @HasQuery("override") boolean override) {
+ if (override) {
+ properties.put("p1", "x");
+ properties.put("p2", "x");
+ properties.put("p3", "x");
+ properties.put("p4", "x");
+ properties.put("p5", "x");
+ }
+ return transform(properties);
+ }
+
+ private ObjectMap transform(ObjectMap properties) {
+ ObjectMap m = new ObjectMap();
+ for (Map.Entry<String,Object> e : properties.entrySet()) {
+ if (e.getKey().startsWith("p"))
+ m.put(e.getKey(), e.getValue());
+ }
+ return m;
+ }
+ }
+
+ public static class DummyParser extends ReaderParser {
+
+ public DummyParser(String...consumes) {
+ super(PropertyStore.create(), consumes);
+ }
+
+ @Override /* Parser */
+ public ReaderParserSession createSession(ParserSessionArgs args) {
+ return new ReaderParserSession(args) {
+
+ @Override /* ParserSession */
+ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
+ return null;
+ }
+ };
+ }
+ }
+
+ public static class DummySerializer extends WriterSerializer {
+
+ public DummySerializer(String produces) {
+ super(PropertyStore.create(), produces);
+ }
+
+ @Override /* Serializer */
+ public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ return new WriterSerializerSession(args) {
+
+ @Override /* SerializerSession */
+ protected void doSerialize(SerializerPipe out, Object o) throws Exception {
+ out.getWriter().write(o.toString());
+ }
+ };
+ }
+ }
+
+ public static class P1 extends DummyParser{ public P1(PropertyStore ps) {super("text/p1");} }
+
+ public static class P2 extends DummyParser{ public P2(PropertyStore ps) {super("text/p2");} }
+
+ public static class P3 extends DummyParser{ public P3(PropertyStore ps) {super("text/p3");} }
+
+ public static class P4 extends DummyParser{ public P4(PropertyStore ps) {super("text/p4");} }
+
+ public static class P5 extends DummyParser{ public P5(PropertyStore ps) {super("text/p5");} }
+
+ public static class S1 extends DummySerializer{ public S1(PropertyStore ps) {super("text/s1");} }
+
+ public static class S2 extends DummySerializer{ public S2(PropertyStore ps) {super("text/s2");} }
+
+ public static class S3 extends DummySerializer{ public S3(PropertyStore ps) {super("text/s3");} }
+
+ public static class S4 extends DummySerializer{ public S4(PropertyStore ps) {super("text/s4");} }
+
+ public static class S5 extends DummySerializer{ public S5(PropertyStore ps) {super("text/s5");} }
+
+ public static class E1 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e1"};
+ }
+ }
+
+ public static class E2 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e2"};
+ }
+ }
+
+ public static class E3 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e3"};
+ }
+ }
+
+ public static class E4 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e4"};
+ }
+ }
+
+ public static class Foo1 {@Override public String toString(){return "Foo1";}}
+ public static class Foo2 {@Override public String toString(){return "Foo2";}}
+ public static class Foo3 {@Override public String toString(){return "Foo3";}}
+
+ public static class F1Swap extends StringSwap<Foo1> {
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Foo1 o) throws SerializeException {
+ return "F1";
+ }
+ }
+
+ public static class F2Swap extends StringSwap<Foo2> {
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Foo2 o) throws SerializeException {
+ return "F2";
+ }
+ }
+
+ public static class F3Swap extends StringSwap<Foo3> {
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Foo3 o) throws SerializeException {
+ return "F3";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
new file mode 100644
index 0000000..b2af7a6
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
@@ -0,0 +1,191 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import java.util.*;
+
+import org.apache.juneau.remoteable.*;
+import org.apache.juneau.rest.test.pojos.*;
+
+/**
+ * Interface proxy exposed in InterfaceProxyResource and tested in InterfaceProxyTest.
+ */
+@Remoteable
+public interface InterfaceProxy {
+
+ public static final String SWAP = "swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/";
+
+ //--------------------------------------------------------------------------------
+ // Test return types.
+ //--------------------------------------------------------------------------------
+
+ // Various primitives
+ void returnVoid();
+ int returnInt();
+ Integer returnInteger();
+ boolean returnBoolean();
+ float returnFloat();
+ Float returnFloatObject();
+ String returnString();
+ String returnNullString();
+ int[][][] returnInt3dArray();
+ Integer[][][] returnInteger3dArray();
+ String[][][] returnString3dArray();
+ List<Integer> returnIntegerList();
+ List<List<List<Integer>>> returnInteger3dList();
+ List<Integer[][][]> returnInteger1d3dList();
+ List<int[][][]> returnInt1d3dList();
+ List<String> returnStringList();
+
+ // Beans
+ ABean returnBean();
+ ABean[][][] returnBean3dArray();
+ List<ABean> returnBeanList();
+ List<ABean[][][]> returnBean1d3dList();
+ Map<String,ABean> returnBeanMap();
+ Map<String,List<ABean>> returnBeanListMap();
+ Map<String,List<ABean[][][]>> returnBean1d3dListMap();
+ Map<Integer,List<ABean>> returnBeanListMapIntegerKeys();
+
+ // Typed beans
+ TypedBean returnTypedBean();
+ TypedBean[][][] returnTypedBean3dArray();
+ List<TypedBean> returnTypedBeanList();
+ List<TypedBean[][][]> returnTypedBean1d3dList();
+ Map<String,TypedBean> returnTypedBeanMap();
+ Map<String,List<TypedBean>> returnTypedBeanListMap();
+ Map<String,List<TypedBean[][][]>> returnTypedBean1d3dListMap();
+ Map<Integer,List<TypedBean>> returnTypedBeanListMapIntegerKeys();
+
+ // Swapped POJOs
+ SwappedPojo returnSwappedPojo();
+ SwappedPojo[][][] returnSwappedPojo3dArray();
+ Map<SwappedPojo,SwappedPojo> returnSwappedPojoMap();
+ Map<SwappedPojo,SwappedPojo[][][]> returnSwappedPojo3dMap();
+
+ // Implicit swapped POJOs
+ ImplicitSwappedPojo returnImplicitSwappedPojo();
+ ImplicitSwappedPojo[][][] returnImplicitSwappedPojo3dArray();
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo> returnImplicitSwappedPojoMap();
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> returnImplicitSwappedPojo3dMap();
+
+ // Enums
+ TestEnum returnEnum();
+ TestEnum[][][] returnEnum3d();
+ List<TestEnum> returnEnumList();
+ List<List<List<TestEnum>>> returnEnum3dList();
+ List<TestEnum[][][]> returnEnum1d3dList();
+ Map<TestEnum,TestEnum> returnEnumMap();
+ Map<TestEnum,TestEnum[][][]> returnEnum3dArrayMap();
+ Map<TestEnum,List<TestEnum[][][]>> returnEnum1d3dListMap();
+
+ //--------------------------------------------------------------------------------
+ // Test server-side exception serialization.
+ //--------------------------------------------------------------------------------
+
+ void throwException1() throws InterfaceProxyException1;
+ void throwException2() throws InterfaceProxyException2;
+
+ //--------------------------------------------------------------------------------
+ // Test parameters
+ //--------------------------------------------------------------------------------
+
+ // Various primitives
+ void setNothing();
+ void setInt(int x);
+ void setInteger(Integer x);
+ void setBoolean(boolean x);
+ void setFloat(float x);
+ void setFloatObject(Float x);
+ void setString(String x);
+ void setNullString(String x);
+ void setInt3dArray(int[][][] x);
+ void setInteger3dArray(Integer[][][] x);
+ void setString3dArray(String[][][] x);
+ void setIntegerList(List<Integer> x);
+ void setInteger3dList(List<List<List<Integer>>> x);
+ void setInteger1d3dList(List<Integer[][][]> x);
+ void setInt1d3dList(List<int[][][]> x);
+ void setStringList(List<String> x);
+
+ // Beans
+ void setBean(ABean x);
+ void setBean3dArray(ABean[][][] x);
+ void setBeanList(List<ABean> x);
+ void setBean1d3dList(List<ABean[][][]> x);
+ void setBeanMap(Map<String,ABean> x);
+ void setBeanListMap(Map<String,List<ABean>> x);
+ void setBean1d3dListMap(Map<String,List<ABean[][][]>> x);
+ void setBeanListMapIntegerKeys(Map<Integer,List<ABean>> x);
+
+ // Typed beans
+ void setTypedBean(TypedBean x);
+ void setTypedBean3dArray(TypedBean[][][] x);
+ void setTypedBeanList(List<TypedBean> x);
+ void setTypedBean1d3dList(List<TypedBean[][][]> x);
+ void setTypedBeanMap(Map<String,TypedBean> x);
+ void setTypedBeanListMap(Map<String,List<TypedBean>> x);
+ void setTypedBean1d3dListMap(Map<String,List<TypedBean[][][]>> x);
+ void setTypedBeanListMapIntegerKeys(Map<Integer,List<TypedBean>> x);
+
+ // Swapped POJOs
+ void setSwappedPojo(SwappedPojo x);
+ void setSwappedPojo3dArray(SwappedPojo[][][] x);
+ void setSwappedPojoMap(Map<SwappedPojo,SwappedPojo> x);
+ void setSwappedPojo3dMap(Map<SwappedPojo,SwappedPojo[][][]> x);
+
+ // Implicit swapped POJOs
+ void setImplicitSwappedPojo(ImplicitSwappedPojo x);
+ void setImplicitSwappedPojo3dArray(ImplicitSwappedPojo[][][] x);
+ void setImplicitSwappedPojoMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x);
+ void setImplicitSwappedPojo3dMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> x);
+
+ // Enums
+ void setEnum(TestEnum x);
+ void setEnum3d(TestEnum[][][] x);
+ void setEnumList(List<TestEnum> x);
+ void setEnum3dList(List<List<List<TestEnum>>> x);
+ void setEnum1d3dList(List<TestEnum[][][]> x);
+ void setEnumMap(Map<TestEnum,TestEnum> x);
+ void setEnum3dArrayMap(Map<TestEnum,TestEnum[][][]> x);
+ void setEnum1d3dListMap(Map<TestEnum,List<TestEnum[][][]>> x);
+
+ //--------------------------------------------------------------------------------
+ // Test multi-parameters
+ //--------------------------------------------------------------------------------
+
+ void setMultiParamsInts(int x1, int[][][] x2, int[][][] x2n, List<int[][][]> x3, List<int[][][]> x3n);
+ void setMultiParamsInteger(Integer x1, Integer x1n, Integer[][][] x2, Integer[][][] x2n, List<Integer[][][]> x3, List<Integer[][][]> x3n);
+ void setMultiParamsFloat(float x1, float[][][] x2, float[][][] x2n, List<float[][][]> x3, List<float[][][]> x3n);
+ void setMultiParamsFloatObject(Float x1, Float x1n, Float[][][] x2, Float[][][] x2n, List<Float[][][]> x3, List<Float[][][]> x3n);
+ void setMultiParamsString(String x1, String[][][] x2, String[][][] x2n, List<String[][][]> x3, List<String[][][]> x3n);
+ void setMultiParamsBean(ABean x1, ABean[][][] x2, ABean[][][] x2n, List<ABean[][][]> x3, List<ABean[][][]> x3n, Map<String,ABean> x4, Map<String,ABean> x4n, Map<String,List<ABean[][][]>> x5, Map<String,List<ABean[][][]>> x5n);
+ void setMultiParamsSwappedPojo(SwappedPojo x1, SwappedPojo[][][] x2, SwappedPojo[][][] x2n, List<SwappedPojo[][][]> x3, List<SwappedPojo[][][]> x3n, Map<SwappedPojo,SwappedPojo> x4, Map<SwappedPojo,SwappedPojo> x4n, Map<SwappedPojo,List<SwappedPojo[][][]>> x5, Map<SwappedPojo,List<SwappedPojo[][][]>> x5n);
+ void setMultiParamsImplicitSwappedPojo(ImplicitSwappedPojo x1, ImplicitSwappedPojo[][][] x2, ImplicitSwappedPojo[][][] x2n, List<ImplicitSwappedPojo[][][]> x3, List<ImplicitSwappedPojo[][][]> x3n, Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4, Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4n, Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5, Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5n);
+ void setMultiParamsEnum(TestEnum x1, TestEnum[][][] x2, TestEnum[][][] x2n, List<TestEnum[][][]> x3, List<TestEnum[][][]> x3n, Map<TestEnum,TestEnum> x4, Map<TestEnum,TestEnum> x4n, Map<TestEnum,List<TestEnum[][][]>> x5, Map<TestEnum,List<TestEnum[][][]>> x5n);
+
+ //--------------------------------------------------------------------------------
+ // Helper classes
+ //--------------------------------------------------------------------------------
+
+ @SuppressWarnings("serial")
+ public static class InterfaceProxyException1 extends Throwable {
+ public InterfaceProxyException1(String msg) {
+ super(msg);
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class InterfaceProxyException2 extends Throwable {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
new file mode 100644
index 0000000..a964187
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
@@ -0,0 +1,738 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import static java.util.Arrays.*;
+import static org.apache.juneau.rest.test.TestUtils.*;
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.test.pojos.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+/**
+ * Tests inteface proxies exposed through <code>@RestMethod(name="PROXY")</code>
+ */
+@RestResource(
+ path="/testInterfaceProxyResource")
+public class InterfaceProxyResource extends ResourceJena {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test that Q-values are being resolved correctly.
+ //====================================================================================================
+ @RestMethod(name="PROXY", path="/proxy/*")
+ public InterfaceProxy getProxy() {
+ return new InterfaceProxy() {
+
+ //--------------------------------------------------------------------------------
+ // Test return types.
+ //--------------------------------------------------------------------------------
+
+ // Various primitives
+
+ @Override
+ public void returnVoid() {
+ }
+
+ @Override
+ public Integer returnInteger() {
+ return 1;
+ }
+
+ @Override
+ public int returnInt() {
+ return 1;
+ }
+
+ @Override
+ public boolean returnBoolean() {
+ return true;
+ }
+
+ @Override
+ public float returnFloat() {
+ return 1f;
+ }
+
+ @Override
+ public Float returnFloatObject() {
+ return 1f;
+ }
+
+ @Override
+ public String returnString() {
+ return "foobar";
+ }
+
+ @Override
+ public String returnNullString() {
+ return null;
+ }
+
+ @Override
+ public int[][][] returnInt3dArray() {
+ return new int[][][]{{{1,2},null},null};
+ }
+
+ @Override
+ public Integer[][][] returnInteger3dArray() {
+ return new Integer[][][]{{{1,null},null},null};
+ }
+
+ @Override
+ public String[][][] returnString3dArray() {
+ return new String[][][]{{{"foo","bar",null},null},null};
+ }
+
+ @Override
+ public List<Integer> returnIntegerList() {
+ return asList(new Integer[]{1,null});
+ }
+
+ @Override
+ public List<List<List<Integer>>> returnInteger3dList() {
+ return new AList<List<List<Integer>>>()
+ .append(
+ new AList<List<Integer>>()
+ .append(
+ new AList<Integer>().append(1).append(null)
+ )
+ .append(null)
+ )
+ .append(null);
+ }
+
+ @Override
+ public List<Integer[][][]> returnInteger1d3dList() {
+ return new AList<Integer[][][]>().append(new Integer[][][]{{{1,null},null},null}).append(null);
+ }
+
+ @Override
+ public List<int[][][]> returnInt1d3dList() {
+ return new AList<int[][][]>().append(new int[][][]{{{1,2},null},null}).append(null);
+ }
+
+ @Override
+ public List<String> returnStringList() {
+ return asList(new String[]{"foo","bar",null});
+ }
+
+ // Beans
+
+ @Override
+ public ABean returnBean() {
+ return new ABean().init();
+ }
+
+ @Override
+ public ABean[][][] returnBean3dArray() {
+ return new ABean[][][]{{{new ABean().init(),null},null},null};
+ }
+
+ @Override
+ public List<ABean> returnBeanList() {
+ return asList(new ABean().init());
+ }
+
+ @Override
+ public List<ABean[][][]> returnBean1d3dList() {
+ return new AList<ABean[][][]>().append(new ABean[][][]{{{new ABean().init(),null},null},null}).append(null);
+ }
+
+ @Override
+ public Map<String,ABean> returnBeanMap() {
+ return new AMap<String,ABean>().append("foo",new ABean().init());
+ }
+
+ @Override
+ public Map<String,List<ABean>> returnBeanListMap() {
+ return new AMap<String,List<ABean>>().append("foo",asList(new ABean().init()));
+ }
+
+ @Override
+ public Map<String,List<ABean[][][]>> returnBean1d3dListMap() {
+ return new AMap<String,List<ABean[][][]>>().append("foo", new AList<ABean[][][]>().append(new ABean[][][]{{{new ABean().init(),null},null},null}).append(null));
+ }
+
+ @Override
+ public Map<Integer,List<ABean>> returnBeanListMapIntegerKeys() {
+ return new AMap<Integer,List<ABean>>().append(1,asList(new ABean().init()));
+ }
+
+ // Typed beans
+
+ @Override
+ public TypedBean returnTypedBean() {
+ return new TypedBeanImpl().init();
+ }
+
+ @Override
+ public TypedBean[][][] returnTypedBean3dArray() {
+ return new TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null};
+ }
+
+ @Override
+ public List<TypedBean> returnTypedBeanList() {
+ return asList((TypedBean)new TypedBeanImpl().init());
+ }
+
+ @Override
+ public List<TypedBean[][][]> returnTypedBean1d3dList() {
+ return new AList<TypedBean[][][]>().append(new TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null}).append(null);
+ }
+
+ @Override
+ public Map<String,TypedBean> returnTypedBeanMap() {
+ return new AMap<String,TypedBean>().append("foo",new TypedBeanImpl().init());
+ }
+
+ @Override
+ public Map<String,List<TypedBean>> returnTypedBeanListMap() {
+ return new AMap<String,List<TypedBean>>().append("foo",asList((TypedBean)new TypedBeanImpl().init()));
+ }
+
+ @Override
+ public Map<String,List<TypedBean[][][]>> returnTypedBean1d3dListMap() {
+ return new AMap<String,List<TypedBean[][][]>>().append("foo", new AList<TypedBean[][][]>().append(new TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null}).append(null));
+ }
+
+ @Override
+ public Map<Integer,List<TypedBean>> returnTypedBeanListMapIntegerKeys() {
+ return new AMap<Integer,List<TypedBean>>().append(1,asList((TypedBean)new TypedBeanImpl().init()));
+ }
+
+ // Swapped POJOs
+
+ @Override
+ public SwappedPojo returnSwappedPojo() {
+ return new SwappedPojo();
+ }
+
+ @Override
+ public SwappedPojo[][][] returnSwappedPojo3dArray() {
+ return new SwappedPojo[][][]{{{new SwappedPojo(),null},null},null};
+ }
+
+ @Override
+ public Map<SwappedPojo,SwappedPojo> returnSwappedPojoMap() {
+ return new AMap<SwappedPojo,SwappedPojo>().append(new SwappedPojo(), new SwappedPojo());
+ }
+
+ @Override
+ public Map<SwappedPojo,SwappedPojo[][][]> returnSwappedPojo3dMap() {
+ return new AMap<SwappedPojo,SwappedPojo[][][]>().append(new SwappedPojo(), new SwappedPojo[][][]{{{new SwappedPojo(),null},null},null});
+ }
+
+ // Implicit swapped POJOs
+
+ @Override
+ public ImplicitSwappedPojo returnImplicitSwappedPojo() {
+ return new ImplicitSwappedPojo();
+ }
+
+ @Override
+ public ImplicitSwappedPojo[][][] returnImplicitSwappedPojo3dArray() {
+ return new ImplicitSwappedPojo[][][]{{{new ImplicitSwappedPojo(),null},null},null};
+ }
+
+ @Override
+ public Map<ImplicitSwappedPojo,ImplicitSwappedPojo> returnImplicitSwappedPojoMap() {
+ return new AMap<ImplicitSwappedPojo,ImplicitSwappedPojo>().append(new ImplicitSwappedPojo(), new ImplicitSwappedPojo());
+ }
+
+ @Override
+ public Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> returnImplicitSwappedPojo3dMap() {
+ return new AMap<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>().append(new ImplicitSwappedPojo(), new ImplicitSwappedPojo[][][]{{{new ImplicitSwappedPojo(),null},null},null});
+ }
+
+ // Enums
+
+ @Override
+ public TestEnum returnEnum() {
+ return TestEnum.TWO;
+ }
+
+ @Override
+ public TestEnum[][][] returnEnum3d() {
+ return new TestEnum[][][]{{{TestEnum.TWO,null},null},null};
+ }
+
+ @Override
+ public List<TestEnum> returnEnumList() {
+ return new AList<TestEnum>().append(TestEnum.TWO).append(null);
+ }
+
+ @Override
+ public List<List<List<TestEnum>>> returnEnum3dList() {
+ return new AList<List<List<TestEnum>>>()
+ .append(
+ new AList<List<TestEnum>>()
+ .append(
+ new AList<TestEnum>().append(TestEnum.TWO).append(null)
+ )
+ .append(null)
+ .append(null)
+ );
+ }
+
+ @Override
+ public List<TestEnum[][][]> returnEnum1d3dList() {
+ return new AList<TestEnum[][][]>().append(new TestEnum[][][]{{{TestEnum.TWO,null},null},null}).append(null);
+ }
+
+ @Override
+ public Map<TestEnum,TestEnum> returnEnumMap() {
+ return new AMap<TestEnum,TestEnum>().append(TestEnum.ONE,TestEnum.TWO);
+ }
+
+ @Override
+ public Map<TestEnum,TestEnum[][][]> returnEnum3dArrayMap() {
+ return new AMap<TestEnum,TestEnum[][][]>().append(TestEnum.ONE, new TestEnum[][][]{{{TestEnum.TWO,null},null},null});
+ }
+
+ @Override
+ public Map<TestEnum,List<TestEnum[][][]>> returnEnum1d3dListMap() {
+ return new AMap<TestEnum,List<TestEnum[][][]>>().append(TestEnum.ONE, new AList<TestEnum[][][]>().append(new TestEnum[][][]{{{TestEnum.TWO,null},null},null}).append(null));
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test server-side exception serialization.
+ //--------------------------------------------------------------------------------
+
+ @Override
+ public void throwException1() throws InterfaceProxy.InterfaceProxyException1 {
+ throw new InterfaceProxy.InterfaceProxyException1("foo");
+ }
+
+ @Override
+ public void throwException2() throws InterfaceProxy.InterfaceProxyException2 {
+ throw new InterfaceProxy.InterfaceProxyException2();
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test parameters
+ //--------------------------------------------------------------------------------
+
+ // Various primitives
+
+ @Override
+ public void setNothing() {
+ }
+
+ @Override
+ public void setInt(int x) {
+ assertEquals(1, x);
+ }
+
+ @Override
+ public void setInteger(Integer x) {
+ assertEquals((Integer)1, x);
+ }
+
+ @Override
+ public void setBoolean(boolean x) {
+ assertTrue(x);
+ }
+
+ @Override
+ public void setFloat(float x) {
+ assertTrue(1f == x);
+ }
+
+ @Override
+ public void setFloatObject(Float x) {
+ assertTrue(1f == x);
+ }
+
+ @Override
+ public void setString(String x) {
+ assertEquals("foo", x);
+ }
+
+ @Override
+ public void setNullString(String x) {
+ assertNull(x);
+ }
+
+ @Override
+ public void setInt3dArray(int[][][] x) {
+ assertObjectEquals("[[[1,2],null],null]", x);
+ }
+
+ @Override
+ public void setInteger3dArray(Integer[][][] x) {
+ assertObjectEquals("[[[1,null],null],null]", x);
+ }
+
+ @Override
+ public void setString3dArray(String[][][] x) {
+ assertObjectEquals("[[['foo',null],null],null]", x);
+ }
+
+ @Override
+ public void setIntegerList(List<Integer> x) {
+ assertObjectEquals("[1,null]", x);
+ assertClass(Integer.class, x.get(0));
+ }
+
+ @Override
+ public void setInteger3dList(List<List<List<Integer>>> x) {
+ assertObjectEquals("[[[1,null],null],null]", x);
+ assertClass(Integer.class, x.get(0).get(0).get(0));
+ }
+
+ @Override
+ public void setInteger1d3dList(List<Integer[][][]> x) {
+ assertObjectEquals("[[[[1,null],null],null],null]", x);
+ assertClass(Integer[][][].class, x.get(0));
+ assertClass(Integer.class, x.get(0)[0][0][0]);
+ }
+
+ @Override
+ public void setInt1d3dList(List<int[][][]> x) {
+ assertObjectEquals("[[[[1,2],null],null],null]", x);
+ assertClass(int[][][].class, x.get(0));
+ }
+
+ @Override
+ public void setStringList(List<String> x) {
+ assertObjectEquals("['foo','bar',null]", x);
+ }
+
+ // Beans
+
+ @Override
+ public void setBean(ABean x) {
+ assertObjectEquals("{a:1,b:'foo'}", x);
+ }
+
+ @Override
+ public void setBean3dArray(ABean[][][] x) {
+ assertObjectEquals("[[[{a:1,b:'foo'},null],null],null]", x);
+ }
+
+ @Override
+ public void setBeanList(List<ABean> x) {
+ assertObjectEquals("[{a:1,b:'foo'}]", x);
+ }
+
+ @Override
+ public void setBean1d3dList(List<ABean[][][]> x) {
+ assertObjectEquals("[[[[{a:1,b:'foo'},null],null],null],null]", x);
+ }
+
+ @Override
+ public void setBeanMap(Map<String,ABean> x) {
+ assertObjectEquals("{foo:{a:1,b:'foo'}}", x);
+ }
+
+ @Override
+ public void setBeanListMap(Map<String,List<ABean>> x) {
+ assertObjectEquals("{foo:[{a:1,b:'foo'}]}", x);
+ }
+
+ @Override
+ public void setBean1d3dListMap(Map<String,List<ABean[][][]>> x) {
+ assertObjectEquals("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}", x);
+ }
+
+ @Override
+ public void setBeanListMapIntegerKeys(Map<Integer,List<ABean>> x) {
+ assertObjectEquals("{'1':[{a:1,b:'foo'}]}", x); // Note: JsonSerializer serializes key as string.
+ assertClass(Integer.class, x.keySet().iterator().next());
+ }
+
+ // Typed beans
+
+ @Override
+ public void setTypedBean(TypedBean x) {
+ assertObjectEquals("{_type:'TypedBeanImpl',a:1,b:'foo'}", x);
+ assertClass(TypedBeanImpl.class, x);
+ }
+
+ @Override
+ public void setTypedBean3dArray(TypedBean[][][] x) {
+ assertObjectEquals("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]", x);
+ assertClass(TypedBeanImpl.class, x[0][0][0]);
+ }
+
+ @Override
+ public void setTypedBeanList(List<TypedBean> x) {
+ assertObjectEquals("[{_type:'TypedBeanImpl',a:1,b:'foo'}]", x);
+ assertClass(TypedBeanImpl.class, x.get(0));
+ }
+
+ @Override
+ public void setTypedBean1d3dList(List<TypedBean[][][]> x) {
+ assertObjectEquals("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]", x);
+ assertClass(TypedBeanImpl.class, x.get(0)[0][0][0]);
+ }
+
+ @Override
+ public void setTypedBeanMap(Map<String,TypedBean> x) {
+ assertObjectEquals("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo"));
+ }
+
+ @Override
+ public void setTypedBeanListMap(Map<String,List<TypedBean>> x) {
+ assertObjectEquals("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo").get(0));
+ }
+
+ @Override
+ public void setTypedBean1d3dListMap(Map<String,List<TypedBean[][][]>> x) {
+ assertObjectEquals("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo").get(0)[0][0][0]);
+ }
+
+ @Override
+ public void setTypedBeanListMapIntegerKeys(Map<Integer,List<TypedBean>> x) {
+ assertObjectEquals("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", x); // Note: JsonSerializer serializes key as string.
+ assertClass(TypedBeanImpl.class, x.get(1).get(0));
+ }
+
+ // Swapped POJOs
+
+ @Override
+ public void setSwappedPojo(SwappedPojo x) {
+ assertTrue(x.wasUnswapped);
+ }
+
+ @Override
+ public void setSwappedPojo3dArray(SwappedPojo[][][] x) {
+ assertObjectEquals("[[['"+SWAP+"',null],null],null]", x);
+ assertTrue(x[0][0][0].wasUnswapped);
+ }
+
+ @Override
+ public void setSwappedPojoMap(Map<SwappedPojo,SwappedPojo> x) {
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}", x);
+ Map.Entry<SwappedPojo,SwappedPojo> e = x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue().wasUnswapped);
+ }
+
+ @Override
+ public void setSwappedPojo3dMap(Map<SwappedPojo,SwappedPojo[][][]> x) {
+ assertObjectEquals("{'"+SWAP+"':[[['"+SWAP+"',null],null],null]}", x);
+ Map.Entry<SwappedPojo,SwappedPojo[][][]> e = x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue()[0][0][0].wasUnswapped);
+ }
+
+ // Implicit swapped POJOs
+
+ @Override
+ public void setImplicitSwappedPojo(ImplicitSwappedPojo x) {
+ assertTrue(x.wasUnswapped);
+ }
+
+ @Override
+ public void setImplicitSwappedPojo3dArray(ImplicitSwappedPojo[][][] x) {
+ assertObjectEquals("[[['"+SWAP+"',null],null],null]", x);
+ assertTrue(x[0][0][0].wasUnswapped);
+ }
+
+ @Override
+ public void setImplicitSwappedPojoMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x) {
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}", x);
+ Map.Entry<ImplicitSwappedPojo,ImplicitSwappedPojo> e = x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue().wasUnswapped);
+ }
+
+ @Override
+ public void setImplicitSwappedPojo3dMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> x) {
+ assertObjectEquals("{'"+SWAP+"':[[['"+SWAP+"',null],null],null]}", x);
+ Map.Entry<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> e = x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue()[0][0][0].wasUnswapped);
+ }
+
+ // Enums
+
+ @Override
+ public void setEnum(TestEnum x) {
+ assertEquals(TestEnum.TWO, x);
+ }
+
+ @Override
+ public void setEnum3d(TestEnum[][][] x) {
+ assertObjectEquals("[[['TWO',null],null],null]", x);
+ }
+
+ @Override
+ public void setEnumList(List<TestEnum> x) {
+ assertObjectEquals("['TWO',null]", x);
+ assertClass(TestEnum.class, x.get(0));
+ }
+
+ @Override
+ public void setEnum3dList(List<List<List<TestEnum>>> x) {
+ assertObjectEquals("[[['TWO',null],null,null]]", x);
+ assertClass(TestEnum.class, x.get(0).get(0).get(0));
+ }
+
+ @Override
+ public void setEnum1d3dList(List<TestEnum[][][]> x) {
+ assertObjectEquals("[[[['TWO',null],null],null],null]", x);
+ assertClass(TestEnum[][][].class, x.get(0));
+ }
+
+ @Override
+ public void setEnumMap(Map<TestEnum,TestEnum> x) {
+ assertObjectEquals("{ONE:'TWO'}", x);
+ Map.Entry<TestEnum,TestEnum> e = x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum.class, e.getValue());
+ }
+
+ @Override
+ public void setEnum3dArrayMap(Map<TestEnum,TestEnum[][][]> x) {
+ assertObjectEquals("{ONE:[[['TWO',null],null],null]}", x);
+ Map.Entry<TestEnum,TestEnum[][][]> e = x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum[][][].class, e.getValue());
+ }
+
+ @Override
+ public void setEnum1d3dListMap(Map<TestEnum,List<TestEnum[][][]>> x) {
+ assertObjectEquals("{ONE:[[[['TWO',null],null],null],null]}", x);
+ Map.Entry<TestEnum,List<TestEnum[][][]>> e = x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum[][][].class, e.getValue().get(0));
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test multi-parameters
+ //--------------------------------------------------------------------------------
+
+ @Override
+ public void setMultiParamsInts(int x1, int[][][] x2, int[][][] x2n, List<int[][][]> x3, List<int[][][]> x3n) {
+ assertObjectEquals("1", x1);
+ assertObjectEquals("[[[1,2],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[[1,2],null],null],null]", x3);
+ assertClass(int[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsInteger(Integer x1, Integer x1n, Integer[][][] x2, Integer[][][] x2n, List<Integer[][][]> x3, List<Integer[][][]> x3n) {
+ assertObjectEquals("1", x1);
+ assertObjectEquals("[[[1,null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[[1,null],null],null],null]", x3);
+ assertClass(Integer[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsFloat(float x1, float[][][] x2, float[][][] x2n, List<float[][][]> x3, List<float[][][]> x3n) {
+ assertObjectEquals("1.0", x1);
+ assertObjectEquals("[[[1.0,2.0],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[[1.0,2.0],null],null],null]", x3);
+ assertClass(float[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsFloatObject(Float x1, Float x1n, Float[][][] x2, Float[][][] x2n, List<Float[][][]> x3, List<Float[][][]> x3n) {
+ assertObjectEquals("1.0", x1);
+ assertObjectEquals("[[[1.0,null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[[1.0,null],null],null],null]", x3);
+ assertClass(Float[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsString(String x1, String[][][] x2, String[][][] x2n, List<String[][][]> x3, List<String[][][]> x3n) {
+ assertObjectEquals("'foo'", x1);
+ assertObjectEquals("[[['foo',null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[['foo',null],null],null],null]", x3);
+ assertClass(String[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsBean(ABean x1, ABean[][][] x2, ABean[][][] x2n, List<ABean[][][]> x3, List<ABean[][][]> x3n, Map<String,ABean> x4, Map<String,ABean> x4n, Map<String,List<ABean[][][]>> x5, Map<String,List<ABean[][][]>> x5n) {
+ assertObjectEquals("{a:1,b:'foo'}", x1);
+ assertObjectEquals("[[[{a:1,b:'foo'},null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[[{a:1,b:'foo'},null],null],null],null]", x3);
+ assertClass(ABean[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{foo:{a:1,b:'foo'}}", x4);
+ assertNull(x4n);
+ assertObjectEquals("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+
+ @Override
+ public void setMultiParamsSwappedPojo(SwappedPojo x1, SwappedPojo[][][] x2, SwappedPojo[][][] x2n, List<SwappedPojo[][][]> x3, List<SwappedPojo[][][]> x3n, Map<SwappedPojo,SwappedPojo> x4, Map<SwappedPojo,SwappedPojo> x4n, Map<SwappedPojo,List<SwappedPojo[][][]>> x5, Map<SwappedPojo,List<SwappedPojo[][][]>> x5n) {
+ assertObjectEquals("'"+SWAP+"'", x1);
+ assertObjectEquals("[[['"+SWAP+"',null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[['"+SWAP+"',null],null],null],null]", x3);
+ assertClass(SwappedPojo[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}", x4);
+ assertNull(x4n);
+ assertObjectEquals("{'"+SWAP+"':[[[['"+SWAP+"',null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+
+ @Override
+ public void setMultiParamsImplicitSwappedPojo(ImplicitSwappedPojo x1, ImplicitSwappedPojo[][][] x2, ImplicitSwappedPojo[][][] x2n, List<ImplicitSwappedPojo[][][]> x3, List<ImplicitSwappedPojo[][][]> x3n, Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4, Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4n, Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5, Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5n) {
+ assertObjectEquals("'"+SWAP+"'", x1);
+ assertObjectEquals("[[['"+SWAP+"',null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[['"+SWAP+"',null],null],null],null]", x3);
+ assertClass(ImplicitSwappedPojo[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}", x4);
+ assertNull(x4n);
+ assertObjectEquals("{'"+SWAP+"':[[[['"+SWAP+"',null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+
+ @Override
+ public void setMultiParamsEnum(TestEnum x1, TestEnum[][][] x2, TestEnum[][][] x2n, List<TestEnum[][][]> x3, List<TestEnum[][][]> x3n, Map<TestEnum,TestEnum> x4, Map<TestEnum,TestEnum> x4n, Map<TestEnum,List<TestEnum[][][]>> x5, Map<TestEnum,List<TestEnum[][][]>> x5n) {
+ assertObjectEquals("'TWO'", x1);
+ assertObjectEquals("[[['TWO',null],null],null]", x2);
+ assertNull(x2n);
+ assertObjectEquals("[[[['TWO',null],null],null],null]", x3);
+ assertClass(TestEnum[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{ONE:'TWO'}", x4);
+ assertNull(x4n);
+ assertObjectEquals("{ONE:[[[['TWO',null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+ };
+ }
+
+ private static void assertObjectEquals(String e, Object o) {
+ Assert.assertEquals(e, JsonSerializer.DEFAULT_LAX.toString(o));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
new file mode 100644
index 0000000..3ff1c5a
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
@@ -0,0 +1,45 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import java.util.*;
+
+/**
+ * A large POJO object.
+ */
+@SuppressWarnings("serial")
+public class LargePojo {
+ public A1Map a1Map;
+ public A1List a1List;
+ public A1[] a1Array;
+
+ public static LargePojo create() {
+ LargePojo a = new LargePojo();
+ a.a1Map = new A1Map();
+ a.a1List = new A1List();
+ for (int i = 0; i < 20000; i++) {
+ a.a1Map.put(String.valueOf(i), new A1());
+ a.a1List.add(new A1());
+ }
+ a.a1Array = a.a1List.toArray(new A1[0]);
+ return a;
+ }
+
+ public static class A1 {
+ public String f1 = "a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789";
+ }
+
+ public static class A1Map extends LinkedHashMap<String,A1> {}
+
+ public static class A1List extends LinkedList<A1> {}
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
new file mode 100644
index 0000000..f31bbb5
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
@@ -0,0 +1,39 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testLargePojos"
+)
+public class LargePojosResource extends ResourceJena {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test how long it takes to serialize/parse various content types.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/")
+ public LargePojo testGet() {
+ return LargePojo.create();
+ }
+
+ @RestMethod(name="PUT", path="/")
+ public String testPut(@Body LargePojo in) {
+ return "ok";
+ }
+}