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:16 UTC
[23/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/test/java/org/apache/juneau/rest/test/HeadersTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HeadersTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HeadersTest.java
new file mode 100644
index 0000000..2f11c12
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HeadersTest.java
@@ -0,0 +1,261 @@
+// ***************************************************************************************************************************
+// * 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.test.TestUtils.*;
+import static org.junit.Assert.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.rest.client.*;
+import org.junit.*;
+
+public class HeadersTest extends RestTestcase {
+
+ RestClient client = TestMicroservice.DEFAULT_CLIENT;
+
+ private static String URL = "/testHeaders";
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+
+ @Test
+ public void accept() throws Exception {
+ assertEquals("text/foo", client.doGet(URL + "/accept").accept("text/foo").getResponseAsString());
+ assertEquals("text/foo+bar", client.doGet(URL + "/accept").accept("text/foo+bar").getResponseAsString());
+ assertEquals("text/*", client.doGet(URL + "/accept").accept("text/*").getResponseAsString());
+ assertEquals("*/foo", client.doGet(URL + "/accept").accept("*/foo").getResponseAsString());
+
+ assertEquals("text/foo", client.doGet(URL + "/accept").accept("text/foo;q=1.0").getResponseAsString());
+ assertEquals("text/foo;q=0.9", client.doGet(URL + "/accept").accept("text/foo;q=0.9").getResponseAsString());
+ assertEquals("text/foo;x=X;q=0.9;y=Y", client.doGet(URL + "/accept").accept("text/foo;x=X;q=0.9;y=Y").getResponseAsString());
+
+ assertEquals("text/foo", client.doGet(URL + "/accept").query("Accept", "text/foo").getResponseAsString());
+ }
+
+ @Test
+ public void acceptCharset() throws Exception {
+ assertEquals("UTF-8", client.doGet(URL + "/acceptCharset").acceptCharset("UTF-8").getResponseAsString());
+ assertEquals("UTF-8", client.doGet(URL + "/acceptCharset").query("Accept-Charset", "UTF-8").getResponseAsString());
+ }
+
+ @Test
+ public void acceptEncoding() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/acceptEncoding").acceptEncoding("foo").getResponseAsString());
+ assertEquals("*", client.doGet(URL + "/acceptEncoding").acceptEncoding("*").getResponseAsString());
+ assertEquals("*", client.doGet(URL + "/acceptEncoding").query("Accept-Encoding", "*").getResponseAsString());
+ }
+
+ @Test
+ public void acceptLanguage() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/acceptLanguage").acceptLanguage("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/acceptLanguage").query("Accept-Language", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void authorization() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/authorization").authorization("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/authorization").query("Authorization", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void cacheControl() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/cacheControl").cacheControl("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/cacheControl").query("Cache-Control", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void connection() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/connection").connection("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/connection").query("Connection", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void contentLength() throws Exception {
+ assertEquals("0", client.doGet(URL + "/contentLength").contentLength(0).getResponseAsString());
+ assertEquals("0", client.doGet(URL + "/contentLength").query("Content-Length", 0).getResponseAsString());
+ }
+
+ @Test
+ public void contentType() throws Exception {
+ assertEquals("text/foo", client.doGet(URL + "/contentType").contentType("text/foo").getResponseAsString());
+ assertEquals("text/foo", client.doGet(URL + "/contentType").query("Content-Type", "text/foo").getResponseAsString());
+ }
+
+ @Test
+ public void date() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/date").date("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/date").query("Date", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void expect() throws Exception {
+ assertEquals("100-continue", client.doGet(URL + "/expect").expect("100-continue").getResponseAsString());
+ assertEquals("100-continue", client.doGet(URL + "/expect").query("Expect", "100-continue").getResponseAsString());
+ }
+
+ @Test
+ public void from() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/from").from("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/from").query("From", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void host() throws Exception {
+ assertTrue(client.doGet(URL + "/host").host("localhost").getResponseAsString().startsWith("localhost"));
+ assertTrue(client.doGet(URL + "/host").query("Host", "localhost").getResponseAsString().startsWith("localhost"));
+ }
+
+ @Test
+ public void ifMatch() throws Exception {
+ RestClient client = TestMicroservice.DEFAULT_CLIENT;
+ assertEquals("\"foo\"", client.doGet(URL + "/ifMatch").ifMatch("foo").getResponseAsString());
+ assertEquals("\"foo\"", client.doGet(URL + "/ifMatch").ifMatch("\"foo\"").getResponseAsString());
+ assertEquals("W/\"foo\"", client.doGet(URL + "/ifMatch").ifMatch("W/\"foo\"").getResponseAsString());
+ assertEquals("W/\"foo\", \"bar\"", client.doGet(URL + "/ifMatch").ifMatch("W/\"foo\",\"bar\"").getResponseAsString());
+ assertEquals("\"foo\"", client.doGet(URL + "/ifMatch").query("If-Match", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void ifModifiedSince() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/ifModifiedSince").ifModifiedSince("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/ifModifiedSince").query("If-Modified-Since", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void ifNoneMatch() throws Exception {
+ assertEquals("\"foo\"", client.doGet(URL + "/ifNoneMatch").ifNoneMatch("foo").getResponseAsString());
+ assertEquals("\"foo\"", client.doGet(URL + "/ifNoneMatch").ifNoneMatch("\"foo\"").getResponseAsString());
+ assertEquals("W/\"foo\"", client.doGet(URL + "/ifNoneMatch").ifNoneMatch("W/\"foo\"").getResponseAsString());
+ assertEquals("W/\"foo\", \"bar\"", client.doGet(URL + "/ifNoneMatch").ifNoneMatch("W/\"foo\",\"bar\"").getResponseAsString());
+ assertEquals("\"foo\"", client.doGet(URL + "/ifNoneMatch").query("If-None-Match", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void ifRange() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/ifRange").ifRange("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/ifRange").query("If-Range", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void ifUnmodifiedSince() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/ifUnmodifiedSince").ifUnmodifiedSince("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/ifUnmodifiedSince").query("If-Unmodified-Since", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void maxForwards() throws Exception {
+ assertEquals("123", client.doGet(URL + "/maxForwards").maxForwards(123).getResponseAsString());
+ assertEquals("123", client.doGet(URL + "/maxForwards").query("Max-Forwards", 123).getResponseAsString());
+ }
+
+ @Test
+ public void pragma() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/pragma").pragma("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/pragma").query("Pragma", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void proxyAuthorization() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/proxyAuthorization").proxyAuthorization("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/proxyAuthorization").query("Proxy-Authorization", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void range() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/range").range("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/range").query("Range", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void referer() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/referer").referer("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/referer").query("Referer", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void te() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/te").te("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/te").query("TE", "foo").getResponseAsString());
+ }
+
+// @Test
+// public void upgrade() throws Exception {
+// assertEquals("foo", client.doGet(URL + "/upgrade").upgrade("foo").getResponseAsString());
+// assertEquals("foo", client.doGet(URL + "/upgrade").query("Upgrade", "foo").getResponseAsString());
+// }
+//
+ @Test
+ public void userAgent() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/userAgent").userAgent("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/userAgent").query("User-Agent", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void warning() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/warning").warning("foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/warning").query("Warning", "foo").getResponseAsString());
+ }
+
+ @Test
+ public void customHeader() throws Exception {
+ assertEquals("foo", client.doGet(URL + "/customHeader").header("Custom", "foo").getResponseAsString());
+ assertEquals("foo", client.doGet(URL + "/customHeader").query("Custom", "foo").getResponseAsString());
+ }
+
+ //====================================================================================================
+ // Default values.
+ //====================================================================================================
+
+ @Test
+ public void defaultRequestHeaders() throws Exception {
+ assertObjectEquals("{h1:'1',h2:'2',h3:'3'}", client.doGet(URL + "/defaultRequestHeaders").getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/defaultRequestHeaders").header("H1",4).header("H2",5).header("H3",6).getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/defaultRequestHeaders").header("h1",4).header("h2",5).header("h3",6).getResponse(ObjectMap.class));
+ }
+
+ @Test
+ public void defaultRequestHeadersCaseInsensitive() throws Exception {
+ assertObjectEquals("{h1:'1',h2:'2',h3:'3'}", client.doGet(URL + "/defaultRequestHeadersCaseInsensitive").getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/defaultRequestHeadersCaseInsensitive").header("H1",4).header("H2",5).header("H3",6).getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/defaultRequestHeadersCaseInsensitive").header("h1",4).header("h2",5).header("h3",6).getResponse(ObjectMap.class));
+ }
+
+ @Test
+ public void annotatedHeaders() throws Exception {
+ assertObjectEquals("{h1:null,h2:null,h3:null}", client.doGet(URL + "/annotatedHeaders").getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedHeaders").header("H1",4).header("H2",5).header("H3",6).getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedHeaders").header("h1",4).header("h2",5).header("h3",6).getResponse(ObjectMap.class));
+ }
+
+ @Test
+ public void annotatedHeadersCaseInsensitive() throws Exception {
+ assertObjectEquals("{h1:null,h2:null,h3:null}", client.doGet(URL + "/annotatedHeadersCaseInsensitive").getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedHeadersCaseInsensitive").header("H1",4).header("H2",5).header("H3",6).getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedHeadersCaseInsensitive").header("h1",4).header("h2",5).header("h3",6).getResponse(ObjectMap.class));
+ }
+
+ @Test
+ public void annotatedHeadersDefault() throws Exception {
+ assertObjectEquals("{h1:'1',h2:'2',h3:'3'}", client.doGet(URL + "/annotatedHeadersDefault").getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedHeadersDefault").header("H1",4).header("H2",5).header("H3",6).getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedHeadersDefault").header("h1",4).header("h2",5).header("h3",6).getResponse(ObjectMap.class));
+ }
+
+ @Test
+ public void annotatedAndDefaultHeaders() throws Exception {
+ assertObjectEquals("{h1:'4',h2:'5',h3:'6'}", client.doGet(URL + "/annotatedAndDefaultHeaders").getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'7',h2:'8',h3:'9'}", client.doGet(URL + "/annotatedAndDefaultHeaders").header("H1",7).header("H2",8).header("H3",9).getResponse(ObjectMap.class));
+ assertObjectEquals("{h1:'7',h2:'8',h3:'9'}", client.doGet(URL + "/annotatedAndDefaultHeaders").header("h1",7).header("h2",8).header("h3",9).getResponse(ObjectMap.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocLinksTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocLinksTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocLinksTest.java
new file mode 100644
index 0000000..5e88c08
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocLinksTest.java
@@ -0,0 +1,337 @@
+// ***************************************************************************************************************************
+// * 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.junit.Assert.*;
+
+import org.apache.juneau.rest.client.*;
+import org.junit.*;
+
+/**
+ * Validates inheritance on the @HtmlDoc.links() annotation.
+ */
+public class HtmlDocLinksTest extends RestTestcase {
+ private RestClient client = TestMicroservice.DEFAULT_CLIENT;
+
+ private String get(String uri) throws Exception {
+ return client.doGet(uri).accept("text/html").getResponseAsString().replace('\n', ' ').replace('"', '\'').replaceAll(".*<nav>", "<nav>").replaceAll("</nav>.*", "</nav>");
+ }
+
+ /**
+ * @RestResource(
+ * path="/testHtmlDocLinks",
+ * htmldoc=@HtmlDoc(
+ * links={"links1a","links1b"}
+ * )
+ * )
+ */
+ @Test
+ public void test1() throws Exception {
+ String r = get("/testHtmlDocLinks/test1");
+ assertEquals("<nav><ol><li>links1a</li><li>links1b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test2",
+ * htmldoc=@HtmlDoc(
+ * links={"links2a","links2b"}
+ * )
+ * )
+ */
+ @Test
+ public void test2() throws Exception {
+ String r = get("/testHtmlDocLinks/test2");
+ assertEquals("<nav><ol><li>links2a</li><li>links2b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test3",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","links3a","links3b"}
+ * )
+ * )
+ */
+ @Test
+ public void test3() throws Exception {
+ String r = get("/testHtmlDocLinks/test3");
+ assertEquals("<nav><ol><li>links1a</li><li>links1b</li><li>links3a</li><li>links3b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test4",
+ * htmldoc=@HtmlDoc(
+ * links={"links4a","INHERIT","links4b"}
+ * )
+ * )
+ */
+ @Test
+ public void test4() throws Exception {
+ String r = get("/testHtmlDocLinks/test4");
+ assertEquals("<nav><ol><li>links4a</li><li>links1a</li><li>links1b</li><li>links4b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test5",
+ * htmldoc=@HtmlDoc(
+ * links={"links5a","links5b","INHERIT"}
+ * )
+ * )
+ */
+ @Test
+ public void test5() throws Exception {
+ String r = get("/testHtmlDocLinks/test5");
+ assertEquals("<nav><ol><li>links5a</li><li>links5b</li><li>links1a</li><li>links1b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test6a",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","[0]:links6a","[3]:links6b"}
+ * )
+ * )
+ */
+ @Test
+ public void test6a() throws Exception {
+ String r = get("/testHtmlDocLinks/test6a");
+ assertEquals("<nav><ol><li>links6a</li><li>links1a</li><li>links1b</li><li>links6b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test6b",
+ * htmldoc=@HtmlDoc(
+ * links={"[1]:links6a","[2]:links6b","INHERIT"}
+ * )
+ * )
+ */
+ @Test
+ public void test6b() throws Exception {
+ String r = get("/testHtmlDocLinks/test6b");
+ assertEquals("<nav><ol><li>links6a</li><li>links6b</li><li>links1a</li><li>links1b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test6c",
+ * htmldoc=@HtmlDoc(
+ * links={"[1]:links6a","[0]:links6b"}
+ * )
+ * )
+ */
+ @Test
+ public void test6c() throws Exception {
+ String r = get("/testHtmlDocLinks/test6c");
+ assertEquals("<nav><ol><li>links6b</li><li>links6a</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test6d",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","foo[0]:links6a","bar[3]:links6b"}
+ * )
+ * )
+ */
+ @Test
+ public void test6d() throws Exception {
+ String r = get("/testHtmlDocLinks/test6d");
+ assertEquals("<nav><ol><li><a href='/testHtmlDocLinks/links6a'>foo</a></li><li>links1a</li><li>links1b</li><li><a href='/testHtmlDocLinks/links6b'>bar</a></li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test6e",
+ * htmldoc=@HtmlDoc(
+ * links={"foo[1]:links6a","bar[2]:links6b","INHERIT"}
+ * )
+ * )
+ */
+ @Test
+ public void test6e() throws Exception {
+ String r = get("/testHtmlDocLinks/test6e");
+ assertEquals("<nav><ol><li><a href='/testHtmlDocLinks/links6a'>foo</a></li><li><a href='/testHtmlDocLinks/links6b'>bar</a></li><li>links1a</li><li>links1b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test6f",
+ * htmldoc=@HtmlDoc(
+ * links={"foo[1]:links6a","bar[0]:links6b"}
+ * )
+ * )
+ */
+ @Test
+ public void test6f() throws Exception {
+ String r = get("/testHtmlDocLinks/test6f");
+ assertEquals("<nav><ol><li><a href='/testHtmlDocLinks/links6b'>bar</a></li><li><a href='/testHtmlDocLinks/links6a'>foo</a></li></ol></nav>", r);
+ }
+
+ /**
+ * @RestResource(
+ * path="/testHtmlDocLinks2",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","links11a","links11b"}
+ * )
+ * )
+ */
+ @Test
+ public void test11() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test11");
+ assertEquals("<nav><ol><li>links1a</li><li>links1b</li><li>links11a</li><li>links11b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test12",
+ * htmldoc=@HtmlDoc(
+ * links={"links12a","links12b"}
+ * )
+ * )
+ */
+ @Test
+ public void test12() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test12");
+ assertEquals("<nav><ol><li>links12a</li><li>links12b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test13",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","links13a","links13b"}
+ * )
+ * )
+ */
+ @Test
+ public void test13() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test13");
+ assertEquals("<nav><ol><li>links1a</li><li>links1b</li><li>links11a</li><li>links11b</li><li>links13a</li><li>links13b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test14",
+ * htmldoc=@HtmlDoc(
+ * links={"links14a","INHERIT","links14b"}
+ * )
+ * )
+ */
+ @Test
+ public void test14() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test14");
+ assertEquals("<nav><ol><li>links14a</li><li>links1a</li><li>links1b</li><li>links11a</li><li>links11b</li><li>links14b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test15",
+ * htmldoc=@HtmlDoc(
+ * links={"links15a","links15b","INHERIT"}
+ * )
+ * )
+ */
+ @Test
+ public void test15() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test15");
+ assertEquals("<nav><ol><li>links15a</li><li>links15b</li><li>links1a</li><li>links1b</li><li>links11a</li><li>links11b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test16a",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","[0]:links16a","[3]:links16b"}
+ * )
+ * )
+ */
+ @Test
+ public void test16a() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test16a");
+ assertEquals("<nav><ol><li>links16a</li><li>links1a</li><li>links1b</li><li>links16b</li><li>links11a</li><li>links11b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test16b",
+ * htmldoc=@HtmlDoc(
+ * links={"[1]:links16a","[2]:links16b","INHERIT"}
+ * )
+ * )
+ */
+ @Test
+ public void test16b() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test16b");
+ assertEquals("<nav><ol><li>links16a</li><li>links16b</li><li>links1a</li><li>links1b</li><li>links11a</li><li>links11b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test16c",
+ * htmldoc=@HtmlDoc(
+ * links={"[1]:links16a","[0]:links16b"}
+ * )
+ * )
+ */
+ @Test
+ public void test16c() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test16c");
+ assertEquals("<nav><ol><li>links16b</li><li>links16a</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test16d",
+ * htmldoc=@HtmlDoc(
+ * links={"INHERIT","foo[0]:links16a","bar[3]:links16b"}
+ * )
+ * )
+ */
+ @Test
+ public void test16d() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test16d");
+ assertEquals("<nav><ol><li><a href='/testHtmlDocLinks/testHtmlDocLinks2/links16a'>foo</a></li><li>links1a</li><li>links1b</li><li><a href='/testHtmlDocLinks/testHtmlDocLinks2/links16b'>bar</a></li><li>links11a</li><li>links11b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test16e",
+ * htmldoc=@HtmlDoc(
+ * links={"foo[1]:links16a","bar[2]:links16b","INHERIT"}
+ * )
+ * )
+ */
+ @Test
+ public void test16e() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test16e");
+ assertEquals("<nav><ol><li><a href='/testHtmlDocLinks/testHtmlDocLinks2/links16a'>foo</a></li><li><a href='/testHtmlDocLinks/testHtmlDocLinks2/links16b'>bar</a></li><li>links1a</li><li>links1b</li><li>links11a</li><li>links11b</li></ol></nav>", r);
+ }
+
+ /**
+ * @RestMethod(
+ * path="/test16f",
+ * htmldoc=@HtmlDoc(
+ * links={"foo[1]:links16a","bar[0]:links16b"}
+ * )
+ * )
+ */
+ @Test
+ public void test16f() throws Exception {
+ String r = get("/testHtmlDocLinks/testHtmlDocLinks2/test16f");
+ assertEquals("<nav><ol><li><a href='/testHtmlDocLinks/testHtmlDocLinks2/links16b'>bar</a></li><li><a href='/testHtmlDocLinks/testHtmlDocLinks2/links16a'>foo</a></li></ol></nav>", r);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocTest.java
new file mode 100644
index 0000000..d3c337b
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/HtmlDocTest.java
@@ -0,0 +1,291 @@
+// ***************************************************************************************************************************
+// * 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.junit.Assert.*;
+
+import org.apache.juneau.rest.client.*;
+import org.junit.*;
+
+/**
+ * Validates inheritance on the @HtmlDoc annotation.
+ */
+public class HtmlDocTest extends RestTestcase {
+ private RestClient client = TestMicroservice.DEFAULT_CLIENT;
+
+ private String get(String uri) throws Exception {
+ return client.doGet(uri).accept("text/html").getResponseAsString().replace('\n', ' ').replace('"', '\'');
+ }
+ private String header(String r) {
+ return r.substring(r.indexOf("<header>")+8, r.indexOf("</header>"));
+ }
+ private String script(String r) {
+ return r.substring(r.indexOf("<script>")+8, r.indexOf("</script>"));
+ }
+ private String style(String r) {
+ return r.substring(r.indexOf("<style>")+7, r.indexOf("</style>"));
+ }
+ private String nav(String r) {
+ return r.substring(r.indexOf("<nav>")+5, r.indexOf("</nav>"));
+ }
+ private String aside(String r) {
+ return r.substring(r.indexOf("<aside>")+7, r.indexOf("</aside>"));
+ }
+ private String footer(String r) {
+ return r.substring(r.indexOf("<footer>")+8, r.indexOf("</footer>"));
+ }
+
+ /**
+ * @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"
+ * )
+ * )
+ */
+ @Test
+ public void test1() throws Exception {
+ String r = get("/testHtmlDoc/test1");
+ assertEquals("header1a header1b", header(r));
+ assertEquals("script1a script1b", script(r));
+ assertEquals("@import '/testHtmlDoc/stylesheet1'; style1a style1b ", style(r));
+ assertEquals("nav1a nav1b", nav(r));
+ assertEquals("aside1a aside1b", aside(r));
+ assertEquals("footer1a footer1b", footer(r));
+ }
+
+ /**
+ * @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"
+ * )
+ * )
+ */
+ @Test
+ public void test2() throws Exception {
+ String r = get("/testHtmlDoc/test2");
+ assertEquals("header2a header2b", header(r));
+ assertEquals("script2a script2b", script(r));
+ assertEquals("@import '/testHtmlDoc/stylesheet2'; style2a style2b ", style(r));
+ assertEquals("nav2a nav2b", nav(r));
+ assertEquals("aside2a aside2b", aside(r));
+ assertEquals("footer2a footer2b", footer(r));
+ }
+
+ /**
+ * @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"}
+ * )
+ * )
+ */
+ @Test
+ public void test3() throws Exception {
+ String r = get("/testHtmlDoc/test3");
+ assertEquals("header1a header1b header3a header3b", header(r));
+ assertEquals("script1a script1b script3a script3b", script(r));
+ assertEquals("@import '/testHtmlDoc/stylesheet1'; style1a style1b style3a style3b ", style(r));
+ assertEquals("nav1a nav1b nav3a nav3b", nav(r));
+ assertEquals("aside1a aside1b aside3a aside3b", aside(r));
+ assertEquals("footer1a footer1b footer3a footer3b", footer(r));
+ }
+
+ /**
+ * @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"}
+ * )
+ * )
+ */
+ @Test
+ public void test4() throws Exception {
+ String r = get("/testHtmlDoc/test4");
+ assertEquals("header4a header1a header1b header4b", header(r));
+ assertEquals("script4a script1a script1b script4b", script(r));
+ assertEquals("@import '/testHtmlDoc/stylesheet1'; style4a style1a style1b style4b ", style(r));
+ assertEquals("nav4a nav1a nav1b nav4b", nav(r));
+ assertEquals("aside4a aside1a aside1b aside4b", aside(r));
+ assertEquals("footer4a footer1a footer1b footer4b", footer(r));
+ }
+
+ /**
+ * @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"}
+ * )
+ * )
+ */
+ @Test
+ public void test5() throws Exception {
+ String r = get("/testHtmlDoc/test5");
+ assertEquals("header5a header5b header1a header1b", header(r));
+ assertEquals("script5a script5b script1a script1b", script(r));
+ assertEquals("@import '/testHtmlDoc/stylesheet1'; style5a style5b style1a style1b ", style(r));
+ assertEquals("nav5a nav5b nav1a nav1b", nav(r));
+ assertEquals("aside5a aside5b aside1a aside1b", aside(r));
+ assertEquals("footer5a footer5b footer1a footer1b", footer(r));
+ }
+
+ /**
+ * @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"
+ * )
+ * )
+ */
+ @Test
+ public void test11() throws Exception {
+ String r = get("/testHtmlDoc/testHtmlDoc2/test11");
+ assertEquals("header11a header11b header1a header1b", header(r));
+ assertEquals("script11a script11b", script(r));
+ assertEquals("@import '/testHtmlDoc/testHtmlDoc2/stylesheet11'; style11a style11b ", style(r));
+ assertEquals("nav1a nav1b nav11a nav11b", nav(r));
+ assertEquals("aside1a aside1b aside11a aside11b", aside(r));
+ assertEquals("footer11a footer1a footer1b footer11b", footer(r));
+ }
+
+ /**
+ * @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"
+ * )
+ * )
+ */
+ @Test
+ public void test12() throws Exception {
+ String r = get("/testHtmlDoc/testHtmlDoc2/test12");
+ assertEquals("header12a header12b", header(r));
+ assertEquals("script12a script12b", script(r));
+ assertEquals("@import '/testHtmlDoc/testHtmlDoc2/stylesheet12'; style12a style12b ", style(r));
+ assertEquals("nav12a nav12b", nav(r));
+ assertEquals("aside12a aside12b", aside(r));
+ assertEquals("footer12a footer12b", footer(r));
+ }
+
+ /**
+ * @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"}
+ * )
+ * )
+ */
+ @Test
+ public void test13() throws Exception {
+ String r = get("/testHtmlDoc/testHtmlDoc2/test13");
+ assertEquals("header11a header11b header1a header1b header13a header13b", header(r));
+ assertEquals("script11a script11b script13a script13b", script(r));
+ assertEquals("@import '/testHtmlDoc/testHtmlDoc2/stylesheet11'; style11a style11b style13a style13b ", style(r));
+ assertEquals("nav1a nav1b nav11a nav11b nav13a nav13b", nav(r));
+ assertEquals("aside1a aside1b aside11a aside11b aside13a aside13b", aside(r));
+ assertEquals("footer11a footer1a footer1b footer11b footer13a footer13b", footer(r));
+ }
+
+ /**
+ * @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"}
+ * )
+ * )
+ */
+ @Test
+ public void test14() throws Exception {
+ String r = get("/testHtmlDoc/testHtmlDoc2/test14");
+ assertEquals("header14a header11a header11b header1a header1b header14b", header(r));
+ assertEquals("script14a script11a script11b script14b", script(r));
+ assertEquals("@import '/testHtmlDoc/testHtmlDoc2/stylesheet11'; style14a style11a style11b style14b ", style(r));
+ assertEquals("nav14a nav1a nav1b nav11a nav11b nav14b", nav(r));
+ assertEquals("aside14a aside1a aside1b aside11a aside11b aside14b", aside(r));
+ assertEquals("footer14a footer11a footer1a footer1b footer11b footer14b", footer(r));
+ }
+
+ /**
+ * @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"}
+ * )
+ * )
+ */
+ @Test
+ public void test15() throws Exception {
+ String r = get("/testHtmlDoc/testHtmlDoc2/test15");
+ assertEquals("header15a header15b header11a header11b header1a header1b", header(r));
+ assertEquals("script15a script15b script11a script11b", script(r));
+ assertEquals("@import '/testHtmlDoc/testHtmlDoc2/stylesheet11'; style15a style15b style11a style11b ", style(r));
+ assertEquals("nav15a nav15b nav1a nav1b nav11a nav11b", nav(r));
+ assertEquals("aside15a aside15b aside1a aside1b aside11a aside11b", aside(r));
+ assertEquals("footer15a footer15b footer11a footer1a footer1b footer11b", footer(r));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java
new file mode 100644
index 0000000..a716cc8
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java
@@ -0,0 +1,116 @@
+// ***************************************************************************************************************************
+// * 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.junit.Assert.*;
+
+import org.apache.juneau.rest.client.*;
+import org.junit.*;
+
+public class InheritanceTest extends RestTestcase {
+
+ private RestClient client = TestMicroservice.DEFAULT_CLIENT;
+
+
+ //====================================================================================================
+ // Test serializer inheritance.
+ //====================================================================================================
+ @Test
+ public void testSerializers() throws Exception {
+ String r;
+ String url = "/testInheritanceSerializers";
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("['text/s3','text/s4','text/s1','text/s2']", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("['text/s5']", r);
+
+ r = client.doGet(url + "/test3").getResponseAsString();
+ assertEquals("['text/s5','text/s3','text/s4','text/s1','text/s2']", r);
+ }
+
+ //====================================================================================================
+ // Test parser inheritance.
+ //====================================================================================================
+ @Test
+ public void testParsers() throws Exception {
+ String r;
+ String url = "/testInheritanceParsers";
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("['text/p3','text/p4','text/p1','text/p2']", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("['text/p5']", r);
+
+ r = client.doGet(url + "/test3").getResponseAsString();
+ assertEquals("['text/p5','text/p3','text/p4','text/p1','text/p2']", r);
+ }
+
+ //====================================================================================================
+ // Test encoder inheritance.
+ //====================================================================================================
+ @Test
+ public void testEncoders() throws Exception {
+ String url = "/testInheritanceEncoders";
+ String r = client.doGet(url + "/test").getResponseAsString();
+ assertEquals("['e3','e4','e1','e2','identity']", r);
+ }
+
+ //====================================================================================================
+ // Test filter inheritance.
+ //====================================================================================================
+ @Test
+ public void testTransforms() throws Exception {
+ RestClient client = TestMicroservice.client().accept("text/json+simple").build();
+ String r;
+ String url = "/testInheritanceTransforms";
+
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("['F1','F2','Foo3']", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("['F1','F2','F3']", r);
+
+ r = client.doGet(url + "/test3").getResponseAsString();
+ assertEquals("['F1','F2','F3']", r);
+
+ r = client.doGet(url + "/test4").getResponseAsString();
+ assertEquals("['Foo1','Foo2','F3']", r);
+
+ r = client.doGet(url + "/test5").getResponseAsString();
+ assertEquals("['F1','F2','F3']", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test properties inheritance.
+ //====================================================================================================
+ @Test
+ public void testProperties() throws Exception {
+ RestClient client = TestMicroservice.client().accept("text/json+simple").build();
+ String r;
+ String url = "/testInheritanceProperties";
+
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}", r);
+
+ r = client.doGet(url + "/test2?override").getResponseAsString();
+ assertEquals("{p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'}", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'}", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InterfaceProxyTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InterfaceProxyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InterfaceProxyTest.java
new file mode 100644
index 0000000..e9940d1
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InterfaceProxyTest.java
@@ -0,0 +1,833 @@
+// ***************************************************************************************************************************
+// * 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.test.TestUtils.*;
+import static org.apache.juneau.rest.test.pojos.Constants.*;
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.apache.juneau.html.*;
+import org.apache.juneau.jena.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.msgpack.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.rest.test.pojos.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.utils.*;
+import org.apache.juneau.xml.*;
+import org.junit.*;
+import org.junit.runner.*;
+import org.junit.runners.*;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@RunWith(Parameterized.class)
+public class InterfaceProxyTest extends RestTestcase {
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> getParameters() {
+ return Arrays.asList(new Object[][] {
+ { /* 0 */ "Json", JsonSerializer.DEFAULT, JsonParser.DEFAULT },
+ { /* 1 */ "Xml", XmlSerializer.DEFAULT, XmlParser.DEFAULT },
+ { /* 2 */ "Mixed", JsonSerializer.DEFAULT, XmlParser.DEFAULT },
+ { /* 3 */ "Html", HtmlSerializer.DEFAULT, HtmlParser.DEFAULT },
+ { /* 4 */ "MessagePack", MsgPackSerializer.DEFAULT, MsgPackParser.DEFAULT },
+ { /* 5 */ "UrlEncoding", UrlEncodingSerializer.DEFAULT, UrlEncodingParser.DEFAULT },
+ { /* 6 */ "Uon", UonSerializer.DEFAULT, UonParser.DEFAULT },
+ { /* 7 */ "RdfXml", RdfSerializer.DEFAULT_XMLABBREV, RdfParser.DEFAULT_XML },
+ });
+ }
+
+ private InterfaceProxy proxy;
+
+ public InterfaceProxyTest(String label, Serializer serializer, Parser parser) {
+ proxy = getCached(label, InterfaceProxy.class);
+ if (proxy == null) {
+ proxy = getClient(label, serializer, parser).getRemoteableProxy(InterfaceProxy.class, "/testInterfaceProxyResource/proxy");
+ cache(label, proxy);
+ }
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test return types.
+ //--------------------------------------------------------------------------------
+
+ // Various primitives
+ @Test
+ public void a01_returnVoid() {
+ proxy.returnVoid();
+ }
+
+ @Test
+ public void a02_returnInteger() {
+ assertEquals((Integer)1, proxy.returnInteger());
+ }
+
+ @Test
+ public void a03_returnInt() {
+ assertEquals(1, proxy.returnInt());
+ }
+
+ @Test
+ public void a04_returnBoolean() {
+ assertEquals(true, proxy.returnBoolean());
+ }
+
+ @Test
+ public void a05_returnFloat() {
+ assertTrue(1f == proxy.returnFloat());
+ }
+
+ @Test
+ public void a06_returnFloatObject() {
+ assertTrue(1f == proxy.returnFloatObject());
+ }
+
+ @Test
+ public void a07_returnString() {
+ assertEquals("foobar", proxy.returnString());
+ }
+
+ @Test
+ public void a08_returnNullString() {
+ assertNull(proxy.returnNullString());
+ }
+
+ @Test
+ public void a09_returnInt3dArray() {
+ assertObjectEquals("[[[1,2],null],null]", proxy.returnInt3dArray());
+ }
+
+ @Test
+ public void a10_returnInteger3dArray() {
+ assertObjectEquals("[[[1,null],null],null]", proxy.returnInteger3dArray());
+ }
+
+ @Test
+ public void a11_returnString3dArray() {
+ assertObjectEquals("[[['foo','bar',null],null],null]", proxy.returnString3dArray());
+ }
+
+ @Test
+ public void a12_returnIntegerList() {
+ List<Integer> x = proxy.returnIntegerList();
+ assertObjectEquals("[1,null]", x);
+ assertClass(Integer.class, x.get(0));
+ }
+
+ @Test
+ public void a13_returnInteger3dList() {
+ List<List<List<Integer>>> x = proxy.returnInteger3dList();
+ assertObjectEquals("[[[1,null],null],null]", x);
+ assertClass(Integer.class, x.get(0).get(0).get(0));
+ }
+
+ @Test
+ public void a14_returnInteger1d3dList() {
+ List<Integer[][][]> x = proxy.returnInteger1d3dList();
+ assertObjectEquals("[[[[1,null],null],null],null]", x);
+ assertClass(Integer.class, x.get(0)[0][0][0]);
+ }
+
+ @Test
+ public void a15_returnInt1d3dList() {
+ List<int[][][]> x = proxy.returnInt1d3dList();
+ assertObjectEquals("[[[[1,2],null],null],null]", x);
+ assertClass(int[][][].class, x.get(0));
+ }
+
+ @Test
+ public void a16_returnStringList() {
+ assertObjectEquals("['foo','bar',null]", proxy.returnStringList());
+ }
+
+ // Beans
+
+ @Test
+ public void b01_returnBean() {
+ ABean x = proxy.returnBean();
+ assertObjectEquals("{a:1,b:'foo'}", x);
+ assertClass(ABean.class, x);
+ }
+
+ @Test
+ public void b02_returnBean3dArray() {
+ ABean[][][] x = proxy.returnBean3dArray();
+ assertObjectEquals("[[[{a:1,b:'foo'},null],null],null]", x);
+ assertClass(ABean.class, x[0][0][0]);
+ }
+
+ @Test
+ public void b03_returnBeanList() {
+ List<ABean> x = proxy.returnBeanList();
+ assertObjectEquals("[{a:1,b:'foo'}]", x);
+ assertClass(ABean.class, x.get(0));
+ }
+
+ @Test
+ public void b04_returnBean1d3dList() {
+ List<ABean[][][]> x = proxy.returnBean1d3dList();
+ assertObjectEquals("[[[[{a:1,b:'foo'},null],null],null],null]", x);
+ assertClass(ABean.class, x.get(0)[0][0][0]);
+ }
+
+ @Test
+ public void b05_returnBeanMap() {
+ Map<String,ABean> x = proxy.returnBeanMap();
+ assertObjectEquals("{foo:{a:1,b:'foo'}}", x);
+ assertClass(ABean.class, x.get("foo"));
+ }
+
+ @Test
+ public void b06_returnBeanListMap() {
+ Map<String,List<ABean>> x = proxy.returnBeanListMap();
+ assertObjectEquals("{foo:[{a:1,b:'foo'}]}", x);
+ assertClass(ABean.class, x.get("foo").get(0));
+ }
+
+ @Test
+ public void b07_returnBean1d3dListMap() {
+ Map<String,List<ABean[][][]>> x = proxy.returnBean1d3dListMap();
+ assertObjectEquals("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}", x);
+ assertClass(ABean.class, x.get("foo").get(0)[0][0][0]);
+ }
+
+ @Test
+ public void b08_returnBeanListMapIntegerKeys() {
+ // Note: JsonSerializer serializes key as string.
+ Map<Integer,List<ABean>> x = proxy.returnBeanListMapIntegerKeys();
+ assertObjectEquals("{'1':[{a:1,b:'foo'}]}", x);
+ assertClass(Integer.class, x.keySet().iterator().next());
+ }
+
+ // Typed beans
+
+ @Test
+ public void c01_returnTypedBean() {
+ TypedBean x = proxy.returnTypedBean();
+ assertObjectEquals("{_type:'TypedBeanImpl',a:1,b:'foo'}", x);
+ assertClass(TypedBeanImpl.class, x);
+ }
+
+ @Test
+ public void c02_returnTypedBean3dArray() {
+ TypedBean[][][] x = proxy.returnTypedBean3dArray();
+ assertObjectEquals("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]", x);
+ assertClass(TypedBeanImpl.class, x[0][0][0]);
+ }
+
+ @Test
+ public void c03_returnTypedBeanList() {
+ List<TypedBean> x = proxy.returnTypedBeanList();
+ assertObjectEquals("[{_type:'TypedBeanImpl',a:1,b:'foo'}]", x);
+ assertClass(TypedBeanImpl.class, x.get(0));
+ }
+
+ @Test
+ public void c04_returnTypedBean1d3dList() {
+ List<TypedBean[][][]> x = proxy.returnTypedBean1d3dList();
+ assertObjectEquals("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]", x);
+ assertClass(TypedBeanImpl.class, x.get(0)[0][0][0]);
+ }
+
+ @Test
+ public void c05_returnTypedBeanMap() {
+ Map<String,TypedBean> x = proxy.returnTypedBeanMap();
+ assertObjectEquals("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo"));
+ }
+
+ @Test
+ public void c06_returnTypedBeanListMap() {
+ Map<String,List<TypedBean>> x = proxy.returnTypedBeanListMap();
+ assertObjectEquals("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo").get(0));
+ }
+
+ @Test
+ public void c07_returnTypedBean1d3dListMap() {
+ Map<String,List<TypedBean[][][]>> x = proxy.returnTypedBean1d3dListMap();
+ assertObjectEquals("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo").get(0)[0][0][0]);
+ }
+
+ @Test
+ public void c08_returnTypedBeanListMapIntegerKeys() {
+ // Note: JsonSerializer serializes key as string.
+ Map<Integer,List<TypedBean>> x = proxy.returnTypedBeanListMapIntegerKeys();
+ assertObjectEquals("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", x);
+ assertClass(TypedBeanImpl.class, x.get(1).get(0));
+ }
+
+ // Swapped POJOs
+
+ @Test
+ public void d01_returnSwappedPojo() {
+ SwappedPojo x = proxy.returnSwappedPojo();
+ assertObjectEquals("'"+SWAP+"'", x);
+ assertTrue(x.wasUnswapped);
+ }
+
+ @Test
+ public void d02_returnSwappedPojo3dArray() {
+ SwappedPojo[][][] x = proxy.returnSwappedPojo3dArray();
+ assertObjectEquals("[[['"+SWAP+"',null],null],null]", x);
+ assertTrue(x[0][0][0].wasUnswapped);
+ }
+
+ @Test
+ public void d03_returnSwappedPojoMap() {
+ Map<SwappedPojo,SwappedPojo> x = proxy.returnSwappedPojoMap();
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}", x);
+ Map.Entry<SwappedPojo,SwappedPojo> e = x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue().wasUnswapped);
+ }
+
+ @Test
+ public void d04_returnSwappedPojo3dMap() {
+ Map<SwappedPojo,SwappedPojo[][][]> x = proxy.returnSwappedPojo3dMap();
+ 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
+
+ @Test
+ public void e01_returnImplicitSwappedPojo() {
+ ImplicitSwappedPojo x = proxy.returnImplicitSwappedPojo();
+ assertObjectEquals("'"+SWAP+"'", x);
+ assertTrue(x.wasUnswapped);
+ }
+
+ @Test
+ public void e02_returnImplicitSwappedPojo3dArray() {
+ ImplicitSwappedPojo[][][] x = proxy.returnImplicitSwappedPojo3dArray();
+ assertObjectEquals("[[['"+SWAP+"',null],null],null]", x);
+ assertTrue(x[0][0][0].wasUnswapped);
+ }
+
+ @Test
+ public void e03_returnImplicitSwappedPojoMap() {
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x = proxy.returnImplicitSwappedPojoMap();
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}", x);
+ Map.Entry<ImplicitSwappedPojo,ImplicitSwappedPojo> e = x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue().wasUnswapped);
+ }
+
+ @Test
+ public void e04_returnImplicitSwappedPojo3dMap() {
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> x = proxy.returnImplicitSwappedPojo3dMap();
+ 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
+
+ @Test
+ public void f01_returnEnum() {
+ TestEnum x = proxy.returnEnum();
+ assertObjectEquals("'TWO'", x);
+ }
+
+ @Test
+ public void f02_returnEnum3d() {
+ TestEnum[][][] x = proxy.returnEnum3d();
+ assertObjectEquals("[[['TWO',null],null],null]", x);
+ assertClass(TestEnum.class, x[0][0][0]);
+ }
+
+ @Test
+ public void f03_returnEnumList() {
+ List<TestEnum> x = proxy.returnEnumList();
+ assertObjectEquals("['TWO',null]", x);
+ assertClass(TestEnum.class, x.get(0));
+ }
+
+ @Test
+ public void f04_returnEnum3dList() {
+ List<List<List<TestEnum>>> x = proxy.returnEnum3dList();
+ assertObjectEquals("[[['TWO',null],null,null]]", x);
+ assertClass(TestEnum.class, x.get(0).get(0).get(0));
+ }
+
+ @Test
+ public void f05_returnEnum1d3dList() {
+ List<TestEnum[][][]> x = proxy.returnEnum1d3dList();
+ assertObjectEquals("[[[['TWO',null],null],null],null]", x);
+ assertClass(TestEnum[][][].class, x.get(0));
+ }
+
+ @Test
+ public void f06_returnEnumMap() {
+ Map<TestEnum,TestEnum> x = proxy.returnEnumMap();
+ assertObjectEquals("{ONE:'TWO'}", x);
+ Map.Entry<TestEnum,TestEnum> e = x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum.class, e.getValue());
+ }
+
+ @Test
+ public void f07_returnEnum3dArrayMap() {
+ Map<TestEnum,TestEnum[][][]> x = proxy.returnEnum3dArrayMap();
+ 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());
+ }
+
+ @Test
+ public void f08_returnEnum1d3dListMap() {
+ Map<TestEnum,List<TestEnum[][][]>> x = proxy.returnEnum1d3dListMap();
+ assertObjectEquals("{ONE:[[[['TWO',null],null],null],null]}", x);
+ assertClass(TestEnum[][][].class, x.get(TestEnum.ONE).get(0));
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test server-side exception serialization.
+ //--------------------------------------------------------------------------------
+
+ @Test
+ public void g01_throwException1() {
+ try {
+ proxy.throwException1();
+ fail("Exception expected");
+ } catch (InterfaceProxy.InterfaceProxyException1 e) {
+ assertEquals("foo", e.getMessage());
+ }
+ }
+
+ @Test
+ public void g02_throwException2() {
+ try {
+ proxy.throwException2();
+ fail("Exception expected");
+ } catch (InterfaceProxy.InterfaceProxyException2 e) {
+ }
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test parameters
+ //--------------------------------------------------------------------------------
+
+ // Various primitives
+ @Test
+ public void h01_setNothing() {
+ proxy.setNothing();
+ }
+
+ @Test
+ public void h02_setInt() {
+ proxy.setInt(1);
+ }
+
+ @Test
+ public void h03_setWrongInt() {
+ try {
+ proxy.setInt(2);
+ fail("Exception expected");
+ } catch (AssertionError e) { // AssertionError thrown on server side.
+ assertEquals("expected:<1> but was:<2>", e.getMessage());
+ }
+ }
+
+ @Test
+ public void h04_setInteger() {
+ proxy.setInteger(1);
+ }
+
+ @Test
+ public void h05_setBoolean() {
+ proxy.setBoolean(true);
+ }
+
+ @Test
+ public void h06_setFloat() {
+ proxy.setFloat(1f);
+ }
+
+ @Test
+ public void h07_setFloatObject() {
+ proxy.setFloatObject(1f);
+ }
+
+ @Test
+ public void h08_setString() {
+ proxy.setString("foo");
+ }
+
+ @Test
+ public void h09_setNullString() {
+ proxy.setNullString(null);
+ }
+
+ @Test
+ public void h10_setNullStringBad() {
+ try {
+ proxy.setNullString("foo");
+ fail("Exception expected");
+ } catch (AssertionError e) { // AssertionError thrown on server side.
+ assertEquals("expected null, but was:<foo>", e.getLocalizedMessage());
+ }
+ }
+
+ @Test
+ public void h11_setInt3dArray() {
+ proxy.setInt3dArray(new int[][][]{{{1,2},null},null});
+ }
+
+ @Test
+ public void h12_setInteger3dArray() {
+ proxy.setInteger3dArray(new Integer[][][]{{{1,null},null},null});
+ }
+
+ @Test
+ public void h13_setString3dArray() {
+ proxy.setString3dArray(new String[][][]{{{"foo",null},null},null});
+ }
+
+ @Test
+ public void h14_setIntegerList() {
+ proxy.setIntegerList(new AList<Integer>().append(1).append(null));
+ }
+
+ @Test
+ public void h15_setInteger3dList() {
+ proxy.setInteger3dList(
+ new AList<List<List<Integer>>>()
+ .append(
+ new AList<List<Integer>>()
+ .append(new AList<Integer>().append(1).append(null))
+ .append(null)
+ )
+ .append(null)
+ );
+ }
+
+ @Test
+ public void h16_setInteger1d3dList() {
+ proxy.setInteger1d3dList(
+ new AList<Integer[][][]>().append(new Integer[][][]{{{1,null},null},null}).append(null)
+ );
+ }
+
+ @Test
+ public void h17_setInt1d3dList() {
+ proxy.setInt1d3dList(
+ new AList<int[][][]>().append(new int[][][]{{{1,2},null},null}).append(null)
+ );
+ }
+
+ @Test
+ public void h18_setStringList() {
+ proxy.setStringList(Arrays.asList("foo","bar",null));
+ }
+
+ // Beans
+ @Test
+ public void h19_setBean() {
+ proxy.setBean(new ABean().init());
+ }
+
+ @Test
+ public void h20_setBean3dArray() {
+ proxy.setBean3dArray(new ABean[][][]{{{new ABean().init(),null},null},null});
+ }
+
+ @Test
+ public void h21_setBeanList() {
+ proxy.setBeanList(Arrays.asList(new ABean().init()));
+ }
+
+ @Test
+ public void h22_setBean1d3dList() {
+ proxy.setBean1d3dList(new AList<ABean[][][]>().append(new ABean[][][]{{{new ABean().init(),null},null},null}).append(null));
+ }
+
+ @Test
+ public void h23_setBeanMap() {
+ proxy.setBeanMap(new AMap<String,ABean>().append("foo",new ABean().init()));
+ }
+
+ @Test
+ public void h24_setBeanListMap() {
+ proxy.setBeanListMap(new AMap<String,List<ABean>>().append("foo",Arrays.asList(new ABean().init())));
+ }
+
+ @Test
+ public void h25_setBean1d3dListMap() {
+ proxy.setBean1d3dListMap(new AMap<String,List<ABean[][][]>>().append("foo",new AList<ABean[][][]>().append(new ABean[][][]{{{new ABean().init(),null},null},null}).append(null)));
+ }
+
+ @Test
+ public void h26_setBeanListMapIntegerKeys() {
+ proxy.setBeanListMapIntegerKeys(new AMap<Integer,List<ABean>>().append(1,Arrays.asList(new ABean().init())));
+ }
+
+ // Typed beans
+
+ @Test
+ public void i01_setTypedBean() {
+ proxy.setTypedBean(new TypedBeanImpl().init());
+ }
+
+ @Test
+ public void i02_setTypedBean3dArray() {
+ proxy.setTypedBean3dArray(new TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null});
+ }
+
+ @Test
+ public void i03_setTypedBeanList() {
+ proxy.setTypedBeanList(Arrays.asList((TypedBean)new TypedBeanImpl().init()));
+ }
+
+ @Test
+ public void i04_setTypedBean1d3dList() {
+ proxy.setTypedBean1d3dList(new AList<TypedBean[][][]>().append(new TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null}).append(null));
+ }
+
+ @Test
+ public void i05_setTypedBeanMap() {
+ proxy.setTypedBeanMap(new AMap<String,TypedBean>().append("foo",new TypedBeanImpl().init()));
+ }
+
+ @Test
+ public void i06_setTypedBeanListMap() {
+ proxy.setTypedBeanListMap(new AMap<String,List<TypedBean>>().append("foo",Arrays.asList((TypedBean)new TypedBeanImpl().init())));
+ }
+
+ @Test
+ public void i07_setTypedBean1d3dListMap() {
+ proxy.setTypedBean1d3dListMap(new AMap<String,List<TypedBean[][][]>>().append("foo",new AList<TypedBean[][][]>().append(new TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null}).append(null)));
+ }
+
+ @Test
+ public void i08_setTypedBeanListMapIntegerKeys() {
+ proxy.setTypedBeanListMapIntegerKeys(new AMap<Integer,List<TypedBean>>().append(1,Arrays.asList((TypedBean)new TypedBeanImpl().init())));
+ }
+
+ // Swapped POJOs
+
+ @Test
+ public void j01_setSwappedPojo() {
+ proxy.setSwappedPojo(new SwappedPojo());
+ }
+
+ @Test
+ public void j02_setSwappedPojo3dArray() {
+ proxy.setSwappedPojo3dArray(new SwappedPojo[][][]{{{new SwappedPojo(),null},null},null});
+ }
+
+ @Test
+ public void j03_setSwappedPojoMap() {
+ proxy.setSwappedPojoMap(new AMap<SwappedPojo,SwappedPojo>().append(new SwappedPojo(), new SwappedPojo()));
+ }
+
+ @Test
+ public void j04_setSwappedPojo3dMap() {
+ proxy.setSwappedPojo3dMap(new AMap<SwappedPojo,SwappedPojo[][][]>().append(new SwappedPojo(), new SwappedPojo[][][]{{{new SwappedPojo(),null},null},null}));
+ }
+
+ // Implicit swapped POJOs
+ @Test
+ public void k01_setImplicitSwappedPojo() {
+ proxy.setImplicitSwappedPojo(new ImplicitSwappedPojo());
+ }
+
+ @Test
+ public void k02_setImplicitSwappedPojo3dArray() {
+ proxy.setImplicitSwappedPojo3dArray(new ImplicitSwappedPojo[][][]{{{new ImplicitSwappedPojo(),null},null},null});
+ }
+
+ @Test
+ public void k03_setImplicitSwappedPojoMap() {
+ proxy.setImplicitSwappedPojoMap(new AMap<ImplicitSwappedPojo,ImplicitSwappedPojo>().append(new ImplicitSwappedPojo(), new ImplicitSwappedPojo()));
+ }
+
+ @Test
+ public void k04_setImplicitSwappedPojo3dMap() {
+ proxy.setImplicitSwappedPojo3dMap(new AMap<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>().append(new ImplicitSwappedPojo(), new ImplicitSwappedPojo[][][]{{{new ImplicitSwappedPojo(),null},null},null}));
+ }
+
+ // Enums
+
+ @Test
+ public void l01_setEnum() {
+ proxy.setEnum(TestEnum.TWO);
+ }
+
+ @Test
+ public void l02_setEnum3d() {
+ proxy.setEnum3d(new TestEnum[][][]{{{TestEnum.TWO,null},null},null});
+ }
+
+ @Test
+ public void l03_setEnumList() {
+ proxy.setEnumList(new AList<TestEnum>().append(TestEnum.TWO).append(null));
+ }
+
+ @Test
+ public void l04_setEnum3dList() {
+ proxy.setEnum3dList(
+ new AList<List<List<TestEnum>>>()
+ .append(
+ new AList<List<TestEnum>>()
+ .append(
+ new AList<TestEnum>().append(TestEnum.TWO).append(null)
+ )
+ .append(null)
+ .append(null)
+ )
+ );
+ }
+
+ @Test
+ public void l05_setEnum1d3dList() {
+ proxy.setEnum1d3dList(new AList<TestEnum[][][]>().append(new TestEnum[][][]{{{TestEnum.TWO,null},null},null}).append(null));
+ }
+
+ @Test
+ public void l06_setEnumMap() {
+ proxy.setEnumMap(new AMap<TestEnum,TestEnum>().append(TestEnum.ONE,TestEnum.TWO));
+ }
+
+ @Test
+ public void l07_setEnum3dArrayMap() {
+ proxy.setEnum3dArrayMap(new AMap<TestEnum,TestEnum[][][]>().append(TestEnum.ONE, new TestEnum[][][]{{{TestEnum.TWO,null},null},null}));
+ }
+
+ @Test
+ public void l08_setEnum1d3dListMap() {
+ proxy.setEnum1d3dListMap(new AMap<TestEnum,List<TestEnum[][][]>>().append(TestEnum.ONE, new AList<TestEnum[][][]>().append(new TestEnum[][][]{{{TestEnum.TWO,null},null},null}).append(null)));
+ }
+
+ //--------------------------------------------------------------------------------
+ // Test multi-parameters
+ //--------------------------------------------------------------------------------
+
+ @Test
+ public void m01_setMultiParamsInts() {
+ int x1 = 1;
+ int[][][] x2 = new int[][][]{{{1,2},null},null};
+ int[][][] x2n = null;
+ List<int[][][]> x3 = new AList<int[][][]>().append(x2).append(null);
+ List<int[][][]> x3n = null;
+ proxy.setMultiParamsInts(x1, x2, x2n, x3, x3n);
+ }
+
+ @Test
+ public void m02_setMultiParamsInteger() {
+ Integer x1 = 1;
+ Integer x1n = null;
+ Integer[][][] x2 = new Integer[][][]{{{1,null},null},null};
+ Integer[][][] x2n = null;
+ List<Integer[][][]> x3 = new AList<Integer[][][]>().append(x2).append(null);
+ List<Integer[][][]> x3n = null;
+ proxy.setMultiParamsInteger(x1, x1n, x2, x2n, x3, x3n);
+ }
+
+ @Test
+ public void m03_setMultiParamsFloat() {
+ float x1 = 1;
+ float[][][] x2 = new float[][][]{{{1,2},null},null};
+ float[][][] x2n = null;
+ List<float[][][]> x3 = new AList<float[][][]>().append(x2).append(null);
+ List<float[][][]> x3n = null;
+ proxy.setMultiParamsFloat(x1, x2, x2n, x3, x3n);
+ }
+
+ @Test
+ public void m04_setMultiParamsFloatObject() {
+ Float x1 = 1f;
+ Float x1n = null;
+ Float[][][] x2 = new Float[][][]{{{1f,null},null},null};
+ Float[][][] x2n = null;
+ List<Float[][][]> x3 = new AList<Float[][][]>().append(x2).append(null);
+ List<Float[][][]> x3n = null;
+ proxy.setMultiParamsFloatObject(x1, x1n, x2, x2n, x3, x3n);
+ }
+
+ @Test
+ public void m05_setMultiParamsString() {
+ String x1 = "foo";
+ String[][][] x2 = new String[][][]{{{"foo",null},null},null};
+ String[][][] x2n = null;
+ List<String[][][]> x3 = new AList<String[][][]>().append(x2).append(null);
+ List<String[][][]> x3n = null;
+ proxy.setMultiParamsString(x1, x2, x2n, x3, x3n);
+ }
+
+ @Test
+ public void m06_setMultiParamsBean() {
+ ABean x1 = new ABean().init();
+ ABean[][][] x2 = new ABean[][][]{{{new ABean().init(),null},null},null};
+ ABean[][][] x2n = null;
+ List<ABean[][][]> x3 = new AList<ABean[][][]>().append(x2).append(null);
+ List<ABean[][][]> x3n = null;
+ Map<String,ABean> x4 = new AMap<String,ABean>().append("foo",new ABean().init());
+ Map<String,ABean> x4n = null;
+ Map<String,List<ABean[][][]>> x5 = new AMap<String,List<ABean[][][]>>().append("foo", x3);
+ Map<String,List<ABean[][][]>> x5n = null;
+ proxy.setMultiParamsBean(x1, x2, x2n, x3, x3n, x4, x4n, x5, x5n);
+ }
+
+ @Test
+ public void m07_setMultiParamsSwappedPojo() {
+ SwappedPojo x1 = new SwappedPojo();
+ SwappedPojo[][][] x2 = new SwappedPojo[][][]{{{new SwappedPojo(),null},null},null};
+ SwappedPojo[][][] x2n = null;
+ List<SwappedPojo[][][]> x3 = new AList<SwappedPojo[][][]>().append(x2).append(null);
+ List<SwappedPojo[][][]> x3n = null;
+ Map<SwappedPojo,SwappedPojo> x4 = new AMap<SwappedPojo,SwappedPojo>().append(new SwappedPojo(), new SwappedPojo());
+ Map<SwappedPojo,SwappedPojo> x4n = null;
+ Map<SwappedPojo,List<SwappedPojo[][][]>> x5 = new AMap<SwappedPojo,List<SwappedPojo[][][]>>().append(new SwappedPojo(), x3);
+ Map<SwappedPojo,List<SwappedPojo[][][]>> x5n = null;
+ proxy.setMultiParamsSwappedPojo(x1, x2, x2n, x3, x3n, x4, x4n, x5, x5n);
+ }
+
+ @Test
+ public void m08_setMultiParamsImplicitSwappedPojo() {
+ ImplicitSwappedPojo x1 = new ImplicitSwappedPojo();
+ ImplicitSwappedPojo[][][] x2 = new ImplicitSwappedPojo[][][]{{{new ImplicitSwappedPojo(),null},null},null};
+ ImplicitSwappedPojo[][][] x2n = null;
+ List<ImplicitSwappedPojo[][][]> x3 = new AList<ImplicitSwappedPojo[][][]>().append(x2).append(null);
+ List<ImplicitSwappedPojo[][][]> x3n = null;
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4 = new AMap<ImplicitSwappedPojo,ImplicitSwappedPojo>().append(new ImplicitSwappedPojo(), new ImplicitSwappedPojo());
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4n = null;
+ Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5 = new AMap<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>>().append(new ImplicitSwappedPojo(), x3);
+ Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5n = null;
+ proxy.setMultiParamsImplicitSwappedPojo(x1, x2, x2n, x3, x3n, x4, x4n, x5, x5n);
+ }
+
+ @Test
+ public void m09_setMultiParamsEnum() {
+ TestEnum x1 = TestEnum.TWO;
+ TestEnum[][][] x2 = new TestEnum[][][]{{{TestEnum.TWO,null},null},null};
+ TestEnum[][][] x2n = null;
+ List<TestEnum[][][]> x3 = new AList<TestEnum[][][]>().append(x2).append(null);
+ List<TestEnum[][][]> x3n = null;
+ Map<TestEnum,TestEnum> x4 = new AMap<TestEnum,TestEnum>().append(TestEnum.ONE,TestEnum.TWO);
+ Map<TestEnum,TestEnum> x4n = null;
+ Map<TestEnum,List<TestEnum[][][]>> x5 = new AMap<TestEnum,List<TestEnum[][][]>>().append(TestEnum.ONE, x3);
+ Map<TestEnum,List<TestEnum[][][]>> x5n = null;
+ proxy.setMultiParamsEnum(x1, x2, x2n, x3, x3n, x4, x4n, x5, x5n);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/JacocoDummyTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/JacocoDummyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/JacocoDummyTest.java
new file mode 100644
index 0000000..c1496ce
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/JacocoDummyTest.java
@@ -0,0 +1,38 @@
+// ***************************************************************************************************************************
+// * 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.lang.reflect.*;
+
+import org.apache.juneau.rest.*;
+import org.junit.*;
+
+public class JacocoDummyTest {
+
+ //====================================================================================================
+ // Dummy code to add test coverage in Jacoco.
+ //====================================================================================================
+ @Test
+ public void accessPrivateConstructorsOnStaticUtilityClasses() throws Exception {
+
+ Class<?>[] classes = new Class[] {
+ RestUtils.class
+ };
+
+ for (Class<?> c : classes) {
+ Constructor<?> c1 = c.getDeclaredConstructor();
+ c1.setAccessible(true);
+ c1.newInstance();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/LargePojosTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/LargePojosTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/LargePojosTest.java
new file mode 100644
index 0000000..f2db303
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/LargePojosTest.java
@@ -0,0 +1,84 @@
+// ***************************************************************************************************************************
+// * 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.html.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.xml.*;
+import org.junit.*;
+
+@Ignore
+public class LargePojosTest extends RestTestcase {
+
+ private static String URL = "/testLargePojos";
+ boolean debug = false;
+
+ //====================================================================================================
+ // Test how long it takes to serialize/parse various content types.
+ //====================================================================================================
+ @Test
+ public void test() throws Exception {
+ LargePojo p;
+ long t;
+ RestClient c;
+
+ System.err.println("\n---Testing JSON---");
+ c = TestMicroservice.DEFAULT_CLIENT;
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ System.err.println("\n---Testing XML---");
+ c = TestMicroservice.client(XmlSerializer.class, XmlParser.class).build();
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ System.err.println("\n---Testing HTML---");
+ c = TestMicroservice.client(HtmlSerializer.class, HtmlParser.class).accept("text/html+stripped").build();
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ c.closeQuietly();
+
+ System.err.println("\n---Testing UrlEncoding---");
+ c = TestMicroservice.client(UonSerializer.class, UonParser.class).build();
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ c.closeQuietly();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/MessagesTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/MessagesTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/MessagesTest.java
new file mode 100644
index 0000000..5cb4b82
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/MessagesTest.java
@@ -0,0 +1,44 @@
+// ***************************************************************************************************************************
+// * 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.test.TestUtils.*;
+
+import java.util.*;
+
+import org.apache.juneau.rest.client.*;
+import org.junit.*;
+
+/**
+ * Validates that resource bundles can be defined on both parent and child classes.
+ */
+public class MessagesTest extends RestTestcase {
+
+ //====================================================================================================
+ // Return contents of resource bundle.
+ //====================================================================================================
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void test() throws Exception {
+ RestClient client = TestMicroservice.DEFAULT_CLIENT;
+
+ // Parent resource should just pick up values from its bundle.
+ TreeMap r = client.doGet("/testMessages/test").getResponse(TreeMap.class);
+ assertObjectEquals("{key1:'value1a',key2:'value2a'}", r);
+
+ // Child resource should pick up values from both parent and child,
+ // ordered child before parent.
+ r = client.doGet("/testMessages2/test").getResponse(TreeMap.class);
+ assertObjectEquals("{key1:'value1a',key2:'value2b',key3:'value3b'}", r);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java
new file mode 100644
index 0000000..55b0272
--- /dev/null
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java
@@ -0,0 +1,43 @@
+// ***************************************************************************************************************************
+// * 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.junit.Assert.*;
+
+import org.apache.juneau.rest.client.*;
+import org.junit.*;
+
+public class NlsPropertyTest extends RestTestcase {
+
+ private static String URL = "/testNlsProperty";
+
+ //====================================================================================================
+ // Test getting an NLS property defined on a class.
+ //====================================================================================================
+ @Test
+ public void testInheritedFromClass() throws Exception {
+ RestClient client = TestMicroservice.DEFAULT_CLIENT_PLAINTEXT;
+ String r = client.doGet(URL + "/testInheritedFromClass").getResponseAsString();
+ assertEquals("value1", r);
+ }
+
+ //====================================================================================================
+ // Test getting an NLS property defined on a method.
+ //====================================================================================================
+ @Test
+ public void testInheritedFromMethod() throws Exception {
+ RestClient client = TestMicroservice.DEFAULT_CLIENT_PLAINTEXT;
+ String r = client.doGet(URL + "/testInheritedFromMethod").getResponseAsString();
+ assertEquals("value2", r);
+ }
+}