You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2020/07/31 22:55:18 UTC
[juneau] branch master updated: Rest server tests.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new b9cb2fe Rest server tests.
b9cb2fe is described below
commit b9cb2fe5545a017a59ef6a032e47ba10d2dc00c6
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Fri Jul 31 18:55:11 2020 -0400
Rest server tests.
---
.../juneau/html/annotation/HtmlDocConfig_Test.java | 681 +++++++++
.../org/apache/juneau/rest/BasicResponsesTest.java | 175 ---
...ggerTest.java => BasicRestCallLogger_Test.java} | 148 +-
.../juneau/rest/BeanContextPropertiesTest.java | 54 -
.../java/org/apache/juneau/rest/DebugModeTest.java | 1196 ---------------
...setTest.java => Header_AcceptCharset_Test.java} | 59 +-
...ngTest.java => Header_AcceptEncoding_Test.java} | 140 +-
.../AcceptTest.java => Header_Accept_Test.java} | 149 +-
...tTypeTest.java => Header_ContentType_Test.java} | 168 +--
.../juneau/rest/{NlsTest.java => Nls_Test.java} | 46 +-
.../rest/{PathsTest.java => Paths_Test.java} | 30 +-
...figTest.java => RestCallLoggerConfig_Test.java} | 2 +-
...rRuleTest.java => RestCallLoggerRule_Test.java} | 2 +-
...est.java => RestContext_ThreadLocals_Test.java} | 16 +-
.../apache/juneau/rest/RestMethod_Params_Test.java | 414 +++++
.../juneau/rest/RestMethod_Returns_Test.java | 188 +++
.../BasicTest.java => RestMethod_Throws_Test.java} | 640 +-------
.../org/apache/juneau/rest/RestParamsTest.java | 209 ---
...t.java => Rest_PredefinedStatusCodes_Test.java} | 134 +-
...ppingTest.java => StaticFilesMapping_Test.java} | 2 +-
...RestInfoProviderTest.java => Swagger_Test.java} | 1238 +++++++--------
.../BeanConfig_Swaps_Test.java} | 58 +-
.../apache/juneau/rest/annotation/Body_Test.java | 1006 +++++++++++++
.../juneau/rest/annotation/FormData_Test.java | 214 +++
.../HasFormData_Test.java} | 43 +-
.../juneau/rest/annotation/HasQuery_Test.java | 76 +
.../apache/juneau/rest/annotation/Header_Test.java | 212 +++
.../juneau/rest/annotation/HtmlDocAsideTest.java | 124 --
.../rest/annotation/HtmlDocConfigAsideTest.java | 135 --
.../rest/annotation/HtmlDocConfigFooterTest.java | 135 --
.../rest/annotation/HtmlDocConfigHeaderTest.java | 135 --
.../rest/annotation/HtmlDocConfigNavTest.java | 135 --
.../rest/annotation/HtmlDocConfigNavlinksTest.java | 245 ---
.../rest/annotation/HtmlDocConfigScriptTest.java | 135 --
.../rest/annotation/HtmlDocConfigStyleTest.java | 135 --
.../juneau/rest/annotation/HtmlDocFooterTest.java | 124 --
.../juneau/rest/annotation/HtmlDocHeaderTest.java | 124 --
.../juneau/rest/annotation/HtmlDocNavTest.java | 124 --
.../rest/annotation/HtmlDocNavlinksTest.java | 222 ---
.../juneau/rest/annotation/HtmlDocScriptTest.java | 124 --
.../juneau/rest/annotation/HtmlDocStyleTest.java | 124 --
.../PathRemainder_Test.java} | 44 +-
.../apache/juneau/rest/annotation/Path_Test.java | 890 +++++++++++
.../apache/juneau/rest/annotation/Query_Test.java | 292 ++++
...yAnnotationTest.java => ResponseBody_Test.java} | 2 +-
.../annotation/ResponseHeaderAnnotationTest.java | 279 ----
.../rest/annotation/ResponseHeader_Test.java | 252 ++++
...nnotationTest.java => ResponseStatus_Test.java} | 16 +-
.../juneau/rest/annotation/Response_Test.java | 348 +++++
.../RestHook_Test.java} | 149 +-
.../juneau/rest/annotation/RestMethodBpiTest.java | 533 -------
.../juneau/rest/annotation/RestMethodPathTest.java | 109 --
.../annotation/RestMethod_BeanConfig_Test.java | 299 ++++
.../RestMethod_ClientVersion_Test.java} | 38 +-
...GuardsTest.java => RestMethod_Guards_Test.java} | 40 +-
...hersTest.java => RestMethod_Matchers_Test.java} | 35 +-
.../RestMethod_ReqHeaders_Test.java} | 101 +-
.../rest/annotation/RestResourceLoggingTest.java | 685 ---------
.../juneau/rest/annotation/RestResourceTest.java | 485 ------
...PathTest.java => Rest_AllowBodyParam_Test.java} | 69 +-
.../annotation/Rest_AllowedHeaderParams_Test.java | 103 ++
.../annotation/Rest_AllowedMethodHeaders_Test.java | 128 ++
.../annotation/Rest_AllowedMethodParams_Test.java | 168 +++
.../Rest_AnnotationInheritance_Test.java} | 50 +-
.../Rest_Context_Test.java} | 36 +-
.../juneau/rest/annotation/Rest_Debug_Test.java | 1198 +++++++++++++++
.../Rest_Encoders_Test.java} | 44 +-
.../juneau/rest/annotation/Rest_Logging_Test.java | 557 +++++++
.../juneau/rest/annotation/Rest_Messages_Test.java | 28 +-
...rcePropertiesTest.java => Rest_RVars_Test.java} | 21 +-
...icFilesTest.java => Rest_StaticFiles_Test.java} | 75 +-
.../Restx_Parsers_Test.java} | 134 +-
.../juneau/rest/annotation/Restx_Path_Test.java | 147 ++
.../Restx_ReqAttrs_Test.java} | 181 +--
.../Restx_RoleGuard_Test.java} | 682 +++------
...lizersTest.java => Restx_Serializers_Test.java} | 115 +-
.../juneau/rest/annotation/Swagger_Body_Test.java | 345 +++++
.../rest/annotation/Swagger_FormData_Test.java | 301 ++++
.../rest/annotation/Swagger_Header_Test.java | 295 ++++
.../juneau/rest/annotation/Swagger_Path_Test.java | 349 +++++
.../juneau/rest/annotation/Swagger_Query_Test.java | 271 ++++
.../rest/annotation/Swagger_Response_Test.java | 431 ++++++
.../annotation/Swagger_RestMethod_Parameters.java | 229 +++
.../rest/annotation2/BodyAnnotationTest.java | 1590 --------------------
.../rest/annotation2/FormDataAnnotationTest.java | 556 -------
.../rest/annotation2/HasQueryAnnotationTest.java | 76 -
.../rest/annotation2/HeaderAnnotationTest.java | 422 ------
.../rest/annotation2/PathAnnotationTest.java | 1500 ------------------
.../rest/annotation2/QueryAnnotationTest.java | 622 --------
.../rest/annotation2/ResponseAnnotationTest.java | 1028 -------------
.../rest/annotation2/RestMethodInheritTest.java | 322 ----
.../RoleMatcher_Test.java} | 5 +-
.../apache/juneau/rest/headers/HeadersTest.java | 792 ----------
.../juneau/rest/helper/BasicHttpResourceTest.java | 117 --
.../{HyperlinkTest.java => Hyperlink_Test.java} | 35 +-
.../ResourceDescription_Test.java} | 5 +-
...questTest.java => MockServletRequest_Test.java} | 2 +-
.../{RestUtilsTest.java => RestUtils_Test.java} | 65 +-
...thPatternTest.java => UrlPathPattern_Test.java} | 2 +-
99 files changed, 11386 insertions(+), 15628 deletions(-)
diff --git a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/annotation/HtmlDocConfig_Test.java b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/annotation/HtmlDocConfig_Test.java
new file mode 100644
index 0000000..d611825
--- /dev/null
+++ b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/html/annotation/HtmlDocConfig_Test.java
@@ -0,0 +1,681 @@
+package org.apache.juneau.html.annotation;
+
+import static org.junit.runners.MethodSorters.*;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.mock2.*;
+import org.junit.*;
+
+//***************************************************************************************************************************
+//* 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. *
+//***************************************************************************************************************************
+
+@FixMethodOrder(NAME_ASCENDING)
+@SuppressWarnings({"serial"})
+public class HtmlDocConfig_Test {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(aside)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(aside={"a01a","a01b","INHERIT"})
+ public static class A1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"a02a","a02b"})
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void a01_aside() throws Exception {
+ RestClient a1 = client(A1.class);
+ a1.get("/a01").accept("text/html").run().assertBody().contains("<aside>a01a a01b</aside>");
+ a1.get("/a02").accept("text/html").run().assertBody().contains("<aside>a02a a02b</aside>");
+ a1.get("/a03").accept("text/html").run().assertBody().contains("<aside>a01a a01b a03a a03b</aside>");
+ a1.get("/a04").accept("text/html").run().assertBody().contains("<aside>a04a a01a a01b a04b</aside>");
+ a1.get("/a05").accept("text/html").run().assertBody().contains("<aside>a05a a05b a01a a01b</aside>");
+ }
+
+ @Rest
+ @HtmlDocConfig(aside={"INHERIT","b01a","b01b"})
+ public static class A2 extends A1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"b02a","b02b"})
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(aside={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void a02_aside_inherited() throws Exception {
+ RestClient a2 = client(A2.class);
+ a2.get("/b01").accept("text/html").run().assertBody().contains("<aside>a01a a01b b01a b01b</aside>");
+ a2.get("/b02").accept("text/html").run().assertBody().contains("<aside>b02a b02b</aside>");
+ a2.get("/b03").accept("text/html").run().assertBody().contains("<aside>a01a a01b b01a b01b b03a b03b</aside>");
+ a2.get("/b04").accept("text/html").run().assertBody().contains("<aside>b04a a01a a01b b01a b01b b04b</aside>");
+ a2.get("/b05").accept("text/html").run().assertBody().contains("<aside>b05a b05b a01a a01b b01a b01b</aside>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(footer)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(footer={"a01a","a01b"})
+ public static class B1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"a02a","a02b"})
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void b01_footer() throws Exception {
+ RestClient b1 = client(B1.class);
+ b1.get("/a01").accept("text/html").run().assertBody().contains("<footer>a01a a01b</footer>");
+ b1.get("/a02").accept("text/html").run().assertBody().contains("<footer>a02a a02b</footer>");
+ b1.get("/a03").accept("text/html").run().assertBody().contains("<footer>a01a a01b a03a a03b</footer>");
+ b1.get("/a04").accept("text/html").run().assertBody().contains("<footer>a04a a01a a01b a04b</footer>");
+ b1.get("/a05").accept("text/html").run().assertBody().contains("<footer>a05a a05b a01a a01b</footer>");
+ }
+
+ @Rest
+ @HtmlDocConfig(footer={"b01a","INHERIT","b01b"})
+ public static class B2 extends B1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"b02a","b02b"})
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(footer={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void b02_footer_inherited() throws Exception {
+ RestClient b2 = client(B2.class);
+ b2.get("/b01").accept("text/html").run().assertBody().contains("<footer>b01a a01a a01b b01b</footer>");
+ b2.get("/b02").accept("text/html").run().assertBody().contains("<footer>b02a b02b</footer>");
+ b2.get("/b03").accept("text/html").run().assertBody().contains("<footer>b01a a01a a01b b01b b03a b03b</footer>");
+ b2.get("/b04").accept("text/html").run().assertBody().contains("<footer>b04a b01a a01a a01b b01b b04b</footer>");
+ b2.get("/b05").accept("text/html").run().assertBody().contains("<footer>b05a b05b b01a a01a a01b b01b</footer>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(header)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(header={"a01a","a01b"})
+ public static class C1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"a02a","a02b"})
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void c01_header() throws Exception {
+ RestClient c1 = client(C1.class);
+ c1.get("/a01").accept("text/html").run().assertBody().contains("<header>a01a a01b</header>");
+ c1.get("/a02").accept("text/html").run().assertBody().contains("<header>a02a a02b</header>");
+ c1.get("/a03").accept("text/html").run().assertBody().contains("<header>a01a a01b a03a a03b</header>");
+ c1.get("/a04").accept("text/html").run().assertBody().contains("<header>a04a a01a a01b a04b</header>");
+ c1.get("/a05").accept("text/html").run().assertBody().contains("<header>a05a a05b a01a a01b</header>");
+ }
+
+ @Rest
+ @HtmlDocConfig(header={"b01a","b01b","INHERIT"})
+ public static class C2 extends C1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"b02a","b02b"})
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(header={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void c02_header_inherited() throws Exception {
+ RestClient c2 = client(C2.class);
+ c2.get("/b01").accept("text/html").run().assertBody().contains("<header>b01a b01b a01a a01b</header>");
+ c2.get("/b02").accept("text/html").run().assertBody().contains("<header>b02a b02b</header>");
+ c2.get("/b03").accept("text/html").run().assertBody().contains("<header>b01a b01b a01a a01b b03a b03b</header>");
+ c2.get("/b04").accept("text/html").run().assertBody().contains("<header>b04a b01a b01b a01a a01b b04b</header>");
+ c2.get("/b05").accept("text/html").run().assertBody().contains("<header>b05a b05b b01a b01b a01a a01b</header>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(navlinks)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(navlinks={"a01a","a01b"})
+ public static class D1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"a02a","a02b"})
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"INHERIT","[0]:a06a","[3]:a06b"})
+ public Object a06() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"[1]:a07a","[2]:a07b","INHERIT"})
+ public Object a07() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"[1]:a08a","[0]:a08b"})
+ public Object a08() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"INHERIT","foo[0]:a09a","bar[3]:a09b"})
+ public Object a09() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"foo[1]:a10a","bar[2]:a10b","INHERIT"})
+ public Object a10() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"foo[1]:a11a","bar[0]:a11b"})
+ public Object a11() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void d01_navlinks() throws Exception {
+ RestClient d1 = client(D1.class);
+ d1.get("/a01").accept("text/html").run().assertBody().contains("<nav><ol><li>a01a</li><li>a01b</li></ol></nav>");
+ d1.get("/a02").accept("text/html").run().assertBody().contains("<nav><ol><li>a02a</li><li>a02b</li></ol></nav>");
+ d1.get("/a03").accept("text/html").run().assertBody().contains("<nav><ol><li>a01a</li><li>a01b</li><li>a03a</li><li>a03b</li></ol></nav>");
+ d1.get("/a04").accept("text/html").run().assertBody().contains("<nav><ol><li>a04a</li><li>a01a</li><li>a01b</li><li>a04b</li></ol></nav>");
+ d1.get("/a05").accept("text/html").run().assertBody().contains("<nav><ol><li>a05a</li><li>a05b</li><li>a01a</li><li>a01b</li></ol></nav>");
+ d1.get("/a06").accept("text/html").run().assertBody().contains("<nav><ol><li>a06a</li><li>a01a</li><li>a01b</li><li>a06b</li></ol></nav>");
+ d1.get("/a07").accept("text/html").run().assertBody().contains("<nav><ol><li>a07a</li><li>a07b</li><li>a01a</li><li>a01b</li></ol></nav>");
+ d1.get("/a08").accept("text/html").run().assertBody().contains("<nav><ol><li>a08b</li><li>a08a</li></ol></nav>");
+ d1.get("/a09").accept("text/html").run().assertBody().contains("<nav><ol><li><a href=\"/a09a\">foo</a></li><li>a01a</li><li>a01b</li><li><a href=\"/a09b\">bar</a></li></ol></nav>");
+ d1.get("/a10").accept("text/html").run().assertBody().contains("<nav><ol><li><a href=\"/a10a\">foo</a></li><li><a href=\"/a10b\">bar</a></li><li>a01a</li><li>a01b</li></ol></nav>");
+ d1.get("/a11").accept("text/html").run().assertBody().contains("<nav><ol><li><a href=\"/a11b\">bar</a></li><li><a href=\"/a11a\">foo</a></li></ol></nav>");
+ }
+
+ @Rest
+ @HtmlDocConfig(navlinks={"INHERIT","b01a","b01b"})
+ public static class D2 extends D1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"b02a","b02b"})
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"INHERIT","[0]:b06a","[3]:b06b"})
+ public Object b06() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"[1]:b07a","[2]:b07b","INHERIT"})
+ public Object b07() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"[1]:b08a","[0]:b08b"})
+ public Object b08() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"INHERIT","foo[0]:b09a","bar[3]:b09b"})
+ public Object b09() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"foo[1]:b10a","bar[2]:b10b","INHERIT"})
+ public Object b10() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(navlinks={"foo[1]:b11a","bar[0]:b11b"})
+ public Object b11() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void d02_navlinks_inherited() throws Exception {
+ RestClient d2 = client(D2.class);
+ d2.get("/b01").accept("text/html").run().assertBody().contains("<nav><ol><li>a01a</li><li>a01b</li><li>b01a</li><li>b01b</li></ol></nav>");
+ d2.get("/b02").accept("text/html").run().assertBody().contains("<nav><ol><li>b02a</li><li>b02b</li></ol></nav>");
+ d2.get("/b03").accept("text/html").run().assertBody().contains("<nav><ol><li>a01a</li><li>a01b</li><li>b01a</li><li>b01b</li><li>b03a</li><li>b03b</li></ol></nav>");
+ d2.get("/b04").accept("text/html").run().assertBody().contains("<nav><ol><li>b04a</li><li>a01a</li><li>a01b</li><li>b01a</li><li>b01b</li><li>b04b</li></ol></nav>");
+ d2.get("/b05").accept("text/html").run().assertBody().contains("<nav><ol><li>b05a</li><li>b05b</li><li>a01a</li><li>a01b</li><li>b01a</li><li>b01b</li></ol></nav>");
+ d2.get("/b06").accept("text/html").run().assertBody().contains("<nav><ol><li>b06a</li><li>a01a</li><li>a01b</li><li>b06b</li><li>b01a</li><li>b01b</li></ol></nav>");
+ d2.get("/b07").accept("text/html").run().assertBody().contains("<nav><ol><li>b07a</li><li>b07b</li><li>a01a</li><li>a01b</li><li>b01a</li><li>b01b</li></ol></nav>");
+ d2.get("/b08").accept("text/html").run().assertBody().contains("<nav><ol><li>b08b</li><li>b08a</li></ol></nav>");
+ d2.get("/b09").accept("text/html").run().assertBody().contains("<nav><ol><li><a href=\"/b09a\">foo</a></li><li>a01a</li><li>a01b</li><li><a href=\"/b09b\">bar</a></li><li>b01a</li><li>b01b</li></ol></nav>");
+ d2.get("/b10").accept("text/html").run().assertBody().contains("<nav><ol><li><a href=\"/b10a\">foo</a></li><li><a href=\"/b10b\">bar</a></li><li>a01a</li><li>a01b</li><li>b01a</li><li>b01b</li></ol></nav>");
+ d2.get("/b11").accept("text/html").run().assertBody().contains("<nav><ol><li><a href=\"/b11b\">bar</a></li><li><a href=\"/b11a\">foo</a></li></ol></nav>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(nav)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(navlinks={"NONE"},nav={"a01a","a01b"})
+ public static class E1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(nav={"a02a","a02b"})
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(nav={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(nav={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(nav={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void e01_nav() throws Exception {
+ RestClient e1 = client(E1.class);
+ e1.get("/a01").accept("text/html").run().assertBody().contains("<nav>a01a a01b</nav>");
+ e1.get("/a02").accept("text/html").run().assertBody().contains("<nav>a02a a02b</nav>");
+ e1.get("/a03").accept("text/html").run().assertBody().contains("<nav>a01a a01b a03a a03b</nav>");
+ e1.get("/a04").accept("text/html").run().assertBody().contains("<nav>a04a a01a a01b a04b</nav>");
+ e1.get("/a05").accept("text/html").run().assertBody().contains("<nav>a05a a05b a01a a01b</nav>");
+ }
+
+ @Rest
+ @HtmlDocConfig(nav={"INHERIT","b01a","b01b"})
+ public static class E2 extends E1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(nav={"b02a","b02b"})
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod(path="/b03")
+ @HtmlDocConfig(nav={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod(path="/b04")
+ @HtmlDocConfig(nav={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod(path="/b05")
+ @HtmlDocConfig(nav={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void e02_nav_inherited() throws Exception {
+ RestClient e2 = client(E2.class);
+ e2.get("/b01").accept("text/html").run().assertBody().contains("<nav>a01a a01b b01a b01b</nav>");
+ e2.get("/b02").accept("text/html").run().assertBody().contains("<nav>b02a b02b</nav>");
+ e2.get("/b03").accept("text/html").run().assertBody().contains("<nav>a01a a01b b01a b01b b03a b03b</nav>");
+ e2.get("/b04").accept("text/html").run().assertBody().contains("<nav>b04a a01a a01b b01a b01b b04b</nav>");
+ e2.get("/b05").accept("text/html").run().assertBody().contains("<nav>b05a b05b a01a a01b b01a b01b</nav>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(script)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(script={"a01a","a01b"})
+ public static class F1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"a02a","a02b"})
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void f01_script() throws Exception {
+ RestClient f1 = client(F1.class);
+ f1.get("/a01").accept("text/html").run().assertBody().contains("<script>a01a\n a01b\n</script>");
+ f1.get("/a02").accept("text/html").run().assertBody().contains("<script>a02a\n a02b\n</script>");
+ f1.get("/a03").accept("text/html").run().assertBody().contains("<script>a01a\n a01b\n a03a\n a03b\n</script>");
+ f1.get("/a04").accept("text/html").run().assertBody().contains("<script>a04a\n a01a\n a01b\n a04b\n</script>");
+ f1.get("/a05").accept("text/html").run().assertBody().contains("<script>a05a\n a05b\n a01a\n a01b\n</script>");
+ }
+
+ @Rest
+ @HtmlDocConfig(script={"b01a","b01b"})
+ public static class F2 extends F1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"b02a","b02b"})
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(script={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void f02_script_inherited() throws Exception {
+ RestClient f2 = client(F2.class);
+ f2.get("/b01").accept("text/html").run().assertBody().contains("<script>b01a\n b01b\n</script>");
+ f2.get("/b02").accept("text/html").run().assertBody().contains("<script>b02a\n b02b\n</script>");
+ f2.get("/b03").accept("text/html").run().assertBody().contains("<script>b01a\n b01b\n b03a\n b03b\n</script>");
+ f2.get("/b04").accept("text/html").run().assertBody().contains("<script>b04a\n b01a\n b01b\n b04b\n</script>");
+ f2.get("/b05").accept("text/html").run().assertBody().contains("<script>b05a\n b05b\n b01a\n b01b\n</script>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @HtmlDocConfig(style)
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ @HtmlDocConfig(style={"a01a","a01b"},stylesheet="a01s",nowrap="false")
+ public static class G1 extends BasicRestServlet {
+ @RestMethod
+ public Object a01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"a02a","a02b"},stylesheet="a02s")
+ public Object a02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"INHERIT","a03a","a03b"})
+ public Object a03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"a04a","INHERIT","a04b"})
+ public Object a04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"a05a","a05b","INHERIT"})
+ public Object a05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void g01_style() throws Exception {
+ RestClient g1 = client(G1.class);
+ g1.get("/a01").accept("text/html").run().assertBody().contains("<style>@import \"/a01s\"; a01a a01b</style>");
+ g1.get("/a02").accept("text/html").run().assertBody().contains("<style>@import \"/a02s\"; a02a a02b</style>");
+ g1.get("/a03").accept("text/html").run().assertBody().contains("<style>@import \"/a01s\"; a01a a01b a03a a03b</style>");
+ g1.get("/a04").accept("text/html").run().assertBody().contains("<style>@import \"/a01s\"; a04a a01a a01b a04b</style>");
+ g1.get("/a05").accept("text/html").run().assertBody().contains("<style>@import \"/a01s\"; a05a a05b a01a a01b</style>");
+ }
+
+ @Rest
+ @HtmlDocConfig(style={"b01a","b01b"},stylesheet="b01s")
+ public static class G2 extends G1 {
+ @RestMethod
+ public Object b01() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"b02a","b02b"},stylesheet="b02s")
+ public Object b02() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"INHERIT","b03a","b03b"})
+ public Object b03() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"b04a","INHERIT","b04b"})
+ public Object b04() {
+ return "OK";
+ }
+ @RestMethod
+ @HtmlDocConfig(style={"b05a","b05b","INHERIT"})
+ public Object b05() {
+ return "OK";
+ }
+ }
+
+ @Test
+ public void g02_style_inherited() throws Exception {
+ RestClient g2 = client(G2.class);
+ g2.get("/b01").accept("text/html").run().assertBody().contains("<style>@import \"/b01s\"; b01a b01b</style>");
+ g2.get("/b02").accept("text/html").run().assertBody().contains("<style>@import \"/b02s\"; b02a b02b</style>");
+ g2.get("/b03").accept("text/html").run().assertBody().contains("<style>@import \"/b01s\"; b01a b01b b03a b03b</style>");
+ g2.get("/b04").accept("text/html").run().assertBody().contains("<style>@import \"/b01s\"; b04a b01a b01b b04b</style>");
+ g2.get("/b05").accept("text/html").run().assertBody().contains("<style>@import \"/b01s\"; b05a b05b b01a b01b</style>");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Helper methods.
+ //------------------------------------------------------------------------------------------------------------------
+
+ private RestClient client(Class<?> c) {
+ return MockRestClient.build(c);
+ }
+}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicResponsesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicResponsesTest.java
deleted file mode 100644
index eff109e..0000000
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicResponsesTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.rest;
-
-import static org.apache.juneau.rest.testutils.TestUtils.*;
-
-import static org.junit.Assert.*;
-import static org.junit.runners.MethodSorters.*;
-
-import org.apache.juneau.dto.swagger.*;
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.http.response.*;
-import org.junit.*;
-
-@FixMethodOrder(NAME_ASCENDING)
-public class BasicResponsesTest {
-
- //-----------------------------------------------------------------------------------------------------------------
- // Basic sanity tests
- //-----------------------------------------------------------------------------------------------------------------
-
- @Rest
- public static class A {
- @RestMethod public Accepted accepted() { return new Accepted(); }
- @RestMethod public AlreadyReported alreadyReported() { return new AlreadyReported(); }
- @RestMethod(path="/continue") public Continue _continue() { return new Continue(); }
- @RestMethod public Created created() { return new Created(); }
- @RestMethod public EarlyHints earlyHints() { return new EarlyHints(); }
- @RestMethod public Found found() { return new Found(); }
- @RestMethod public IMUsed imUsed() { return new IMUsed(); }
- @RestMethod public MovedPermanently movedPermanently() { return new MovedPermanently(); }
- @RestMethod public MultipleChoices multipleChoices() { return new MultipleChoices(); }
- @RestMethod public MultiStatus multiStatus() { return new MultiStatus(); }
- @RestMethod public NoContent noContent() { return new NoContent(); }
- @RestMethod public NonAuthoritiveInformation nonAuthoritiveInformation() { return new NonAuthoritiveInformation(); }
- @RestMethod public NotModified notModified() { return new NotModified(); }
- @RestMethod public Ok ok() { return new Ok(); }
- @RestMethod public PartialContent partialContent() { return new PartialContent(); }
- @RestMethod public PermanentRedirect permanentRedirect() { return new PermanentRedirect(); }
- @RestMethod public Processing processing() { return new Processing(); }
- @RestMethod public ResetContent resetContent() { return new ResetContent(); }
- @RestMethod public SeeOther seeOther() { return new SeeOther(); }
- @RestMethod public SwitchingProtocols switchingProtocols() { return new SwitchingProtocols(); }
- @RestMethod public TemporaryRedirect temporaryRedirect() { return new TemporaryRedirect(); }
- @RestMethod public UseProxy useProxy() { return new UseProxy(); }
- }
-
-
- //-----------------------------------------------------------------------------------------------------------------
- // Test Swagger
- //-----------------------------------------------------------------------------------------------------------------
-
- static Swagger e = getSwagger(A.class);
-
- @Test
- public void e01_accepted() throws Exception {
- ResponseInfo ri = e.getPaths().get("/accepted").get("get").getResponse(Accepted.CODE);
- assertEquals(Accepted.MESSAGE, ri.getDescription());
- }
- @Test
- public void e02_alreadyReported() throws Exception {
- ResponseInfo ri = e.getPaths().get("/alreadyReported").get("get").getResponse(AlreadyReported.CODE);
- assertEquals(AlreadyReported.MESSAGE, ri.getDescription());
- }
- @Test
- public void e03_continue() throws Exception {
- ResponseInfo ri = e.getPaths().get("/continue").get("get").getResponse(Continue.CODE);
- assertEquals(Continue.MESSAGE, ri.getDescription());
- }
- @Test
- public void e04_created() throws Exception {
- ResponseInfo ri = e.getPaths().get("/created").get("get").getResponse(Created.CODE);
- assertEquals(Created.MESSAGE, ri.getDescription());
- }
- @Test
- public void e05_earlyHints() throws Exception {
- ResponseInfo ri = e.getPaths().get("/earlyHints").get("get").getResponse(EarlyHints.CODE);
- assertEquals(EarlyHints.MESSAGE, ri.getDescription());
- }
- @Test
- public void e06_found() throws Exception {
- ResponseInfo ri = e.getPaths().get("/found").get("get").getResponse(Found.CODE);
- assertEquals(Found.MESSAGE, ri.getDescription());
- }
- @Test
- public void e07_imUsed() throws Exception {
- ResponseInfo ri = e.getPaths().get("/imUsed").get("get").getResponse(IMUsed.CODE);
- assertEquals(IMUsed.MESSAGE, ri.getDescription());
- }
- @Test
- public void e08_movedPermanently() throws Exception {
- ResponseInfo ri = e.getPaths().get("/movedPermanently").get("get").getResponse(MovedPermanently.CODE);
- assertEquals(MovedPermanently.MESSAGE, ri.getDescription());
- }
- @Test
- public void e09_multipleChoices() throws Exception {
- ResponseInfo ri = e.getPaths().get("/multipleChoices").get("get").getResponse(MultipleChoices.CODE);
- assertEquals(MultipleChoices.MESSAGE, ri.getDescription());
- }
- @Test
- public void e10_multiStatus() throws Exception {
- ResponseInfo ri = e.getPaths().get("/multiStatus").get("get").getResponse(MultiStatus.CODE);
- assertEquals(MultiStatus.MESSAGE, ri.getDescription());
- }
- @Test
- public void e11_noContent() throws Exception {
- ResponseInfo ri = e.getPaths().get("/noContent").get("get").getResponse(NoContent.CODE);
- assertEquals(NoContent.MESSAGE, ri.getDescription());
- }
- @Test
- public void e12_nonAuthoritiveInformation() throws Exception {
- ResponseInfo ri = e.getPaths().get("/nonAuthoritiveInformation").get("get").getResponse(NonAuthoritiveInformation.CODE);
- assertEquals(NonAuthoritiveInformation.MESSAGE, ri.getDescription());
- }
- @Test
- public void e13_notModified() throws Exception {
- ResponseInfo ri = e.getPaths().get("/notModified").get("get").getResponse(NotModified.CODE);
- assertEquals(NotModified.MESSAGE, ri.getDescription());
- }
- @Test
- public void e14_ok() throws Exception {
- ResponseInfo ri = e.getPaths().get("/ok").get("get").getResponse(Ok.CODE);
- assertEquals(Ok.MESSAGE, ri.getDescription());
- }
- @Test
- public void e15_partialContent() throws Exception {
- ResponseInfo ri = e.getPaths().get("/partialContent").get("get").getResponse(PartialContent.CODE);
- assertEquals(PartialContent.MESSAGE, ri.getDescription());
- }
- @Test
- public void e16_permanentRedirect() throws Exception {
- ResponseInfo ri = e.getPaths().get("/permanentRedirect").get("get").getResponse(PermanentRedirect.CODE);
- assertEquals(PermanentRedirect.MESSAGE, ri.getDescription());
- }
- @Test
- public void e17_processing() throws Exception {
- ResponseInfo ri = e.getPaths().get("/processing").get("get").getResponse(Processing.CODE);
- assertEquals(Processing.MESSAGE, ri.getDescription());
- }
- @Test
- public void e18_resetContent() throws Exception {
- ResponseInfo ri = e.getPaths().get("/resetContent").get("get").getResponse(ResetContent.CODE);
- assertEquals(ResetContent.MESSAGE, ri.getDescription());
- }
- @Test
- public void e19_seeOther() throws Exception {
- ResponseInfo ri = e.getPaths().get("/seeOther").get("get").getResponse(SeeOther.CODE);
- assertEquals(SeeOther.MESSAGE, ri.getDescription());
- }
- @Test
- public void e20_switchingProtocols() throws Exception {
- ResponseInfo ri = e.getPaths().get("/switchingProtocols").get("get").getResponse(SwitchingProtocols.CODE);
- assertEquals(SwitchingProtocols.MESSAGE, ri.getDescription());
- }
- @Test
- public void e21_temporaryRedirect() throws Exception {
- ResponseInfo ri = e.getPaths().get("/temporaryRedirect").get("get").getResponse(TemporaryRedirect.CODE);
- assertEquals(TemporaryRedirect.MESSAGE, ri.getDescription());
- }
- @Test
- public void e22_useProxy() throws Exception {
- ResponseInfo ri = e.getPaths().get("/useProxy").get("get").getResponse(UseProxy.CODE);
- assertEquals(UseProxy.MESSAGE, ri.getDescription());
- }
-}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestCallLoggerTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestCallLogger_Test.java
similarity index 98%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestCallLoggerTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestCallLogger_Test.java
index 567c75b..1b6e389 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestCallLoggerTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestCallLogger_Test.java
@@ -26,84 +26,13 @@ import org.apache.juneau.utils.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class BasicRestCallLoggerTest {
+public class BasicRestCallLogger_Test {
- static class TestLogger extends Logger {
- Level level;
- String msg;
- Throwable t;
-
- protected TestLogger() {
- super(null, null);
- }
-
- @Override
- public void log(Level level, String msg, Throwable t) {
- this.level = level;
- this.msg = msg;
- this.t = t;
- }
-
- public void check(Level level, String msg, boolean hasThrowable) {
- boolean isNot = (msg != null && msg.length() > 0 && msg.charAt(0) == '!');
- if (isNot)
- msg = msg.substring(1);
- if (msg != null && msg.indexOf('*') != -1) {
- Pattern p = StringUtils.getMatchPattern(msg, Pattern.DOTALL);
- boolean eq = p.matcher(this.msg).matches();
- if (isNot ? eq : ! eq)
- fail("Message text didn't match [2].\nExpected=["+msg+"]\nActual=["+this.msg+"]");
- } else {
- boolean eq = StringUtils.isEquals(this.msg, msg);
- if (isNot ? eq : ! eq)
- fail("Message text didn't match [1].\nExpected=["+msg+"]\nActual=["+this.msg+"]");
- }
-
- assertEquals("Message level didn't match.", level, this.level);
- if (hasThrowable && t == null)
- fail("Throwable not present");
- if (t != null && ! hasThrowable)
- fail("Throwable present.");
- }
- }
-
- private RestCallLoggerConfig.Builder config() {
- return RestCallLoggerConfig.create();
- }
-
- private RestCallLoggerConfig wrapped(RestCallLoggerConfig config) {
- return RestCallLoggerConfig.create().parent(config).build();
- }
-
- private BasicRestCallLogger logger(Logger l, StackTraceDatabase std) {
- return new BasicRestCallLogger(l, std);
- }
-
- private BasicRestCallLogger logger(Logger l) {
- return new BasicRestCallLogger(l, new StackTraceDatabase());
- }
-
- private RestCallLoggerRule.Builder rule() {
- return RestCallLoggerRule.create();
- }
-
- private MockServletRequest req() {
- return MockServletRequest.create();
- }
-
- private MockServletResponse res() {
- return MockServletResponse.create();
- }
-
- private MockServletResponse res(int status) {
- return MockServletResponse.create().status(status);
- }
//------------------------------------------------------------------------------------------------------------------
// No logging
//------------------------------------------------------------------------------------------------------------------
-
@Test
public void a01a_noRules() {
RestCallLoggerConfig lc = config().build();
@@ -883,4 +812,79 @@ public class BasicRestCallLoggerTest {
tc.check(INFO, "!*---Response Body UTF-8---\nfoo\n*", false);
tc.check(INFO, "!*---Response Body Hex---\n66 6F 6F\n*", false);
}
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Helper methods
+ //------------------------------------------------------------------------------------------------------------------
+
+ static class TestLogger extends Logger {
+ Level level;
+ String msg;
+ Throwable t;
+
+ protected TestLogger() {
+ super(null, null);
+ }
+
+ @Override
+ public void log(Level level, String msg, Throwable t) {
+ this.level = level;
+ this.msg = msg;
+ this.t = t;
+ }
+
+ public void check(Level level, String msg, boolean hasThrowable) {
+ boolean isNot = (msg != null && msg.length() > 0 && msg.charAt(0) == '!');
+ if (isNot)
+ msg = msg.substring(1);
+ if (msg != null && msg.indexOf('*') != -1) {
+ Pattern p = StringUtils.getMatchPattern(msg, Pattern.DOTALL);
+ boolean eq = p.matcher(this.msg).matches();
+ if (isNot ? eq : ! eq)
+ fail("Message text didn't match [2].\nExpected=["+msg+"]\nActual=["+this.msg+"]");
+ } else {
+ boolean eq = StringUtils.isEquals(this.msg, msg);
+ if (isNot ? eq : ! eq)
+ fail("Message text didn't match [1].\nExpected=["+msg+"]\nActual=["+this.msg+"]");
+ }
+
+ assertEquals("Message level didn't match.", level, this.level);
+ if (hasThrowable && t == null)
+ fail("Throwable not present");
+ if (t != null && ! hasThrowable)
+ fail("Throwable present.");
+ }
+ }
+
+ private RestCallLoggerConfig.Builder config() {
+ return RestCallLoggerConfig.create();
+ }
+
+ private RestCallLoggerConfig wrapped(RestCallLoggerConfig config) {
+ return RestCallLoggerConfig.create().parent(config).build();
+ }
+
+ private BasicRestCallLogger logger(Logger l, StackTraceDatabase std) {
+ return new BasicRestCallLogger(l, std);
+ }
+
+ private BasicRestCallLogger logger(Logger l) {
+ return new BasicRestCallLogger(l, new StackTraceDatabase());
+ }
+
+ private RestCallLoggerRule.Builder rule() {
+ return RestCallLoggerRule.create();
+ }
+
+ private MockServletRequest req() {
+ return MockServletRequest.create();
+ }
+
+ private MockServletResponse res() {
+ return MockServletResponse.create();
+ }
+
+ private MockServletResponse res(int status) {
+ return MockServletResponse.create().status(status);
+ }
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java
deleted file mode 100644
index 4768b11..0000000
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BeanContextPropertiesTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.rest;
-
-import static org.apache.juneau.http.HttpMethod.*;
-import static org.junit.runners.MethodSorters.*;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.http.annotation.Header;
-import org.apache.juneau.http.annotation.Path;
-import org.apache.juneau.http.annotation.Query;
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.mock2.*;
-import org.apache.juneau.transforms.*;
-import org.junit.*;
-
-@FixMethodOrder(NAME_ASCENDING)
-public class BeanContextPropertiesTest {
-
- //=================================================================================================================
- // Validate that transforms defined on class transform to underlying bean context.
- //=================================================================================================================
-
- @Rest
- @BeanConfig(pojoSwaps=TemporalDateSwap.IsoInstant.class)
- public static class A {
- @RestMethod(name=GET, path="/{d1}")
- public String testClassTransforms(@Path("d1") Date d1, @Query("d2") Date d2, @Header("X-D3") Date d3) throws Exception {
- TemporalDateSwap df = TemporalDateSwap.IsoInstant.class.newInstance();
- BeanSession session = BeanContext.DEFAULT.createSession();
- return "d1="+df.swap(session, d1)+",d2="+df.swap(session, d2)+",d3="+df.swap(session, d3)+"";
- }
- }
- static MockRestClient a = MockRestClient.build(A.class);
-
- @Test
- public void a01_testClassTransforms() throws Exception {
- a.get("/2001-07-04T15:30:45Z?d2=2001-07-05T15:30:45Z").header("X-D3", "2001-07-06T15:30:45Z").run()
- .assertBody().is("d1=2001-07-04T15:30:45Z,d2=2001-07-05T15:30:45Z,d3=2001-07-06T15:30:45Z");
- }
-}
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java
deleted file mode 100644
index c7b9881..0000000
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/DebugModeTest.java
+++ /dev/null
@@ -1,1196 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.rest;
-
-import static org.junit.Assert.*;
-import static org.junit.runners.MethodSorters.*;
-
-import java.util.logging.*;
-
-import javax.servlet.http.*;
-
-import org.apache.juneau.internal.*;
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.config.*;
-import org.apache.juneau.rest.mock2.*;
-import org.junit.*;
-
-@FixMethodOrder(NAME_ASCENDING)
-public class DebugModeTest {
-
- public static final CaptureCallLogger LOGGER = new CaptureCallLogger();
-
- public static class CaptureCallLogger extends BasicRestCallLogger {
-
- private volatile String msg;
-
- public static CaptureCallLogger create() {
- return LOGGER;
- }
-
- private CaptureCallLogger() {
- super(null);
- }
-
- @Override
- protected synchronized void log(Level level, String msg, Throwable e) {
- this.msg = StringUtils.emptyIfNull(msg);
- }
-
- synchronized CaptureCallLogger reset() {
- this.msg = null;
- return this;
- }
-
- synchronized String getMessage() {
- return msg;
- }
-
- public synchronized CaptureCallLogger assertMessageContains(String s) {
- assertNotNull(msg);
- if (! msg.contains(s))
- assertEquals("Substring not found.", s, msg);
- return this;
- }
- }
-
- private static void assertLogged(boolean b) {
- assertEquals(b, LOGGER.getMessage() != null);
- LOGGER.reset();
- }
-
- private static void assertLoggedContains(String s) {
- String msg = LOGGER.getMessage();
- assertLogged(true);
- if (! msg.contains(s))
- assertEquals("Substring not found.", s, msg);
- LOGGER.reset();
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // @Rest(debug=""), various @RestMethod(debug)
- //------------------------------------------------------------------------------------------------------------------
-
- @Rest(callLogger=CaptureCallLogger.class)
- public static class A1 implements BasicUniversalRest {
- @RestMethod
- public boolean getA01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getA02(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getA03(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getA04(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="foo")
- public boolean getA05(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getA06(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod
- public boolean getA07(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient a1 = MockRestClient.buildSimpleJson(A1.class);
- static MockRestClient a1d = MockRestClient.create(A1.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void a01_debugDefault() throws Exception {
-
- a1.get("/a01").run().assertBody().is("false");
- assertLogged(false);
- a1d.get("/a01").run().assertBody().is("false");
- assertLogged(false);
-
- a1.get("/a02").run().assertBody().is("false");
- assertLogged(false);
- a1d.get("/a02").run().assertBody().is("false");
- assertLogged(false);
-
- a1.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
- a1d.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
-
- a1.get("/a04").run().assertBody().is("false");
- assertLogged(false);
- a1d.get("/a04").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a04");
-
- a1.get("/a05").run().assertBody().is("false");
- assertLogged(false);
- a1d.get("/a05").run().assertBody().is("false");
- assertLogged(false);
-
- a1.get("/a06").run().assertBody().is("true");
- assertLogged(true);
- a1d.get("/a06").run().assertBody().is("true");
- assertLogged(true);
-
- a1.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- a1d.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- }
-
- @Rest(callLogger=CaptureCallLogger.class)
- public static class A1a extends BasicRest {
- @RestMethod
- public boolean getA01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getA02(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getA03(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getA04(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="foo")
- public boolean getA05(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getA06(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod
- public boolean getA07(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient a1a = MockRestClient.buildSimpleJson(A1a.class);
- static MockRestClient a1ad = MockRestClient.create(A1a.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void a01a_debugDefault() throws Exception {
-
- a1a.get("/a01").run().assertBody().is("false");
- assertLogged(false);
- a1ad.get("/a01").run().assertBody().is("false");
- assertLogged(false);
-
- a1a.get("/a02").run().assertBody().is("false");
- assertLogged(false);
- a1ad.get("/a02").run().assertBody().is("false");
- assertLogged(false);
-
- a1a.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
- a1ad.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
-
- a1a.get("/a04").run().assertBody().is("false");
- assertLogged(false);
- a1ad.get("/a04").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a04");
-
- a1a.get("/a05").run().assertBody().is("false");
- assertLogged(false);
- a1ad.get("/a05").run().assertBody().is("false");
- assertLogged(false);
-
- a1a.get("/a06").run().assertBody().is("true");
- assertLogged(true);
- a1ad.get("/a06").run().assertBody().is("true");
- assertLogged(true);
-
- a1a.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- a1ad.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // @Rest(debug="true"), various @RestMethod(debug)
- //------------------------------------------------------------------------------------------------------------------
-
- @Rest(callLogger=CaptureCallLogger.class, debug="true")
- public static class A2 implements BasicUniversalRest {
- @RestMethod
- public boolean getA01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getA02(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getA03(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getA04(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="foo")
- public boolean getA05(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getA06(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod
- public boolean getA07(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient a2 = MockRestClient.buildSimpleJson(A2.class);
- static MockRestClient a2d = MockRestClient.create(A2.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void a02_debugTrue() throws Exception {
-
- a2.get("/a01").run().assertBody().is("true");
- assertLogged(true);
- a2d.get("/a01").run().assertBody().is("true");
- assertLogged(true);
-
- a2.get("/a02").run().assertBody().is("false");
- assertLogged(false);
- a2d.get("/a02").run().assertBody().is("false");
- assertLogged(false);
-
- a2.get("/a03").run().assertBody().is("true");
- assertLogged(true);
- a2d.get("/a03").run().assertBody().is("true");
- assertLogged(true);
-
- a2.get("/a04").run().assertBody().is("false");
- assertLogged(false);
- a2d.get("/a04").run().assertBody().is("true");
- assertLogged(true);
-
- a2.get("/a05").run().assertBody().is("true");
- assertLogged(true);
- a2d.get("/a05").run().assertBody().is("true");
- assertLogged(true);
-
- a2.get("/a06").run().assertBody().is("true");
- assertLogged(true);
- a2d.get("/a06").run().assertBody().is("true");
- assertLogged(true);
-
- a2.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- a2d.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // @Rest(debug="false"), various @RestMethod(debug)
- //------------------------------------------------------------------------------------------------------------------
-
- @Rest(callLogger=CaptureCallLogger.class,debug="false")
- public static class A3 implements BasicUniversalRest {
- @RestMethod
- public boolean getA01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getA02(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getA03(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getA04(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="foo")
- public boolean getA05(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getA06(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod
- public boolean getA07(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient a3 = MockRestClient.buildSimpleJson(A3.class);
- static MockRestClient a3d = MockRestClient.create(A3.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void a03_restDebugFalse() throws Exception {
-
- a3.get("/a01").run().assertBody().is("false");
- assertLogged(false);
- a3d.get("/a01").run().assertBody().is("false");
- assertLogged(false);
-
- a3.get("/a02").run().assertBody().is("false");
- assertLogged(false);
- a3d.get("/a02").run().assertBody().is("false");
- assertLogged(false);
-
- a3.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
- a3d.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
-
- a3.get("/a04").run().assertBody().is("false");
- assertLogged(false);
- a3d.get("/a04").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a04");
-
- a3.get("/a05").run().assertBody().is("false");
- assertLogged(false);
- a3d.get("/a05").run().assertBody().is("false");
- assertLogged(false);
-
- a3.get("/a06").run().assertBody().is("true");
- assertLogged(true);
- a3d.get("/a06").run().assertBody().is("true");
- assertLogged(true);
-
- a3.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- a3d.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // @Rest(debug="per-request"), various @RestMethod(debug)
- //------------------------------------------------------------------------------------------------------------------
-
- @Rest(callLogger=CaptureCallLogger.class,debug="per-request")
- public static class A4 implements BasicUniversalRest {
- @RestMethod
- public boolean getA01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getA02(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getA03(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getA04(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="foo")
- public boolean getA05(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getA06(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod
- public boolean getA07(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient a4 = MockRestClient.buildSimpleJson(A4.class);
- static MockRestClient a4d = MockRestClient.create(A4.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void a04_debugPerRequest() throws Exception {
-
- a4.get("/a01").run().assertBody().is("false");
- assertLogged(false);
- a4d.get("/a01").run().assertBody().is("true");
- assertLogged(true);
-
- a4.get("/a02").run().assertBody().is("false");
- assertLogged(false);
- a4d.get("/a02").run().assertBody().is("false");
- assertLogged(false);
-
- a4.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
- a4d.get("/a03").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a03");
-
- a4.get("/a04").run().assertBody().is("false");
- assertLogged(false);
- a4d.get("/a04").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /a04");
-
- a4.get("/a05").run().assertBody().is("false");
- assertLogged(false);
- a4d.get("/a05").run().assertBody().is("true");
- assertLogged(true);
-
- a4.get("/a06").run().assertBody().is("true");
- assertLogged(true);
- a4d.get("/a06").run().assertBody().is("true");
- assertLogged(true);
-
- a4.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- a4d.get("/a07").run().assertBody().is("false");
- assertLogged(false);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Implement RestCallLogger directly.
- //------------------------------------------------------------------------------------------------------------------
-
- @Rest
- public static class B1 implements BasicUniversalRest, RestCallLogger {
- @RestMethod
- public boolean getB01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getB02(RestRequest req) {
- return req.isDebug();
- }
- @Override
- public void log(RestCallLoggerConfig config, HttpServletRequest req, HttpServletResponse res) {
- LOGGER.log(config, req, res);
- }
- }
- static MockRestClient b1 = MockRestClient.buildSimpleJson(B1.class);
-
- @Test
- public void b01_debugDefault() throws Exception {
-
- b1.get("/b01").run().assertBody().is("false");
- assertLogged(false);
- b1.get("/b02").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /b02");
- }
-
- @Rest
- public static class B2 extends BasicRest {
- @RestMethod
- public boolean getB01(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getB02(RestRequest req) {
- return req.isDebug();
- }
- @Override
- public void log(RestCallLoggerConfig config, HttpServletRequest req, HttpServletResponse res) {
- LOGGER.log(config, req, res);
- }
- }
- static MockRestClient b2 = MockRestClient.buildSimpleJson(B2.class);
-
- @Test
- public void b02_debugDefault() throws Exception {
-
- b2.get("/b01").run().assertBody().is("false");
- assertLogged(false);
- b2.get("/b02").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /b02");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // @Rest(debugOn=""), various @RestMethod(debug)
- //------------------------------------------------------------------------------------------------------------------
-
- @Rest(
- callLogger=CaptureCallLogger.class,
- debugOn=""
- + "C1.getC02a=false,C1.getC02b=false,C1.getC02c=FALSE,C1.getC02d=FALSE,C1.getC02e=FALSE,C1.getC02f=FALSE,"
- + " C1.getC03a , C1.getC03b = true , C1.getC03c = TRUE , C1.getC03d = TRUE , C1.getC03e = TRUE , C1.getC03f = TRUE , "
- + "C1.getC04a=per-request,C1.getC04b=per-request,C1.getC04c=PER-REQUEST,C1.getC04d=PER-REQUEST,C1.getC04e=PER-REQUEST,C1.getC04f=PER-REQUEST,"
- + "C1.getC05a=foo,C1.getC05b=,C1.getC05c=foo,C1.getC05d=foo,C1.getC05e=foo,C1.getC05f=foo,"
- )
- public static class C1 implements BasicUniversalRest {
-
- @RestMethod
- public boolean getC01a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC01b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC01c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC01d(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=false
- @RestMethod
- public boolean getC02a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC02b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC02c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC02d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC02e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC02f(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=true
- @RestMethod
- public boolean getC03a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC03b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC03c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC03d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC03e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC03f(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=per-request
- @RestMethod
- public boolean getC04a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC04b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC04c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC04d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC04e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC04f(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=foo
- @RestMethod
- public boolean getC05a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC05b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC05c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC05d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC05e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC05f(RestRequest req) {
- return req.isDebug();
- }
-
- @RestMethod
- public boolean getC06a(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC06b(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC06c(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC06d(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
-
- @RestMethod
- public boolean getC07a(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC07b(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC07c(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC07d(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient c1 = MockRestClient.buildSimpleJson(C1.class);
- static MockRestClient c1d = MockRestClient.create(C1.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void c01_debugDefault() throws Exception {
-
- c1.get("/c01a").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c01a").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c01b").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c01b").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c01c").run().assertBody().is("true");
- assertLogged(true);
- c1d.get("/c01c").run().assertBody().is("true");
- assertLogged(true);
- c1.get("/c01d").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c01d").run().assertBody().is("true");
- assertLogged(true);
-
- c1.get("/c02a").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c02a").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c02b").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c02b").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c02c").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c02c").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c02d").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c02d").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c02e").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c02e").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c02f").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c02f").run().assertBody().is("false");
- assertLogged(false);
-
- c1.get("/c03a").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03a");
- c1d.get("/c03a").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03a");
- c1.get("/c03b").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03b");
- c1d.get("/c03b").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03b");
- c1.get("/c03c").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03c");
- c1d.get("/c03c").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03c");
- c1.get("/c03d").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03d");
- c1d.get("/c03d").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03d");
- c1.get("/c03e").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03e");
- c1d.get("/c03e").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03e");
- c1.get("/c03f").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03f");
- c1d.get("/c03f").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03f");
-
- c1.get("/c04a").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c04a").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04a");
- c1.get("/c04b").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c04b").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04b");
- c1.get("/c04c").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c04c").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04c");
- c1.get("/c04d").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c04d").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04d");
- c1.get("/c04e").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c04e").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04e");
- c1.get("/c04f").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c04f").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04f");
-
- c1.get("/c05a").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c05a").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c05b").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c05b").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c05c").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c05c").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c05d").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c05d").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c05e").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c05e").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c05f").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c05f").run().assertBody().is("false");
- assertLogged(false);
-
- c1.get("/c06a").run().assertBody().is("true");
- assertLogged(true);
- c1d.get("/c06a").run().assertBody().is("true");
- assertLogged(true);
- c1.get("/c06b").run().assertBody().is("true");
- assertLogged(true);
- c1d.get("/c06b").run().assertBody().is("true");
- assertLogged(true);
- c1.get("/c06c").run().assertBody().is("true");
- assertLogged(true);
- c1d.get("/c06c").run().assertBody().is("true");
- assertLogged(true);
- c1.get("/c06d").run().assertBody().is("true");
- assertLogged(true);
- c1d.get("/c06d").run().assertBody().is("true");
- assertLogged(true);
-
- c1.get("/c07a").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c07a").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c07b").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c07b").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c07c").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c07c").run().assertBody().is("false");
- assertLogged(false);
- c1.get("/c07d").run().assertBody().is("false");
- assertLogged(false);
- c1d.get("/c07d").run().assertBody().is("false");
- assertLogged(false);
- }
-
- static {
- System.setProperty("C2DebugEnabled", "C2=true");
- }
- @Rest(
- callLogger=CaptureCallLogger.class,
- debugOn="$S{C2DebugEnabled},"
- + "C2.getC02a=false,C2.getC02b=false,C2.getC02c=FALSE,C2.getC02d=FALSE,C2.getC02e=FALSE,C2.getC02f=FALSE,"
- + " C2.getC03a , C2.getC03b = true , C2.getC03c = TRUE , C2.getC03d = TRUE , C2.getC03e = TRUE , C2.getC03f = TRUE , "
- + "C2.getC04a=per-request,C2.getC04b=per-request,C2.getC04c=PER-REQUEST,C2.getC04d=PER-REQUEST,C2.getC04e=PER-REQUEST,C2.getC04f=PER-REQUEST,"
- + "C2.getC05a=foo,C2.getC05b=,C2.getC05c=foo,C2.getC05d=foo,C2.getC05e=foo,C2.getC05f=foo,"
- )
- public static class C2 implements BasicUniversalRest {
-
- @RestMethod
- public boolean getC01a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC01b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC01c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC01d(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=false
- @RestMethod
- public boolean getC02a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC02b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC02c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC02d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC02e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC02f(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=true
- @RestMethod
- public boolean getC03a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC03b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC03c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC03d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC03e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC03f(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=per-request
- @RestMethod
- public boolean getC04a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC04b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC04c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC04d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC04e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC04f(RestRequest req) {
- return req.isDebug();
- }
-
- // debug=foo
- @RestMethod
- public boolean getC05a(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC05b(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod
- public boolean getC05c(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC05d(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC05e(RestRequest req) {
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC05f(RestRequest req) {
- return req.isDebug();
- }
-
- @RestMethod
- public boolean getC06a(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC06b(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC06c(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC06d(RestRequest req) throws Exception {
- req.setDebug();
- return req.isDebug();
- }
-
- @RestMethod
- public boolean getC07a(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- @RestMethod(debug="false")
- public boolean getC07b(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- @RestMethod(debug="true")
- public boolean getC07c(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- @RestMethod(debug="per-request")
- public boolean getC07d(RestRequest req) throws Exception {
- req.setDebug(false);
- return req.isDebug();
- }
- }
- static MockRestClient c2 = MockRestClient.buildSimpleJson(C2.class);
- static MockRestClient c2d = MockRestClient.create(C2.class).simpleJson().header("X-Debug", true).build();
-
- @Test
- public void c02_debugTrue() throws Exception {
-
- c2.get("/c01a").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c01a").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c01b").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c01b").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c01c").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c01c").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c01d").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c01d").run().assertBody().is("true");
- assertLogged(true);
-
- c2.get("/c02a").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c02a").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c02b").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c02b").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c02c").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c02c").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c02d").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c02d").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c02e").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c02e").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c02f").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c02f").run().assertBody().is("false");
- assertLogged(false);
-
- c2.get("/c03a").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03a");
- c2d.get("/c03a").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03a");
- c2.get("/c03b").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03b");
- c2d.get("/c03b").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03b");
- c2.get("/c03c").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03c");
- c2d.get("/c03c").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03c");
- c2.get("/c03d").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03d");
- c2d.get("/c03d").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03d");
- c2.get("/c03e").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03e");
- c2d.get("/c03e").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03e");
- c2.get("/c03f").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03f");
- c2d.get("/c03f").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c03f");
-
- c2.get("/c04a").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c04a").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04a");
- c2.get("/c04b").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c04b").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04b");
- c2.get("/c04c").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c04c").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04c");
- c2.get("/c04d").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c04d").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04d");
- c2.get("/c04e").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c04e").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04e");
- c2.get("/c04f").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c04f").run().assertBody().is("true");
- assertLoggedContains("[200] HTTP GET /c04f");
-
- c2.get("/c05a").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c05a").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c05b").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c05b").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c05c").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c05c").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c05d").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c05d").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c05e").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c05e").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c05f").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c05f").run().assertBody().is("true");
- assertLogged(true);
-
- c2.get("/c06a").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c06a").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c06b").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c06b").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c06c").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c06c").run().assertBody().is("true");
- assertLogged(true);
- c2.get("/c06d").run().assertBody().is("true");
- assertLogged(true);
- c2d.get("/c06d").run().assertBody().is("true");
- assertLogged(true);
-
- c2.get("/c07a").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c07a").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c07b").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c07b").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c07c").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c07c").run().assertBody().is("false");
- assertLogged(false);
- c2.get("/c07d").run().assertBody().is("false");
- assertLogged(false);
- c2d.get("/c07d").run().assertBody().is("false");
- assertLogged(false);
- }
-
-}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_AcceptCharset_Test.java
similarity index 56%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_AcceptCharset_Test.java
index 5966da8..9cf7ec8 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_AcceptCharset_Test.java
@@ -10,7 +10,7 @@
// * "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.headers;
+package org.apache.juneau.rest;
import static org.apache.juneau.http.HttpMethod.*;
import static org.junit.runners.MethodSorters.*;
@@ -22,50 +22,51 @@ import org.apache.juneau.http.annotation.Body;
import org.apache.juneau.parser.*;
import org.apache.juneau.plaintext.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.apache.juneau.serializer.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class AcceptCharsetTest {
+public class Header_AcceptCharset_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that Q-values are being resolved correctly.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(defaultCharset="utf-8",serializers=PlainTextSerializer.class)
public static class A {
@RestMethod
- public String qValues() {
+ public String a() {
return "foo";
}
}
- static MockRestClient a = MockRestClient.build(A.class);
@Test
public void a01_qValues() throws Exception {
- a.get("/qValues").accept("text/plain").acceptCharset("utf-8").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("iso-8859-1").run().assertCharset().is("iso-8859-1");
- a.get("/qValues").accept("text/plain").acceptCharset("bad,utf-8").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("utf-8,bad").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("bad;q=0.9,utf-8;q=0.1").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("bad;q=0.1,utf-8;q=0.9").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("utf-8;q=0.9,iso-8859-1;q=0.1").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("utf-8;q=0.1,iso-8859-1;q=0.9").run().assertCharset().is("iso-8859-1");
- a.get("/qValues").accept("text/plain").acceptCharset("*").run().assertCharset().is("utf-8");
- a.get("/qValues").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.5,*;q=0.1").run().assertCharset().is("iso-8859-1");
- a.get("/qValues").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.1,*;q=0.5").run().assertCharset().is("utf-8");
+ RestClient a = MockRestClient.build(A.class);
+ a.get("/a").accept("text/plain").acceptCharset("utf-8").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("iso-8859-1").run().assertCharset().is("iso-8859-1");
+ a.get("/a").accept("text/plain").acceptCharset("bad,utf-8").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("utf-8,bad").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("bad;q=0.9,utf-8;q=0.1").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("bad;q=0.1,utf-8;q=0.9").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("utf-8;q=0.9,iso-8859-1;q=0.1").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("utf-8;q=0.1,iso-8859-1;q=0.9").run().assertCharset().is("iso-8859-1");
+ a.get("/a").accept("text/plain").acceptCharset("*").run().assertCharset().is("utf-8");
+ a.get("/a").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.5,*;q=0.1").run().assertCharset().is("iso-8859-1");
+ a.get("/a").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.1,*;q=0.5").run().assertCharset().is("utf-8");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Validate various Accept-Charset variations.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(defaultCharset="utf-8")
public static class B {
@RestMethod(name=PUT, parsers=TestParser.class, serializers=TestSerializer.class)
- public String charsetOnResponse(@Body String in) {
+ public String a(@Body String in) {
return in;
}
@@ -103,16 +104,16 @@ public class AcceptCharsetTest {
}
}
}
- static MockRestClient b = MockRestClient.buildLax(B.class);
@Test
- public void b01_testCharsetOnResponse() throws Exception {
- b.put("/charsetOnResponse", null).plainText().run().assertBody().is("UTF-8/UTF-8");
- b.put("/charsetOnResponse", null).plainText().acceptCharset("Shift_JIS").run().assertBody().is("UTF-8/Shift_JIS");
- b.put("/charsetOnResponse?noTrace=true", null).plainText().acceptCharset("BAD").run().assertCode().is(406).assertBody().contains("No supported charsets in header 'Accept-Charset': 'BAD'");
- b.put("/charsetOnResponse", null).plainText().acceptCharset("UTF-8").run().assertBody().is("UTF-8/UTF-8");
- b.put("/charsetOnResponse", null).plainText().acceptCharset("bad,iso-8859-1").run().assertBody().is("UTF-8/ISO-8859-1");
- b.put("/charsetOnResponse", null).plainText().acceptCharset("bad;q=0.9,iso-8859-1;q=0.1").run().assertBody().is("UTF-8/ISO-8859-1");
- b.put("/charsetOnResponse", null).plainText().acceptCharset("bad;q=0.1,iso-8859-1;q=0.9").run().assertBody().is("UTF-8/ISO-8859-1");
+ public void b01_charsetOnResponse() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
+ b.put("/a", null).plainText().run().assertBody().is("UTF-8/UTF-8");
+ b.put("/a", null).plainText().acceptCharset("Shift_JIS").run().assertBody().is("UTF-8/Shift_JIS");
+ b.put("/a?noTrace=true", null).plainText().acceptCharset("BAD").run().assertCode().is(406).assertBody().contains("No supported charsets in header 'Accept-Charset': 'BAD'");
+ b.put("/a", null).plainText().acceptCharset("UTF-8").run().assertBody().is("UTF-8/UTF-8");
+ b.put("/a", null).plainText().acceptCharset("bad,iso-8859-1").run().assertBody().is("UTF-8/ISO-8859-1");
+ b.put("/a", null).plainText().acceptCharset("bad;q=0.9,iso-8859-1;q=0.1").run().assertBody().is("UTF-8/ISO-8859-1");
+ b.put("/a", null).plainText().acceptCharset("bad;q=0.1,iso-8859-1;q=0.9").run().assertBody().is("UTF-8/ISO-8859-1");
}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_AcceptEncoding_Test.java
similarity index 66%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_AcceptEncoding_Test.java
index 441215a..2cfb232 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_AcceptEncoding_Test.java
@@ -10,7 +10,7 @@
// * "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.headers;
+package org.apache.juneau.rest;
import static org.junit.Assert.*;
import static org.junit.runners.MethodSorters.*;
@@ -19,28 +19,18 @@ import java.io.*;
import org.apache.juneau.encoders.*;
import org.apache.juneau.internal.*;
-import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.RestResponse;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class AcceptEncodingTest {
+public class Header_AcceptEncoding_Test {
- //=================================================================================================================
- // Setup classes
- //=================================================================================================================
-
- public static class MyEncoder extends GzipEncoder {
- @Override /* ConfigEncoder */
- public String[] getCodings() {
- return new String[]{"mycoding"};
- }
- }
-
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test with no compression enabled.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
public static class A {
@@ -49,28 +39,22 @@ public class AcceptEncodingTest {
return "foo";
}
}
- static MockRestClient a = MockRestClient.buildLax(A.class);
@Test
public void a01_noCompression() throws Exception {
+ RestClient a = MockRestClient.buildLax(A.class);
a.get("/").run().assertBody().is("foo");
a.get("/").acceptEncoding("").run().assertBody().is("foo");
a.get("/").acceptEncoding("*").run().assertBody().is("foo");
a.get("/").acceptEncoding("identity").run().assertBody().is("foo");
- }
- @Test
- public void a02_noCompression_qValues() throws Exception {
// The following should all match identity.
a.get("/").acceptEncoding("mycoding").run().assertBody().is("foo");
a.get("/").acceptEncoding("identity;q=0.8,mycoding;q=0.6").run().assertBody().is("foo");
a.get("/").acceptEncoding("mycoding;q=0.8,identity;q=0.6").run().assertBody().is("foo");
a.get("/").acceptEncoding("mycoding;q=0.8,*;q=0.6").run().assertBody().is("foo");
a.get("/").acceptEncoding("*;q=0.8,myencoding;q=0.6").run().assertBody().is("foo");
- }
- @Test
- public void a03_noCompression_nomatch() throws Exception {
a.get("?noTrace=true").acceptEncoding("mycoding,identity;q=0").run()
.assertCode().is(406)
.assertBody().contains(
@@ -109,62 +93,53 @@ public class AcceptEncodingTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test with compression enabled.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(encoders=MyEncoder.class)
public static class B {
@RestMethod
- public String b01() {
+ public String get() {
return "foo";
}
}
- static MockRestClient b = MockRestClient.buildLax(B.class);
@Test
- public void b01_withCompression_identity() throws Exception {
- b.get("/b01").run().assertBody().is("foo");
- b.get("/b01").acceptEncoding("").run().assertBody().is("foo");
- b.get("/b01").acceptEncoding("identity").run().assertBody().is("foo");
- }
- @Test
- public void b02_withCompression_identity_qValues() throws Exception {
- b.get("/b01").acceptEncoding("identity;q=0.8,mycoding;q=0.6").run().assertBody().is("foo");
- }
- @Test
- public void b03_withCompression_gzip() throws Exception {
- assertEquals("foo", StringUtils.decompress(b.get("/b01").acceptEncoding("*").run().getBody().asBytes()));
- assertEquals("foo", StringUtils.decompress(b.get("/b01").acceptEncoding("mycoding").run().getBody().asBytes()));
- }
- @Test
- public void b04_withCompression_gzip_qValues() throws Exception {
- assertEquals("foo", StringUtils.decompress(b.get("/b01").acceptEncoding("mycoding,identity;q=0").run().getBody().asBytes()));
- assertEquals("foo", StringUtils.decompress(b.get("/b01").acceptEncoding("mycoding,*;q=0").run().getBody().asBytes()));
- assertEquals("foo", StringUtils.decompress(b.get("/b01").acceptEncoding("mycoding;q=0.8,identity;q=0.6").run().getBody().asBytes()));
- assertEquals("foo", StringUtils.decompress(b.get("/b01").acceptEncoding("mycoding;q=0.8,*;q=0.6").run().getBody().asBytes()));
- }
- @Test
- public void b05_withCompression_nomatch() throws Exception {
- b.get("/b01?noTrace=true").acceptEncoding("identity;q=0").run()
+ public void b01_withCompression() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
+ b.get("/").run().assertBody().is("foo");
+ b.get("/").acceptEncoding("").run().assertBody().is("foo");
+ b.get("/").acceptEncoding("identity").run().assertBody().is("foo");
+ b.get("/").acceptEncoding("identity;q=0.8,mycoding;q=0.6").run().assertBody().is("foo");
+
+ assertEquals("foo", StringUtils.decompress(b.get("/").acceptEncoding("*").run().getBody().asBytes()));
+ assertEquals("foo", StringUtils.decompress(b.get("/").acceptEncoding("mycoding").run().getBody().asBytes()));
+
+ assertEquals("foo", StringUtils.decompress(b.get("/").acceptEncoding("mycoding,identity;q=0").run().getBody().asBytes()));
+ assertEquals("foo", StringUtils.decompress(b.get("/").acceptEncoding("mycoding,*;q=0").run().getBody().asBytes()));
+ assertEquals("foo", StringUtils.decompress(b.get("/").acceptEncoding("mycoding;q=0.8,identity;q=0.6").run().getBody().asBytes()));
+ assertEquals("foo", StringUtils.decompress(b.get("/").acceptEncoding("mycoding;q=0.8,*;q=0.6").run().getBody().asBytes()));
+
+ b.get("?noTrace=true").acceptEncoding("identity;q=0").run()
.assertCode().is(406)
.assertBody().contains(
"Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0'",
"Supported codings: ['mycoding','identity']"
);
- b.get("/b01?noTrace=true").acceptEncoding("identity;q=0.0").run()
+ b.get("?noTrace=true").acceptEncoding("identity;q=0.0").run()
.assertCode().is(406)
.assertBody().contains(
"Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0.0'",
"Supported codings: ['mycoding','identity']"
);
- b.get("/b01?noTrace=true").acceptEncoding("*;q=0").run()
+ b.get("?noTrace=true").acceptEncoding("*;q=0").run()
.assertCode().is(406)
.assertBody().contains(
"Unsupported encoding in request header 'Accept-Encoding': '*;q=0'",
"Supported codings: ['mycoding','identity']"
);
- b.get("/b01?noTrace=true").acceptEncoding("*;q=0.0").run()
+ b.get("?noTrace=true").acceptEncoding("*;q=0.0").run()
.assertCode().is(406)
.assertBody().contains(
"Unsupported encoding in request header 'Accept-Encoding': '*;q=0.0'",
@@ -172,16 +147,15 @@ public class AcceptEncodingTest {
);
}
-
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test with compression enabled but with servlet using output stream directly.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(encoders=MyEncoder.class)
@SuppressWarnings("resource")
public static class C {
@RestMethod
- public void c01(RestResponse res) throws Exception {
+ public void a(RestResponse res) throws Exception {
// This method bypasses the content type and encoding from
// the serializers and encoders when calling getOutputStream() directly.
res.setContentType("text/direct");
@@ -190,7 +164,7 @@ public class AcceptEncodingTest {
os.flush();
}
@RestMethod
- public void c02(RestResponse res) throws Exception {
+ public void b(RestResponse res) throws Exception {
// This method bypasses the content type and encoding from
// the serializers and encoders when calling getWriter() directly.
Writer w = res.getWriter();
@@ -198,7 +172,7 @@ public class AcceptEncodingTest {
w.flush();
}
@RestMethod
- public void c03(RestResponse res) throws Exception {
+ public void c(RestResponse res) throws Exception {
// This method uses getNegotiatedWriter() which should use GZip encoding.
Writer w = res.getNegotiatedWriter();
w.append("foo");
@@ -206,70 +180,76 @@ public class AcceptEncodingTest {
w.close();
}
@RestMethod(encoders={IdentityEncoder.class})
- public void c04(RestResponse res) throws Exception {
+ public void d(RestResponse res) throws Exception {
// This method overrides the set of encoders at the method level and so shouldn't use GZip encoding.
Writer w = res.getNegotiatedWriter();
w.append("foo");
w.flush();
}
}
- static MockRestClient c = MockRestClient.build(C.class);
@Test
- public void c01_direct1() throws Exception {
- c.get("/c01")
+ public void c01_direct() throws Exception {
+ RestClient c = MockRestClient.build(C.class);
+
+ c.get("/a")
.acceptEncoding("mycoding")
.run()
.assertStringHeader("Content-Encoding").doesNotExist() // Should not be set
.assertStringHeader("Content-Type").is("text/direct")
.assertBody().is("foo");
- c.get("/c01")
+ c.get("/a")
.acceptEncoding("*")
.run()
.assertStringHeader("Content-Encoding").doesNotExist() // Should not be set
.assertStringHeader("Content-Type").is("text/direct")
.assertBody().is("foo");
- }
- @Test
- public void c02_direct2() throws Exception {
- c.get("/c02")
+
+ c.get("/b")
.acceptEncoding("mycoding")
.run()
.assertStringHeader("Content-Encoding").doesNotExist() // Should not be set
.assertBody().is("foo");
- c.get("/c02")
+ c.get("/b")
.acceptEncoding("*")
.run()
.assertStringHeader("Content-Encoding").doesNotExist() // Should not be set
.assertBody().is("foo");
- }
- @Test
- public void c03_direct3() throws Exception {
+
byte[] body;
- body = c.get("/c03")
+ body = c.get("/c")
.acceptEncoding("mycoding")
.run()
.assertStringHeader("Content-Encoding").is("mycoding")
.getBody().asBytes();
assertEquals("foo", StringUtils.decompress(body));
- body = c.get("/c03")
+ body = c.get("/c")
.acceptEncoding("*")
.run()
.assertStringHeader("Content-Encoding").is("mycoding")
.getBody().asBytes();
assertEquals("foo", StringUtils.decompress(body));
- }
- @Test
- public void c04_direct4() throws Exception {
- c.get("/c04")
+
+ c.get("/d")
.acceptEncoding("mycoding")
.run()
.assertStringHeader("Content-Encoding").doesNotExist() // Should not be set
.assertBody().is("foo");
- c.get("/c04")
+ c.get("/d")
.acceptEncoding("*")
.run()
.assertStringHeader("Content-Encoding").doesNotExist() // Should not be set
.assertBody().is("foo");
}
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Helpers
+ //------------------------------------------------------------------------------------------------------------------
+
+ public static class MyEncoder extends GzipEncoder {
+ @Override /* ConfigEncoder */
+ public String[] getCodings() {
+ return new String[]{"mycoding"};
+ }
+ }
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_Accept_Test.java
similarity index 54%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_Accept_Test.java
index f32dd99..66a29d1 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_Accept_Test.java
@@ -10,27 +10,26 @@
// * "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.headers;
+package org.apache.juneau.rest;
-import static org.apache.juneau.http.HttpMethod.*;
import static org.junit.runners.MethodSorters.*;
import java.io.IOException;
import org.apache.juneau.*;
import org.apache.juneau.http.annotation.Body;
-import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.apache.juneau.serializer.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class AcceptTest {
+public class Header_Accept_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Setup classes
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
public static class DummySerializer extends WriterSerializer {
String name;
@@ -53,9 +52,9 @@ public class AcceptTest {
public static class S2 extends DummySerializer { public S2(PropertyStore ps) {super(ps, "s2", "text/s2");}}
public static class S3 extends DummySerializer { public S3(PropertyStore ps) {super(ps, "s3", "text/s3");}}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Accept headers on servlet annotation are picked up.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Accept : text/s2 "},
@@ -63,61 +62,53 @@ public class AcceptTest {
)
public static class A {
@RestMethod
- public String putA01(@Body String in) {
+ public String put(@Body String in) {
return in;
}
}
- private static MockRestClient a = MockRestClient.buildLax(A.class);
@Test
- public void a01_defaultHeadersOnServletAnnotation_valid() throws Exception {
- a.put("/a01", null)
+ public void a01_defaultHeadersOnServletAnnotation() throws Exception {
+ RestClient a = MockRestClient.buildLax(A.class);
+ a.put("/", null)
.run()
.assertBody().is("s2");
- a.put("/a01", null)
+ a.put("/", null)
.accept("text/s1")
.run()
.assertBody().is("s1");
- a.put("/a01", null)
+ a.put("/", null)
.accept("text/s2")
.run()
.assertBody().is("s2");
- }
-
- @Test
- public void a02_defaultHeadersOnServletAnnotation_invalid() throws Exception {
- a.put("/a01?noTrace=true", null)
+ a.put("?noTrace=true", null)
.accept("text/s3")
.run()
.assertCode().is(406)
.assertBody().contains("Unsupported media-type in request header 'Accept': 'text/s3'");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Accept headers on servlet annotation are picked up
// when @RestMethod.parsers/serializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Accept : text/s2 "},
serializers={S1.class,S2.class}
)
public static class B {
- @RestMethod(name=PUT, serializers=S3.class)
- public String b(@Body String in) {
+ @RestMethod(serializers=S3.class)
+ public String put(@Body String in) {
return in;
}
}
- private static MockRestClient b = MockRestClient.buildLax(B.class);
-
- @Test
- public void b01_restMethodWithParsersSerializers_valid() throws Exception {
- b.put("/b", null).accept("text/s3").run().assertBody().is("s3");
- }
@Test
- public void b02_restMethodWithParsersSerializers_invalid() throws Exception {
- b.put("/b?noTrace=true", null)
+ public void b01_restMethodWithParsersSerializers() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
+ b.put("/", null).accept("text/s3").run().assertBody().is("s3");
+ b.put("?noTrace=true", null)
.accept("text/s4")
.run()
.assertCode().is(406)
@@ -127,45 +118,41 @@ public class AcceptTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Accept headers on servlet annotation are picked up
// when @RestMethod.addParsers/addSerializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Accept : text/s2 "},
serializers={S1.class,S2.class}
)
public static class C {
- @RestMethod(name=PUT, serializers={S3.class,Inherit.class})
- public String c(@Body String in) {
+ @RestMethod(serializers={S3.class,Inherit.class})
+ public String put(@Body String in) {
return in;
}
}
- private static MockRestClient c = MockRestClient.buildLax(C.class);
@Test
public void c01_restMethodAddParsersSerializersInherit() throws Exception {
- c.put("/c", null)
+ RestClient c = MockRestClient.buildLax(C.class);
+ c.put("/", null)
.run()
.assertBody().is("s2");
- c.put("/c", null)
+ c.put("/", null)
.accept("text/s1")
.run()
.assertBody().is("s1");
- c.put("/c", null)
+ c.put("/", null)
.accept("text/s2")
.run()
.assertBody().is("s2");
- c.put("/c", null)
+ c.put("/", null)
.accept("text/s3")
.run()
.assertBody().is("s3");
- }
-
- @Test
- public void c02_restMethodAddParsersSerializersInherit_invalid() throws Exception {
- c.put("/c?noTrace=true", null)
+ c.put("?noTrace=true", null)
.accept("text/s4")
.run()
.assertCode().is(406)
@@ -175,36 +162,33 @@ public class AcceptTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Various Accept incantations.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Accept : text/s2 "},
serializers={S1.class,S2.class}
)
public static class D {
- @RestMethod(name=PUT)
- public String d(@Body String in) {
+ @RestMethod
+ public String put(@Body String in) {
return in;
}
}
- private static MockRestClient d = MockRestClient.buildLax(D.class);
@Test
public void d01_accept_valid() throws Exception {
+ RestClient d = MockRestClient.buildLax(D.class);
// "*/*" should match the first serializer, not the default serializer.
- d.put("/d", null).accept("*/*").run().assertBody().is("s1");
+ d.put("/", null).accept("*/*").run().assertBody().is("s1");
// "text/*" should match the first serializer, not the default serializer.
- d.put("/d", null).accept("text/*").run().assertBody().is("s1");
- d.put("/d", null).accept("bad/*,text/*").run().assertBody().is("s1");
- d.put("/d", null).accept("text/*,bad/*").run().assertBody().is("s1");
- d.put("/d", null).accept("text/s1;q=0.5,text/s2").run().assertBody().is("s2");
- d.put("/d", null).accept("text/s1,text/s2;q=0.5").run().assertBody().is("s1");
- }
- @Test
- public void d02_accept_invalid() throws Exception {
- d.put("/d?noTrace=true", null)
+ d.put("/", null).accept("text/*").run().assertBody().is("s1");
+ d.put("/", null).accept("bad/*,text/*").run().assertBody().is("s1");
+ d.put("/", null).accept("text/*,bad/*").run().assertBody().is("s1");
+ d.put("/", null).accept("text/s1;q=0.5,text/s2").run().assertBody().is("s2");
+ d.put("/", null).accept("text/s1,text/s2;q=0.5").run().assertBody().is("s1");
+ d.put("?noTrace=true", null)
.accept("bad/*")
.run()
.assertCode().is(406)
@@ -214,31 +198,28 @@ public class AcceptTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Accept headers on method annotation are picked up
// when @RestMethod.parsers/serializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Accept : text/s2 "},
serializers={S1.class,S2.class}
)
public static class E {
- @RestMethod(name=PUT, reqHeaders={"Accept: text/s3"}, serializers=S3.class)
- public String d(@Body String in) {
+ @RestMethod(reqHeaders={"Accept: text/s3"}, serializers=S3.class)
+ public String put(@Body String in) {
return in;
}
}
- private static MockRestClient e = MockRestClient.buildLax(E.class);
@Test
- public void e01_restMethodParserSerializerAnnotations_valid() throws Exception {
- e.put("/d", null).run().assertBody().is("s3");
- e.put("/d", null).accept("text/s3").run().assertBody().is("s3");
- }
- @Test
- public void e02_restMethodParserSerializerAnnotations_invalid() throws Exception {
- e.put("/d?noTrace=true", null)
+ public void e01_restMethodParserSerializerAnnotations() throws Exception {
+ RestClient e = MockRestClient.buildLax(E.class);
+ e.put("/", null).run().assertBody().is("s3");
+ e.put("/", null).accept("text/s3").run().assertBody().is("s3");
+ e.put("?noTrace=true", null)
.accept("text/s1")
.run()
.assertCode().is(406)
@@ -246,7 +227,7 @@ public class AcceptTest {
"Unsupported media-type in request header 'Accept': 'text/s1'",
"Supported media-types: ['text/s3']"
);
- e.put("/d?noTrace=true", null).accept("text/s2").run()
+ e.put("?noTrace=true", null).accept("text/s2").run()
.assertCode().is(406)
.assertBody().contains(
"Unsupported media-type in request header 'Accept': 'text/s2'",
@@ -254,28 +235,28 @@ public class AcceptTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Accept headers on method annotation are picked up
// when @RestMethod.addParsers/addSerializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
- reqHeaders={" Accept : text/s2 ",},
+ reqHeaders={" Accept : text/s2 "},
serializers={S1.class,S2.class}
)
public static class F {
- @RestMethod(name=PUT, reqHeaders={"Accept: text/s3"}, serializers={Inherit.class, S3.class})
- public String f(@Body String in) {
+ @RestMethod(reqHeaders={"Accept: text/s3"}, serializers={Inherit.class, S3.class})
+ public String put(@Body String in) {
return in;
}
}
- private static MockRestClient f = MockRestClient.build(F.class);
@Test
- public void f01_restMethodAddParsersSerializersAnnotations_valid() throws Exception {
- f.put("/f", null).run().assertBody().is("s3");
- f.put("/f", null).accept("text/s1").run().assertBody().is("s1");
- f.put("/f", null).accept("text/s2").run().assertBody().is("s2");
- f.put("/f", null).accept("text/s3").run().assertBody().is("s3");
+ public void f01_restMethodAddParsersSerializersAnnotations() throws Exception {
+ RestClient f = MockRestClient.build(F.class);
+ f.put("/", null).run().assertBody().is("s3");
+ f.put("/", null).accept("text/s1").run().assertBody().is("s1");
+ f.put("/", null).accept("text/s2").run().assertBody().is("s2");
+ f.put("/", null).accept("text/s3").run().assertBody().is("s3");
}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_ContentType_Test.java
similarity index 60%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_ContentType_Test.java
index 55551d0..eb436cf 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Header_ContentType_Test.java
@@ -10,7 +10,7 @@
// * "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.headers;
+package org.apache.juneau.rest;
import static org.apache.juneau.http.HttpMethod.*;
import static org.junit.runners.MethodSorters.*;
@@ -20,43 +20,17 @@ import java.io.IOException;
import org.apache.juneau.*;
import org.apache.juneau.http.annotation.Body;
import org.apache.juneau.parser.*;
-import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class ContentTypeTest {
+public class Header_ContentType_Test {
- //=================================================================================================================
- // Setup classes
- //=================================================================================================================
-
- public static class DummyParser extends ReaderParser {
- String name;
- DummyParser(PropertyStore ps, String name, String...consumes) {
- super(ps, consumes);
- this.name = name;
- }
- @Override /* Parser */
- public ReaderParserSession createSession(ParserSessionArgs args) {
- return new ReaderParserSession(args) {
- @Override /* ParserSession */
- @SuppressWarnings("unchecked")
- protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException {
- return (T)name;
- }
- };
- }
- }
-
- public static class P1 extends DummyParser { public P1(PropertyStore ps) {super(ps, "p1", "text/p1");}}
- public static class P2 extends DummyParser { public P2(PropertyStore ps) {super(ps, "p2", "text/p2");}}
- public static class P3 extends DummyParser { public P3(PropertyStore ps) {super(ps, "p3", "text/p3");}}
-
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Content-Type headers on servlet annotation are picked up.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Content-Type : text/p2 "},
@@ -64,37 +38,33 @@ public class ContentTypeTest {
)
public static class A {
@RestMethod(name=PUT)
- public String a01(@Body String in) {
+ public String a(@Body String in) {
return in;
}
}
- private static MockRestClient a = MockRestClient.buildLax(A.class);
@Test
- public void a01_defaultHeadersOnServletAnnotation_valid() throws Exception {
- a.put("/a01", null, "")
+ public void a01_defaultHeadersOnServletAnnotation() throws Exception {
+ RestClient a = MockRestClient.buildLax(A.class);
+ a.put("/a", null, "")
.run()
.assertBody().is("p2");
- a.put("/a01", null, "text/p1")
+ a.put("/a", null, "text/p1")
.run()
.assertBody().is("p1");
- a.put("/a01", null, "text/p2")
+ a.put("/a", null, "text/p2")
.run()
.assertBody().is("p2");
- }
-
- @Test
- public void a02_defaultHeadersOnServletAnnotation_invalid() throws Exception {
- a.put("/a01?noTrace=true", null, "text/p3")
+ a.put("/a?noTrace=true", null, "text/p3")
.run()
.assertCode().is(415)
.assertBody().contains("Unsupported media-type in request header 'Content-Type': 'text/p3'");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Content-Type headers on servlet annotation are picked up
// when @RestMethod.parsers/serializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Content-Type : text/p2 "},
@@ -102,34 +72,30 @@ public class ContentTypeTest {
)
public static class B {
@RestMethod(name=PUT, parsers=P3.class)
- public String b(@Body String in) {
+ public String a(@Body String in) {
return in;
}
}
- private static MockRestClient b = MockRestClient.buildLax(B.class);
@Test
- public void b01_restMethodWithParsersSerializers_valid() throws Exception {
- b.put("/b", null).contentType("text/p3").run().assertBody().is("p3");
- }
-
- @Test
- public void b02_restMethodWithParsersSerializers_invalid() throws Exception {
- b.put("/b?noTrace=true", null, "")
+ public void b01_restMethodWithParsersSerializers() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
+ b.put("/a", null).contentType("text/p3").run().assertBody().is("p3");
+ b.put("/a?noTrace=true", null, "")
.run()
.assertCode().is(415)
.assertBody().contains(
"Unsupported media-type in request header 'Content-Type': 'text/p2'",
"Supported media-types: ['text/p3']"
);
- b.put("/b?noTrace=true", null, "text/p1")
+ b.put("/a?noTrace=true", null, "text/p1")
.run()
.assertCode().is(415)
.assertBody().contains(
"Unsupported media-type in request header 'Content-Type': 'text/p1'",
"Supported media-types: ['text/p3']"
);
- b.put("/b?noTrace=true", null, "text/p2")
+ b.put("/a?noTrace=true", null, "text/p2")
.run()
.assertCode().is(415)
.assertBody().contains(
@@ -138,10 +104,10 @@ public class ContentTypeTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Content-Type headers on servlet annotation are picked up
// when @RestMethod.addParsers/addSerializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Content-Type : text/p2 "},
@@ -149,23 +115,19 @@ public class ContentTypeTest {
)
public static class C {
@RestMethod(name=PUT, parsers={P3.class,Inherit.class})
- public String c(@Body String in) {
+ public String a(@Body String in) {
return in;
}
}
- private static MockRestClient c = MockRestClient.buildLax(C.class);
@Test
public void c01_restMethodAddParsersSerializersInherit() throws Exception {
- c.put("/c", null, "").run().assertBody().is("p2");
- c.put("/c", null, "text/p1").run().assertBody().is("p1");
- c.put("/c", null, "text/p2").run().assertBody().is("p2");
- c.put("/c", null, "text/p3").run().assertBody().is("p3");
- }
-
- @Test
- public void c02_restMethodAddParsersSerializersInherit_invalid() throws Exception {
- c.put("/c?noTrace=true", null).contentType("text/p4")
+ RestClient c = MockRestClient.buildLax(C.class);
+ c.put("/a", null, "").run().assertBody().is("p2");
+ c.put("/a", null, "text/p1").run().assertBody().is("p1");
+ c.put("/a", null, "text/p2").run().assertBody().is("p2");
+ c.put("/a", null, "text/p3").run().assertBody().is("p3");
+ c.put("/a?noTrace=true", null).contentType("text/p4")
.run()
.assertCode().is(415)
.assertBody().contains(
@@ -174,42 +136,39 @@ public class ContentTypeTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Content-Type headers on method annotation are picked up
// when @RestMethod.parsers/serializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Content-Type : text/p2 "},
parsers={P1.class,P2.class}
)
- public static class E {
+ public static class D {
@RestMethod(name=PUT, reqHeaders={"Content-Type: text/p3"}, parsers=P3.class)
- public String e(@Body String in) {
+ public String a(@Body String in) {
return in;
}
}
- private static MockRestClient e = MockRestClient.buildLax(E.class);
@Test
- public void e01_restMethodParserSerializerAnnotations_valid() throws Exception {
- e.put("/e", null, "")
+ public void d01_restMethodParserSerializerAnnotations() throws Exception {
+ RestClient d = MockRestClient.buildLax(D.class);
+ d.put("/a", null, "")
.run()
.assertBody().is("p3");
- e.put("/e", null, "text/p3")
+ d.put("/a", null, "text/p3")
.run()
.assertBody().is("p3");
- }
- @Test
- public void e02_restMethodParserSerializerAnnotations_invalid() throws Exception {
- e.put("/e?noTrace=true", null, "text/p1")
+ d.put("/a?noTrace=true", null, "text/p1")
.run()
.assertCode().is(415)
.assertBody().contains(
"Unsupported media-type in request header 'Content-Type': 'text/p1'",
"Supported media-types: ['text/p3']"
);
- e.put("/e?noTrace=true", null, "text/p2")
+ d.put("/a?noTrace=true", null, "text/p2")
.run()
.assertCode().is(415)
.assertBody().contains(
@@ -218,37 +177,62 @@ public class ContentTypeTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test that default Content-Type headers on method annotation are picked up
// when @RestMethod.addParsers/addSerializers annotations are used.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
reqHeaders={" Content-Type : text/p2 "},
parsers={P1.class,P2.class}
)
- public static class F {
+ public static class E {
@RestMethod(name=PUT, reqHeaders={"Content-Type: text/p3"}, parsers={Inherit.class,P3.class})
- public String f(@Body String in) {
+ public String a(@Body String in) {
return in;
}
}
- private static MockRestClient f = MockRestClient.build(F.class);
-
@Test
- public void f01_restMethodAddParsersSerializersAnnotations_valid() throws Exception {
- f.put("/f", null, "")
+ public void e01_restMethodAddParsersSerializersAnnotations() throws Exception {
+ RestClient e = MockRestClient.build(E.class);
+ e.put("/a", null, "")
.run()
.assertBody().is("p3");
- f.put("/f", null, "text/p1")
+ e.put("/a", null, "text/p1")
.run()
.assertBody().is("p1");
- f.put("/f", null, "text/p2")
+ e.put("/a", null, "text/p2")
.run()
.assertBody().is("p2");
- f.put("/f", null, "text/p3")
+ e.put("/a", null, "text/p3")
.run()
.assertBody().is("p3");
}
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Helpers
+ //------------------------------------------------------------------------------------------------------------------
+
+ public static class DummyParser extends ReaderParser {
+ String name;
+ DummyParser(PropertyStore ps, String name, String...consumes) {
+ super(ps, consumes);
+ this.name = name;
+ }
+ @Override /* Parser */
+ public ReaderParserSession createSession(ParserSessionArgs args) {
+ return new ReaderParserSession(args) {
+ @Override /* ParserSession */
+ @SuppressWarnings("unchecked")
+ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException {
+ return (T)name;
+ }
+ };
+ }
+ }
+
+ public static class P1 extends DummyParser { public P1(PropertyStore ps) {super(ps, "p1", "text/p1");}}
+ public static class P2 extends DummyParser { public P2(PropertyStore ps) {super(ps, "p2", "text/p2");}}
+ public static class P3 extends DummyParser { public P3(PropertyStore ps) {super(ps, "p3", "text/p3");}}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Nls_Test.java
similarity index 68%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Nls_Test.java
index b09c9f1..0636b77 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/NlsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Nls_Test.java
@@ -19,38 +19,37 @@ import java.io.IOException;
import org.apache.juneau.*;
import org.apache.juneau.dto.swagger.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.apache.juneau.serializer.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class NlsTest {
+public class Nls_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test getting an NLS property defined on a class or method.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
- serializers={A01.class},
+ serializers={A1.class},
reqAttrs={"TestProperty:$L{key1}"},
messages="NlsTest"
)
public static class A {
@RestMethod
- public String a01() {
+ public String a() {
return null;
}
@RestMethod(
reqAttrs={"TestProperty:$L{key2}"}
)
- public String a02() {
+ public String b() {
return null;
}
}
- static MockRestClient a = MockRestClient.build(A.class);
-
- public static class A01 extends WriterSerializer {
- public A01(PropertyStore ps) {
+ public static class A1 extends WriterSerializer {
+ public A1(PropertyStore ps) {
super(ps, "text/plain", null);
}
@Override /* Serializer */
@@ -65,18 +64,15 @@ public class NlsTest {
}
@Test
- public void a01_fromClass() throws Exception {
- a.get("/a01").run().assertBody().is("value1");
- }
-
- @Test
- public void a02_fromMethod() throws Exception {
- a.get("/a02").run().assertBody().is("value2");
+ public void a01_basic() throws Exception {
+ RestClient a = MockRestClient.build(A.class);
+ a.get("/a").run().assertBody().is("value1");
+ a.get("/b").run().assertBody().is("value2");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test OPTIONS pages without NLS
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(title="test")
public static class B {
@@ -86,29 +82,29 @@ public class NlsTest {
return req.getSwagger();
}
}
- static MockRestClient b = MockRestClient.build(B.class);
@Test
public void b01_optionsPageWithoutNls() throws Exception {
+ MockRestClient b = MockRestClient.build(B.class);
b.options("/").run().assertBody().contains("foo");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Test Missing resource bundles.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
public static class C {
@RestMethod
- public String test(RestRequest req) {
+ public String a(RestRequest req) {
// Missing resource bundle should cause {!!x} string.
return req.getMessage("bad", 1, 2, 3);
}
}
- static MockRestClient c = MockRestClient.build(C.class);
@Test
public void c01_missingResourceBundle() throws Exception {
- c.get("/test").run().assertBody().is("{!bad}");
+ MockRestClient c = MockRestClient.build(C.class);
+ c.get("/a").run().assertBody().is("{!bad}");
}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Paths_Test.java
similarity index 93%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Paths_Test.java
index 235c48f..bd1c684 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/PathsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Paths_Test.java
@@ -22,11 +22,11 @@ import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class PathsTest {
+public class Paths_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Setup
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
static OMap getPaths(RestRequest req) {
return OMap.of()
@@ -41,9 +41,9 @@ public class PathsTest {
.a("servletParentURI", req.getUriContext().getRootRelativeServletPathParent());
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// No subpath
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
public static class A {
@@ -190,9 +190,9 @@ public class PathsTest {
;
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Subpath in method
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
public static class B {
@RestMethod(name=GET, path="/subpath/*")
@@ -338,15 +338,15 @@ public class PathsTest {
;
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Child resource
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
- @Rest(children={C01.class})
+ @Rest(children={C1.class})
public static class C {}
@Rest(path="/a")
- public static class C01 {
+ public static class C1 {
@RestMethod(name=GET,path="/*")
public OMap get(RestRequest req, @Path("/*") String r) {
return getPaths(req).append("pathRemainder2", r).append("method",3);
@@ -490,15 +490,15 @@ public class PathsTest {
;
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Child resource and subpath in method
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
- @Rest(children={D01.class})
+ @Rest(children={D1.class})
public static class D {}
@Rest(path="/a")
- public static class D01 {
+ public static class D1 {
@RestMethod(name=GET, path="/subpath/*")
public OMap get(RestRequest req, @Path("/*") String r) {
return getPaths(req).append("pathRemainder2", r).append("method",4);
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerConfigTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerConfig_Test.java
similarity index 99%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerConfigTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerConfig_Test.java
index cf6b63e..e310cf9 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerConfigTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerConfig_Test.java
@@ -24,7 +24,7 @@ import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class RestCallLoggerConfigTest {
+public class RestCallLoggerConfig_Test {
private MockServletRequest req() {
return MockServletRequest.create();
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerRuleTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerRule_Test.java
similarity index 99%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerRuleTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerRule_Test.java
index 98ba08a..1f446ef 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerRuleTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestCallLoggerRule_Test.java
@@ -22,7 +22,7 @@ import org.apache.juneau.parser.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class RestCallLoggerRuleTest {
+public class RestCallLoggerRule_Test {
static final Throwable T1 = new IndexOutOfBoundsException();
static final Throwable T2 = new NoSuchMethodError();
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/ThreadLocalObjectsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestContext_ThreadLocals_Test.java
similarity index 79%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/ThreadLocalObjectsTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestContext_ThreadLocals_Test.java
index 0c108f9..8241ee8 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/ThreadLocalObjectsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestContext_ThreadLocals_Test.java
@@ -20,17 +20,17 @@ import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class ThreadLocalObjectsTest {
+public class RestContext_ThreadLocals_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Thread-locals on top-level resource.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@SuppressWarnings("serial")
@Rest(path="/a")
public static class A extends BasicRestServlet {
@RestMethod
- public void getA01() throws Exception {
+ public void a() throws Exception {
getResponse().getWriter().append(getRequest().getQuery("foo"));
}
@@ -44,14 +44,14 @@ public class ThreadLocalObjectsTest {
@Test
public void a01() throws Exception {
- a.get("/a01?foo=bar").run()
+ a.get("/a?foo=bar").run()
.assertBody().contains("bar")
;
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Thread-locals on child resource.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@SuppressWarnings("serial")
@Rest(
@@ -70,7 +70,7 @@ public class ThreadLocalObjectsTest {
@Test
public void b01() throws Exception {
- b.get("/a/a01?foo=bar").run()
+ b.get("/a/a?foo=bar").run()
.assertBody().contains("bar")
;
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Params_Test.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Params_Test.java
new file mode 100644
index 0000000..118dc2f
--- /dev/null
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Params_Test.java
@@ -0,0 +1,414 @@
+// ***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.http.HttpMethod.*;
+import static org.apache.juneau.internal.IOUtils.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.io.*;
+import java.util.*;
+
+import javax.servlet.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.config.*;
+import org.apache.juneau.cp.Messages;
+import org.apache.juneau.dto.swagger.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.http.header.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.RestRequest;
+import org.apache.juneau.rest.RestResponse;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.mock2.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class RestMethod_Params_Test {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Various parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(messages="RestParamsTest")
+ public static class A {
+ @RestMethod
+ public String a(ResourceBundle t) {
+ return t == null ? null : t.getString("foo");
+ }
+ @RestMethod
+ public String b(Messages t) {
+ return t == null ? null : t.getString("foo");
+ }
+ @RestMethod(name=POST)
+ public String c(InputStream t) throws IOException {
+ return read(t);
+ }
+ @RestMethod(name=POST)
+ public String d(ServletInputStream t) throws IOException {
+ return read(t);
+ }
+ @RestMethod(name=POST)
+ public String e(Reader t) throws IOException {
+ return read(t);
+ }
+ @RestMethod
+ public void f(OutputStream t) throws IOException {
+ t.write("OK".getBytes());
+ }
+ @RestMethod
+ public void g(ServletOutputStream t) throws IOException {
+ t.write("OK".getBytes());
+ }
+ @RestMethod
+ public void h(Writer t) throws IOException {
+ t.write("OK");
+ }
+ @RestMethod
+ public boolean i(RequestHeaders t) {
+ return t != null;
+ }
+ @RestMethod
+ public boolean j(RequestQuery t) {
+ return t != null;
+ }
+ @RestMethod
+ public boolean k(RequestFormData t) {
+ return t != null;
+ }
+ @RestMethod
+ public String l(@Method String t) {
+ return t;
+ }
+ @SuppressWarnings("deprecation")
+ @RestMethod
+ public boolean m(RestLogger t) {
+ return t != null;
+ }
+ @RestMethod
+ public boolean n(RestContext t) {
+ return t != null;
+ }
+ @RestMethod(parsers={JsonParser.class})
+ public String o(Parser t) {
+ return t.getClass().getName();
+ }
+ @RestMethod
+ public String p(Locale t) {
+ return t.toString();
+ }
+ @RestMethod
+ public boolean q(Swagger t) {
+ return t != null;
+ }
+ @RestMethod
+ public boolean r(RequestPath t) {
+ return t != null;
+ }
+ @RestMethod
+ public boolean s(RequestBody t) {
+ return t != null;
+ }
+ @RestMethod
+ public boolean t(Config t) {
+ return t != null;
+ }
+ }
+
+ @Test
+ public void a01_params() throws Exception {
+ RestClient a = MockRestClient.build(A.class);
+ a.get("/a").acceptLanguage("en-US").run().assertBody().is("bar");
+ a.get("/a").acceptLanguage("ja-JP").run().assertBody().is("baz");
+ a.get("/b").acceptLanguage("en-US").run().assertBody().is("bar");
+ a.get("/b").acceptLanguage("ja-JP").run().assertBody().is("baz");
+ a.post("/c", "foo").run().assertBody().is("foo");
+ a.post("/d", "foo").run().assertBody().is("foo");
+ a.post("/e", "foo").run().assertBody().is("foo");
+ a.get("/f").run().assertBody().is("OK");
+ a.get("/g").run().assertBody().is("OK");
+ a.get("/h").run().assertBody().is("OK");
+ a.get("/i").run().assertBody().is("true");
+ a.get("/j").run().assertBody().is("true");
+ a.get("/k").run().assertBody().is("true");
+ a.get("/l").run().assertBody().is("GET");
+ a.get("/m").run().assertBody().is("true");
+ a.get("/n").run().assertBody().is("true");
+ a.get("/o").contentType("application/json").run().assertBody().is("org.apache.juneau.json.JsonParser");
+ a.get("/p").acceptLanguage("en-US").run().assertBody().is("en_US");
+ a.get("/p").acceptLanguage("ja-JP").run().assertBody().is("ja_JP");
+ a.get("/q").run().assertBody().is("true");
+ a.get("/r").run().assertBody().is("true");
+ a.get("/s").run().assertBody().is("true");
+ a.get("/t").run().assertBody().is("true");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Headers
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(
+ serializers=B1a.class,
+ parsers=B1b.class,
+ encoders=B1c.class,
+ allowedHeaderParams="*"
+ )
+ public static class B1 {
+
+ @RestMethod
+ public String accept(Accept accept) {
+ return accept.getValue();
+ }
+ @RestMethod
+ public String acceptCharset(AcceptCharset acceptCharset) {
+ return acceptCharset.getValue();
+ }
+ @RestMethod
+ public String acceptEncoding(AcceptEncoding acceptEncoding) {
+ return acceptEncoding.getValue();
+ }
+ @RestMethod
+ public String acceptLanguage(AcceptLanguage acceptLanguage) {
+ return acceptLanguage.getValue();
+ }
+ @RestMethod
+ public String authorization(Authorization authorization) {
+ return authorization.getValue();
+ }
+ @RestMethod
+ public String cacheControl(CacheControl cacheControl) {
+ return cacheControl.getValue();
+ }
+ @RestMethod
+ public String connection(Connection connection) {
+ return connection.getValue();
+ }
+ @RestMethod
+ public String contentLength(ContentLength contentLength) {
+ return contentLength.getValue();
+ }
+ @RestMethod
+ public String contentType(ContentType contentType) {
+ return contentType.getValue();
+ }
+ @RestMethod
+ public String date(org.apache.juneau.http.header.Date date) {
+ return date.getValue();
+ }
+ @RestMethod
+ public String expect(Expect expect) {
+ return expect.getValue();
+ }
+ @RestMethod
+ public String from(From from) {
+ return from.getValue();
+ }
+ @RestMethod
+ public String host(Host host) {
+ return host.getValue();
+ }
+ @RestMethod
+ public String ifMatch(IfMatch ifMatch) {
+ return ifMatch.getValue();
+ }
+ @RestMethod
+ public String ifModifiedSince(IfModifiedSince ifModifiedSince) {
+ return ifModifiedSince.getValue();
+ }
+ @RestMethod
+ public String ifNoneMatch(IfNoneMatch ifNoneMatch) {
+ return ifNoneMatch.getValue();
+ }
+ @RestMethod
+ public String ifRange(IfRange ifRange) {
+ return ifRange.getValue();
+ }
+ @RestMethod
+ public String ifUnmodifiedSince(IfUnmodifiedSince ifUnmodifiedSince) {
+ return ifUnmodifiedSince.getValue();
+ }
+ @RestMethod
+ public String maxForwards(MaxForwards maxForwards) {
+ return maxForwards.getValue();
+ }
+ @RestMethod
+ public String pragma(Pragma pragma) {
+ return pragma.getValue();
+ }
+ @RestMethod
+ public String proxyAuthorization(ProxyAuthorization proxyAuthorization) {
+ return proxyAuthorization.getValue();
+ }
+ @RestMethod
+ public String range(Range range) {
+ return range.getValue();
+ }
+ @RestMethod
+ public String referer(Referer referer) {
+ return referer.getValue();
+ }
+ @RestMethod
+ public String te(TE te) {
+ return te.getValue();
+ }
+ @RestMethod
+ public String upgrade(Upgrade upgrade) {
+ return upgrade.getValue();
+ }
+ @RestMethod
+ public String userAgent(UserAgent userAgent) {
+ return userAgent.getValue();
+ }
+ @RestMethod
+ public String warning(Warning warning) {
+ return warning.getValue();
+ }
+ }
+
+ public static class B1a extends PlainTextSerializer {
+ public B1a(PropertyStore ps) {
+ super(ps, "text/plain", "*/*");
+ }
+ }
+
+ public static class B1b extends PlainTextParser {
+ public B1b(PropertyStore ps) {
+ super(ps, "*/*");
+ }
+ }
+
+ public static class B1c extends IdentityEncoder {
+ @Override /* ConfigEncoder */
+ public String[] getCodings() {
+ return new String[]{"*"};
+ }
+ }
+
+ @Test
+ public void b01_headers() throws Exception {
+ RestClient b = MockRestClient.build(B1.class);
+
+ b.get("/accept").accept("text/foo").run().assertBody().is("text/foo");
+ b.get("/accept").accept("text/foo+bar").run().assertBody().is("text/foo+bar");
+ b.get("/accept").accept("text/*").run().assertBody().is("text/*");
+ b.get("/accept").accept("*/foo").run().assertBody().is("*/foo");
+ b.get("/accept").accept("text/foo;q=1.0").run().assertBody().is("text/foo");
+ b.get("/accept").accept("text/foo;q=0.9").run().assertBody().is("text/foo;q=0.9");
+ b.get("/accept").accept("text/foo;x=X;q=0.9;y=Y").run().assertBody().is("text/foo;x=X;q=0.9;y=Y");
+ b.get("/accept?Accept=text/foo").run().assertBody().is("text/foo");
+ b.get("/acceptCharset").acceptCharset("UTF-8").run().assertBody().is("UTF-8");
+ b.get("/acceptCharset?Accept-Charset=UTF-8").run().assertBody().is("UTF-8");
+ b.get("/acceptEncoding").acceptEncoding("foo").run().assertBody().is("foo");
+ b.get("/acceptEncoding").acceptEncoding("*").run().assertBody().is("*");
+ b.get("/acceptEncoding?Accept-Encoding=*").run().assertBody().is("*");
+ b.get("/acceptLanguage").acceptLanguage("foo").run().assertBody().is("foo");
+ b.get("/acceptLanguage?Accept-Language=foo").acceptLanguage("foo").run().assertBody().is("foo");
+ b.get("/authorization").authorization("foo").run().assertBody().is("foo");
+ b.get("/authorization?Authorization=foo").run().assertBody().is("foo");
+ b.get("/cacheControl").cacheControl("foo").run().assertBody().is("foo");
+ b.get("/cacheControl?Cache-Control=foo").run().assertBody().is("foo");
+ b.get("/connection").connection("foo").run().assertBody().is("foo");
+ b.get("/connection?Connection=foo").run().assertBody().is("foo");
+ b.get("/contentLength").contentLength(0).run().assertBody().is("0");
+ b.get("/contentLength?Content-Length=0").run().assertBody().is("0");
+ b.get("/contentType").contentType("text/foo").run().assertBody().is("text/foo");
+ b.get("/contentType?Content-Type=text/foo").run().assertBody().is("text/foo");
+ b.get("/date").date("Wed, 21 Oct 2015 07:28:00 GMT").run().assertBody().is("Wed, 21 Oct 2015 07:28:00 GMT");
+ b.get("/date?Date=Wed, 21 Oct 2015 07:28:00 GMT").run().assertBody().is("Wed, 21 Oct 2015 07:28:00 GMT");
+ b.get("/expect").expect("100-continue").run().assertBody().is("100-continue");
+ b.get("/expect?Expect=100-continue").run().assertBody().is("100-continue");
+ b.get("/from").from("foo").run().assertBody().is("foo");
+ b.get("/from?From=foo").run().assertBody().is("foo");
+ b.get("/host").host("localhost").run().assertBody().is("localhost");
+ b.get("/host?Host=localhost").run().assertBody().is("localhost");
+ b.get("/ifMatch").ifMatch("\"foo\"").run().assertBody().is("\"foo\"");
+ b.get("/ifMatch").ifMatch("W/\"foo\"").run().assertBody().is("W/\"foo\"");
+ b.get("/ifMatch").ifMatch("W/\"foo\",\"bar\"").run().assertBody().is("W/\"foo\",\"bar\"");
+ b.get("/ifMatch?If-Match=\"foo\"").run().assertBody().is("\"foo\"");
+ b.get("/ifModifiedSince").ifModifiedSince("Wed, 21 Oct 2015 07:28:00 GMT").run().assertBody().is("Wed, 21 Oct 2015 07:28:00 GMT");
+ b.get("/ifModifiedSince?If-Modified-Since=Wed, 21 Oct 2015 07:28:00 GMT").run().assertBody().is("Wed, 21 Oct 2015 07:28:00 GMT");
+ b.get("/ifNoneMatch").ifNoneMatch("\"foo\"").run().assertBody().is("\"foo\"");
+ b.get("/ifNoneMatch").ifNoneMatch("W/\"foo\"").run().assertBody().is("W/\"foo\"");
+ b.get("/ifNoneMatch").ifNoneMatch("W/\"foo\",\"bar\"").run().assertBody().is("W/\"foo\",\"bar\"");
+ b.get("/ifNoneMatch?If-None-Match=\"foo\"").run().assertBody().is("\"foo\"");
+ b.get("/ifRange").ifRange("\"foo\"").run().assertBody().is("\"foo\"");
+ b.get("/ifRange?If-Range=\"foo\"").run().assertBody().is("\"foo\"");
+ b.get("/ifUnmodifiedSince").ifUnmodifiedSince("Wed, 21 Oct 2015 07:28:00 GMT").run().assertBody().is("Wed, 21 Oct 2015 07:28:00 GMT");
+ b.get("/ifUnmodifiedSince?If-Unmodified-Since=Wed, 21 Oct 2015 07:28:00 GMT").run().assertBody().is("Wed, 21 Oct 2015 07:28:00 GMT");
+ b.get("/maxForwards").maxForwards(123).run().assertBody().is("123");
+ b.get("/maxForwards?Max-Forwards=123").run().assertBody().is("123");
+ b.get("/pragma").pragma("foo").run().assertBody().is("foo");
+ b.get("/pragma?Pragma=foo").run().assertBody().is("foo");
+ b.get("/proxyAuthorization").proxyAuthorization("foo").run().assertBody().is("foo");
+ b.get("/proxyAuthorization?Proxy-Authorization=foo").run().assertBody().is("foo");
+ b.get("/range").range("foo").run().assertBody().is("foo");
+ b.get("/range?Range=foo").run().assertBody().is("foo");
+ b.get("/referer").referer("foo").run().assertBody().is("foo");
+ b.get("/referer?Referer=foo").run().assertBody().is("foo");
+ b.get("/te").te("foo").run().assertBody().is("foo");
+ b.get("/te?TE=foo").run().assertBody().is("foo");
+ b.get("/upgrade").upgrade("foo").run().assertBody().is("foo");
+ b.get("/upgrade?Upgrade=foo").run().assertBody().is("foo");
+ b.get("/userAgent").userAgent("foo").run().assertBody().is("foo");
+ b.get("/userAgent?User-Agent=foo").run().assertBody().is("foo");
+ b.get("/warning").warning("foo").run().assertBody().is("foo");
+ b.get("/warning?Warning=foo").run().assertBody().is("foo");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Custom header.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(
+ paramResolvers=B2a.class,
+ allowedHeaderParams="Custom"
+ )
+ public static class B2 {
+ @RestMethod
+ public String a(B2b customHeader) {
+ return customHeader.toString();
+ }
+ }
+
+ public static class B2a extends RestMethodParam {
+ public B2a() {
+ super(RestParamType.HEADER, "Custom", B2b.class);
+ }
+ @Override
+ public Object resolve(RestRequest req, RestResponse res) throws Exception {
+ return new B2b(req.getHeader("Custom"));
+ }
+ }
+
+ public static class B2b {
+ public String value;
+ public B2b(String value) {
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ @Test
+ public void b02_customHeader() throws Exception {
+ RestClient b = MockRestClient.build(B2.class);
+ b.get("/a").header("Custom", "foo").run().assertBody().is("foo");
+ b.get("/a?Custom=foo").run().assertBody().is("foo");
+ }
+}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Returns_Test.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Returns_Test.java
new file mode 100644
index 0000000..bce0a56
--- /dev/null
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Returns_Test.java
@@ -0,0 +1,188 @@
+// ***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.rest.testutils.TestUtils.*;
+
+import static org.junit.Assert.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.dto.swagger.*;
+import org.apache.juneau.rest.RestRequest;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.mock2.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.http.response.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class RestMethod_Returns_Test {
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Response beans
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ public static class A {
+ @RestMethod public Accepted accepted() { return new Accepted(); }
+ @RestMethod public AlreadyReported alreadyReported() { return new AlreadyReported(); }
+ @RestMethod(path="/continue") public Continue _continue() { return new Continue(); }
+ @RestMethod public Created created() { return new Created(); }
+ @RestMethod public EarlyHints earlyHints() { return new EarlyHints(); }
+ @RestMethod public Found found() { return new Found(); }
+ @RestMethod public IMUsed imUsed() { return new IMUsed(); }
+ @RestMethod public MovedPermanently movedPermanently() { return new MovedPermanently(); }
+ @RestMethod public MultipleChoices multipleChoices() { return new MultipleChoices(); }
+ @RestMethod public MultiStatus multiStatus() { return new MultiStatus(); }
+ @RestMethod public NoContent noContent() { return new NoContent(); }
+ @RestMethod public NonAuthoritiveInformation nonAuthoritiveInformation() { return new NonAuthoritiveInformation(); }
+ @RestMethod public NotModified notModified() { return new NotModified(); }
+ @RestMethod public Ok ok() { return new Ok(); }
+ @RestMethod public PartialContent partialContent() { return new PartialContent(); }
+ @RestMethod public PermanentRedirect permanentRedirect() { return new PermanentRedirect(); }
+ @RestMethod public Processing processing() { return new Processing(); }
+ @RestMethod public ResetContent resetContent() { return new ResetContent(); }
+ @RestMethod public SeeOther seeOther() { return new SeeOther(); }
+ @RestMethod public SwitchingProtocols switchingProtocols() { return new SwitchingProtocols(); }
+ @RestMethod public TemporaryRedirect temporaryRedirect() { return new TemporaryRedirect(); }
+ @RestMethod public UseProxy useProxy() { return new UseProxy(); }
+ }
+
+ @Test
+ public void a01_responseBeans() throws Exception {
+ RestClient c = client(A.class);
+ c.get("/accepted").run().assertStatus().code().is(Accepted.CODE).assertBody().is(Accepted.MESSAGE);
+ c.get("/alreadyReported").run().assertStatus().code().is(AlreadyReported.CODE).assertBody().is(AlreadyReported.MESSAGE);
+ c.get("/continue").run().assertStatus().code().is(Continue.CODE + 1000).assertBody().is(Continue.MESSAGE);
+ c.get("/created").run().assertStatus().code().is(Created.CODE).assertBody().is(Created.MESSAGE);
+ c.get("/earlyHints").run().assertStatus().code().is(EarlyHints.CODE + 1000).assertBody().is(EarlyHints.MESSAGE);
+ c.get("/found").run().assertStatus().code().is(Found.CODE).assertBody().is(Found.MESSAGE);
+ c.get("/imUsed").run().assertStatus().code().is(IMUsed.CODE).assertBody().is(IMUsed.MESSAGE);
+ c.get("/movedPermanently").run().assertStatus().code().is(MovedPermanently.CODE).assertBody().is(MovedPermanently.MESSAGE);
+ c.get("/multipleChoices").run().assertStatus().code().is(MultipleChoices.CODE).assertBody().is(MultipleChoices.MESSAGE);
+ c.get("/multiStatus").run().assertStatus().code().is(MultiStatus.CODE).assertBody().is(MultiStatus.MESSAGE);
+ c.get("/noContent").run().assertStatus().code().is(NoContent.CODE).assertBody().isEmpty();
+ c.get("/nonAuthoritiveInformation").run().assertStatus().code().is(NonAuthoritiveInformation.CODE).assertBody().is(NonAuthoritiveInformation.MESSAGE);
+ c.get("/notModified").run().assertStatus().code().is(NotModified.CODE).assertBody().isEmpty();
+ c.get("/ok").run().assertStatus().code().is(Ok.CODE).assertBody().is(Ok.MESSAGE);
+ c.get("/partialContent").run().assertStatus().code().is(PartialContent.CODE).assertBody().is(PartialContent.MESSAGE);
+ c.get("/permanentRedirect").run().assertStatus().code().is(PermanentRedirect.CODE).assertBody().is(PermanentRedirect.MESSAGE);
+ c.get("/processing").run().assertStatus().code().is(Processing.CODE + 1000).assertBody().is(Processing.MESSAGE);
+ c.get("/resetContent").run().assertStatus().code().is(ResetContent.CODE).assertBody().isEmpty();
+ c.get("/seeOther").run().assertStatus().code().is(SeeOther.CODE).assertBody().is(SeeOther.MESSAGE);
+ c.get("/switchingProtocols").run().assertStatus().code().is(SwitchingProtocols.CODE + 1000).assertBody().is(SwitchingProtocols.MESSAGE);
+ c.get("/temporaryRedirect").run().assertStatus().code().is(TemporaryRedirect.CODE).assertBody().is(TemporaryRedirect.MESSAGE);
+ c.get("/useProxy").run().assertStatus().code().is(UseProxy.CODE).assertBody().is(UseProxy.MESSAGE);
+ }
+
+ @Test
+ public void a02_responseBeans_swagger() throws Exception {
+ Map<String,OperationMap> paths = getSwagger(A.class).getPaths();
+ assertEquals(Accepted.MESSAGE, paths.get("/accepted").get("get").getResponse(Accepted.CODE).getDescription());
+ assertEquals(AlreadyReported.MESSAGE, paths.get("/alreadyReported").get("get").getResponse(AlreadyReported.CODE).getDescription());
+ assertEquals(Continue.MESSAGE, paths.get("/continue").get("get").getResponse(Continue.CODE).getDescription());
+ assertEquals(Created.MESSAGE, paths.get("/created").get("get").getResponse(Created.CODE).getDescription());
+ assertEquals(EarlyHints.MESSAGE, paths.get("/earlyHints").get("get").getResponse(EarlyHints.CODE).getDescription());
+ assertEquals(Found.MESSAGE, paths.get("/found").get("get").getResponse(Found.CODE).getDescription());
+ assertEquals(IMUsed.MESSAGE, paths.get("/imUsed").get("get").getResponse(IMUsed.CODE).getDescription());
+ assertEquals(MovedPermanently.MESSAGE, paths.get("/movedPermanently").get("get").getResponse(MovedPermanently.CODE).getDescription());
+ assertEquals(MultipleChoices.MESSAGE, paths.get("/multipleChoices").get("get").getResponse(MultipleChoices.CODE).getDescription());
+ assertEquals(MultiStatus.MESSAGE, paths.get("/multiStatus").get("get").getResponse(MultiStatus.CODE).getDescription());
+ assertEquals(NoContent.MESSAGE, paths.get("/noContent").get("get").getResponse(NoContent.CODE).getDescription());
+ assertEquals(NonAuthoritiveInformation.MESSAGE, paths.get("/nonAuthoritiveInformation").get("get").getResponse(NonAuthoritiveInformation.CODE).getDescription());
+ assertEquals(NotModified.MESSAGE, paths.get("/notModified").get("get").getResponse(NotModified.CODE).getDescription());
+ assertEquals(Ok.MESSAGE, paths.get("/ok").get("get").getResponse(Ok.CODE).getDescription());
+ assertEquals(PartialContent.MESSAGE, paths.get("/partialContent").get("get").getResponse(PartialContent.CODE).getDescription());
+ assertEquals(PermanentRedirect.MESSAGE, paths.get("/permanentRedirect").get("get").getResponse(PermanentRedirect.CODE).getDescription());
+ assertEquals(Processing.MESSAGE, paths.get("/processing").get("get").getResponse(Processing.CODE).getDescription());
+ assertEquals(ResetContent.MESSAGE, paths.get("/resetContent").get("get").getResponse(ResetContent.CODE).getDescription());
+ assertEquals(SeeOther.MESSAGE, paths.get("/seeOther").get("get").getResponse(SeeOther.CODE).getDescription());
+ assertEquals(SwitchingProtocols.MESSAGE, paths.get("/switchingProtocols").get("get").getResponse(SwitchingProtocols.CODE).getDescription());
+ assertEquals(TemporaryRedirect.MESSAGE, paths.get("/temporaryRedirect").get("get").getResponse(TemporaryRedirect.CODE).getDescription());
+ assertEquals(UseProxy.MESSAGE, paths.get("/useProxy").get("get").getResponse(UseProxy.CODE).getDescription());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // BasicHttpResource
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ public static class B {
+ @RestMethod
+ public BasicHttpResource a() throws Exception {
+ return BasicHttpResource.of("foo");
+ }
+ @RestMethod
+ public BasicHttpResource b() throws Exception {
+ return BasicHttpResource.of(null).header("Foo", "Bar");
+ }
+ @RestMethod
+ public BasicHttpResource c() throws Exception {
+ return BasicHttpResource.of(null).contentType("application/json");
+ }
+ @RestMethod
+ public BasicHttpResource d(RestRequest req) throws Exception {
+ return BasicHttpResource.of(()->req.getVarResolverSession().resolve("$RQ{foo}"));
+ }
+ @RestMethod
+ public BasicHttpResource e() throws Exception {
+ return BasicHttpResource.of(new ByteArrayInputStream("foo".getBytes()));
+ }
+ @RestMethod
+ public BasicHttpResource f() throws Exception {
+ return BasicHttpResource.of(new StringReader("foo"));
+ }
+ @RestMethod
+ public BasicHttpResource g() throws Exception {
+ return BasicHttpResource.of(new StringBuilder("foo"));
+ }
+ }
+
+ @Test
+ public void b01_BasicHttpResource() throws Exception {
+ RestClient b = MockRestClient.build(B.class);
+ b.get("/a")
+ .run()
+ .assertBody().is("foo");
+ b.get("/b")
+ .run()
+ .assertStringHeader("Foo").is("Bar");
+ b.get("/c")
+ .run()
+ .assertStringHeader("Content-Type").is("application/json");
+ b.get("/d?foo=bar")
+ .run()
+ .assertBody().is("bar");
+ b.get("/e")
+ .run()
+ .assertBody().is("foo");
+ b.get("/f")
+ .run()
+ .assertBody().is("foo");
+ b.get("/g")
+ .run()
+ .assertBody().is("foo");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Helper methods
+ //------------------------------------------------------------------------------------------------------------------
+
+ private static MockRestClient client(Class<?> c) {
+ return MockRestClient.create(c).disableRedirectHandling().ignoreErrors().build();
+ }
+}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Throws_Test.java
similarity index 65%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Throws_Test.java
index 1061191..fc18e6b 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/exceptions/BasicTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestMethod_Throws_Test.java
@@ -10,24 +10,27 @@
// * "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.exceptions;
+package org.apache.juneau.rest;
+
+import static org.apache.juneau.rest.testutils.TestUtils.*;
import static org.junit.Assert.*;
import static org.junit.runners.MethodSorters.*;
-import static org.apache.juneau.rest.testutils.TestUtils.*;
+
+import java.util.*;
import org.apache.juneau.dto.swagger.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.helper.*;
import org.apache.juneau.rest.mock2.*;
-import org.junit.*;
import org.apache.juneau.http.exception.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.parser.*;
+import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class BasicTest {
-
+public class RestMethod_Throws_Test {
//-----------------------------------------------------------------------------------------------------------------
// Basic sanity tests
//-----------------------------------------------------------------------------------------------------------------
@@ -69,234 +72,137 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates(); }
}
- static MockRestClient a = MockRestClient.buildLax(A.class);
-
@Test
- public void a01_badRequest() throws Exception {
+ public void a01_noArgs() throws Exception {
+ RestClient a = MockRestClient.buildLax(A.class);
a.get("/badRequest")
.run()
.assertCode().is(400)
.assertBody().is("Bad Request");
- }
- @Test
- public void a02_conflict() throws Exception {
a.get("/conflict")
.run()
.assertCode().is(409)
.assertBody().is("Conflict");
- }
- @Test
- public void a03_expectationFailed() throws Exception {
a.get("/expectationFailed")
.run()
.assertCode().is(417)
.assertBody().is("Expectation Failed");
- }
- @Test
- public void a04_failedDependency() throws Exception {
a.get("/failedDependency")
.run()
.assertCode().is(424)
.assertBody().is("Failed Dependency");
- }
- @Test
- public void a05_forbidden() throws Exception {
a.get("/forbidden")
.run()
.assertCode().is(403)
.assertBody().is("Forbidden");
- }
- @Test
- public void a06_gone() throws Exception {
a.get("/gone")
.run()
.assertCode().is(410)
.assertBody().is("Gone");
- }
- @Test
- public void a07_httpVersionNotSupported() throws Exception {
a.get("/httpVersionNotSupported")
.run()
.assertCode().is(505)
.assertBody().is("HTTP Version Not Supported");
- }
- @Test
- public void a08_insufficientStorage() throws Exception {
a.get("/insufficientStorage")
.run()
.assertCode().is(507)
.assertBody().is("Insufficient Storage");
- }
- @Test
- public void a09_internalServerError() throws Exception {
a.get("/internalServerError")
.run()
.assertCode().is(500)
.assertBody().is("Internal Server Error");
- }
- @Test
- public void a10_lengthRequired() throws Exception {
a.get("/lengthRequired")
.run()
.assertCode().is(411)
.assertBody().is("Length Required");
- }
- @Test
- public void a11_locked() throws Exception {
a.get("/locked")
.run()
.assertCode().is(423)
.assertBody().is("Locked");
- }
- @Test
- public void a12_loopDetected() throws Exception {
a.get("/loopDetected")
.run()
.assertCode().is(508)
.assertBody().is("Loop Detected");
- }
- @Test
- public void a13_methodNotAllowed() throws Exception {
a.get("/methodNotAllowed")
.run()
.assertCode().is(405)
.assertBody().is("Method Not Allowed");
- }
- @Test
- public void a14_misdirectedRequest() throws Exception {
a.get("/misdirectedRequest")
.run()
.assertCode().is(421)
.assertBody().is("Misdirected Request");
- }
- @Test
- public void a15_networkAuthenticationRequired() throws Exception {
a.get("/networkAuthenticationRequired")
.run()
.assertCode().is(511)
.assertBody().is("Network Authentication Required");
- }
- @Test
- public void a16_notAcceptable() throws Exception {
a.get("/notAcceptable")
.run()
.assertCode().is(406)
.assertBody().is("Not Acceptable");
- }
- @Test
- public void a17_notExtended() throws Exception {
a.get("/notExtended")
.run()
.assertCode().is(510)
.assertBody().is("Not Extended");
- }
- @Test
- public void a18_notFound() throws Exception {
a.get("/notFound")
.run()
.assertCode().is(404)
.assertBody().is("Not Found");
- }
- @Test
- public void a19_notImplemented() throws Exception {
a.get("/notImplemented")
.run()
.assertCode().is(501)
.assertBody().is("Not Implemented");
- }
- @Test
- public void a20_payloadTooLarge() throws Exception {
a.get("/payloadTooLarge")
.run()
.assertCode().is(413)
.assertBody().is("Payload Too Large");
- }
- @Test
- public void a21_preconditionFailed() throws Exception {
a.get("/preconditionFailed")
.run()
.assertCode().is(412)
.assertBody().is("Precondition Failed");
- }
- @Test
- public void a22_preconditionRequired() throws Exception {
a.get("/preconditionRequired")
.run()
.assertCode().is(428)
.assertBody().is("Precondition Required");
- }
- @Test
- public void a23_rangeNotSatisfiable() throws Exception {
a.get("/rangeNotSatisfiable")
.run()
.assertCode().is(416)
.assertBody().is("Range Not Satisfiable");
- }
- @Test
- public void a24_requestHeaderFieldsTooLarge() throws Exception {
a.get("/requestHeaderFieldsTooLarge")
.run()
.assertCode().is(431)
.assertBody().is("Request Header Fields Too Large");
- }
- @Test
- public void a25_serviceUnavailable() throws Exception {
a.get("/serviceUnavailable")
.run()
.assertCode().is(503)
.assertBody().is("Service Unavailable");
- }
- @Test
- public void a26_tooManyRequests() throws Exception {
a.get("/tooManyRequests")
.run()
.assertCode().is(429)
.assertBody().is("Too Many Requests");
- }
- @Test
- public void a27_unauthorized() throws Exception {
a.get("/unauthorized")
.run()
.assertCode().is(401)
.assertBody().is("Unauthorized");
- }
- @Test
- public void a28_unavailableForLegalReasons() throws Exception {
a.get("/unavailableForLegalReasons")
.run()
.assertCode().is(451)
.assertBody().is("Unavailable For Legal Reasons");
- }
- @Test
- public void a29_unprocessableEntity() throws Exception {
a.get("/unprocessableEntity")
.run()
.assertCode().is(422)
.assertBody().is("Unprocessable Entity");
- }
- @Test
- public void a30_unsupportedMediaType() throws Exception {
a.get("/unsupportedMediaType")
.run()
.assertCode().is(415)
.assertBody().is("Unsupported Media Type");
- }
- @Test
- public void a31_upgradeRequired() throws Exception {
a.get("/upgradeRequired")
.run()
.assertCode().is(426)
.assertBody().is("Upgrade Required");
- }
- @Test
- public void a32_uriTooLong() throws Exception {
a.get("/uriTooLong")
.run()
.assertCode().is(414)
.assertBody().is("URI Too Long");
- }
- @Test
- public void a33_variantAlsoNegotiates() throws Exception {
a.get("/variantAlsoNegotiates")
.run()
.assertCode().is(506)
@@ -344,234 +250,138 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates("foo {0}", "bar"); }
}
- static MockRestClient b = MockRestClient.buildLax(B.class);
@Test
- public void b01_badRequest() throws Exception {
+ public void b01_userSpecifiedMessage() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
b.get("/badRequest")
.run()
.assertCode().is(400)
.assertBody().is("foo bar");
- }
- @Test
- public void b02_conflict() throws Exception {
b.get("/conflict")
.run()
.assertCode().is(409)
.assertBody().is("foo bar");
- }
- @Test
- public void b03_expectationFailed() throws Exception {
b.get("/expectationFailed")
.run()
.assertCode().is(417)
.assertBody().is("foo bar");
- }
- @Test
- public void b04_failedDependency() throws Exception {
b.get("/failedDependency")
.run()
.assertCode().is(424)
.assertBody().is("foo bar");
- }
- @Test
- public void b05_forbidden() throws Exception {
b.get("/forbidden")
.run()
.assertCode().is(403)
.assertBody().is("foo bar");
- }
- @Test
- public void b06_gone() throws Exception {
b.get("/gone")
.run()
.assertCode().is(410)
.assertBody().is("foo bar");
- }
- @Test
- public void b07_httpVersionNotSupported() throws Exception {
b.get("/httpVersionNotSupported")
.run()
.assertCode().is(505)
.assertBody().is("foo bar");
- }
- @Test
- public void b08_insufficientStorage() throws Exception {
b.get("/insufficientStorage")
.run()
.assertCode().is(507)
.assertBody().is("foo bar");
- }
- @Test
- public void b09_internalServerError() throws Exception {
b.get("/internalServerError")
.run()
.assertCode().is(500)
.assertBody().is("foo bar");
- }
- @Test
- public void b10_lengthRequired() throws Exception {
b.get("/lengthRequired")
.run()
.assertCode().is(411)
.assertBody().is("foo bar");
- }
- @Test
- public void b11_locked() throws Exception {
b.get("/locked")
.run()
.assertCode().is(423)
.assertBody().is("foo bar");
- }
- @Test
- public void b12_loopDetected() throws Exception {
b.get("/loopDetected")
.run()
.assertCode().is(508)
.assertBody().is("foo bar");
- }
- @Test
- public void b13_methodNotAllowed() throws Exception {
b.get("/methodNotAllowed")
.run()
.assertCode().is(405)
.assertBody().is("foo bar");
- }
- @Test
- public void b14_misdirectedRequest() throws Exception {
b.get("/misdirectedRequest")
.run()
.assertCode().is(421)
.assertBody().is("foo bar");
- }
- @Test
- public void b15_networkAuthenticationRequired() throws Exception {
b.get("/networkAuthenticationRequired")
.run()
.assertCode().is(511)
.assertBody().is("foo bar");
- }
- @Test
- public void b16_notAcceptable() throws Exception {
b.get("/notAcceptable")
.run()
.assertCode().is(406)
.assertBody().is("foo bar");
- }
- @Test
- public void b17_notExtended() throws Exception {
b.get("/notExtended")
.run()
.assertCode().is(510)
.assertBody().is("foo bar");
- }
- @Test
- public void b18_notFound() throws Exception {
b.get("/notFound")
.run()
.assertCode().is(404)
.assertBody().is("foo bar");
- }
- @Test
- public void b19_notImplemented() throws Exception {
b.get("/notImplemented")
.run()
.assertCode().is(501)
.assertBody().is("foo bar");
- }
- @Test
- public void b20_payloadTooLarge() throws Exception {
b.get("/payloadTooLarge")
.run()
.assertCode().is(413)
.assertBody().is("foo bar");
- }
- @Test
- public void b21_preconditionFailed() throws Exception {
b.get("/preconditionFailed")
.run()
.assertCode().is(412)
.assertBody().is("foo bar");
- }
- @Test
- public void b22_preconditionRequired() throws Exception {
b.get("/preconditionRequired")
.run()
.assertCode().is(428)
.assertBody().is("foo bar");
- }
- @Test
- public void b23_rangeNotSatisfiable() throws Exception {
b.get("/rangeNotSatisfiable")
.run()
.assertCode().is(416)
.assertBody().is("foo bar");
- }
- @Test
- public void b24_requestHeaderFieldsTooLarge() throws Exception {
b.get("/requestHeaderFieldsTooLarge")
.run()
.assertCode().is(431)
.assertBody().is("foo bar");
- }
- @Test
- public void b25_serviceUnavailable() throws Exception {
b.get("/serviceUnavailable")
.run()
.assertCode().is(503)
.assertBody().is("foo bar");
- }
- @Test
- public void b26_tooManyRequests() throws Exception {
b.get("/tooManyRequests")
.run()
.assertCode().is(429)
.assertBody().is("foo bar");
- }
- @Test
- public void b27_unauthorized() throws Exception {
b.get("/unauthorized")
.run()
.assertCode().is(401)
.assertBody().is("foo bar");
- }
- @Test
- public void b28_unavailableForLegalReasons() throws Exception {
b.get("/unavailableForLegalReasons")
.run()
.assertCode().is(451)
.assertBody().is("foo bar");
- }
- @Test
- public void b29_unprocessableEntity() throws Exception {
b.get("/unprocessableEntity")
.run()
.assertCode().is(422)
.assertBody().is("foo bar");
- }
- @Test
- public void b30_unsupportedMediaType() throws Exception {
b.get("/unsupportedMediaType")
.run()
.assertCode().is(415)
.assertBody().is("foo bar");
- }
- @Test
- public void b31_upgradeRequired() throws Exception {
b.get("/upgradeRequired")
.run()
.assertCode().is(426)
.assertBody().is("foo bar");
- }
- @Test
- public void b32_uriTooLong() throws Exception {
b.get("/uriTooLong")
.run()
.assertCode().is(414)
.assertBody().is("foo bar");
- }
- @Test
- public void b33_variantAlsoNegotiates() throws Exception {
b.get("/variantAlsoNegotiates")
.run()
.assertCode().is(506)
@@ -621,234 +431,137 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates(t); }
}
- static MockRestClient c = MockRestClient.buildLax(C.class);
-
@Test
- public void c01_badRequest() throws Exception {
+ public void c01_nestedThrowable() throws Exception {
+ RestClient c = MockRestClient.buildLax(C.class);
c.get("/badRequest")
.run()
.assertCode().is(400)
.assertBody().is("foo");
- }
- @Test
- public void c02_conflict() throws Exception {
c.get("/conflict")
.run()
.assertCode().is(409)
.assertBody().is("foo");
- }
- @Test
- public void c03_expectationFailed() throws Exception {
c.get("/expectationFailed")
.run()
.assertCode().is(417)
.assertBody().is("foo");
- }
- @Test
- public void c04_failedDependency() throws Exception {
c.get("/failedDependency")
.run()
.assertCode().is(424)
.assertBody().is("foo");
- }
- @Test
- public void c05_forbidden() throws Exception {
c.get("/forbidden")
.run()
.assertCode().is(403)
.assertBody().is("foo");
- }
- @Test
- public void c06_gone() throws Exception {
c.get("/gone")
.run()
.assertCode().is(410)
.assertBody().is("foo");
- }
- @Test
- public void c07_httpVersionNotSupported() throws Exception {
c.get("/httpVersionNotSupported")
.run()
.assertCode().is(505)
.assertBody().is("foo");
- }
- @Test
- public void c08_insufficientStorage() throws Exception {
c.get("/insufficientStorage")
.run()
.assertCode().is(507)
.assertBody().is("foo");
- }
- @Test
- public void c09_internalServerError() throws Exception {
c.get("/internalServerError")
.run()
.assertCode().is(500)
.assertBody().is("foo");
- }
- @Test
- public void c10_lengthRequired() throws Exception {
c.get("/lengthRequired")
.run()
.assertCode().is(411)
.assertBody().is("foo");
- }
- @Test
- public void c11_locked() throws Exception {
c.get("/locked")
.run()
.assertCode().is(423)
.assertBody().is("foo");
- }
- @Test
- public void c12_loopDetected() throws Exception {
c.get("/loopDetected")
.run()
.assertCode().is(508)
.assertBody().is("foo");
- }
- @Test
- public void c13_methodNotAllowed() throws Exception {
c.get("/methodNotAllowed")
.run()
.assertCode().is(405)
.assertBody().is("foo");
- }
- @Test
- public void c14_misdirectedRequest() throws Exception {
c.get("/misdirectedRequest")
.run()
.assertCode().is(421)
.assertBody().is("foo");
- }
- @Test
- public void c15_networkAuthenticationRequired() throws Exception {
c.get("/networkAuthenticationRequired")
.run()
.assertCode().is(511)
.assertBody().is("foo");
- }
- @Test
- public void c16_notAcceptable() throws Exception {
c.get("/notAcceptable")
.run()
.assertCode().is(406)
.assertBody().is("foo");
- }
- @Test
- public void c17_notExtended() throws Exception {
c.get("/notExtended")
.run()
.assertCode().is(510)
.assertBody().is("foo");
- }
- @Test
- public void c18_notFound() throws Exception {
c.get("/notFound")
.run()
.assertCode().is(404)
.assertBody().is("foo");
- }
- @Test
- public void c19_notImplemented() throws Exception {
c.get("/notImplemented")
.run()
.assertCode().is(501)
.assertBody().is("foo");
- }
- @Test
- public void c20_payloadTooLarge() throws Exception {
c.get("/payloadTooLarge")
.run()
.assertCode().is(413)
.assertBody().is("foo");
- }
- @Test
- public void c21_preconditionFailed() throws Exception {
c.get("/preconditionFailed").
run()
.assertCode().is(412)
.assertBody().is("foo");
- }
- @Test
- public void c22_preconditionRequired() throws Exception {
c.get("/preconditionRequired")
.run()
.assertCode().is(428)
.assertBody().is("foo");
- }
- @Test
- public void c23_rangeNotSatisfiable() throws Exception {
c.get("/rangeNotSatisfiable")
.run()
.assertCode().is(416)
.assertBody().is("foo");
- }
- @Test
- public void c24_requestHeaderFieldsTooLarge() throws Exception {
c.get("/requestHeaderFieldsTooLarge")
.run()
.assertCode().is(431)
.assertBody().is("foo");
- }
- @Test
- public void c25_serviceUnavailable() throws Exception {
c.get("/serviceUnavailable")
.run()
.assertCode().is(503)
.assertBody().is("foo");
- }
- @Test
- public void c26_tooManyRequests() throws Exception {
c.get("/tooManyRequests")
.run()
.assertCode().is(429)
.assertBody().is("foo");
- }
- @Test
- public void c27_unauthorized() throws Exception {
c.get("/unauthorized")
.run()
.assertCode().is(401)
.assertBody().is("foo");
- }
- @Test
- public void c28_unavailableForLegalReasons() throws Exception {
c.get("/unavailableForLegalReasons")
.run()
.assertCode().is(451)
.assertBody().is("foo");
- }
- @Test
- public void c29_unprocessableEntity() throws Exception {
c.get("/unprocessableEntity")
.run()
.assertCode().is(422)
.assertBody().is("foo");
- }
- @Test
- public void c30_unsupportedMediaType() throws Exception {
c.get("/unsupportedMediaType")
.run()
.assertCode().is(415)
.assertBody().is("foo");
- }
- @Test
- public void c31_upgradeRequired() throws Exception {
c.get("/upgradeRequired")
.run()
.assertCode().is(426)
.assertBody().is("foo");
- }
- @Test
- public void c32_uriTooLong() throws Exception {
c.get("/uriTooLong")
.run()
.assertCode().is(414)
.assertBody().is("foo");
- }
- @Test
- public void c33_variantAlsoNegotiates() throws Exception {
c.get("/variantAlsoNegotiates")
.run()
.assertCode().is(506)
@@ -896,234 +609,137 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() { throw new VariantAlsoNegotiates(t, "foo {0}", "bar"); }
}
- static MockRestClient d = MockRestClient.buildLax(D.class);
-
@Test
- public void d01_badRequest() throws Exception {
+ public void d01_nestedThrowableWithMessage() throws Exception {
+ RestClient d = MockRestClient.buildLax(D.class);
d.get("/badRequest")
.run()
.assertCode().is(400)
.assertBody().is("foo bar");
- }
- @Test
- public void d02_conflict() throws Exception {
d.get("/conflict")
.run()
.assertCode().is(409)
.assertBody().is("foo bar");
- }
- @Test
- public void d03_expectationFailed() throws Exception {
d.get("/expectationFailed")
.run()
.assertCode().is(417)
.assertBody().is("foo bar");
- }
- @Test
- public void d04_failedDependency() throws Exception {
d.get("/failedDependency")
.run()
.assertCode().is(424)
.assertBody().is("foo bar");
- }
- @Test
- public void d05_forbidden() throws Exception {
d.get("/forbidden")
.run()
.assertCode().is(403)
.assertBody().is("foo bar");
- }
- @Test
- public void d06_gone() throws Exception {
d.get("/gone")
.run()
.assertCode().is(410)
.assertBody().is("foo bar");
- }
- @Test
- public void d07_httpVersionNotSupported() throws Exception {
d.get("/httpVersionNotSupported")
.run()
.assertCode().is(505)
.assertBody().is("foo bar");
- }
- @Test
- public void d08_insufficientStorage() throws Exception {
d.get("/insufficientStorage")
.run()
.assertCode().is(507)
.assertBody().is("foo bar");
- }
- @Test
- public void d09_internalServerError() throws Exception {
d.get("/internalServerError")
.run()
.assertCode().is(500)
.assertBody().is("foo bar");
- }
- @Test
- public void d10_lengthRequired() throws Exception {
d.get("/lengthRequired")
.run()
.assertCode().is(411)
.assertBody().is("foo bar");
- }
- @Test
- public void d11_locked() throws Exception {
d.get("/locked")
.run()
.assertCode().is(423)
.assertBody().is("foo bar");
- }
- @Test
- public void d12_loopDetected() throws Exception {
d.get("/loopDetected")
.run()
.assertCode().is(508)
.assertBody().is("foo bar");
- }
- @Test
- public void d13_methodNotAllowed() throws Exception {
d.get("/methodNotAllowed")
.run()
.assertCode().is(405)
.assertBody().is("foo bar");
- }
- @Test
- public void d14_misdirectedRequest() throws Exception {
d.get("/misdirectedRequest")
.run()
.assertCode().is(421)
.assertBody().is("foo bar");
- }
- @Test
- public void d15_networkAuthenticationRequired() throws Exception {
d.get("/networkAuthenticationRequired")
.run()
.assertCode().is(511)
.assertBody().is("foo bar");
- }
- @Test
- public void d16_notAcceptable() throws Exception {
d.get("/notAcceptable")
.run()
.assertCode().is(406)
.assertBody().is("foo bar");
- }
- @Test
- public void d17_notExtended() throws Exception {
d.get("/notExtended")
.run()
.assertCode().is(510)
.assertBody().is("foo bar");
- }
- @Test
- public void d18_notFound() throws Exception {
d.get("/notFound")
.run()
.assertCode().is(404)
.assertBody().is("foo bar");
- }
- @Test
- public void d19_notImplemented() throws Exception {
d.get("/notImplemented")
.run()
.assertCode().is(501)
.assertBody().is("foo bar");
- }
- @Test
- public void d20_payloadTooLarge() throws Exception {
d.get("/payloadTooLarge")
.run()
.assertCode().is(413)
.assertBody().is("foo bar");
- }
- @Test
- public void d21_preconditionFailed() throws Exception {
d.get("/preconditionFailed")
.run()
.assertCode().is(412)
.assertBody().is("foo bar");
- }
- @Test
- public void d22_preconditionRequired() throws Exception {
d.get("/preconditionRequired")
.run()
.assertCode().is(428)
.assertBody().is("foo bar");
- }
- @Test
- public void d23_rangeNotSatisfiable() throws Exception {
d.get("/rangeNotSatisfiable")
.run()
.assertCode().is(416)
.assertBody().is("foo bar");
- }
- @Test
- public void d24_requestHeaderFieldsTooLarge() throws Exception {
d.get("/requestHeaderFieldsTooLarge")
.run()
.assertCode().is(431)
.assertBody().is("foo bar");
- }
- @Test
- public void d25_serviceUnavailable() throws Exception {
d.get("/serviceUnavailable")
.run()
.assertCode().is(503)
.assertBody().is("foo bar");
- }
- @Test
- public void d26_tooManyRequests() throws Exception {
d.get("/tooManyRequests")
.run()
.assertCode().is(429)
.assertBody().is("foo bar");
- }
- @Test
- public void d27_unauthorized() throws Exception {
d.get("/unauthorized")
.run()
.assertCode().is(401)
.assertBody().is("foo bar");
- }
- @Test
- public void d28_unavailableForLegalReasons() throws Exception {
d.get("/unavailableForLegalReasons")
.run()
.assertCode().is(451)
.assertBody().is("foo bar");
- }
- @Test
- public void d29_unprocessableEntity() throws Exception {
d.get("/unprocessableEntity")
.run()
.assertCode().is(422)
.assertBody().is("foo bar");
- }
- @Test
- public void d30_unsupportedMediaType() throws Exception {
d.get("/unsupportedMediaType")
.run()
.assertCode().is(415)
.assertBody().is("foo bar");
- }
- @Test
- public void d31_upgradeRequired() throws Exception {
d.get("/upgradeRequired")
.run()
.assertCode().is(426)
.assertBody().is("foo bar");
- }
- @Test
- public void d32_uriTooLong() throws Exception {
d.get("/uriTooLong")
.run()
.assertCode().is(414)
.assertBody().is("foo bar");
- }
- @Test
- public void d33_variantAlsoNegotiates() throws Exception {
d.get("/variantAlsoNegotiates")
.run()
.assertCode().is(506)
@@ -1139,10 +755,9 @@ public class BasicTest {
@RestMethod public void badRequest() { throw new BadRequest(t, "foo {0}", "bar"); }
}
- static MockRestClient e = MockRestClient.buildLax(E.class);
-
@Test
- public void e01_badRequest() throws Exception {
+ public void e01_useAcceptForSerialization() throws Exception {
+ RestClient e = MockRestClient.buildLax(E.class);
e.get("/badRequest")
.json()
.run()
@@ -1191,172 +806,43 @@ public class BasicTest {
@RestMethod public void variantAlsoNegotiates() throws VariantAlsoNegotiates {}
}
- static Swagger f = getSwagger(F.class);
-
- @Test
- public void f01_badRequest() throws Exception {
- ResponseInfo ri = f.getPaths().get("/badRequest").get("get").getResponse(BadRequest.CODE);
- assertEquals(BadRequest.MESSAGE, ri.getDescription());
- }
- @Test
- public void f02_conflict() throws Exception {
- ResponseInfo ri = f.getPaths().get("/conflict").get("get").getResponse(Conflict.CODE);
- assertEquals(Conflict.MESSAGE, ri.getDescription());
- }
- @Test
- public void f03_expectationFailed() throws Exception {
- ResponseInfo ri = f.getPaths().get("/expectationFailed").get("get").getResponse(ExpectationFailed.CODE);
- assertEquals(ExpectationFailed.MESSAGE, ri.getDescription());
- }
- @Test
- public void f04_failedDependency() throws Exception {
- ResponseInfo ri = f.getPaths().get("/failedDependency").get("get").getResponse(FailedDependency.CODE);
- assertEquals(FailedDependency.MESSAGE, ri.getDescription());
- }
- @Test
- public void f05_forbidden() throws Exception {
- ResponseInfo ri = f.getPaths().get("/forbidden").get("get").getResponse(Forbidden.CODE);
- assertEquals(Forbidden.MESSAGE, ri.getDescription());
- }
- @Test
- public void f06_gone() throws Exception {
- ResponseInfo ri = f.getPaths().get("/gone").get("get").getResponse(Gone.CODE);
- assertEquals(Gone.MESSAGE, ri.getDescription());
- }
- @Test
- public void f07_httpVersionNotSupported() throws Exception {
- ResponseInfo ri = f.getPaths().get("/httpVersionNotSupported").get("get").getResponse(HttpVersionNotSupported.CODE);
- assertEquals(HttpVersionNotSupported.MESSAGE, ri.getDescription());
- }
- @Test
- public void f08_insufficientStorage() throws Exception {
- ResponseInfo ri = f.getPaths().get("/insufficientStorage").get("get").getResponse(InsufficientStorage.CODE);
- assertEquals(InsufficientStorage.MESSAGE, ri.getDescription());
- }
- @Test
- public void f09_internalServerError() throws Exception {
- ResponseInfo ri = f.getPaths().get("/internalServerError").get("get").getResponse(InternalServerError.CODE);
- assertEquals(InternalServerError.MESSAGE, ri.getDescription());
- }
- @Test
- public void f10_lengthRequired() throws Exception {
- ResponseInfo ri = f.getPaths().get("/lengthRequired").get("get").getResponse(LengthRequired.CODE);
- assertEquals(LengthRequired.MESSAGE, ri.getDescription());
- }
- @Test
- public void f11_locked() throws Exception {
- ResponseInfo ri = f.getPaths().get("/locked").get("get").getResponse(Locked.CODE);
- assertEquals(Locked.MESSAGE, ri.getDescription());
- }
- @Test
- public void f12_loopDetected() throws Exception {
- ResponseInfo ri = f.getPaths().get("/loopDetected").get("get").getResponse(LoopDetected.CODE);
- assertEquals(LoopDetected.MESSAGE, ri.getDescription());
- }
@Test
- public void f13_methodNotAllowed() throws Exception {
- ResponseInfo ri = f.getPaths().get("/methodNotAllowed").get("get").getResponse(MethodNotAllowed.CODE);
- assertEquals(MethodNotAllowed.MESSAGE, ri.getDescription());
- }
- @Test
- public void f14_misdirectedRequest() throws Exception {
- ResponseInfo ri = f.getPaths().get("/misdirectedRequest").get("get").getResponse(MisdirectedRequest.CODE);
- assertEquals(MisdirectedRequest.MESSAGE, ri.getDescription());
- }
- @Test
- public void f15_networkAuthenticationRequired() throws Exception {
- ResponseInfo ri = f.getPaths().get("/networkAuthenticationRequired").get("get").getResponse(NetworkAuthenticationRequired.CODE);
- assertEquals(NetworkAuthenticationRequired.MESSAGE, ri.getDescription());
- }
- @Test
- public void f16_notAcceptable() throws Exception {
- ResponseInfo ri = f.getPaths().get("/notAcceptable").get("get").getResponse(NotAcceptable.CODE);
- assertEquals(NotAcceptable.MESSAGE, ri.getDescription());
- }
- @Test
- public void f17_notExtended() throws Exception {
- ResponseInfo ri = f.getPaths().get("/notExtended").get("get").getResponse(NotExtended.CODE);
- assertEquals(NotExtended.MESSAGE, ri.getDescription());
- }
- @Test
- public void f18_notFound() throws Exception {
- ResponseInfo ri = f.getPaths().get("/notFound").get("get").getResponse(NotFound.CODE);
- assertEquals(NotFound.MESSAGE, ri.getDescription());
- }
- @Test
- public void f19_notImplemented() throws Exception {
- ResponseInfo ri = f.getPaths().get("/notImplemented").get("get").getResponse(NotImplemented.CODE);
- assertEquals(NotImplemented.MESSAGE, ri.getDescription());
- }
- @Test
- public void f20_payloadTooLarge() throws Exception {
- ResponseInfo ri = f.getPaths().get("/payloadTooLarge").get("get").getResponse(PayloadTooLarge.CODE);
- assertEquals(PayloadTooLarge.MESSAGE, ri.getDescription());
- }
- @Test
- public void f21_preconditionFailed() throws Exception {
- ResponseInfo ri = f.getPaths().get("/preconditionFailed").get("get").getResponse(PreconditionFailed.CODE);
- assertEquals(PreconditionFailed.MESSAGE, ri.getDescription());
- }
- @Test
- public void f22_preconditionRequired() throws Exception {
- ResponseInfo ri = f.getPaths().get("/preconditionRequired").get("get").getResponse(PreconditionRequired.CODE);
- assertEquals(PreconditionRequired.MESSAGE, ri.getDescription());
- }
- @Test
- public void f23_rangeNotSatisfiable() throws Exception {
- ResponseInfo ri = f.getPaths().get("/rangeNotSatisfiable").get("get").getResponse(RangeNotSatisfiable.CODE);
- assertEquals(RangeNotSatisfiable.MESSAGE, ri.getDescription());
- }
- @Test
- public void f24_requestHeaderFieldsTooLarge() throws Exception {
- ResponseInfo ri = f.getPaths().get("/requestHeaderFieldsTooLarge").get("get").getResponse(RequestHeaderFieldsTooLarge.CODE);
- assertEquals(RequestHeaderFieldsTooLarge.MESSAGE, ri.getDescription());
- }
- @Test
- public void f25_serviceUnavailable() throws Exception {
- ResponseInfo ri = f.getPaths().get("/serviceUnavailable").get("get").getResponse(ServiceUnavailable.CODE);
- assertEquals(ServiceUnavailable.MESSAGE, ri.getDescription());
- }
- @Test
- public void f26_tooManyRequests() throws Exception {
- ResponseInfo ri = f.getPaths().get("/tooManyRequests").get("get").getResponse(TooManyRequests.CODE);
- assertEquals(TooManyRequests.MESSAGE, ri.getDescription());
- }
- @Test
- public void f27_unauthorized() throws Exception {
- ResponseInfo ri = f.getPaths().get("/unauthorized").get("get").getResponse(Unauthorized.CODE);
- assertEquals(Unauthorized.MESSAGE, ri.getDescription());
- }
- @Test
- public void f28_unavailableForLegalReasons() throws Exception {
- ResponseInfo ri = f.getPaths().get("/unavailableForLegalReasons").get("get").getResponse(UnavailableForLegalReasons.CODE);
- assertEquals(UnavailableForLegalReasons.MESSAGE, ri.getDescription());
- }
- @Test
- public void f29_unprocessableEntity() throws Exception {
- ResponseInfo ri = f.getPaths().get("/unprocessableEntity").get("get").getResponse(UnprocessableEntity.CODE);
- assertEquals(UnprocessableEntity.MESSAGE, ri.getDescription());
- }
- @Test
- public void f30_unsupportedMediaType() throws Exception {
- ResponseInfo ri = f.getPaths().get("/unsupportedMediaType").get("get").getResponse(UnsupportedMediaType.CODE);
- assertEquals(UnsupportedMediaType.MESSAGE, ri.getDescription());
- }
- @Test
- public void f31_upgradeRequired() throws Exception {
- ResponseInfo ri = f.getPaths().get("/upgradeRequired").get("get").getResponse(UpgradeRequired.CODE);
- assertEquals(UpgradeRequired.MESSAGE, ri.getDescription());
- }
- @Test
- public void f32_uriTooLong() throws Exception {
- ResponseInfo ri = f.getPaths().get("/uriTooLong").get("get").getResponse(UriTooLong.CODE);
- assertEquals(UriTooLong.MESSAGE, ri.getDescription());
- }
- @Test
- public void f33_variantAlsoNegotiates() throws Exception {
- ResponseInfo ri = f.getPaths().get("/variantAlsoNegotiates").get("get").getResponse(VariantAlsoNegotiates.CODE);
- assertEquals(VariantAlsoNegotiates.MESSAGE, ri.getDescription());
+ public void f01_swagger() throws Exception {
+ Map<String,OperationMap> paths = getSwagger(F.class).getPaths();
+
+ assertEquals(BadRequest.MESSAGE, paths.get("/badRequest").get("get").getResponse(BadRequest.CODE).getDescription());
+ assertEquals(Conflict.MESSAGE, paths.get("/conflict").get("get").getResponse(Conflict.CODE).getDescription());
+ assertEquals(ExpectationFailed.MESSAGE, paths.get("/expectationFailed").get("get").getResponse(ExpectationFailed.CODE).getDescription());
+ assertEquals(FailedDependency.MESSAGE, paths.get("/failedDependency").get("get").getResponse(FailedDependency.CODE).getDescription());
+ assertEquals(Forbidden.MESSAGE, paths.get("/forbidden").get("get").getResponse(Forbidden.CODE).getDescription());
+ assertEquals(Gone.MESSAGE, paths.get("/gone").get("get").getResponse(Gone.CODE).getDescription());
+ assertEquals(HttpVersionNotSupported.MESSAGE, paths.get("/httpVersionNotSupported").get("get").getResponse(HttpVersionNotSupported.CODE).getDescription());
+ assertEquals(InsufficientStorage.MESSAGE, paths.get("/insufficientStorage").get("get").getResponse(InsufficientStorage.CODE).getDescription());
+ assertEquals(InternalServerError.MESSAGE, paths.get("/internalServerError").get("get").getResponse(InternalServerError.CODE).getDescription());
+ assertEquals(LengthRequired.MESSAGE, paths.get("/lengthRequired").get("get").getResponse(LengthRequired.CODE).getDescription());
+ assertEquals(Locked.MESSAGE, paths.get("/locked").get("get").getResponse(Locked.CODE).getDescription());
+ assertEquals(LoopDetected.MESSAGE, paths.get("/loopDetected").get("get").getResponse(LoopDetected.CODE).getDescription());
+ assertEquals(MethodNotAllowed.MESSAGE, paths.get("/methodNotAllowed").get("get").getResponse(MethodNotAllowed.CODE).getDescription());
+ assertEquals(MisdirectedRequest.MESSAGE, paths.get("/misdirectedRequest").get("get").getResponse(MisdirectedRequest.CODE).getDescription());
+ assertEquals(NetworkAuthenticationRequired.MESSAGE, paths.get("/networkAuthenticationRequired").get("get").getResponse(NetworkAuthenticationRequired.CODE).getDescription());
+ assertEquals(NotAcceptable.MESSAGE, paths.get("/notAcceptable").get("get").getResponse(NotAcceptable.CODE).getDescription());
+ assertEquals(NotExtended.MESSAGE, paths.get("/notExtended").get("get").getResponse(NotExtended.CODE).getDescription());
+ assertEquals(NotFound.MESSAGE, paths.get("/notFound").get("get").getResponse(NotFound.CODE).getDescription());
+ assertEquals(NotImplemented.MESSAGE, paths.get("/notImplemented").get("get").getResponse(NotImplemented.CODE).getDescription());
+ assertEquals(PayloadTooLarge.MESSAGE, paths.get("/payloadTooLarge").get("get").getResponse(PayloadTooLarge.CODE).getDescription());
+ assertEquals(PreconditionFailed.MESSAGE, paths.get("/preconditionFailed").get("get").getResponse(PreconditionFailed.CODE).getDescription());
+ assertEquals(PreconditionRequired.MESSAGE, paths.get("/preconditionRequired").get("get").getResponse(PreconditionRequired.CODE).getDescription());
+ assertEquals(RangeNotSatisfiable.MESSAGE, paths.get("/rangeNotSatisfiable").get("get").getResponse(RangeNotSatisfiable.CODE).getDescription());
+ assertEquals(RequestHeaderFieldsTooLarge.MESSAGE, paths.get("/requestHeaderFieldsTooLarge").get("get").getResponse(RequestHeaderFieldsTooLarge.CODE).getDescription());
+ assertEquals(ServiceUnavailable.MESSAGE, paths.get("/serviceUnavailable").get("get").getResponse(ServiceUnavailable.CODE).getDescription());
+ assertEquals(TooManyRequests.MESSAGE, paths.get("/tooManyRequests").get("get").getResponse(TooManyRequests.CODE).getDescription());
+ assertEquals(Unauthorized.MESSAGE, paths.get("/unauthorized").get("get").getResponse(Unauthorized.CODE).getDescription());
+ assertEquals(UnavailableForLegalReasons.MESSAGE, paths.get("/unavailableForLegalReasons").get("get").getResponse(UnavailableForLegalReasons.CODE).getDescription());
+ assertEquals(UnprocessableEntity.MESSAGE, paths.get("/unprocessableEntity").get("get").getResponse(UnprocessableEntity.CODE).getDescription());
+ assertEquals(UnsupportedMediaType.MESSAGE, paths.get("/unsupportedMediaType").get("get").getResponse(UnsupportedMediaType.CODE).getDescription());
+ assertEquals(UpgradeRequired.MESSAGE, paths.get("/upgradeRequired").get("get").getResponse(UpgradeRequired.CODE).getDescription());
+ assertEquals(UriTooLong.MESSAGE, paths.get("/uriTooLong").get("get").getResponse(UriTooLong.CODE).getDescription());
+ assertEquals(VariantAlsoNegotiates.MESSAGE, paths.get("/variantAlsoNegotiates").get("get").getResponse(VariantAlsoNegotiates.CODE).getDescription());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -1366,14 +852,13 @@ public class BasicTest {
@Rest
public static class G {
@RestMethod
- public SeeOtherRoot thrownObjectDoesntMatchReturnType() throws Exception { throw new NotFound(); }
+ public SeeOtherRoot a() throws Exception { throw new NotFound(); }
}
- static MockRestClient g = MockRestClient.buildLax(G.class);
-
@Test
public void g01_thrownObjectDoesntMatchReturnType() throws Exception {
- g.get("/thrownObjectDoesntMatchReturnType")
+ RestClient g = MockRestClient.buildLax(G.class);
+ g.get("/a")
.run()
.assertCode().is(404);
}
@@ -1385,16 +870,15 @@ public class BasicTest {
@Rest
public static class H {
@RestMethod
- public void getFoo() throws Exception {
+ public void a() throws Exception {
throw new ParseException("Test");
}
}
- static MockRestClient h = MockRestClient.buildLax(H.class);
-
@Test
public void h01_parseExceptionCausesBadRequest() throws Exception {
- h.get("/foo")
+ RestClient h = MockRestClient.buildLax(H.class);
+ h.get("/a")
.run()
.assertCode().is(400);
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestParamsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestParamsTest.java
deleted file mode 100644
index 95dea0e..0000000
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/RestParamsTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.rest;
-
-import static org.apache.juneau.http.HttpMethod.*;
-import static org.apache.juneau.internal.IOUtils.*;
-import static org.junit.runners.MethodSorters.*;
-
-import java.io.*;
-import java.util.*;
-
-import javax.servlet.*;
-
-import org.apache.juneau.config.*;
-import org.apache.juneau.cp.Messages;
-import org.apache.juneau.dto.swagger.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.mock2.*;
-import org.junit.*;
-
-@FixMethodOrder(NAME_ASCENDING)
-public class RestParamsTest {
-
- //=================================================================================================================
- // Various parameters
- //=================================================================================================================
-
- @Rest(messages="RestParamsTest")
- public static class A {
- @RestMethod
- public String a01(ResourceBundle t) {
- return t == null ? null : t.getString("foo");
- }
- @RestMethod
- public String a02(Messages t) {
- return t == null ? null : t.getString("foo");
- }
- @RestMethod(name=POST)
- public String a03(InputStream t) throws IOException {
- return read(t);
- }
- @RestMethod(name=POST)
- public String a04(ServletInputStream t) throws IOException {
- return read(t);
- }
- @RestMethod(name=POST)
- public String a05(Reader t) throws IOException {
- return read(t);
- }
- @RestMethod
- public void a06(OutputStream t) throws IOException {
- t.write("OK".getBytes());
- }
- @RestMethod
- public void a07(ServletOutputStream t) throws IOException {
- t.write("OK".getBytes());
- }
- @RestMethod
- public void a08(Writer t) throws IOException {
- t.write("OK");
- }
- @RestMethod
- public boolean a09(RequestHeaders t) {
- return t != null;
- }
- @RestMethod
- public boolean a10(RequestQuery t) {
- return t != null;
- }
- @RestMethod
- public boolean a11(RequestFormData t) {
- return t != null;
- }
- @RestMethod
- public String a12(@Method String t) {
- return t;
- }
- @SuppressWarnings("deprecation")
- @RestMethod
- public boolean a13(RestLogger t) {
- return t != null;
- }
- @RestMethod
- public boolean a14(RestContext t) {
- return t != null;
- }
- @RestMethod(parsers={JsonParser.class})
- public String a15(Parser t) {
- return t.getClass().getName();
- }
- @RestMethod
- public String a16(Locale t) {
- return t.toString();
- }
- @RestMethod
- public boolean a17(Swagger t) {
- return t != null;
- }
- @RestMethod
- public boolean a18(RequestPath t) {
- return t != null;
- }
- @RestMethod
- public boolean a19(RequestBody t) {
- return t != null;
- }
- @RestMethod
- public boolean a20(Config t) {
- return t != null;
- }
- }
- static MockRestClient a = MockRestClient.build(A.class);
-
- @Test
- public void a01_ResourceBundle() throws Exception {
- a.get("/a01").acceptLanguage("en-US").run().assertBody().is("bar");
- a.get("/a01").acceptLanguage("ja-JP").run().assertBody().is("baz");
- }
- @Test
- public void a02_MessageBundle() throws Exception {
- a.get("/a02").acceptLanguage("en-US").run().assertBody().is("bar");
- a.get("/a02").acceptLanguage("ja-JP").run().assertBody().is("baz");
- }
- @Test
- public void a03_InputStream() throws Exception {
- a.post("/a03", "foo").run().assertBody().is("foo");
- }
- @Test
- public void a04_ServletInputStream() throws Exception {
- a.post("/a04", "foo").run().assertBody().is("foo");
- }
- @Test
- public void a05_Reader() throws Exception {
- a.post("/a05", "foo").run().assertBody().is("foo");
- }
- @Test
- public void a06_OutputStream() throws Exception {
- a.get("/a06").run().assertBody().is("OK");
- }
- @Test
- public void a07_ServletOutputStream() throws Exception {
- a.get("/a07").run().assertBody().is("OK");
- }
- @Test
- public void a08_Writer() throws Exception {
- a.get("/a08").run().assertBody().is("OK");
- }
- @Test
- public void a09_RequestHeaders() throws Exception {
- a.get("/a09").run().assertBody().is("true");
- }
- @Test
- public void a10_RequestQuery() throws Exception {
- a.get("/a10").run().assertBody().is("true");
- }
- @Test
- public void a11_RequestFormData() throws Exception {
- a.get("/a11").run().assertBody().is("true");
- }
- @Test
- public void a12_HttpMethod() throws Exception {
- a.get("/a12").run().assertBody().is("GET");
- }
- @Test
- public void a13_RestLogger() throws Exception {
- a.get("/a13").run().assertBody().is("true");
- }
- @Test
- public void a14_RestContext() throws Exception {
- a.get("/a14").run().assertBody().is("true");
- }
- @Test
- public void a15_Parser() throws Exception {
- a.get("/a15").contentType("application/json").run().assertBody().is("org.apache.juneau.json.JsonParser");
- }
- @Test
- public void a16_Locale() throws Exception {
- a.get("/a16").acceptLanguage("en-US").run().assertBody().is("en_US");
- a.get("/a16").acceptLanguage("ja-JP").run().assertBody().is("ja_JP");
- }
- @Test
- public void a17_Swagger() throws Exception {
- a.get("/a17").run().assertBody().is("true");
- }
- @Test
- public void a18_RequestPathMatch() throws Exception {
- a.get("/a18").run().assertBody().is("true");
- }
- @Test
- public void a19_RequestBody() throws Exception {
- a.get("/a19").run().assertBody().is("true");
- }
- @Test
- public void a20_Config() throws Exception {
- a.get("/a20").run().assertBody().is("true");
- }
-}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Rest_PredefinedStatusCodes_Test.java
similarity index 55%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Rest_PredefinedStatusCodes_Test.java
index c8caa5e..f60fb87 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Rest_PredefinedStatusCodes_Test.java
@@ -23,175 +23,149 @@ import org.apache.juneau.http.annotation.Path;
import org.apache.juneau.http.annotation.Query;
import org.apache.juneau.json.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class StatusCodesTest {
+public class Rest_PredefinedStatusCodes_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// OK (200)
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
public static class A {
@RestMethod(name=PUT)
- public Reader a01(@Body String b) {
+ public Reader a(@Body String b) {
return new StringReader(b);
}
}
- private static MockRestClient a = MockRestClient.build(A.class);
@Test
- public void a01a_OK() throws Exception {
- a.put("/a01", "foo")
+ public void a01_OK() throws Exception {
+ RestClient a = MockRestClient.build(A.class);
+ a.put("/a", "foo")
.run()
.assertCode().is(200);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Bad Request (400)
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(parsers=JsonParser.class)
public static class B {
- @RestMethod(name=PUT, path="/nonExistentBeanProperties")
- public String b01(@Body B01 in) {
+ @RestMethod(name=PUT)
+ public String a(@Body B1 in) {
return "OK";
}
- public static class B01 {
+ public static class B1 {
public String f1;
}
- @RestMethod(name=PUT, path="/wrongDataType")
- public String b02(@Body B02 in) {
+ @RestMethod(name=PUT)
+ public String b(@Body B2 in) {
return "OK";
}
- public static class B02 {
+ public static class B2 {
public int f1;
}
- @RestMethod(name=PUT, path="/parseIntoNonConstructableBean")
- public String b03(@Body B03 in) {
+ @RestMethod(name=PUT)
+ public String c(@Body B3 in) {
return "OK";
}
- public static class B03 {
+ public static class B3 {
public int f1;
- private B03(){}
+ private B3(){}
}
- @RestMethod(name=PUT, path="/parseIntoNonStaticInnerClass")
- public String b04(@Body B04 in) {
+ @RestMethod(name=PUT)
+ public String d(@Body B4 in) {
return "OK";
}
- public class B04 {
- public B04(){}
+ public class B4 {
+ public B4(){}
}
- @RestMethod(name=PUT, path="/parseIntoNonPublicInnerClass")
- public String b05(@Body B05 in) {
+ @RestMethod(name=PUT)
+ public String e(@Body B5 in) {
return "OK";
}
- static class B05 {
- public B05(){}
+ static class B5 {
+ public B5(){}
}
- @RestMethod(name=PUT, path="/thrownConstructorException")
- public String b06(@Body B06 in) {
+ @RestMethod(name=PUT)
+ public String f(@Body B6 in) {
return "OK";
}
- public static class B06 {
+ public static class B6 {
public int f1;
- private B06(){}
- public static B06 valueOf(String s) {
+ private B6(){}
+ public static B6 valueOf(String s) {
throw new RuntimeException("Test error");
}
}
- @RestMethod(name=PUT, path="/setParameterToInvalidTypes/{a1}")
- public String b07(@Query("p1") int t1, @Path("a1") int a1, @Header("h1") int h1) {
+ @RestMethod(name=PUT, path="/g/{a1}")
+ public String g(@Query("p1") int t1, @Path("a1") int a1, @Header("h1") int h1) {
return "OK";
}
}
- private static MockRestClient b = MockRestClient.buildLax(B.class);
@Test
- public void b01a_nonExistentBeanProperties() throws Exception {
- b.put("/nonExistentBeanProperties?noTrace=true", "{f2:'foo'}", "application/json")
+ public void b01_badRequest() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
+ b.put("/a?noTrace=true", "{f2:'foo'}", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
- "Unknown property 'f2' encountered while trying to parse into class 'org.apache.juneau.rest.StatusCodesTest$B$B01'"
+ "Unknown property 'f2' encountered while trying to parse into class"
);
- }
- @Test
- public void b01b_nonExistentBeanProperties() throws Exception {
- b.put("/nonExistentBeanProperties?noTrace=true", "{f1:'foo', f2:'foo'}", "application/json")
+ b.put("/a?noTrace=true", "{f1:'foo', f2:'foo'}", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
- "Unknown property 'f2' encountered while trying to parse into class 'org.apache.juneau.rest.StatusCodesTest$B$B01'"
+ "Unknown property 'f2' encountered while trying to parse into class"
);
- }
- @Test
- public void b02_wrongDataType() throws Exception {
- b.put("/wrongDataType?noTrace=true", "{f1:'foo'}", "application/json")
+ b.put("/b?noTrace=true", "{f1:'foo'}", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"Invalid number"
);
- }
- @Test
- public void b03_parseIntoNonConstructableBean() throws Exception {
- b.put("/parseIntoNonConstructableBean?noTrace=true", "{f1:1}", "application/json")
+ b.put("/c?noTrace=true", "{f1:1}", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"could not be instantiated"
);
- }
- @Test
- public void b04_parseIntoNonStaticInnerClass() throws Exception {
- b.put("/parseIntoNonStaticInnerClass?noTrace=true", "{f1:1}", "application/json")
+ b.put("/d?noTrace=true", "{f1:1}", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"could not be instantiated"
);
- }
- @Test
- public void b05_parseIntoNonStaticInnerClass() throws Exception {
- b.put("/parseIntoNonPublicInnerClass?noTrace=true", "{f1:1}", "application/json")
+ b.put("/e?noTrace=true", "{f1:1}", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"Class is not public"
);
- }
- @Test
- public void b06_thrownConstructorException() throws Exception {
- b.put("/thrownConstructorException?noTrace=true", "'foo'", "application/json")
+ b.put("/f?noTrace=true", "'foo'", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"Test error"
);
- }
- @Test
- public void b07a_setParameterToInvalidTypes_Query() throws Exception {
- b.put("/setParameterToInvalidTypes/123?noTrace=true&p1=foo", "'foo'", "application/json")
+ b.put("/g/123?noTrace=true&p1=foo", "'foo'", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"Could not parse query parameter 'p1'."
);
- }
- @Test
- public void b07a_setParameterToInvalidTypes_Path() throws Exception {
- b.put("/setParameterToInvalidTypes/foo?noTrace=true&p1=1", "'foo'", "application/json")
+ b.put("/g/foo?noTrace=true&p1=1", "'foo'", "application/json")
.run()
.assertCode().is(400)
.assertBody().contains(
"Could not parse path parameter 'a1'."
);
- }
- @Test
- public void b07a_setParameterToInvalidTypes_Header() throws Exception {
- b.put("/setParameterToInvalidTypes/123?noTrace=true&p1=1", "'foo'", "application/json")
+ b.put("/g/123?noTrace=true&p1=1", "'foo'", "application/json")
.header("h1", "foo")
.run()
.assertCode().is(400)
@@ -200,14 +174,14 @@ public class StatusCodesTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Not Found (404) and Method Not Allowed (405)
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
public static class C {
@RestMethod(name=GET, path="/")
- public String c01() {
+ public String a() {
return "OK";
}
}
@@ -231,9 +205,9 @@ public class StatusCodesTest {
);
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Precondition Failed (412)
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
public static class D {
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StaticFilesMappingTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StaticFilesMapping_Test.java
similarity index 99%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StaticFilesMappingTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StaticFilesMapping_Test.java
index 01727e1..2d220e8 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StaticFilesMappingTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/StaticFilesMapping_Test.java
@@ -21,7 +21,7 @@ import org.apache.juneau.parser.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class StaticFilesMappingTest {
+public class StaticFilesMapping_Test {
private static Collection<StaticFileMapping> parse(String input) throws ParseException {
return StaticFileMapping.parse(null, input);
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
similarity index 53%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
index 8f441dc..0abbce1 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/BasicRestInfoProviderTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/Swagger_Test.java
@@ -40,11 +40,11 @@ import org.apache.juneau.rest.mock2.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class BasicRestInfoProviderTest {
+public class Swagger_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Setup
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
private Swagger getSwaggerWithFile(Object resource) throws Exception {
RestContext rc = RestContext.create(resource).classpathResourceFinder(TestClasspathResourceFinder.class).build();
@@ -69,16 +69,16 @@ public class BasicRestInfoProviderTest {
}
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /<root>
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class A01 {}
+ public static class A1 {}
@Test
public void a01_swagger_default() throws Exception {
- Swagger x = getSwagger(new A01());
+ Swagger x = getSwagger(new A1());
assertEquals("2.0", x.getSwagger());
assertEquals(null, x.getHost());
assertEquals(null, x.getBasePath());
@@ -86,7 +86,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void a01_swagger_default_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new A01());
+ Swagger x = getSwaggerWithFile(new A1());
assertEquals("0.0", x.getSwagger());
assertEquals("s-host", x.getHost());
assertEquals("s-basePath", x.getBasePath());
@@ -95,11 +95,11 @@ public class BasicRestInfoProviderTest {
@Rest(swagger=@ResourceSwagger("{swagger:'3.0',host:'a-host',basePath:'a-basePath',schemes:['a-scheme']}"))
- public static class A02 {}
+ public static class A2 {}
@Test
public void a02_swagger_ResourceSwagger_value() throws Exception {
- Swagger x = getSwagger(new A02());
+ Swagger x = getSwagger(new A2());
assertEquals("3.0", x.getSwagger());
assertEquals("a-host", x.getHost());
assertEquals("a-basePath", x.getBasePath());
@@ -107,26 +107,26 @@ public class BasicRestInfoProviderTest {
}
@Test
public void a02_swagger_ResourceSwagger_value_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new A02());
+ Swagger x = getSwaggerWithFile(new A2());
assertEquals("3.0", x.getSwagger());
assertEquals("a-host", x.getHost());
assertEquals("a-basePath", x.getBasePath());
assertObject(x.getSchemes()).json().is("['a-scheme']");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /info
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest(
title="a-title",
description="a-description"
)
- public static class B01 {}
+ public static class B1 {}
@Test
public void b01a_info_Rest() throws Exception {
- Info x = getSwagger(new B01()).getInfo();
+ Info x = getSwagger(new B1()).getInfo();
assertEquals("a-title", x.getTitle());
assertEquals("a-description", x.getDescription());
assertEquals(null, x.getVersion());
@@ -136,7 +136,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void b01b_info_Rest_withFile() throws Exception {
- Info x = getSwaggerWithFile(new B01()).getInfo();
+ Info x = getSwaggerWithFile(new B1()).getInfo();
assertEquals("s-title", x.getTitle());
assertEquals("s-description", x.getDescription());
assertEquals("0.0.0", x.getVersion());
@@ -150,17 +150,17 @@ public class BasicRestInfoProviderTest {
title="$L{foo}",
description="$L{foo}"
)
- public static class B02 {}
+ public static class B2 {}
@Test
public void b02a_info_Rest_localized() throws Exception {
- Info x = getSwagger(new B02()).getInfo();
+ Info x = getSwagger(new B2()).getInfo();
assertEquals("l-foo", x.getTitle());
assertEquals("l-foo", x.getDescription());
}
@Test
public void b02b_info_Rest_localized_withFile() throws Exception {
- Info x = getSwaggerWithFile(new B02()).getInfo();
+ Info x = getSwaggerWithFile(new B2()).getInfo();
assertEquals("s-title", x.getTitle());
assertEquals("s-description", x.getDescription());
}
@@ -181,11 +181,11 @@ public class BasicRestInfoProviderTest {
}
)
)
- public static class B03 {}
+ public static class B3 {}
@Test
public void b03a_info_ResourceSwagger_value() throws Exception {
- Info x = getSwagger(new B03()).getInfo();
+ Info x = getSwagger(new B3()).getInfo();
assertEquals("b-title", x.getTitle());
assertEquals("b-description", x.getDescription());
assertEquals("2.0.0", x.getVersion());
@@ -195,7 +195,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void b03b_info_ResourceSwagger_value_withFile() throws Exception {
- Info x = getSwaggerWithFile(new B03()).getInfo();
+ Info x = getSwaggerWithFile(new B3()).getInfo();
assertEquals("b-title", x.getTitle());
assertEquals("b-description", x.getDescription());
assertEquals("2.0.0", x.getVersion());
@@ -210,14 +210,14 @@ public class BasicRestInfoProviderTest {
description="a-description",
swagger=@ResourceSwagger("{info:{title:'$L{bar}',description:'$L{bar}'}}")
)
- public static class B04 {}
+ public static class B4 {}
@Test
public void b04_info_ResourceSwagger_value_localised() throws Exception {
- assertEquals("l-bar", getSwagger(new B04()).getInfo().getTitle());
- assertEquals("l-bar", getSwaggerWithFile(new B04()).getInfo().getTitle());
- assertEquals("l-bar", getSwagger(new B04()).getInfo().getDescription());
- assertEquals("l-bar", getSwaggerWithFile(new B04()).getInfo().getDescription());
+ assertEquals("l-bar", getSwagger(new B4()).getInfo().getTitle());
+ assertEquals("l-bar", getSwaggerWithFile(new B4()).getInfo().getTitle());
+ assertEquals("l-bar", getSwagger(new B4()).getInfo().getDescription());
+ assertEquals("l-bar", getSwaggerWithFile(new B4()).getInfo().getDescription());
}
@Rest(
@@ -242,11 +242,11 @@ public class BasicRestInfoProviderTest {
license=@License(name="b-name",url="b-url")
)
)
- public static class B05 {}
+ public static class B5 {}
@Test
public void b05a_info_ResourceSwagger_title() throws Exception {
- Info x = getSwagger(new B05()).getInfo();
+ Info x = getSwagger(new B5()).getInfo();
assertEquals("c-title", x.getTitle());
assertEquals("c-description", x.getDescription());
assertEquals("3.0.0", x.getVersion());
@@ -256,7 +256,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void b05b_info_ResourceSwagger_title_withFile() throws Exception {
- Info x = getSwaggerWithFile(new B05()).getInfo();
+ Info x = getSwaggerWithFile(new B5()).getInfo();
assertEquals("c-title", x.getTitle());
assertEquals("c-description", x.getDescription());
assertEquals("3.0.0", x.getVersion());
@@ -288,11 +288,11 @@ public class BasicRestInfoProviderTest {
),
messages="BasicRestInfoProviderTest"
)
- public static class B06 {}
+ public static class B6 {}
@Test
public void b06a_info_ResourceSwagger_title_localized() throws Exception {
- Info x = getSwagger(new B06()).getInfo();
+ Info x = getSwagger(new B6()).getInfo();
assertEquals("l-baz", x.getTitle());
assertEquals("l-baz", x.getDescription());
assertEquals("l-foo", x.getVersion());
@@ -302,7 +302,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void b06b_info_ResourceSwagger_title_localized_withFile() throws Exception {
- Info x = getSwaggerWithFile(new B06()).getInfo();
+ Info x = getSwaggerWithFile(new B6()).getInfo();
assertEquals("l-baz", x.getTitle());
assertEquals("l-baz", x.getDescription());
assertEquals("l-foo", x.getVersion());
@@ -332,21 +332,21 @@ public class BasicRestInfoProviderTest {
assertEquals("c-description", x.getDescription());
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /tags
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class C01 {}
+ public static class C1 {}
@Test
public void c01a_tags_default() throws Exception {
- Swagger x = getSwagger(new C01());
+ Swagger x = getSwagger(new C1());
assertEquals(null, x.getTags());
}
@Test
public void c01b_tags_default_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C01());
+ Swagger x = getSwaggerWithFile(new C1());
assertObject(x.getTags()).json().is("[{name:'s-name',description:'s-description',externalDocs:{description:'s-description',url:'s-url'}}]");
}
@@ -356,16 +356,16 @@ public class BasicRestInfoProviderTest {
"{tags:[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}}]}"
)
)
- public static class C02 {}
+ public static class C2 {}
@Test
public void c02a_tags_ResourceSwagger_value() throws Exception {
- Swagger x = getSwagger(new C02());
+ Swagger x = getSwagger(new C2());
assertObject(x.getTags()).json().is("[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}}]");
}
@Test
public void c02b_tags_ResourceSwagger_value_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C02());
+ Swagger x = getSwaggerWithFile(new C2());
assertObject(x.getTags()).json().is("[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}}]");
}
@@ -376,16 +376,16 @@ public class BasicRestInfoProviderTest {
tags=@Tag(name="b-name",description="b-description",externalDocs=@ExternalDocs(description="b-description",url="b-url"))
)
)
- public static class C03 {}
+ public static class C3 {}
@Test
public void c03a_tags_ResourceSwagger_tags() throws Exception {
- Swagger x = getSwagger(new C03());
+ Swagger x = getSwagger(new C3());
assertObject(x.getTags()).json().is("[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}},{name:'b-name',description:'b-description',externalDocs:{description:'b-description',url:'b-url'}}]");
}
@Test
public void c03b_tags_ResourceSwagger_tags_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C03());
+ Swagger x = getSwaggerWithFile(new C3());
assertObject(x.getTags()).json().is("[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}},{name:'b-name',description:'b-description',externalDocs:{description:'b-description',url:'b-url'}}]");
}
@@ -396,16 +396,16 @@ public class BasicRestInfoProviderTest {
tags=@Tag(name="b-name",value=" { description:'b-description', externalDocs: { description:'b-description', url:'b-url' } } ")
)
)
- public static class C04 {}
+ public static class C4 {}
@Test
public void c04a_tags_ResourceSwagger_tags() throws Exception {
- Swagger x = getSwagger(new C04());
+ Swagger x = getSwagger(new C4());
assertObject(x.getTags()).json().is("[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}},{name:'b-name',description:'b-description',externalDocs:{description:'b-description',url:'b-url'}}]");
}
@Test
public void c04b_tags_ResourceSwagger_tags_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C04());
+ Swagger x = getSwaggerWithFile(new C4());
assertObject(x.getTags()).json().is("[{name:'a-name',description:'a-description',externalDocs:{description:'a-description',url:'a-url'}},{name:'b-name',description:'b-description',externalDocs:{description:'b-description',url:'b-url'}}]");
}
@@ -415,16 +415,16 @@ public class BasicRestInfoProviderTest {
tags=@Tag(name="b-name",description="b-description",externalDocs=@ExternalDocs(description="b-description",url="b-url"))
)
)
- public static class C05 {}
+ public static class C5 {}
@Test
public void c05a_tags_ResourceSwagger_tags_only() throws Exception {
- Swagger x = getSwagger(new C05());
+ Swagger x = getSwagger(new C5());
assertObject(x.getTags()).json().is("[{name:'b-name',description:'b-description',externalDocs:{description:'b-description',url:'b-url'}}]");
}
@Test
public void c05b_tags_ResourceSwagger_tags_only_witFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C05());
+ Swagger x = getSwaggerWithFile(new C5());
assertObject(x.getTags()).json().is("[{name:'s-name',description:'s-description',externalDocs:{description:'s-description',url:'s-url'}},{name:'b-name',description:'b-description',externalDocs:{description:'b-description',url:'b-url'}}]");
}
@@ -437,16 +437,16 @@ public class BasicRestInfoProviderTest {
}
)
)
- public static class C06 {}
+ public static class C6 {}
@Test
public void c06a_tags_ResourceSwagger_tags_dups() throws Exception {
- Swagger x = getSwagger(new C06());
+ Swagger x = getSwagger(new C6());
assertObject(x.getTags()).json().is("[{name:'s-name',description:'c-description',externalDocs:{description:'c-description',url:'c-url'}}]");
}
@Test
public void c06b_tags_ResourceSwagger_tags_dups_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C06());
+ Swagger x = getSwaggerWithFile(new C6());
assertObject(x.getTags()).json().is("[{name:'s-name',description:'c-description',externalDocs:{description:'c-description',url:'c-url'}}]");
}
@@ -457,52 +457,52 @@ public class BasicRestInfoProviderTest {
),
messages="BasicRestInfoProviderTest"
)
- public static class C07 {}
+ public static class C7 {}
@Test
public void c07a_tags_ResourceSwagger_tags_localised() throws Exception {
- Swagger x = getSwagger(new C07());
+ Swagger x = getSwagger(new C7());
assertObject(x.getTags()).json().is("[{name:'l-foo',description:'l-foo',externalDocs:{description:'l-foo',url:'l-foo'}}]");
}
@Test
public void c07b_tags_ResourceSwagger_tags_localised_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C07());
+ Swagger x = getSwaggerWithFile(new C7());
assertObject(x.getTags()).json().is("[{name:'l-foo',description:'l-foo',externalDocs:{description:'l-foo',url:'l-foo'}}]");
}
// Auto-detect tags defined on methods.
@Rest
- public static class C08 {
+ public static class C8 {
@RestMethod(swagger=@MethodSwagger(tags="foo"))
- public void doFoo() {}
+ public void a() {}
}
@Test
public void c08a_tags_ResourceSwagger_tags_loose() throws Exception {
- Swagger x = getSwagger(new C08());
+ Swagger x = getSwagger(new C8());
assertObject(x.getTags()).json().is("[{name:'foo'}]");
}
@Test
public void c08b_tags_ResourceSwagger_tags_loose_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C08());
+ Swagger x = getSwaggerWithFile(new C8());
assertObject(x.getTags()).json().is("[{name:'s-name',description:'s-description',externalDocs:{description:'s-description',url:'s-url'}},{name:'foo'}]");
}
// Comma-delimited list
@Rest
- public static class C09 {
+ public static class C9 {
@RestMethod(swagger=@MethodSwagger(tags=" foo, bar "))
- public void doFoo() {}
+ public void a() {}
}
@Test
public void c09a_tags_ResourceSwagger_tags_loose_cdl() throws Exception {
- Swagger x = getSwagger(new C09());
+ Swagger x = getSwagger(new C9());
assertObject(x.getTags()).json().is("[{name:'foo'},{name:'bar'}]");
}
@Test
public void c09b_tags_ResourceSwagger_tags_loose_cdl_withFile() throws Exception {
- Swagger x = getSwaggerWithFile(new C09());
+ Swagger x = getSwaggerWithFile(new C9());
assertObject(x.getTags()).json().is("[{name:'s-name',description:'s-description',externalDocs:{description:'s-description',url:'s-url'}},{name:'foo'},{name:'bar'}]");
}
@@ -510,7 +510,7 @@ public class BasicRestInfoProviderTest {
@Rest
public static class C10 {
@RestMethod(swagger=@MethodSwagger(tags="['foo', 'bar']"))
- public void doFoo() {}
+ public void a() {}
}
@Test
@@ -528,7 +528,7 @@ public class BasicRestInfoProviderTest {
@Rest(messages="BasicRestInfoProviderTest")
public static class C11 {
@RestMethod(swagger=@MethodSwagger(tags="['$L{foo}', '$L{bar}']"))
- public void doFoo() {}
+ public void a() {}
}
@Test
@@ -546,7 +546,7 @@ public class BasicRestInfoProviderTest {
@Rest(messages="BasicRestInfoProviderTest")
public static class C12 {
@RestMethod(swagger=@MethodSwagger(tags=" $L{foo}, $L{bar} "))
- public void doFoo() {}
+ public void a() {}
}
@Test
@@ -560,21 +560,21 @@ public class BasicRestInfoProviderTest {
assertObject(x.getTags()).json().is("[{name:'s-name',description:'s-description',externalDocs:{description:'s-description',url:'s-url'}},{name:'l-foo'},{name:'l-bar'}]");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /externalDocs
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class D01 {}
+ public static class D1 {}
@Test
public void d01a_externalDocs_default() throws Exception {
- ExternalDocumentation x = getSwagger(new D01()).getExternalDocs();
+ ExternalDocumentation x = getSwagger(new D1()).getExternalDocs();
assertEquals(null, x);
}
@Test
public void d01b_externalDocs_default_withFile() throws Exception {
- ExternalDocumentation x = getSwaggerWithFile(new D01()).getExternalDocs();
+ ExternalDocumentation x = getSwaggerWithFile(new D1()).getExternalDocs();
assertObject(x).json().is("{description:'s-description',url:'s-url'}");
}
@@ -582,16 +582,16 @@ public class BasicRestInfoProviderTest {
@Rest(
swagger=@ResourceSwagger("{externalDocs:{description:'a-description',url:'a-url'}}")
)
- public static class D02 {}
+ public static class D2 {}
@Test
public void d02a_externalDocs_ResourceSwagger_value() throws Exception {
- ExternalDocumentation x = getSwagger(new D02()).getExternalDocs();
+ ExternalDocumentation x = getSwagger(new D2()).getExternalDocs();
assertObject(x).json().is("{description:'a-description',url:'a-url'}");
}
@Test
public void d02b_externalDocs_ResourceSwagger_value_withFile() throws Exception {
- ExternalDocumentation x = getSwaggerWithFile(new D02()).getExternalDocs();
+ ExternalDocumentation x = getSwaggerWithFile(new D2()).getExternalDocs();
assertObject(x).json().is("{description:'a-description',url:'a-url'}");
}
@@ -602,16 +602,16 @@ public class BasicRestInfoProviderTest {
externalDocs=@ExternalDocs(description="b-description",url="b-url")
)
)
- public static class D03 {}
+ public static class D3 {}
@Test
public void d03a_externalDocs_ResourceSwagger_externalDocs() throws Exception {
- ExternalDocumentation x = getSwagger(new D03()).getExternalDocs();
+ ExternalDocumentation x = getSwagger(new D3()).getExternalDocs();
assertObject(x).json().is("{description:'b-description',url:'b-url'}");
}
@Test
public void d03b_externalDocs_ResourceSwagger_externalDocs_withFile() throws Exception {
- ExternalDocumentation x = getSwaggerWithFile(new D03()).getExternalDocs();
+ ExternalDocumentation x = getSwaggerWithFile(new D3()).getExternalDocs();
assertObject(x).json().is("{description:'b-description',url:'b-url'}");
}
@@ -621,16 +621,16 @@ public class BasicRestInfoProviderTest {
externalDocs=@ExternalDocs(" description:'b-description', url:'b-url' ")
)
)
- public static class D04 {}
+ public static class D4 {}
@Test
public void d04a_externalDocs_ResourceSwagger_externalDocs() throws Exception {
- ExternalDocumentation x = getSwagger(new D04()).getExternalDocs();
+ ExternalDocumentation x = getSwagger(new D4()).getExternalDocs();
assertObject(x).json().is("{description:'b-description',url:'b-url'}");
}
@Test
public void d04b_externalDocs_ResourceSwagger_externalDocs_withFile() throws Exception {
- ExternalDocumentation x = getSwaggerWithFile(new D04()).getExternalDocs();
+ ExternalDocumentation x = getSwaggerWithFile(new D4()).getExternalDocs();
assertObject(x).json().is("{description:'b-description',url:'b-url'}");
}
@@ -641,35 +641,35 @@ public class BasicRestInfoProviderTest {
),
messages="BasicRestInfoProviderTest"
)
- public static class D05 {}
+ public static class D5 {}
@Test
public void d05a_externalDocs_ResourceSwagger_externalDocs_localised() throws Exception {
- ExternalDocumentation x = getSwagger(new D05()).getExternalDocs();
+ ExternalDocumentation x = getSwagger(new D5()).getExternalDocs();
assertObject(x).json().is("{description:'l-foo',url:'l-bar'}");
}
@Test
public void d05b_externalDocs_ResourceSwagger_externalDocs_localised_withFile() throws Exception {
- ExternalDocumentation x = getSwaggerWithFile(new D05()).getExternalDocs();
+ ExternalDocumentation x = getSwaggerWithFile(new D5()).getExternalDocs();
assertObject(x).json().is("{description:'l-foo',url:'l-bar'}");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class E01 {
+ public static class E1 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e01a_operation_summary_default() throws Exception {
- Operation x = getSwagger(new E01()).getPaths().get("/path/{foo}").get("get");
- assertEquals("doFoo", x.getOperationId());
+ Operation x = getSwagger(new E1()).getPaths().get("/path/{foo}").get("get");
+ assertEquals("a", x.getOperationId());
assertEquals(null, x.getSummary());
assertEquals(null, x.getDescription());
assertEquals(null, x.getDeprecated());
@@ -677,7 +677,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void e01b_operation_summary_default_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E01()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E1()).getPaths().get("/path/{foo}").get("get");
assertEquals("s-operationId", x.getOperationId());
assertEquals("s-summary", x.getSummary());
assertEquals("s-description", x.getDescription());
@@ -690,16 +690,16 @@ public class BasicRestInfoProviderTest {
"paths:{'/path/{foo}':{get:{operationId:'a-operationId',summary:'a-summary',description:'a-description',deprecated:false,schemes:['a-scheme']}}}"
)
)
- public static class E02 {
+ public static class E2 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e02a_operation_summary_swaggerOnClass() throws Exception {
- Operation x = getSwagger(new E02()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwagger(new E2()).getPaths().get("/path/{foo}").get("get");
assertEquals("a-operationId", x.getOperationId());
assertEquals("a-summary", x.getSummary());
assertEquals("a-description", x.getDescription());
@@ -708,7 +708,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void e02b_operation_summary_swaggerOnClass_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E02()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E2()).getPaths().get("/path/{foo}").get("get");
assertEquals("a-operationId", x.getOperationId());
assertEquals("a-summary", x.getSummary());
assertEquals("a-description", x.getDescription());
@@ -721,18 +721,18 @@ public class BasicRestInfoProviderTest {
"paths:{'/path/{foo}':{get:{operationId:'a-operationId',summary:'a-summary',description:'a-description',deprecated:false,schemes:['a-scheme']}}}"
)
)
- public static class E03 {
+ public static class E3 {
@RestMethod(name=GET,path="/path/{foo}",
swagger=@MethodSwagger("operationId:'b-operationId',summary:'b-summary',description:'b-description',deprecated:false,schemes:['b-scheme']")
)
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e03a_operation_summary_swaggerOnMethod() throws Exception {
- Operation x = getSwagger(new E03()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwagger(new E3()).getPaths().get("/path/{foo}").get("get");
assertEquals("b-operationId", x.getOperationId());
assertEquals("b-summary", x.getSummary());
assertEquals("b-description", x.getDescription());
@@ -741,7 +741,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void e03b_operation_summary_swaggerOnMethod_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E03()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E3()).getPaths().get("/path/{foo}").get("get");
assertEquals("b-operationId", x.getOperationId());
assertEquals("b-summary", x.getSummary());
assertEquals("b-description", x.getDescription());
@@ -754,7 +754,7 @@ public class BasicRestInfoProviderTest {
"paths:{'/path/{foo}':{get:{operationId:'a-operationId',summary:'a-summary',description:'a-description',deprecated:false,schemes:['a-scheme']}}}"
)
)
- public static class E04 {
+ public static class E4 {
@RestMethod(name=GET,path="/path/{foo}",
swagger=@MethodSwagger(
operationId="c-operationId",
@@ -764,14 +764,14 @@ public class BasicRestInfoProviderTest {
schemes="d-scheme-1, d-scheme-2"
)
)
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e04a_operation_summary_swaggerOnAnnotation() throws Exception {
- Operation x = getSwagger(new E04()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwagger(new E4()).getPaths().get("/path/{foo}").get("get");
assertEquals("c-operationId", x.getOperationId());
assertEquals("c-summary", x.getSummary());
assertEquals("c-description", x.getDescription());
@@ -779,7 +779,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void e04b_operation_summary_swaggerOnAnnotation_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E04()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E4()).getPaths().get("/path/{foo}").get("get");
assertEquals("c-operationId", x.getOperationId());
assertEquals("c-summary", x.getSummary());
assertEquals("c-description", x.getDescription());
@@ -792,7 +792,7 @@ public class BasicRestInfoProviderTest {
"paths:{'/path/{foo}':{get:{operationId:'a-operationId',summary:'a-summary',description:'a-description',deprecated:false,schemes:['a-scheme']}}}"
)
)
- public static class E05 {
+ public static class E5 {
@RestMethod(name=GET,path="/path/{foo}",
swagger=@MethodSwagger(
summary="$L{foo}",
@@ -802,14 +802,14 @@ public class BasicRestInfoProviderTest {
schemes="$L{foo}"
)
)
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e05a_operation_summary_swaggerOnAnnotation_localized() throws Exception {
- Operation x = getSwagger(new E05()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwagger(new E5()).getPaths().get("/path/{foo}").get("get");
assertEquals("l-foo", x.getOperationId());
assertEquals("l-foo", x.getSummary());
assertEquals("l-foo", x.getDescription());
@@ -818,7 +818,7 @@ public class BasicRestInfoProviderTest {
}
@Test
public void e05b_operation_summary_swaggerOnAnnotation_localized_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E05()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E5()).getPaths().get("/path/{foo}").get("get");
assertEquals("l-foo", x.getOperationId());
assertEquals("l-foo", x.getSummary());
assertEquals("l-foo", x.getDescription());
@@ -831,25 +831,25 @@ public class BasicRestInfoProviderTest {
"paths:{'/path/{foo}':{get:{summary:'a-summary',description:'a-description'}}}"
)
)
- public static class E06 {
+ public static class E6 {
@RestMethod(name=GET,path="/path/{foo}",
summary="d-summary",
description="d-description"
)
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e06a_operation_summary_RestMethod() throws Exception {
- Operation x = getSwagger(new E06()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwagger(new E6()).getPaths().get("/path/{foo}").get("get");
assertEquals("a-summary", x.getSummary());
assertEquals("a-description", x.getDescription());
}
@Test
public void e06b_operation_summary_RestMethod_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E06()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E6()).getPaths().get("/path/{foo}").get("get");
assertEquals("a-summary", x.getSummary());
assertEquals("a-description", x.getDescription());
}
@@ -859,518 +859,518 @@ public class BasicRestInfoProviderTest {
"paths:{'/path/{foo}':{get:{}}}"
)
)
- public static class E07 {
+ public static class E7 {
@RestMethod(name=GET,path="/path/{foo}",
summary="d-summary",
description="d-description"
)
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
public void e07a_operation_summary_RestMethod() throws Exception {
- Operation x = getSwagger(new E07()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwagger(new E7()).getPaths().get("/path/{foo}").get("get");
assertEquals("d-summary", x.getSummary());
assertEquals("d-description", x.getDescription());
}
@Test
public void e07b_operation_summary_RestMethod_withFile() throws Exception {
- Operation x = getSwaggerWithFile(new E07()).getPaths().get("/path/{foo}").get("get");
+ Operation x = getSwaggerWithFile(new E7()).getPaths().get("/path/{foo}").get("get");
assertEquals("d-summary", x.getSummary());
assertEquals("d-description", x.getDescription());
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/tags
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class MD01 {
+ public static class F1 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void md01_operation_tags_default() throws Exception {
- assertObject(getSwagger(new MD01()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("null");
- assertObject(getSwaggerWithFile(new MD01()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['s-tag']");
+ public void f01_operation_tags_default() throws Exception {
+ assertObject(getSwagger(new F1()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("null");
+ assertObject(getSwaggerWithFile(new F1()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['s-tag']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
- public static class MD02 {
+ public static class F2 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void md02_operation_tags_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new MD02()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['a-tag']");
- assertObject(getSwaggerWithFile(new MD02()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['a-tag']");
+ public void f02_operation_tags_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new F2()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['a-tag']");
+ assertObject(getSwaggerWithFile(new F2()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['a-tag']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
- public static class MD03 {
+ public static class F3 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("tags:['b-tag']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void md03_operation_tags_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new MD03()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['b-tag']");
- assertObject(getSwaggerWithFile(new MD03()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['b-tag']");
+ public void f03_operation_tags_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new F3()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['b-tag']");
+ assertObject(getSwaggerWithFile(new F3()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['b-tag']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
- public static class MD04a {
+ public static class F4 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(tags="['c-tag-1','c-tag-2']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void md04a_operation_tags_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new MD04a()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
- assertObject(getSwaggerWithFile(new MD04a()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
+ public void f04_operation_tags_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new F4()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
+ assertObject(getSwaggerWithFile(new F4()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:['a-tag']}}}"))
- public static class MD04b {
+ public static class F5 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(tags="c-tag-1, c-tag-2"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void md04b_operation_tags_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new MD04b()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
- assertObject(getSwaggerWithFile(new MD04b()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
+ public void f05_operation_tags_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new F5()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
+ assertObject(getSwaggerWithFile(new F5()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['c-tag-1','c-tag-2']");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{tags:'a-tags'}}}"))
- public static class MD05 {
+ public static class F6 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(tags="$L{foo}"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void md05_operation_tags_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new MD05()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['l-foo']");
- assertObject(getSwaggerWithFile(new MD05()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['l-foo']");
+ public void f06_operation_tags_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new F6()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['l-foo']");
+ assertObject(getSwaggerWithFile(new F6()).getPaths().get("/path/{foo}").get("get").getTags()).json().is("['l-foo']");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/externalDocs
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class ME01 {
+ public static class G1 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me01_operation_externalDocs_default() throws Exception {
- assertObject(getSwagger(new ME01()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("null");
- assertObject(getSwaggerWithFile(new ME01()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'s-description',url:'s-url'}");
+ public void g01_operation_externalDocs_default() throws Exception {
+ assertObject(getSwagger(new G1()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("null");
+ assertObject(getSwaggerWithFile(new G1()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'s-description',url:'s-url'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
- public static class ME02 {
+ public static class G2 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me02_operation_externalDocs_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new ME02()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'a-description',url:'a-url'}");
- assertObject(getSwaggerWithFile(new ME02()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'a-description',url:'a-url'}");
+ public void g02_operation_externalDocs_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new G2()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'a-description',url:'a-url'}");
+ assertObject(getSwaggerWithFile(new G2()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'a-description',url:'a-url'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
- public static class ME03 {
+ public static class G3 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("externalDocs:{description:'b-description',url:'b-url'}"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me03_operation_externalDocs_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new ME03()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'b-description',url:'b-url'}");
- assertObject(getSwaggerWithFile(new ME03()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'b-description',url:'b-url'}");
+ public void g03_operation_externalDocs_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new G3()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'b-description',url:'b-url'}");
+ assertObject(getSwaggerWithFile(new G3()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'b-description',url:'b-url'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
- public static class ME04a {
+ public static class G4 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(externalDocs=@ExternalDocs(description="c-description",url="c-url")))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me04a_operation_externalDocs_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new ME04a()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'c-description',url:'c-url'}");
- assertObject(getSwaggerWithFile(new ME04a()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'c-description',url:'c-url'}");
+ public void g04_operation_externalDocs_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new G4()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'c-description',url:'c-url'}");
+ assertObject(getSwaggerWithFile(new G4()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'c-description',url:'c-url'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
- public static class ME04b {
+ public static class G5 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(externalDocs=@ExternalDocs("{description:'d-description',url:'d-url'}")))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me04b_operation_externalDocs_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new ME04b()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'d-description',url:'d-url'}");
- assertObject(getSwaggerWithFile(new ME04b()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'d-description',url:'d-url'}");
+ public void g05_operation_externalDocs_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new G5()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'d-description',url:'d-url'}");
+ assertObject(getSwaggerWithFile(new G5()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'d-description',url:'d-url'}");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{externalDocs:{description:'a-description',url:'a-url'}}}}"))
- public static class ME05 {
+ public static class G6 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(externalDocs=@ExternalDocs("{description:'$L{foo}',url:'$L{foo}'}")))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me05_operation_externalDocs_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new ME05()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'l-foo',url:'l-foo'}");
- assertObject(getSwaggerWithFile(new ME05()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'l-foo',url:'l-foo'}");
+ public void g06_operation_externalDocs_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new G6()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'l-foo',url:'l-foo'}");
+ assertObject(getSwaggerWithFile(new G6()).getPaths().get("/path/{foo}").get("get").getExternalDocs()).json().is("{description:'l-foo',url:'l-foo'}");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/consumes
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class MF01 {
+ public static class H1 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf01_operation_consumes_default() throws Exception {
- assertObject(getSwagger(new MF01()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("null");
- assertObject(getSwaggerWithFile(new MF01()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['s-consumes']");
+ public void h01_operation_consumes_default() throws Exception {
+ assertObject(getSwagger(new H1()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("null");
+ assertObject(getSwaggerWithFile(new H1()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['s-consumes']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
- public static class MF02 {
+ public static class H2 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf02_operation_consumes_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new MF02()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['a-consumes']");
- assertObject(getSwaggerWithFile(new MF02()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['a-consumes']");
+ public void h02_operation_consumes_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new H2()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['a-consumes']");
+ assertObject(getSwaggerWithFile(new H2()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['a-consumes']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
- public static class MF03 {
+ public static class H3 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("consumes:['b-consumes']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf03_operation_consumes_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new MF03()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['b-consumes']");
- assertObject(getSwaggerWithFile(new MF03()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['b-consumes']");
+ public void h03_operation_consumes_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new H3()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['b-consumes']");
+ assertObject(getSwaggerWithFile(new H3()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['b-consumes']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
- public static class MF04a {
+ public static class H4 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(consumes="['c-consumes-1','c-consumes-2']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf04a_operation_consumes_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new MF04a()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
- assertObject(getSwaggerWithFile(new MF04a()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
+ public void h04_operation_consumes_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new H4()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
+ assertObject(getSwaggerWithFile(new H4()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
- public static class MF04b {
+ public static class H5 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(consumes="c-consumes-1, c-consumes-2"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf04b_operation_consumes_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new MF04b()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
- assertObject(getSwaggerWithFile(new MF04b()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
+ public void h05_operation_consumes_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new H5()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
+ assertObject(getSwaggerWithFile(new H5()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['c-consumes-1','c-consumes-2']");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{consumes:['a-consumes']}}}"))
- public static class MF05 {
+ public static class H6 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(consumes="['$L{foo}']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void me05_operation_consumes_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new MF05()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['l-foo']");
- assertObject(getSwaggerWithFile(new MF05()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['l-foo']");
+ public void h06_operation_consumes_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new H6()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['l-foo']");
+ assertObject(getSwaggerWithFile(new H6()).getPaths().get("/path/{foo}").get("get").getConsumes()).json().is("['l-foo']");
}
@Rest(parsers={JsonParser.class})
- public static class MF06a {
+ public static class H7 {
@RestMethod(name=PUT,path="/path2/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf06a_operation_consumes_parsersOnClass() throws Exception {
- assertObject(getSwagger(new MF06a()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("null");
- assertObject(getSwaggerWithFile(new MF06a()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("null");
+ public void h07_operation_consumes_parsersOnClass() throws Exception {
+ assertObject(getSwagger(new H7()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("null");
+ assertObject(getSwaggerWithFile(new H7()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("null");
}
@Rest(parsers={JsonParser.class})
- public static class MF06b {
+ public static class H8 {
@RestMethod(name=PUT,path="/path2/{foo}",parsers={XmlParser.class})
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf06b_operation_consumes_parsersOnClassAndMethod() throws Exception {
- assertObject(getSwagger(new MF06b()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['text/xml','application/xml']");
- assertObject(getSwaggerWithFile(new MF06b()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['text/xml','application/xml']");
+ public void h08_operation_consumes_parsersOnClassAndMethod() throws Exception {
+ assertObject(getSwagger(new H8()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['text/xml','application/xml']");
+ assertObject(getSwaggerWithFile(new H8()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['text/xml','application/xml']");
}
@Rest(parsers={JsonParser.class},swagger=@ResourceSwagger("paths:{'/path2/{foo}':{put:{consumes:['a-consumes']}}}"))
- public static class MF06c {
+ public static class H9 {
@RestMethod(name=PUT,path="/path2/{foo}",parsers={XmlParser.class})
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mf06c_operation_consumes_parsersOnClassAndMethodWithSwagger() throws Exception {
- assertObject(getSwagger(new MF06c()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['a-consumes']");
- assertObject(getSwaggerWithFile(new MF06c()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['a-consumes']");
+ public void h09_operation_consumes_parsersOnClassAndMethodWithSwagger() throws Exception {
+ assertObject(getSwagger(new H9()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['a-consumes']");
+ assertObject(getSwaggerWithFile(new H9()).getPaths().get("/path2/{foo}").get("put").getConsumes()).json().is("['a-consumes']");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/produces
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class MG01 {
+ public static class I1 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg01_operation_produces_default() throws Exception {
- assertObject(getSwagger(new MG01()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("null");
- assertObject(getSwaggerWithFile(new MG01()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['s-produces']");
+ public void i01_operation_produces_default() throws Exception {
+ assertObject(getSwagger(new I1()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("null");
+ assertObject(getSwaggerWithFile(new I1()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['s-produces']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
- public static class MG02 {
+ public static class I2 {
@RestMethod(name=GET,path="/path/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg02_operation_produces_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new MG02()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['a-produces']");
- assertObject(getSwaggerWithFile(new MG02()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['a-produces']");
+ public void i02_operation_produces_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new I2()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['a-produces']");
+ assertObject(getSwaggerWithFile(new I2()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['a-produces']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
- public static class MG03 {
+ public static class I3 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger("produces:['b-produces']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg03_operation_produces_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new MG03()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['b-produces']");
- assertObject(getSwaggerWithFile(new MG03()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['b-produces']");
+ public void i03_operation_produces_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new I3()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['b-produces']");
+ assertObject(getSwaggerWithFile(new I3()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['b-produces']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
- public static class MG04a {
+ public static class I4 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(produces="['c-produces-1','c-produces-2']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg04a_operation_produces_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new MG04a()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
- assertObject(getSwaggerWithFile(new MG04a()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
+ public void i04_operation_produces_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new I4()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
+ assertObject(getSwaggerWithFile(new I4()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
- public static class MG04b {
+ public static class I5 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(produces="c-produces-1, c-produces-2"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg04b_operation_produces_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new MG04b()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
- assertObject(getSwaggerWithFile(new MG04b()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
+ public void i05_operation_produces_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new I5()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
+ assertObject(getSwaggerWithFile(new I5()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['c-produces-1','c-produces-2']");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}':{get:{produces:['a-produces']}}}"))
- public static class MG05 {
+ public static class I6 {
@RestMethod(name=GET,path="/path/{foo}",swagger=@MethodSwagger(produces="['$L{foo}']"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg05_operation_produces_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new MG05()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['l-foo']");
- assertObject(getSwaggerWithFile(new MG05()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['l-foo']");
+ public void i06_operation_produces_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new I6()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['l-foo']");
+ assertObject(getSwaggerWithFile(new I6()).getPaths().get("/path/{foo}").get("get").getProduces()).json().is("['l-foo']");
}
@Rest(serializers={JsonSerializer.class})
- public static class MG06a {
+ public static class I7 {
@RestMethod(name=PUT,path="/path2/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg06a_operation_produces_serializersOnClass() throws Exception {
- assertObject(getSwagger(new MG06a()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("null");
- assertObject(getSwaggerWithFile(new MG06a()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("null");
+ public void i07_operation_produces_serializersOnClass() throws Exception {
+ assertObject(getSwagger(new I7()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("null");
+ assertObject(getSwaggerWithFile(new I7()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("null");
}
@Rest(serializers={JsonSerializer.class})
- public static class MG06b {
+ public static class I8 {
@RestMethod(name=PUT,path="/path2/{foo}",serializers={XmlSerializer.class})
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg06b_operation_produces_serializersOnClassAndMethod() throws Exception {
- assertObject(getSwagger(new MG06b()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['text/xml']");
- assertObject(getSwaggerWithFile(new MG06b()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['text/xml']");
+ public void i08_operation_produces_serializersOnClassAndMethod() throws Exception {
+ assertObject(getSwagger(new I8()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['text/xml']");
+ assertObject(getSwaggerWithFile(new I8()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['text/xml']");
}
@Rest(serializers={JsonSerializer.class},swagger=@ResourceSwagger("paths:{'/path2/{foo}':{put:{produces:['a-produces']}}}"))
- public static class MG06c {
+ public static class I9 {
@RestMethod(name=PUT,path="/path2/{foo}",serializers={XmlSerializer.class})
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mg06c_operation_produces_serializersOnClassAndMethodWithSwagger() throws Exception {
- assertObject(getSwagger(new MG06c()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['a-produces']");
- assertObject(getSwaggerWithFile(new MG06c()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['a-produces']");
+ public void i09_operation_produces_serializersOnClassAndMethodWithSwagger() throws Exception {
+ assertObject(getSwagger(new I9()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['a-produces']");
+ assertObject(getSwaggerWithFile(new I9()).getPaths().get("/path2/{foo}").get("put").getProduces()).json().is("['a-produces']");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/deprecated
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class MH06 {
+ public static class J1 {
@RestMethod(name=GET,path="/path2/{foo}")
@Deprecated
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mh06_operation_deprecated_Deprecated() throws Exception {
- assertObject(getSwagger(new MH06()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
- assertObject(getSwaggerWithFile(new MH06()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
+ public void j01_operation_deprecated_Deprecated() throws Exception {
+ assertObject(getSwagger(new J1()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
+ assertObject(getSwaggerWithFile(new J1()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
}
@Rest
@Deprecated
- public static class MH07 {
+ public static class J2 {
@RestMethod(name=GET,path="/path2/{foo}")
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void mh07_operation_deprecated_Deprecated() throws Exception {
- assertObject(getSwagger(new MH07()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
- assertObject(getSwaggerWithFile(new MH07()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
+ public void j02_operation_deprecated_Deprecated() throws Exception {
+ assertObject(getSwagger(new J2()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
+ assertObject(getSwaggerWithFile(new J2()).getPaths().get("/path2/{foo}").get("get").getDeprecated()).json().is("true");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/parameters/query
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class NA01 {
+ public static class K1 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query("foo") Foo foo) {
+ public X a(@Query("foo") X foo) {
return null;
}
}
@Test
- public void na01a_query_type_default() throws Exception {
- ParameterInfo x = getSwagger(new NA01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
+ public void k01a_query_type_default() throws Exception {
+ ParameterInfo x = getSwagger(new K1()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
assertEquals("object", x.getType());
assertEquals(null, x.getDescription());
assertEquals(null, x.getRequired());
@@ -1390,8 +1390,8 @@ public class BasicRestInfoProviderTest {
assertEquals(null, x.getMinItems());
}
@Test
- public void na01b_query_type_default_withFile() throws Exception {
- ParameterInfo x = getSwaggerWithFile(new NA01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
+ public void k01b_query_type_default_withFile() throws Exception {
+ ParameterInfo x = getSwaggerWithFile(new K1()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
assertEquals("string", x.getType());
assertEquals("s-description", x.getDescription());
assertObject(x.getRequired()).json().is("true");
@@ -1435,16 +1435,16 @@ public class BasicRestInfoProviderTest {
"}]}}}"
})
)
- public static class NA02 {
+ public static class K2 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query("foo") Foo foo) {
+ public X a(@Query("foo") X foo) {
return null;
}
}
@Test
- public void na02a_query_type_swaggerOnClass() throws Exception {
- ParameterInfo x = getSwagger(new NA02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
+ public void k02a_query_type_swaggerOnClass() throws Exception {
+ ParameterInfo x = getSwagger(new K2()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
assertEquals("int32", x.getType());
assertEquals("a-description", x.getDescription());
assertObject(x.getRequired()).json().is("false");
@@ -1464,8 +1464,8 @@ public class BasicRestInfoProviderTest {
assertObject(x.getMinItems()).json().is("2");
}
@Test
- public void na02b_query_type_swaggerOnClass_withFile() throws Exception {
- ParameterInfo x = getSwaggerWithFile(new NA02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
+ public void k02b_query_type_swaggerOnClass_withFile() throws Exception {
+ ParameterInfo x = getSwaggerWithFile(new K2()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
assertEquals("int32", x.getType());
assertEquals("a-description", x.getDescription());
assertObject(x.getRequired()).json().is("false");
@@ -1510,7 +1510,7 @@ public class BasicRestInfoProviderTest {
"}]}}}"
})
)
- public static class NA03 {
+ public static class K3 {
@RestMethod(name=GET,path="/path/{foo}/query",
swagger=@MethodSwagger({
"parameters:[{",
@@ -1535,14 +1535,14 @@ public class BasicRestInfoProviderTest {
"minItems:3",
"}]"
}))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void na03a_query_type_swaggerOnMethod() throws Exception {
- ParameterInfo x = getSwagger(new NA03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
+ public void k03a_query_type_swaggerOnMethod() throws Exception {
+ ParameterInfo x = getSwagger(new K3()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
assertEquals("int64", x.getType());
assertEquals("b-description", x.getDescription());
assertObject(x.getRequired()).json().is("true");
@@ -1562,8 +1562,8 @@ public class BasicRestInfoProviderTest {
assertObject(x.getMinItems()).json().is("3");
}
@Test
- public void na03b_query_type_swaggerOnMethod_withFile() throws Exception {
- ParameterInfo x = getSwaggerWithFile(new NA03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
+ public void k03b_query_type_swaggerOnMethod_withFile() throws Exception {
+ ParameterInfo x = getSwaggerWithFile(new K3()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo");
assertEquals("int64", x.getType());
assertEquals("b-description", x.getDescription());
assertObject(x.getRequired()).json().is("true");
@@ -1583,741 +1583,741 @@ public class BasicRestInfoProviderTest {
assertObject(x.getMinItems()).json().is("3");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/parameters/query/example
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class NR01 {
+ public static class L1 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query("foo") Foo foo) {
+ public X a(@Query("foo") X foo) {
return null;
}
}
@Test
- public void nr01_query_example_default() throws Exception {
- assertEquals(null, getSwagger(new NR01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
- assertEquals("{id:1}", getSwaggerWithFile(new NR01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ public void l01_query_example_default() throws Exception {
+ assertEquals(null, getSwagger(new L1()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertEquals("{id:1}", getSwaggerWithFile(new L1()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:'{id:2}'}]}}}"))
- public static class NR02 {
+ public static class L2 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query("foo") Foo foo) {
+ public X a(@Query("foo") X foo) {
return null;
}
}
@Test
- public void nr02_query_example_swaggerOnClass() throws Exception {
- assertEquals("{id:2}", getSwagger(new NR02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
- assertEquals("{id:2}", getSwaggerWithFile(new NR02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ public void l02_query_example_swaggerOnClass() throws Exception {
+ assertEquals("{id:2}", getSwagger(new L2()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertEquals("{id:2}", getSwaggerWithFile(new L2()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:'{id:2}'}]}}}"))
- public static class NR03 {
+ public static class L3 {
@RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',x-example:'{id:3}'}]"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void nr03_query_example_swaggerOnMethod() throws Exception {
- assertEquals("{id:3}", getSwagger(new NR03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
- assertEquals("{id:3}", getSwaggerWithFile(new NR03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ public void l03_query_example_swaggerOnMethod() throws Exception {
+ assertEquals("{id:3}", getSwagger(new L3()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertEquals("{id:3}", getSwaggerWithFile(new L3()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:'{id:2}'}]}}}"))
- public static class NR04 {
+ public static class L4 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query(n="foo",ex="{id:4}") Foo foo) {
+ public X a(@Query(n="foo",ex="{id:4}") X foo) {
return null;
}
}
@Test
- public void nr04_query_example_swaggerOnAnnotation() throws Exception {
- assertEquals("{id:4}", getSwagger(new NR04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
- assertEquals("{id:4}", getSwaggerWithFile(new NR04()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ public void l04_query_example_swaggerOnAnnotation() throws Exception {
+ assertEquals("{id:4}", getSwagger(new L4()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertEquals("{id:4}", getSwaggerWithFile(new L4()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{'in':'query',name:'foo',x-example:'{id:2}'}]}}}"))
- public static class NR05 {
+ public static class L5 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query(n="foo",ex="{id:$L{5}}") Foo foo) {
+ public X a(@Query(n="foo",ex="{id:$L{5}}") X foo) {
return null;
}
}
@Test
- public void nr05_query_example_swaggerOnAnnotation_localized() throws Exception {
- assertEquals("{id:5}", getSwagger(new NR05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
- assertEquals("{id:5}", getSwaggerWithFile(new NR05()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ public void l05_query_example_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("{id:5}", getSwagger(new L5()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
+ assertEquals("{id:5}", getSwaggerWithFile(new L5()).getPaths().get("/path/{foo}/query").get("get").getParameter("query", "foo").getExample());
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/parameters/body/examples
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class NS01 {
+ public static class M1 {
@RestMethod(name=GET,path="/path/{foo}/body")
- public Foo doFoo(@Body Foo foo) {
+ public X a(@Body X foo) {
return null;
}
}
@Test
- public void ns01_body_examples_default() throws Exception {
- assertEquals(null, getSwagger(new NS01()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
- assertObject(getSwaggerWithFile(new NS01()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'a'}");
+ public void m01_body_examples_default() throws Exception {
+ assertEquals(null, getSwagger(new M1()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples());
+ assertObject(getSwaggerWithFile(new M1()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'a'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',x-examples:{foo:'b'}}]}}}"))
- public static class NS02 {
+ public static class M2 {
@RestMethod(name=GET,path="/path/{foo}/body")
- public Foo doFoo(@Body Foo foo) {
+ public X a(@Body X foo) {
return null;
}
}
@Test
- public void ns02_body_examples_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new NS02()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'b'}");
- assertObject(getSwaggerWithFile(new NS02()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'b'}");
+ public void m02_body_examples_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new M2()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'b'}");
+ assertObject(getSwaggerWithFile(new M2()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'b'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',x-examples:{foo:'b'}}]}}}"))
- public static class NS03 {
+ public static class M3 {
@RestMethod(name=GET,path="/path/{foo}/body",swagger=@MethodSwagger("parameters:[{'in':'body',x-examples:{foo:'c'}}]"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void ns03_body_examples_swaggerOnMethods() throws Exception {
- assertObject(getSwagger(new NS03()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'c'}");
- assertObject(getSwaggerWithFile(new NS03()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'c'}");
+ public void m03_body_examples_swaggerOnMethods() throws Exception {
+ assertObject(getSwagger(new M3()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'c'}");
+ assertObject(getSwaggerWithFile(new M3()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'c'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',x-examples:{foo:'b'}}]}}}"))
- public static class NS04 {
+ public static class M4 {
@RestMethod(name=GET,path="/path/{foo}/body")
- public Foo doFoo(@Body(exs="{foo:'d'}") Foo foo) {
+ public X a(@Body(exs="{foo:'d'}") X foo) {
return null;
}
}
@Test
- public void ns04_body_examples_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new NS04()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'d'}");
- assertObject(getSwaggerWithFile(new NS04()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'d'}");
+ public void m04_body_examples_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new M4()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'d'}");
+ assertObject(getSwaggerWithFile(new M4()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'d'}");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/body':{get:{parameters:[{'in':'body',examples:{foo:'b'}}]}}}"))
- public static class NS05 {
+ public static class M5 {
@RestMethod(name=GET,path="/path/{foo}/body")
- public Foo doFoo(@Body(exs="{foo:'$L{foo}'}") Foo foo) {
+ public X a(@Body(exs="{foo:'$L{foo}'}") X foo) {
return null;
}
}
@Test
- public void ns05_body_examples_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new NS05()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'l-foo'}");
- assertObject(getSwaggerWithFile(new NS05()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'l-foo'}");
+ public void m05_body_examples_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new M5()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'l-foo'}");
+ assertObject(getSwaggerWithFile(new M5()).getPaths().get("/path/{foo}/body").get("get").getParameter("body",null).getExamples()).json().is("{foo:'l-foo'}");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/parameters/query/schema
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class NT01 {
+ public static class N1 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query("foo") Foo foo) {
+ public X a(@Query("foo") X foo) {
return null;
}
}
@Test
- public void nt01_query_schema_default() throws Exception {
- assertObject(getSwagger(new NT01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{properties:{id:{format:'int32',type:'integer'}}}");
- assertObject(getSwaggerWithFile(new NT01()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'#/definitions/Foo'}");
+ public void n01_query_schema_default() throws Exception {
+ assertObject(getSwagger(new N1()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{properties:{a:{format:'int32',type:'integer'}}}");
+ assertObject(getSwaggerWithFile(new N1()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'#/definitions/Foo'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{in:'query',name:'foo',schema:{$ref:'b'}}]}}}"))
- public static class NT02 {
+ public static class N2 {
@RestMethod(name=GET,path="/path/{foo}/query")
- public Foo doFoo(@Query("foo") Foo foo) {
+ public X a(@Query("foo") X foo) {
return null;
}
}
@Test
- public void nt02_query_schema_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new NT02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'b'}");
- assertObject(getSwaggerWithFile(new NT02()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'b'}");
+ public void n02_query_schema_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new N2()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'b'}");
+ assertObject(getSwaggerWithFile(new N2()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'b'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/query':{get:{parameters:[{in:'query',name:'foo',schema:{$ref:'b'}}]}}}"))
- public static class NT03 {
+ public static class N3 {
@RestMethod(name=GET,path="/path/{foo}/query",swagger=@MethodSwagger("parameters:[{'in':'query',name:'foo',schema:{$ref:'c'}}]"))
- public Foo doFoo() {
+ public X a() {
return null;
}
}
@Test
- public void nt03_query_schema_swaggerOnMethnt() throws Exception {
- assertObject(getSwagger(new NT03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'c'}");
- assertObject(getSwaggerWithFile(new NT03()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'c'}");
+ public void n03_query_schema_swaggerOnMethnt() throws Exception {
+ assertObject(getSwagger(new N3()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'c'}");
+ assertObject(getSwaggerWithFile(new N3()).getPaths().get("/path/{foo}/query").get("get").getParameter("query","foo").getSchema()).json().is("{'$ref':'c'}");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/responses/<response>/description
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class OA01a {
+ public static class O1a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OA01x> foo) {}
+ public void a(Value<O1c> foo) {}
}
@Rest
- public static class OA01b {
+ public static class O1b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OA01x doFoo() { return null;}
+ public O1c a() { return null;}
}
@Response(code=100)
- public static class OA01x {
- public String foo;
+ public static class O1c {
+ public String a;
}
@Test
- public void oa01a_responses_100_description_default() throws Exception {
- assertEquals("Continue", getSwagger(new OA01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("s-100-description", getSwaggerWithFile(new OA01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o01a_responses_100_description_default() throws Exception {
+ assertEquals("Continue", getSwagger(new O1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("s-100-description", getSwaggerWithFile(new O1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Test
- public void oa01b_responses_100_description_default() throws Exception {
- assertEquals("Continue", getSwagger(new OA01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("s-100-description", getSwaggerWithFile(new OA01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o01b_responses_100_description_default() throws Exception {
+ assertEquals("Continue", getSwagger(new O1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("s-100-description", getSwaggerWithFile(new O1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
- public static class OA02 {
+ public static class O2 {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void oa02_response_100_description_swaggerOnClass() throws Exception {
- assertEquals("a-100-description", getSwagger(new OA02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("a-100-description", getSwaggerWithFile(new OA02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o02_response_100_description_swaggerOnClass() throws Exception {
+ assertEquals("a-100-description", getSwagger(new O2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("a-100-description", getSwaggerWithFile(new O2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
- public static class OA03 {
+ public static class O3 {
@RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{description:'b-100-description'}}"))
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void oa03_response_100_description_swaggerOnMethod() throws Exception {
- assertEquals("b-100-description", getSwagger(new OA03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("b-100-description", getSwaggerWithFile(new OA03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o03_response_100_description_swaggerOnMethod() throws Exception {
+ assertEquals("b-100-description", getSwagger(new O3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("b-100-description", getSwaggerWithFile(new O3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
- public static class OA04a {
+ public static class O4a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OA04x> foo) {}
+ public void a(Value<O4c> foo) {}
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
- public static class OA04b {
+ public static class O4b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OA04x doFoo() {return null;}
+ public O4c a() {return null;}
}
@Response(code=100,description="c-100-description")
- public static class OA04x {}
+ public static class O4c {}
@Test
- public void oa04a_response_100_description_swaggerOnAnnotation() throws Exception {
- assertEquals("c-100-description", getSwagger(new OA04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("c-100-description", getSwaggerWithFile(new OA04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o04a_response_100_description_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-100-description", getSwagger(new O4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("c-100-description", getSwaggerWithFile(new O4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Test
- public void oa04b_response_100_description_swaggerOnAnnotation() throws Exception {
- assertEquals("c-100-description", getSwagger(new OA04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("c-100-description", getSwaggerWithFile(new OA04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o04b_response_100_description_swaggerOnAnnotation() throws Exception {
+ assertEquals("c-100-description", getSwagger(new O4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("c-100-description", getSwaggerWithFile(new O4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
- public static class OA05a {
+ public static class O5a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OA05x> foo) {}
+ public void a(Value<O5c> foo) {}
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{description:'a-100-description'}}}}}"))
- public static class OA05b {
+ public static class O5b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OA05x doFoo() {return null;}
+ public O5c a() {return null;}
}
@Response(code=100,description="$L{foo}")
- public static class OA05x {}
+ public static class O5c {}
@Test
- public void oa05a_response_100_description_swaggerOnAnnotation_localized() throws Exception {
- assertEquals("l-foo", getSwagger(new OA05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("l-foo", getSwaggerWithFile(new OA05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o05a_response_100_description_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new O5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("l-foo", getSwaggerWithFile(new O5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
@Test
- public void oa05b_response_100_description_swaggerOnAnnotation_localized() throws Exception {
- assertEquals("l-foo", getSwagger(new OA05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
- assertEquals("l-foo", getSwaggerWithFile(new OA05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ public void o05b_response_100_description_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("l-foo", getSwagger(new O5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
+ assertEquals("l-foo", getSwaggerWithFile(new O5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getDescription());
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/responses/<response>/headers
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class OB01a {
+ public static class P1a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OB01x> foo) {}
+ public void a(Value<P1c> foo) {}
}
@Rest
- public static class OB01b {
+ public static class P1b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OB01x doFoo() {return null;}
+ public P1c a() {return null;}
}
@Response(code=100)
- public static class OB01x {
- public String foo;
+ public static class P1c {
+ public String a;
}
@Test
- public void ob01a_responses_100_headers_default() throws Exception {
- assertEquals(null, getSwagger(new OB01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
- assertObject(getSwaggerWithFile(new OB01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'s-description',type:'integer',format:'int32'}}");
+ public void p01a_responses_100_headers_default() throws Exception {
+ assertEquals(null, getSwagger(new P1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObject(getSwaggerWithFile(new P1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'s-description',type:'integer',format:'int32'}}");
}
@Test
- public void ob01b_responses_100_headers_default() throws Exception {
- assertEquals(null, getSwagger(new OB01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
- assertObject(getSwaggerWithFile(new OB01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'s-description',type:'integer',format:'int32'}}");
+ public void p01b_responses_100_headers_default() throws Exception {
+ assertEquals(null, getSwagger(new P1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders());
+ assertObject(getSwaggerWithFile(new P1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'s-description',type:'integer',format:'int32'}}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
- public static class OB02 {
+ public static class P2 {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ public X a(@ResponseStatus Value<Integer> foo) {
return null;
}
}
@Test
- public void ob02_response_100_headers_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new OB02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}");
- assertObject(getSwaggerWithFile(new OB02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}");
+ public void p02_response_100_headers_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new P2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}");
+ assertObject(getSwaggerWithFile(new P2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
- public static class OB03 {
+ public static class P3 {
@RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{headers:{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}}}"))
- public Foo doFoo(@ResponseStatus Value<Integer> foo) {
+ public X a(@ResponseStatus Value<Integer> foo) {
return null;
}
}
@Test
- public void ob03_response_100_headers_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new OB03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}");
- assertObject(getSwaggerWithFile(new OB03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}");
+ public void p03_response_100_headers_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new P3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}");
+ assertObject(getSwaggerWithFile(new P3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'c-description',type:'integer',format:'int32'}}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
- public static class OB04a {
+ public static class P4a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OB04x> foo) {}
+ public void a(Value<P4c> foo) {}
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
- public static class OB04b {
+ public static class P4b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OB04x doFoo() {return null;}
+ public P4c a() {return null;}
}
@Response(code=100,headers=@ResponseHeader(name="X-Foo",description="d-description",type="integer",format="int32"))
- public static class OB04x {}
+ public static class P4c {}
@Test
- public void ob04a_response_100_headers_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new OB04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
- assertObject(getSwaggerWithFile(new OB04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
+ public void p04a_response_100_headers_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new P4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
+ assertObject(getSwaggerWithFile(new P4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
}
@Test
- public void ob04b_response_100_headers_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new OB04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
- assertObject(getSwaggerWithFile(new OB04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
+ public void p04b_response_100_headers_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new P4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
+ assertObject(getSwaggerWithFile(new P4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'d-description',type:'integer',format:'int32'}}");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
- public static class OB05a {
+ public static class P5a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OB05x> foo) {}
+ public void a(Value<P5c> foo) {}
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{headers:{'X-Foo':{description:'b-description',type:'integer',format:'int32'}}}}}}}"))
- public static class OB05b {
+ public static class P5b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OB05x doFoo() {return null;}
+ public P5c a() {return null;}
}
@Response(code=100,headers=@ResponseHeader(name="X-Foo",description="$L{foo}",type="integer",format="int32"))
- public static class OB05x {}
+ public static class P5c {}
@Test
- public void ob05a_response_100_headers_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new OB05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
- assertObject(getSwaggerWithFile(new OB05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
+ public void p05a_response_100_headers_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new P5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
+ assertObject(getSwaggerWithFile(new P5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
}
@Test
- public void ob05b_response_100_headers_swaggerOnAnnotation_localized() throws Exception {
- assertObject(getSwagger(new OB05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
- assertObject(getSwaggerWithFile(new OB05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
+ public void p05b_response_100_headers_swaggerOnAnnotation_localized() throws Exception {
+ assertObject(getSwagger(new P5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
+ assertObject(getSwaggerWithFile(new P5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getHeaders()).json().is("{'X-Foo':{description:'l-foo',type:'integer',format:'int32'}}");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/responses/<response>/example
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class OC01a {
+ public static class Q1a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OC01x> foo) {}
+ public void a(Value<Q1c> foo) {}
}
@Rest
- public static class OC01b {
+ public static class Q1b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OC01x doFoo() {return null;}
+ public Q1c a() {return null;}
}
@Response(code=100)
- public static class OC01x {
- public String foo;
+ public static class Q1c {
+ public String a;
}
@Test
- public void oc01a_responses_100_example_default() throws Exception {
- assertEquals(null, getSwagger(new OC01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'a'}", getSwaggerWithFile(new OC01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ public void q01a_responses_100_example_default() throws Exception {
+ assertEquals(null, getSwagger(new Q1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertEquals("{foo:'a'}", getSwaggerWithFile(new Q1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
}
@Test
- public void oc01b_responses_100_example_default() throws Exception {
- assertEquals(null, getSwagger(new OC01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'a'}", getSwaggerWithFile(new OC01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ public void q01b_responses_100_example_default() throws Exception {
+ assertEquals(null, getSwagger(new Q1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertEquals("{foo:'a'}", getSwaggerWithFile(new Q1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class OC02 {
+ public static class Q2 {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void oc02_response_100_example_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new OC02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'b'}");
- assertObject(getSwaggerWithFile(new OC02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'b'}");
+ public void q02_response_100_example_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new Q2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'b'}");
+ assertObject(getSwaggerWithFile(new Q2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'b'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class OC03 {
+ public static class Q3 {
@RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{example:{foo:'c'}}}"))
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void oc03_response_100_example_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new OC03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'c'}");
- assertObject(getSwaggerWithFile(new OC03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'c'}");
+ public void q03_response_100_example_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new Q3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'c'}");
+ assertObject(getSwaggerWithFile(new Q3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample()).json().is("{foo:'c'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class OC04a {
+ public static class Q4a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OC04x> foo) {}
+ public void a(Value<Q4c> foo) {}
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class OC04b {
+ public static class Q4b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OC04x doFoo() {return null;}
+ public Q4c a() {return null;}
}
@Response(code=100,example="{foo:'d'}")
- public static class OC04x {
- public String foo;
+ public static class Q4c {
+ public String a;
}
@Test
- public void oc04a_response_100_example_swaggerOnAnnotation() throws Exception {
- assertEquals("{foo:'d'}", getSwagger(new OC04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'d'}", getSwaggerWithFile(new OC04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ public void q04a_response_100_example_swaggerOnAnnotation() throws Exception {
+ assertEquals("{foo:'d'}", getSwagger(new Q4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertEquals("{foo:'d'}", getSwaggerWithFile(new Q4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
}
@Test
- public void oc04b_response_100_example_swaggerOnAnnotation() throws Exception {
- assertEquals("{foo:'d'}", getSwagger(new OC04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'d'}", getSwaggerWithFile(new OC04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ public void q04b_response_100_example_swaggerOnAnnotation() throws Exception {
+ assertEquals("{foo:'d'}", getSwagger(new Q4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertEquals("{foo:'d'}", getSwaggerWithFile(new Q4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class OC05a {
+ public static class Q5a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OC05x> foo) {}
+ public void a(Value<Q5c> foo) {}
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{example:{foo:'b'}}}}}}"))
- public static class OC05b {
+ public static class Q5b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OC05x doFoo() {return null;}
+ public Q5c a() {return null;}
}
@Response(code=100,example="{foo:'$L{foo}'}")
- public static class OC05x {
- public String foo;
+ public static class Q5c {
+ public String a;
}
@Test
- public void oc05a_response_100_example_swaggerOnAnnotation_localized() throws Exception {
- assertEquals("{foo:'l-foo'}", getSwagger(new OC05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'l-foo'}", getSwaggerWithFile(new OC05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ public void q05a_response_100_example_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("{foo:'l-foo'}", getSwagger(new Q5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertEquals("{foo:'l-foo'}", getSwaggerWithFile(new Q5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
}
@Test
- public void oc05b_response_100_example_swaggerOnAnnotation_localized() throws Exception {
- assertEquals("{foo:'l-foo'}", getSwagger(new OC05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
- assertEquals("{foo:'l-foo'}", getSwaggerWithFile(new OC05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ public void q05b_response_100_example_swaggerOnAnnotation_localized() throws Exception {
+ assertEquals("{foo:'l-foo'}", getSwagger(new Q5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
+ assertEquals("{foo:'l-foo'}", getSwaggerWithFile(new Q5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExample());
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/responses/<response>/examples
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class OD01a {
+ public static class R1a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OD01x> foo) {}
+ public void a(Value<R1c> foo) {}
}
@Rest
- public static class OD01b {
+ public static class R1b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OD01x doFoo() {return null;}
+ public R1c a() {return null;}
}
@Response(code=100)
- public static class OD01x {
- public String foo;
+ public static class R1c {
+ public String a;
}
@Test
- public void od01a_responses_100_examples_default() throws Exception {
- assertEquals(null, getSwagger(new OD01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
- assertObject(getSwaggerWithFile(new OD01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:'a'}");
+ public void r01a_responses_100_examples_default() throws Exception {
+ assertEquals(null, getSwagger(new R1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObject(getSwaggerWithFile(new R1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:'a'}");
}
@Test
- public void od01b_responses_100_examples_default() throws Exception {
- assertEquals(null, getSwagger(new OD01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
- assertObject(getSwaggerWithFile(new OD01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:'a'}");
+ public void r01b_responses_100_examples_default() throws Exception {
+ assertEquals(null, getSwagger(new R1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples());
+ assertObject(getSwaggerWithFile(new R1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:'a'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
- public static class OD02 {
+ public static class R2 {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void od02_response_100_examples_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new OD02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'b'}}");
- assertObject(getSwaggerWithFile(new OD02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'b'}}");
+ public void r02_response_100_examples_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new R2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'b'}}");
+ assertObject(getSwaggerWithFile(new R2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'b'}}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
- public static class OD03 {
+ public static class R3 {
@RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{examples:{foo:{bar:'c'}}}}"))
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void od03_response_100_examples_swaggerOnMethod() throws Exception {
- assertObject(getSwagger(new OD03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'c'}}");
- assertObject(getSwaggerWithFile(new OD03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'c'}}");
+ public void r03_response_100_examples_swaggerOnMethod() throws Exception {
+ assertObject(getSwagger(new R3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'c'}}");
+ assertObject(getSwaggerWithFile(new R3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'c'}}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
- public static class OD04a {
+ public static class R4a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OD04x> foo) {}
+ public void a(Value<R4c> foo) {}
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
- public static class OD04b {
+ public static class R4b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OD04x doFoo() {return null;}
+ public R4c a() {return null;}
}
@Response(code=100,examples="{foo:{bar:'d'}}")
- public static class OD04x {}
+ public static class R4c {}
@Test
- public void od04a_response_100_examples_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new OD04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
- assertObject(getSwaggerWithFile(new OD04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
+ public void r04a_response_100_examples_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new R4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
+ assertObject(getSwaggerWithFile(new R4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
}
@Test
- public void od04b_response_100_examples_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new OD04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
- assertObject(getSwaggerWithFile(new OD04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
+ public void r04b_response_100_examples_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new R4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
+ assertObject(getSwaggerWithFile(new R4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'d'}}");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
- public static class OD05a {
+ public static class R5a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OD05x> foo) {}
+ public void a(Value<R5c> foo) {}
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{examples:{foo:{bar:'b'}}}}}}}"))
- public static class OD05b {
+ public static class R5b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OD05x doFoo() {return null;}
+ public R5c a() {return null;}
}
@Response(code=100,examples="{foo:{bar:'$L{foo}'}}")
- public static class OD05x {}
+ public static class R5c {}
@Test
- public void od05a_response_100_examples_swaggerOnAnnotation_lodalized() throws Exception {
- assertObject(getSwagger(new OD05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
- assertObject(getSwaggerWithFile(new OD05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
+ public void r05a_response_100_examples_swaggerOnAnnotation_lodalized() throws Exception {
+ assertObject(getSwagger(new R5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
+ assertObject(getSwaggerWithFile(new R5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
}
@Test
- public void od05b_response_100_examples_swaggerOnAnnotation_lodalized() throws Exception {
- assertObject(getSwagger(new OD05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
- assertObject(getSwaggerWithFile(new OD05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
+ public void r05b_response_100_examples_swaggerOnAnnotation_lodalized() throws Exception {
+ assertObject(getSwagger(new R5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
+ assertObject(getSwaggerWithFile(new R5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getExamples()).json().is("{foo:{bar:'l-foo'}}");
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// /paths/<path>/<method>/responses/<response>/schema
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class OE01a {
+ public static class S1a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OE01x> foo) {}
+ public void a(Value<S1c> foo) {}
}
@Rest
- public static class OE01b {
+ public static class S1b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OE01x doFoo() {return null;}
+ public S1c a() {return null;}
}
@Response(code=100)
- public static class OE01x extends Foo {}
+ public static class S1c extends X {}
@Test
- public void oe01a_responses_100_schema_default() throws Exception {
- assertObject(getSwagger(new OE01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'object',properties:{id:{format:'int32',type:'integer'}}}");
- assertObject(getSwaggerWithFile(new OE01a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'array',items:{'$ref':'#/definitions/Foo'}}");
+ public void s01a_responses_100_schema_default() throws Exception {
+ assertObject(getSwagger(new S1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'object',properties:{a:{format:'int32',type:'integer'}}}");
+ assertObject(getSwaggerWithFile(new S1a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'array',items:{'$ref':'#/definitions/Foo'}}");
}
@Test
- public void oe01b_responses_100_schema_default() throws Exception {
- assertObject(getSwagger(new OE01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'object',properties:{id:{format:'int32',type:'integer'}}}");
- assertObject(getSwaggerWithFile(new OE01b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'array',items:{'$ref':'#/definitions/Foo'}}");
+ public void s01b_responses_100_schema_default() throws Exception {
+ assertObject(getSwagger(new S1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'object',properties:{a:{format:'int32',type:'integer'}}}");
+ assertObject(getSwaggerWithFile(new S1b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{type:'array',items:{'$ref':'#/definitions/Foo'}}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{schema:{$ref:'b'}}}}}}"))
- public static class OE02 {
+ public static class S2 {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void oe02_response_100_schema_swaggerOnClass() throws Exception {
- assertObject(getSwagger(new OE02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'b'}");
- assertObject(getSwaggerWithFile(new OE02()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'b'}");
+ public void s02_response_100_schema_swaggerOnClass() throws Exception {
+ assertObject(getSwagger(new S2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'b'}");
+ assertObject(getSwaggerWithFile(new S2()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'b'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{schema:{$ref:'b'}}}}}}"))
- public static class OE03 {
+ public static class S3 {
@RestMethod(name=GET,path="/path/{foo}/responses/100",swagger=@MethodSwagger("responses:{100:{schema:{$ref:'c'}}}}"))
- public void doFoo(@ResponseStatus Value<Integer> foo) {}
+ public void a(@ResponseStatus Value<Integer> foo) {}
}
@Test
- public void oe03_response_100_schema_swaggerOnMethoe() throws Exception {
- assertObject(getSwagger(new OE03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'c'}");
- assertObject(getSwaggerWithFile(new OE03()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'c'}");
+ public void s03_response_100_schema_swaggerOnMethoe() throws Exception {
+ assertObject(getSwagger(new S3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'c'}");
+ assertObject(getSwaggerWithFile(new S3()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'c'}");
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{schema:{$ref:'b'}}}}}}"))
- public static class OE04a {
+ public static class S4a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OE04x> foo) {}
+ public void a(Value<S4c> foo) {}
}
@Rest(swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{schema:{$ref:'b'}}}}}}"))
- public static class OE04b {
+ public static class S4b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OE04x doFoo() {return null;}
+ public S4c a() {return null;}
}
@Response(code=100,schema=@Schema($ref="d"))
- public static class OE04x extends Foo {}
+ public static class S4c extends X {}
@Test
- public void oe04a_response_100_schema_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new OE04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
- assertObject(getSwaggerWithFile(new OE04a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
+ public void s04a_response_100_schema_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new S4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
+ assertObject(getSwaggerWithFile(new S4a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
}
@Test
- public void oe04b_response_100_schema_swaggerOnAnnotation() throws Exception {
- assertObject(getSwagger(new OE04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
- assertObject(getSwaggerWithFile(new OE04b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
+ public void s04b_response_100_schema_swaggerOnAnnotation() throws Exception {
+ assertObject(getSwagger(new S4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
+ assertObject(getSwaggerWithFile(new S4b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'d'}");
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{schema:{$ref:'b'}}}}}}"))
- public static class OE05a {
+ public static class S5a {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public void doFoo(Value<OE05x> foo) {}
+ public void a(Value<S5c> foo) {}
}
@Rest(messages="BasicRestInfoProviderTest", swagger=@ResourceSwagger("paths:{'/path/{foo}/responses/100':{get:{responses:{100:{schema:{$ref:'b'}}}}}}"))
- public static class OE05b {
+ public static class S5b {
@RestMethod(name=GET,path="/path/{foo}/responses/100")
- public OE05x doFoo() {return null;}
+ public S5c a() {return null;}
}
@Response(code=100,schema=@Schema("{$ref:'$L{foo}'}"))
- public static class OE05x extends Foo {}
+ public static class S5c extends X {}
@Test
- public void oe05a_response_100_schema_swaggerOnAnnotation_loealized() throws Exception {
- assertObject(getSwagger(new OE05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
- assertObject(getSwaggerWithFile(new OE05a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
+ public void s05a_response_100_schema_swaggerOnAnnotation_loealized() throws Exception {
+ assertObject(getSwagger(new S5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
+ assertObject(getSwaggerWithFile(new S5a()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
}
@Test
- public void oe05b_response_100_schema_swaggerOnAnnotation_loealized() throws Exception {
- assertObject(getSwagger(new OE05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
- assertObject(getSwaggerWithFile(new OE05b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
+ public void s05b_response_100_schema_swaggerOnAnnotation_loealized() throws Exception {
+ assertObject(getSwagger(new S5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
+ assertObject(getSwaggerWithFile(new S5b()).getPaths().get("/path/{foo}/responses/100").get("get").getResponse(100).getSchema()).json().is("{'$ref':'l-foo'}");
}
@Bean(typeName="Foo")
- public static class Foo {
- public int id;
+ public static class X {
+ public int a;
}
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Example bean with getter-only property.
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
@Rest
- public static class P extends BasicRestServlet {
+ public static class T1 extends BasicRestServlet {
private static final long serialVersionUID = 1L;
@RestMethod(name=GET,path="/")
- public P01 doFoo(@Body P01 body) {
+ public T2 a(@Body T2 body) {
return null;
}
}
@Bean(sort=true)
- public static class P01 {
+ public static class T2 {
private int f1;
- public P01 setF1(int f1) {
+ public T2 setF1(int f1) {
this.f1 = f1;
return this;
}
@@ -2331,15 +2331,15 @@ public class BasicRestInfoProviderTest {
}
@Example
- public static P01 example() {
- return new P01().setF1(1);
+ public static T2 example() {
+ return new T2().setF1(1);
}
}
- static MockRestClient p = MockRestClient.build(P.class);
@Test
- public void p01_bodyWithReadOnlyProperty() throws Exception {
+ public void t01_bodyWithReadOnlyProperty() throws Exception {
+ MockRestClient p = MockRestClient.build(T1.class);
Swagger s = JsonParser.DEFAULT.parse(p.options("/").accept("application/json").run().getBody().asString(), Swagger.class);
Operation o = s.getOperation("/", "get");
ParameterInfo pi = o.getParameter("body", null);
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourcePojoSwapsTest.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/BeanConfig_Swaps_Test.java
similarity index 66%
rename from juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourcePojoSwapsTest.java
rename to juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/BeanConfig_Swaps_Test.java
index ebd2700..a1d1f75 100644
--- a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation2/RestResourcePojoSwapsTest.java
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/BeanConfig_Swaps_Test.java
@@ -10,7 +10,7 @@
// * "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.annotation2;
+package org.apache.juneau.rest.annotation;
import static org.apache.juneau.http.HttpMethod.*;
import static org.junit.runners.MethodSorters.*;
@@ -21,18 +21,18 @@ import org.apache.juneau.http.annotation.Body;
import org.apache.juneau.http.annotation.Path;
import org.apache.juneau.json.*;
import org.apache.juneau.parser.*;
-import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client2.*;
import org.apache.juneau.rest.mock2.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
-public class RestResourcePojoSwapsTest {
+public class BeanConfig_Swaps_Test {
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
// Basic tests
- //=================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
public static class A {
public int f1;
@@ -85,53 +85,49 @@ public class RestResourcePojoSwapsTest {
@Rest(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class)
@BeanConfig(swaps={SwapA1.class})
- public static class A01_Parent {}
+ public static class A2 {}
@Rest
@BeanConfig(swaps={SwapA2.class})
- public static class A01 extends A01_Parent {
+ public static class A1 extends A2 {
- @RestMethod(name=GET, path="/classTransformOverridesParentClassTransform")
- public A a01a() {
+ @RestMethod
+ public A a() {
return new A(); // Should return "A2-1".
}
- @RestMethod(name=PUT, path="/classTransformOverridesParentClassTransform")
- public A a01b(@Body A a) {
+ @RestMethod(name=PUT)
+ public A b(@Body A a) {
return a; // Should return "A2-1".
}
- @RestMethod(name=PUT, path="/classTransformOverridesParentClassTransform/{a}")
- public A a01c(@Path("a") A a) {
+ @RestMethod(name=PUT, path="/c/{a}")
+ public A c(@Path("a") A a) {
return a; // Should return "A2-1".
}
- @RestMethod(name=GET, path="/methodTransformOverridesClassTransform")
+ @RestMethod
@BeanConfig(swaps={SwapA3.class})
- public A a02a() {
+ public A d() {
return new A(); // Should return "A3-1".
}
- @RestMethod(name=PUT, path="/methodTransformOverridesClassTransform")
+ @RestMethod(name=PUT)
@BeanConfig(swaps={SwapA3.class})
- public A a02b(@Body A a) {
+ public A e(@Body A a) {
return a; // Should return "A3-1".
}
- @RestMethod(name=PUT, path="/methodTransformOverridesClassTransform/{a}")
+ @RestMethod(name=PUT, path="/f/{a}")
@BeanConfig(swaps={SwapA3.class})
- public A a02c(@Path("a") A a) {
+ public A f(@Path("a") A a) {
return a; // Should return "A3-1".
}
}
- static MockRestClient a = MockRestClient.build(A01.class);
@Test
- public void a01_classTransformOverridesParentClassTransform() throws Exception {
- a.get("/classTransformOverridesParentClassTransform").json().run().assertBody().is("'A2-0'");
- a.put("/classTransformOverridesParentClassTransform", "'A2-1'", "application/json").run().assertBody().is("'A2-1'");
- a.put("/classTransformOverridesParentClassTransform/A2-2", null, "application/json").run().assertBody().is("'A2-2'");
- }
-
- @Test
- public void a02_methodTransformOverridesClassTransform() throws Exception {
- a.get("/methodTransformOverridesClassTransform").json().run().assertBody().is("'A3-0'");
- a.put("/methodTransformOverridesClassTransform", "'A3-1'", "application/json").run().assertBody().is("'A3-1'");
- a.put("/methodTransformOverridesClassTransform/A3-2", null, "application/json").run().assertBody().is("'A3-2'");
+ public void a01_swaps() throws Exception {
+ RestClient a = MockRestClient.build(A1.class);
+ a.get("/a").json().run().assertBody().is("'A2-0'");
+ a.put("/b", "'A2-1'", "application/json").run().assertBody().is("'A2-1'");
+ a.put("/c/A2-2", null, "application/json").run().assertBody().is("'A2-2'");
+ a.get("/d").json().run().assertBody().is("'A3-0'");
+ a.put("/e", "'A3-1'", "application/json").run().assertBody().is("'A3-1'");
+ a.put("/f/A3-2", null, "application/json").run().assertBody().is("'A3-2'");
}
}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/Body_Test.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/Body_Test.java
new file mode 100644
index 0000000..8b44d43
--- /dev/null
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/Body_Test.java
@@ -0,0 +1,1006 @@
+// ***************************************************************************************************************************
+// * 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.annotation;
+
+import static org.apache.juneau.http.HttpMethod.*;
+import static org.junit.Assert.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.collections.*;
+import org.apache.juneau.http.annotation.Body;
+import org.apache.juneau.http.annotation.HasQuery;
+import org.apache.juneau.http.annotation.Query;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.marshall.*;
+import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.mock2.*;
+import org.apache.juneau.testutils.pojos.*;
+import org.apache.juneau.uon.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.urlencoding.annotation.*;
+import org.apache.juneau.urlencoding.annotation.UrlEncoding;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class Body_Test {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @Body on parameter
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="text/json")
+ public static class A {
+ @RestMethod(name=PUT, path="/String")
+ public String a(@Body String b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/Integer")
+ public Integer b(@Body Integer b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/int")
+ public Integer c(@Body int b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/Boolean")
+ public Boolean d(@Body Boolean b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/boolean")
+ public Boolean e(@Body boolean b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/float")
+ public float f(@Body float f) {
+ return f;
+ }
+ @RestMethod(name=PUT, path="/Float")
+ public Float g(@Body Float f) {
+ return f;
+ }
+ @RestMethod(name=PUT, path="/Map")
+ public TreeMap<String,Integer> h(@Body TreeMap<String,Integer> m) {
+ return m;
+ }
+ @RestMethod(name=PUT, path="/enum")
+ public TestEnum i(@Body TestEnum e) {
+ return e;
+ }
+ public static class A11 {
+ public String f1;
+ }
+ @RestMethod(name=PUT, path="/Bean")
+ public A11 j(@Body A11 b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/InputStream")
+ public String k(@Body InputStream b) throws Exception {
+ return IOUtils.read(b);
+ }
+ @RestMethod(name=PUT, path="/Reader")
+ public String l(@Body Reader b) throws Exception {
+ return IOUtils.read(b);
+ }
+ @RestMethod(name=PUT, path="/InputStreamTransform")
+ public A14 m(@Body A14 b) throws Exception {
+ return b;
+ }
+ public static class A14 {
+ String s;
+ public A14(InputStream in) throws Exception { this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/ReaderTransform")
+ public A15 n(@Body A15 b) throws Exception {
+ return b;
+ }
+ public static class A15 {
+ private String s;
+ public A15(Reader in) throws Exception { this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/StringTransform")
+ public A16 o(@Body A16 b) throws Exception { return b; }
+ public static class A16 {
+ private String s;
+ public A16(String s) throws Exception { this.s = s; }
+ @Override public String toString() { return s; }
+ }
+ }
+
+ @Test
+ public void a01_onParameters() throws Exception {
+ RestClient a = MockRestClient.buildLax(A.class);
+
+ a.put("/String", "foo")
+ .json()
+ .run()
+ .assertBody().is("'foo'");
+ // If no Content-Type specified, should be treated as plain-text.
+ a.put("/String", "'foo'")
+ .run()
+ .assertBody().is("'\\'foo\\''");
+ // If Content-Type not matched, should be treated as plain-text.
+ a.put("/String", "'foo'").contentType("")
+ .run()
+ .assertBody().is("'\\'foo\\''");
+ a.put("/String", "'foo'").contentType("text/plain")
+ .run()
+ .assertBody().is("'\\'foo\\''");
+ a.put("/String?body=foo", null)
+ .run()
+ .assertBody().is("'foo'");
+ a.put("/String?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/String?body=", null)
+ .run()
+ .assertBody().is("''");
+
+ a.put("/Integer", "123").json()
+ .run()
+ .assertBody().is("123");
+ // Integer takes in a String arg, so it can be parsed without Content-Type.
+ a.put("/Integer", "123")
+ .run()
+ .assertBody().is("123");
+ a.put("/Integer?body=123", null)
+ .run()
+ .assertBody().is("123");
+ a.put("/Integer?body=-123", null)
+ .run()
+ .assertBody().is("-123");
+ a.put("/Integer?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Integer?body=", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Integer?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/int", "123").json()
+ .run()
+ .assertBody().is("123");
+ a.put("/int", "123")
+ .run()
+ .assertBody().is("123"); // Uses part parser.
+ a.put("/int?body=123", null)
+ .run()
+ .assertBody().is("123");
+ a.put("/int?body=-123", null)
+ .run()
+ .assertBody().is("-123");
+ a.put("/int?body=null", null)
+ .run()
+ .assertBody().is("0");
+ a.put("/int?body=", null)
+ .run()
+ .assertBody().is("0");
+ a.put("/int?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/Boolean", "true").json()
+ .run()
+ .assertBody().is("true");
+ // Boolean takes in a String arg, so it can be parsed without Content-Type.
+ a.put("/Boolean", "true")
+ .run()
+ .assertBody().is("true");
+ a.put("/Boolean?body=true", null)
+ .run()
+ .assertBody().is("true");
+ a.put("/Boolean?body=false", null)
+ .run()
+ .assertBody().is("false");
+ a.put("/Boolean?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Boolean?body=", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Boolean?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/boolean", "true").json()
+ .run()
+ .assertBody().is("true");
+ a.put("/boolean", "true")
+ .run()
+ .assertBody().is("true"); // Uses part parser.
+ a.put("/boolean?body=true", null)
+ .run()
+ .assertBody().is("true");
+ a.put("/boolean?body=false", null)
+ .run()
+ .assertBody().is("false");
+ a.put("/boolean?body=null", null)
+ .run()
+ .assertBody().is("false");
+ a.put("/boolean?body=", null)
+ .run()
+ .assertBody().is("false");
+ a.put("/boolean?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/float", "1.23").json()
+ .run()
+ .assertBody().is("1.23");
+ a.put("/float", "1.23")
+ .run()
+ .assertBody().is("1.23"); // Uses part parser.
+ a.put("/float?body=1.23", null)
+ .run()
+ .assertBody().is("1.23");
+ a.put("/float?body=-1.23", null)
+ .run()
+ .assertBody().is("-1.23");
+ a.put("/float?body=null", null)
+ .run()
+ .assertBody().is("0.0");
+ a.put("/float?body=", null)
+ .run()
+ .assertBody().is("0.0");
+ a.put("/float?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/Float", "1.23").json()
+ .run()
+ .assertBody().is("1.23");
+ // Float takes in a String arg, so it can be parsed without Content-Type.
+ a.put("/Float", "1.23")
+ .run()
+ .assertBody().is("1.23");
+ a.put("/Float?body=1.23", null)
+ .run()
+ .assertBody().is("1.23");
+ a.put("/Float?body=-1.23", null)
+ .run()
+ .assertBody().is("-1.23");
+ a.put("/Float?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Float?body=", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Float?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/Map", "{foo:123}", "application/json")
+ .run()
+ .assertBody().is("{foo:123}");
+ a.put("/Map", "(foo=123)", "text/openapi")
+ .run()
+ .assertCode().is(415);
+ a.put("/Map?body=(foo=123)", null)
+ .run()
+ .assertBody().is("{foo:123}");
+ a.put("/Map?body=()", null)
+ .run()
+ .assertBody().is("{}");
+ a.put("/Map?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Map?body=", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Map?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/enum", "'ONE'", "application/json")
+ .run()
+ .assertBody().is("'ONE'");
+ a.put("/enum", "ONE")
+ .run()
+ .assertBody().is("'ONE'");
+ a.put("/enum?body=ONE", null)
+ .run()
+ .assertBody().is("'ONE'");
+ a.put("/enum?body=TWO", null)
+ .run()
+ .assertBody().is("'TWO'");
+ a.put("/enum?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/enum?body=", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/enum?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ a.put("/Bean", "{f1:'a'}", "application/json")
+ .run()
+ .assertBody().is("{f1:'a'}");
+ a.put("/Bean", "(f1=a)", "text/openapi")
+ .run()
+ .assertCode().is(415);
+ a.put("/Bean?body=(f1=a)", null)
+ .run()
+ .assertBody().is("{f1:'a'}");
+ a.put("/Bean?body=()", null)
+ .run()
+ .assertBody().is("{}");
+ a.put("/Bean?body=null", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Bean?body=", null)
+ .run()
+ .assertBody().is("null");
+ a.put("/Bean?body=bad&noTrace=true", null)
+ .run()
+ .assertCode().is(400);
+
+ // Content-Type should always be ignored.
+ a.put("/InputStream", "'a'", "application/json")
+ .run()
+ .assertBody().is("'\\'a\\''");
+ a.put("/InputStream", "'a'")
+ .run()
+ .assertBody().is("'\\'a\\''");
+ a.put("/InputStream?body=a", null)
+ .run()
+ .assertBody().is("'a'");
+ a.put("/InputStream?body=null", null)
+ .run()
+ .assertBody().is("'null'");
+ a.put("/InputStream?body=", null)
+ .run()
+ .assertBody().is("''");
+
+ // Content-Type should always be ignored.
+ a.put("/Reader", "'a'", "application/json")
+ .run()
+ .assertBody().is("'\\'a\\''");
+ a.put("/Reader", "'a'")
+ .run()
+ .assertBody().is("'\\'a\\''");
+ a.put("/Reader?body=a", null)
+ .run()
+ .assertBody().is("'a'");
+ a.put("/Reader?body=null", null)
+ .run()
+ .assertBody().is("'null'");
+ a.put("/Reader?body=", null)
+ .run()
+ .assertBody().is("''");
+
+ // It's not currently possible to pass in a &body parameter for InputStream/Reader transforms.
+
+ // Input stream transform requests must not specify Content-Type or else gets resolved as POJO.
+ a.put("/InputStreamTransform?noTrace=true", "'a'", "application/json")
+ .run()
+ .assertBody().contains("Bad Request");
+ a.put("/InputStreamTransform", "'a'")
+ .run()
+ .assertBody().is("'\\'a\\''");
+
+ // Reader transform requests must not specify Content-Type or else gets resolved as POJO.
+ a.put("/ReaderTransform?noTrace=true", "'a'", "application/json")
+ .run()
+ .assertBody().contains("Bad Request");
+ a.put("/ReaderTransform", "'a'")
+ .run()
+ .assertBody().is("'\\'a\\''");
+
+ // When Content-Type specified and matched, treated as a parsed POJO.
+ a.put("/StringTransform", "'a'", "application/json")
+ .run()
+ .assertBody().is("'a'");
+ // When Content-Type not matched, treated as plain text.
+ a.put("/StringTransform", "'a'")
+ .run()
+ .assertBody().is("'\\'a\\''");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // @Body on POJO
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="application/json")
+ public static class B {
+ @RestMethod(name=PUT, path="/StringTransform")
+ public B1 a(B1 b) {
+ return b;
+ }
+ @Body
+ public static class B1 {
+ private String val;
+ public B1(String val) { this.val = val; }
+ @Override public String toString() { return val; }
+ }
+ @RestMethod(name=PUT, path="/Bean")
+ public B2 b(B2 b) {
+ return b;
+ }
+ @Body
+ public static class B2 {
+ public String f1;
+ }
+ @RestMethod(name=PUT, path="/BeanList")
+ public B3 c(B3 b) {
+ return b;
+ }
+ @SuppressWarnings("serial")
+ @Body
+ public static class B3 extends LinkedList<B2> {}
+ @RestMethod(name=PUT, path="/InputStreamTransform")
+ public B4 d(B4 b) throws Exception {
+ return b;
+ }
+ @Body
+ public static class B4 {
+ String s;
+ public B4(InputStream in) throws Exception { this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/ReaderTransform")
+ public B5 e(B5 b) throws Exception {
+ return b;
+ }
+ @Body
+ public static class B5 {
+ private String s;
+ public B5(Reader in) throws Exception { this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ }
+
+ @Test
+ public void b01_onPojos() throws Exception {
+ RestClient b = MockRestClient.buildLax(B.class);
+ b.put("/StringTransform", "'foo'", "application/json")
+ .run()
+ .assertBody().is("'foo'");
+ // When Content-Type not matched, treated as plain text.
+ b.put("/StringTransform", "'foo'")
+ .run()
+ .assertBody().is("'\\'foo\\''");
+ b.put("/Bean", "{f1:'a'}", "application/json")
+ .run()
+ .assertBody().is("{f1:'a'}");
+ b.put("/Bean", "(f1=a)", "text/openapi")
+ .run()
+ .assertCode().is(415);
+ b.put("/BeanList", "[{f1:'a'}]", "application/json")
+ .run()
+ .assertBody().is("[{f1:'a'}]");
+ b.put("/BeanList", "(f1=a)", "text/openapi")
+ .run()
+ .assertCode().is(415);
+ b.put("/InputStreamTransform", "a")
+ .run()
+ .assertBody().is("'a'");
+ // When Content-Type matched, treated as parsed POJO.
+ b.put("/InputStreamTransform?noTrace=true", "a", "application/json")
+ .run()
+ .assertBody().contains("Bad Request");
+ b.put("/ReaderTransform", "a")
+ .run()
+ .assertBody().is("'a'");
+ // When Content-Type matched, treated as parsed POJO.
+ b.put("/ReaderTransform?noTrace=true", "a", "application/json")
+ .run()
+ .assertBody().contains("Bad Request");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // No serializers or parsers needed when using only streams and readers.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ public static class D {
+ @RestMethod(name=PUT, path="/String")
+ public Reader a(@Body Reader b) throws Exception {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/InputStream")
+ public InputStream b(@Body InputStream b) throws Exception {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/Reader")
+ public Reader c(@Body Reader b) throws Exception {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/StringTransform")
+ public Reader d(@Body D1 b) throws Exception {
+ return new StringReader(b.toString());
+ }
+ public static class D1 {
+ private String s;
+ public D1(String in) throws Exception { this.s = in; }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/InputStreamTransform")
+ public Reader e(@Body D2 b) throws Exception {
+ return new StringReader(b.toString());
+ }
+ public static class D2 {
+ String s;
+ public D2(InputStream in) throws Exception { this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/ReaderTransform")
+ public Reader f(@Body D3 b) throws Exception {
+ return new StringReader(b.toString());
+ }
+ public static class D3 {
+ private String s;
+ public D3(Reader in) throws Exception{ this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/StringTransformBodyOnPojo")
+ public Reader g(D4 b) throws Exception {
+ return new StringReader(b.toString());
+ }
+ @Body
+ public static class D4 {
+ private String s;
+ public D4(String in) throws Exception { this.s = in; }
+ @Override public String toString() { return s; }
+ }
+ @RestMethod(name=PUT, path="/InputStreamTransformBodyOnPojo")
+ public Reader h(D5 b) throws Exception {
+ return new StringReader(b.toString());
+ }
+ @Body
+ public static class D5 {
+ String s;
+ public D5(InputStream in) throws Exception { this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+
+ @RestMethod(name=PUT, path="/ReaderTransformBodyOnPojo")
+ public Reader i(D6 b) throws Exception {
+ return new StringReader(b.toString());
+ }
+ @Body
+ public static class D6 {
+ private String s;
+ public D6(Reader in) throws Exception{ this.s = IOUtils.read(in); }
+ @Override public String toString() { return s; }
+ }
+ }
+
+ @Test
+ public void d01_noMediaTypesOnStreams() throws Exception {
+ RestClient d = MockRestClient.buildLax(D.class);
+ d.put("/String", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/String", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ d.put("/InputStream", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/InputStream", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ d.put("/Reader", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/Reader", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ d.put("/StringTransform", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/StringTransform?noTrace=true", "a", "application/json")
+ .run()
+ .assertCode().is(415);
+ d.put("/InputStreamTransform", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/InputStreamTransform", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ d.put("/ReaderTransform", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/ReaderTransform", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ d.put("/StringTransformBodyOnPojo", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/StringTransformBodyOnPojo?noTrace=true", "a", "application/json")
+ .run()
+ .assertCode().is(415);
+ d.put("/InputStreamTransformBodyOnPojo", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/InputStreamTransformBodyOnPojo", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ d.put("/ReaderTransformBodyOnPojo", "a")
+ .run()
+ .assertBody().is("a");
+ d.put("/ReaderTransformBodyOnPojo", "a", "application/json")
+ .run()
+ .assertBody().is("a");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Complex POJOs
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="application/json")
+ public static class E {
+ @RestMethod(name=PUT, path="/B")
+ public XBeans.XB a(@Body XBeans.XB b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/C")
+ public XBeans.XC b(@Body XBeans.XC c) {
+ return c;
+ }
+ }
+
+ @Test
+ public void e01_complexPojos() throws Exception {
+ RestClient e = MockRestClient.build(E.class);
+ String expected;
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e.put("/B", SimpleJsonSerializer.DEFAULT.toString(XBeans.XB.INSTANCE), "application/json")
+ .run()
+ .assertBody().is(expected);
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e.put("/B?body=" + UonSerializer.DEFAULT.serialize(XBeans.XB.INSTANCE), "a")
+ .run()
+ .assertBody().is(expected);
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e.put("/C", SimpleJsonSerializer.DEFAULT.toString(XBeans.XB.INSTANCE), "application/json")
+ .run()
+ .assertBody().is(expected);
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e.put("/C?body=" + UonSerializer.DEFAULT.serialize(XBeans.XB.INSTANCE), "a")
+ .run()
+ .assertBody().is(expected);
+ }
+
+ @Rest(serializers=SimpleJsonSerializer.class, parsers=JsonParser.class, defaultAccept="application/json")
+ @BeanConfig(applyBean={@Bean(on="A,B,C",sort=true)})
+ @UrlEncodingConfig(applyUrlEncoding={@UrlEncoding(on="C",expandedParams=true)})
+ public static class E2 {
+ @RestMethod(name=PUT, path="/B")
+ public XBeans.XE a(@Body XBeans.XE b) {
+ return b;
+ }
+ @RestMethod(name=PUT, path="/C")
+ public XBeans.XF b(@Body XBeans.XF c) {
+ return c;
+ }
+ }
+
+ @Test
+ public void e02_complexPojos() throws Exception {
+ RestClient e2 = MockRestClient.build(E2.class);
+ String expected;
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e2.put("/B", SimpleJsonSerializer.DEFAULT.builder().applyAnnotations(XBeans.Annotations.class).build().toString(XBeans.XE.INSTANCE), "application/json")
+ .run()
+ .assertBody().is(expected);
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e2.put("/B?body=" + UonSerializer.DEFAULT.builder().applyAnnotations(XBeans.Annotations.class).build().serialize(XBeans.XE.INSTANCE), "a")
+ .run()
+ .assertBody().is(expected);
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e2.put("/C", SimpleJsonSerializer.DEFAULT.builder().applyAnnotations(XBeans.Annotations.class).build().toString(XBeans.XE.INSTANCE), "application/json")
+ .run()
+ .assertBody().is(expected);
+
+ expected = "{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[ [...]
+ e2.put("/C?body=" + UonSerializer.DEFAULT.builder().applyAnnotations(XBeans.Annotations.class).build().serialize(XBeans.XE.INSTANCE), "a")
+ .run()
+ .assertBody().is(expected);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Form POSTS with @Body parameter
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=JsonSerializer.class,parsers=JsonParser.class)
+ public static class F {
+ @RestMethod(name=POST, path="/*")
+ public Reader a(
+ @Body F1 bean,
+ @HasQuery("p1") boolean hqp1, @HasQuery("p2") boolean hqp2,
+ @Query("p1") String qp1, @Query("p2") int qp2) throws Exception {
+ return new StringReader("bean=["+SimpleJsonSerializer.DEFAULT.toString(bean)+"],qp1=["+qp1+"],qp2=["+qp2+"],hqp1=["+hqp1+"],hqp2=["+hqp2+"]");
+ }
+ public static class F1 {
+ public String p1;
+ public int p2;
+ }
+ }
+
+ @Test
+ public void f01_formPostAsContent() throws Exception {
+ RestClient f = MockRestClient.build(F.class);
+ f.post("/", "{p1:'p1',p2:2}", "application/json")
+ .run()
+ .assertBody().is("bean=[{p1:'p1',p2:2}],qp1=[null],qp2=[0],hqp1=[false],hqp2=[false]");
+ f.post("/", "{}", "application/json")
+ .run()
+ .assertBody().is("bean=[{p2:0}],qp1=[null],qp2=[0],hqp1=[false],hqp2=[false]");
+ f.post("?p1=p3&p2=4", "{p1:'p1',p2:2}", "application/json")
+ .run()
+ .assertBody().is("bean=[{p1:'p1',p2:2}],qp1=[p3],qp2=[4],hqp1=[true],hqp2=[true]");
+ f.post("?p1=p3&p2=4", "{}", "application/json")
+ .run()
+ .assertBody().is("bean=[{p2:0}],qp1=[p3],qp2=[4],hqp1=[true],hqp2=[true]");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
+ // using @UrlEncoding(expandedParams=true) annotation on bean.
+ // A simple round-trip test to verify that both serializing and parsing works.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=UrlEncodingSerializer.class,parsers=UrlEncodingParser.class)
+ public static class G {
+ @RestMethod(name=POST,path="/")
+ public XBeans.XC a(@Body XBeans.XC content) throws Exception {
+ return content;
+ }
+ }
+
+ @Test
+ public void g01_multiPartParameterKeysOnCollections() throws Exception {
+ RestClient g = MockRestClient.build(G.class);
+ String in = ""
+ + "f01=a&f01=b"
+ + "&f02=c&f02=d"
+ + "&f03=1&f03=2"
+ + "&f04=3&f04=4"
+ + "&f05=@(e,f)&f05=@(g,h)"
+ + "&f06=@(i,j)&f06=@(k,l)"
+ + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
+ + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
+ + "&f09=@((a=a,b=1,c=true))&f09=@((a=b,b=2,c=false))"
+ + "&f10=@((a=a,b=1,c=true))&f10=@((a=b,b=2,c=false))"
+ + "&f11=a&f11=b"
+ + "&f12=c&f12=d"
+ + "&f13=1&f13=2"
+ + "&f14=3&f14=4"
+ + "&f15=@(e,f)&f15=@(g,h)"
+ + "&f16=@(i,j)&f16=@(k,l)"
+ + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
+ + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
+ + "&f19=@((a=a,b=1,c=true))&f19=@((a=b,b=2,c=false))"
+ + "&f20=@((a=a,b=1,c=true))&f20=@((a=b,b=2,c=false))";
+ g.post("/", in, "application/x-www-form-urlencoded")
+ .run()
+ .assertBody().is(in);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
+ // using URLENC_expandedParams property.
+ // A simple round-trip test to verify that both serializing and parsing works.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=UrlEncodingSerializer.class,parsers=UrlEncodingParser.class)
+ public static class H {
+ @RestMethod(name=POST,path="/",
+ properties={
+ @Property(name=UrlEncodingSerializer.URLENC_expandedParams, value="true"),
+ @Property(name=UrlEncodingParser.URLENC_expandedParams, value="true")
+ }
+ )
+ public XBeans.XB a(@Body XBeans.XB content) throws Exception {
+ return content;
+ }
+ }
+
+ @Test
+ public void h01_multiPartParameterKeysOnCollections_usingExpandedParams() throws Exception {
+ RestClient h = MockRestClient.build(H.class);
+ String in = ""
+ + "f01=a&f01=b"
+ + "&f02=c&f02=d"
+ + "&f03=1&f03=2"
+ + "&f04=3&f04=4"
+ + "&f05=@(e,f)&f05=@(g,h)"
+ + "&f06=@(i,j)&f06=@(k,l)"
+ + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
+ + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
+ + "&f09=@((a=a,b=1,c=true))&f09=@((a=b,b=2,c=false))"
+ + "&f10=@((a=a,b=1,c=true))&f10=@((a=b,b=2,c=false))"
+ + "&f11=a&f11=b"
+ + "&f12=c&f12=d"
+ + "&f13=1&f13=2"
+ + "&f14=3&f14=4"
+ + "&f15=@(e,f)&f15=@(g,h)"
+ + "&f16=@(i,j)&f16=@(k,l)"
+ + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
+ + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
+ + "&f19=@((a=a,b=1,c=true))&f19=@((a=b,b=2,c=false))"
+ + "&f20=@((a=a,b=1,c=true))&f20=@((a=b,b=2,c=false))";
+ h.post("/", in, "application/x-www-form-urlencoded")
+ .run()
+ .assertBody().is(in);
+ }
+
+ @Rest(serializers=UrlEncodingSerializer.class,parsers=UrlEncodingParser.class)
+ @BeanConfig(applyBean={@Bean(on="A,B,C",sort=true)})
+ @UrlEncodingConfig(applyUrlEncoding={@UrlEncoding(on="C",expandedParams=true)})
+ public static class H2 {
+ @RestMethod(name=POST,path="/",
+ properties={
+ @Property(name=UrlEncodingSerializer.URLENC_expandedParams, value="true"),
+ @Property(name=UrlEncodingParser.URLENC_expandedParams, value="true")
+ }
+ )
+ public XBeans.XE a(@Body XBeans.XE content) throws Exception {
+ return content;
+ }
+ }
+
+ @Test
+ public void h02_multiPartParameterKeysOnCollections_usingExpandedParams() throws Exception {
+ RestClient h2 = MockRestClient.build(H2.class);
+ String in = ""
+ + "f01=a&f01=b"
+ + "&f02=c&f02=d"
+ + "&f03=1&f03=2"
+ + "&f04=3&f04=4"
+ + "&f05=@(e,f)&f05=@(g,h)"
+ + "&f06=@(i,j)&f06=@(k,l)"
+ + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
+ + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
+ + "&f09=@((a=a,b=1,c=true))&f09=@((a=b,b=2,c=false))"
+ + "&f10=@((a=a,b=1,c=true))&f10=@((a=b,b=2,c=false))"
+ + "&f11=a&f11=b"
+ + "&f12=c&f12=d"
+ + "&f13=1&f13=2"
+ + "&f14=3&f14=4"
+ + "&f15=@(e,f)&f15=@(g,h)"
+ + "&f16=@(i,j)&f16=@(k,l)"
+ + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
+ + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
+ + "&f19=@((a=a,b=1,c=true))&f19=@((a=b,b=2,c=false))"
+ + "&f20=@((a=a,b=1,c=true))&f20=@((a=b,b=2,c=false))";
+ h2.post("/", in, "application/x-www-form-urlencoded")
+ .run()
+ .assertBody().is(in);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Test behavior of @Body(required=true).
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=JsonSerializer.class,parsers=JsonParser.class)
+ public static class I {
+ @RestMethod(name=POST)
+ public XBeans.XB a(@Body(r=true) XBeans.XB content) throws Exception {
+ return content;
+ }
+ @RestMethod(name=POST)
+ @BeanConfig(applyBean={@Bean(on="A,B,C",sort=true)})
+ @UrlEncodingConfig(applyUrlEncoding={@UrlEncoding(on="C",expandedParams=true)})
+ public XBeans.XE b(@Body(r=true) XBeans.XE content) throws Exception {
+ return content;
+ }
+ }
+
+ @Test
+ public void i01_required() throws Exception {
+ RestClient i = MockRestClient.buildLax(I.class);
+
+ i.post("/a", "", "application/json")
+ .run()
+ .assertCode().is(400)
+ .assertBody().contains("Required value not provided.");
+ i.post("/a", "{}", "application/json")
+ .run()
+ .assertCode().is(200);
+
+ i.post("/b", "", "application/json")
+ .run()
+ .assertCode().is(400)
+ .assertBody().contains("Required value not provided.");
+ i.post("/b", "{}", "application/json")
+ .run()
+ .assertCode().is(200);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Optional body parameter.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=SimpleJsonSerializer.class,parsers=JsonParser.class)
+ public static class J {
+ @RestMethod(name=POST)
+ public Object a(@Body Optional<Integer> body) throws Exception {
+ assertNotNull(body);
+ return body;
+ }
+ @RestMethod(name=POST)
+ public Object b(@Body Optional<ABean> body) throws Exception {
+ assertNotNull(body);
+ return body;
+ }
+ @RestMethod(name=POST)
+ public Object c(@Body Optional<List<ABean>> body) throws Exception {
+ assertNotNull(body);
+ return body;
+ }
+ @RestMethod(name=POST)
+ public Object d(@Body List<Optional<ABean>> body) throws Exception {
+ return body;
+ }
+ }
+
+ @Test
+ public void j01_optionalParams() throws Exception {
+ RestClient j = MockRestClient.buildJson(J.class);
+ j.post("/a", 123)
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("123");
+ j.post("/a", null)
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("null");
+
+ j.post("/b", ABean.get())
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("{a:1,b:'foo'}");
+ j.post("/b", null)
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("null");
+
+ String body1 = SimpleJson.DEFAULT.toString(AList.of(ABean.get()));
+ j.post("/c", body1, "application/json")
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("[{a:1,b:'foo'}]");
+ j.post("/c", null)
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("null");
+
+ String body2 = SimpleJson.DEFAULT.toString(AList.of(Optional.of(ABean.get())));
+ j.post("/d", body2, "application/json")
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("[{a:1,b:'foo'}]");
+ j.post("/d", null)
+ .run()
+ .assertCode().is(200)
+ .assertBody().is("null");
+ }
+}
diff --git a/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/FormData_Test.java b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/FormData_Test.java
new file mode 100644
index 0000000..bdd17de
--- /dev/null
+++ b/juneau-rest/juneau-rest-server-utest/src/test/java/org/apache/juneau/rest/annotation/FormData_Test.java
@@ -0,0 +1,214 @@
+// ***************************************************************************************************************************
+// * 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.annotation;
+
+import static org.apache.juneau.http.HttpMethod.*;
+import static org.junit.Assert.*;
+import static org.junit.runners.MethodSorters.*;
+
+import java.util.*;
+
+import org.apache.juneau.collections.*;
+import org.apache.juneau.http.annotation.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.RestRequest;
+import org.apache.juneau.rest.client2.*;
+import org.apache.juneau.rest.mock2.*;
+import org.apache.juneau.testutils.pojos.*;
+import org.apache.juneau.urlencoding.*;
+import org.junit.*;
+
+@FixMethodOrder(NAME_ASCENDING)
+public class FormData_Test {
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Simple tests
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(parsers=UrlEncodingParser.class)
+ public static class A {
+ @RestMethod(method=POST)
+ public String a(RestRequest req, @FormData(name="p1",allowEmptyValue=true) String p1, @FormData(name="p2",allowEmptyValue=true) int p2) throws Exception {
+ RequestFormData f = req.getFormData();
+ return "p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", String.class)+"],p2=["+p2+","+req.getFormData().getString("p2")+","+f.get("p2", int.class)+"]";
+ }
+ }
+
+ @Test
+ public void a01_basic() throws Exception {
+ RestClient a = MockRestClient.build(A.class);
+ a.post("/a", "p1=p1&p2=2").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[p1,p1,p1],p2=[2,2,2]");
+ a.post("/a", "p1&p2").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[null,null,null],p2=[0,null,0]");
+ a.post("/a", "p1=&p2=").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[,,],p2=[0,,0]");
+ a.post("/a", "").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[null,null,null],p2=[0,null,0]");
+ a.post("/a", "p1").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[null,null,null],p2=[0,null,0]");
+ a.post("/a", "p1=").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[,,],p2=[0,null,0]");
+ a.post("/a", "p2").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[null,null,null],p2=[0,null,0]");
+ a.post("/a", "p2=").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[null,null,null],p2=[0,,0]");
+ a.post("/a", "p1=foo&p2").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[foo,foo,foo],p2=[0,null,0]");
+ a.post("/a", "p1&p2=1").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[null,null,null],p2=[1,1,1]");
+ String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
+ a.post("/a", "p1="+x+"&p2=1").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // UON parameters
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ public static class B {
+ @RestMethod(name=POST)
+ public String a(RestRequest req, @FormData(value="p1") String p1) throws Exception {
+ RequestFormData f = req.getFormData();
+ return "p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", String.class)+"]";
+ }
+ @RestMethod(name=POST)
+ public String b(RestRequest req, @FormData(value="p1",format="uon") String p1) throws Exception {
+ RequestFormData f = req.getFormData();
+ return "p1=["+p1+","+req.getFormData().getString("p1")+","+f.get("p1", String.class)+"]";
+ }
+ }
+
+ @Test
+ public void b01_uonParameters() throws Exception {
+ RestClient b = MockRestClient.build(B.class);
+
+ b.post("/a", "p1=p1").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[p1,p1,p1]");
+ b.post("/a", "p1='p1'").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=['p1','p1','p1']");
+
+ b.post("/b", "p1=p1").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[p1,p1,p1]");
+ b.post("/b", "p1='p1'").contentType("application/x-www-form-urlencoded").run().assertBody().is("p1=[p1,'p1','p1']");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Default values.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest
+ public static class C {
+ @RestMethod(name=POST, defaultFormData={"f1:1","f2=2"," f3 : 3 "})
+ public OMap a(RequestFormData formData) {
+ return OMap.of()
+ .a("f1", formData.getString("f1"))
+ .a("f2", formData.getString("f2"))
+ .a("f3", formData.getString("f3"));
+ }
+ @RestMethod(name=POST)
+ public OMap b(@FormData("f1") String f1, @FormData("f2") String f2, @FormData("f3") String f3) {
+ return OMap.of()
+ .a("f1", f1)
+ .a("f2", f2)
+ .a("f3", f3);
+ }
+ @RestMethod(name=POST)
+ public OMap c(@FormData(value="f1",_default="1") String f1, @FormData(value="f2",_default="2") String f2, @FormData(value="f3",_default="3") String f3) {
+ return OMap.of()
+ .a("f1", f1)
+ .a("f2", f2)
+ .a("f3", f3);
+ }
+ @RestMethod(name=POST, defaultFormData={"f1:1","f2=2"," f3 : 3 "})
+ public OMap d(@FormData(value="f1",_default="4") String f1, @FormData(value="f2",_default="5") String f2, @FormData(value="f3",_default="6") String f3) {
+ return OMap.of()
+ .a("f1", f1)
+ .a("f2", f2)
+ .a("f3", f3);
+ }
+ }
+
+ @Test
+ public void c01_defaultFormData() throws Exception {
+ RestClient c = MockRestClient.build(C.class);
+
+ c.post("/a", null).contentType("application/x-www-form-urlencoded").run().assertBody().is("{f1:'1',f2:'2',f3:'3'}");
+ c.post("/a", null).contentType("application/x-www-form-urlencoded").formData("f1",4).formData("f2",5).formData("f3",6).run().assertBody().is("{f1:'4',f2:'5',f3:'6'}");
+
+ c.post("/b", null).contentType("application/x-www-form-urlencoded").run().assertBody().is("{f1:null,f2:null,f3:null}");
+ c.post("/b", null).contentType("application/x-www-form-urlencoded").formData("f1",4).formData("f2",5).formData("f3",6).run().assertBody().is("{f1:'4',f2:'5',f3:'6'}");
+
+ c.post("/c", null).contentType("application/x-www-form-urlencoded").run().assertBody().is("{f1:'1',f2:'2',f3:'3'}");
+ c.post("/c", null).contentType("application/x-www-form-urlencoded").formData("f1",4).formData("f2",5).formData("f3",6).run().assertBody().is("{f1:'4',f2:'5',f3:'6'}");
+
+ c.post("/d", null).contentType("application/x-www-form-urlencoded").run().assertBody().is("{f1:'4',f2:'5',f3:'6'}");
+ c.post("/d", null).contentType("application/x-www-form-urlencoded").formData("f1",7).formData("f2",8).formData("f3",9).run().assertBody().is("{f1:'7',f2:'8',f3:'9'}");
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Optional form data parameter.
+ //------------------------------------------------------------------------------------------------------------------
+
+ @Rest(serializers=SimpleJsonSerializer.class)
+ public static class D {
+ @RestMethod(name=POST)
+ public Object a(@FormData("f1") Optional<Integer> f1) throws Exception {
+ assertNotNull(f1);
+ return f1;
... 22188 lines suppressed ...