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 2018/07/29 15:19:57 UTC
[juneau] branch master updated: Change behavior of default
name/path on @RestMethod.
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 efaf63a Change behavior of default name/path on @RestMethod.
efaf63a is described below
commit efaf63a8887ed714038546aca11b427cf009d732
Author: JamesBognar <ja...@apache.org>
AuthorDate: Sun Jul 29 11:19:35 2018 -0400
Change behavior of default name/path on @RestMethod.
---
juneau-doc/src/main/javadoc/overview.html | 261 ++++++++++++++-------
.../src/main/resources/ReleaseNotes/7.2.0.html | 35 ++-
.../07.juneau-rest-server/06.RestMethod.html | 58 ++++-
.../15.PredefinedResponses.html} | 16 +-
...hrowables.html => 16.PredefinedExceptions.html} | 2 +-
...perBeans.html => 17.PredefinedHelperBeans.html} | 2 +-
.../juneau/examples/rest/AtomFeedResource.java | 9 +-
.../examples/rest/CodeFormatterResource.java | 8 +-
.../examples/rest/DockerRegistryResource.java | 9 +-
.../juneau/examples/rest/JsonSchemaResource.java | 9 +-
.../examples/rest/MethodExampleResource.java | 12 +-
.../examples/rest/PredefinedLabelsResource.java | 12 +-
.../juneau/examples/rest/SqlQueryResource.java | 8 +-
.../examples/rest/SystemPropertiesResource.java | 10 +-
.../juneau/examples/rest/TempDirResource.java | 8 +-
.../examples/rest/UrlEncodedFormResource.java | 8 +-
.../examples/rest/petstore/PetStoreResource.java | 12 +-
.../rest/test/client/CallbackStringsTest.java | 4 +-
.../juneau/rest/test/client/ClientFuturesTest.java | 3 +-
.../juneau/rest/test/client/FormDataTest.java | 5 +-
.../rest/test/client/RequestBeanProxyTest.java | 2 +-
.../org/apache/juneau/rest/RestJavaMethod.java | 27 ++-
.../apache/juneau/rest/annotation/RestMethod.java | 48 +++-
.../org/apache/juneau/rest/response/UseProxy.java | 2 +-
.../test/java/org/apache/juneau/rest/NlsTest.java | 8 +-
.../java/org/apache/juneau/rest/PathsTest.java | 4 +-
.../org/apache/juneau/rest/StatusCodesTest.java | 6 +-
.../juneau/rest/annotation/BodyAnnotationTest.java | 6 +-
.../rest/annotation/FormDataAnnotationTest.java | 2 +-
.../rest/annotation/HasFormDataAnnotationTest.java | 4 +-
.../rest/annotation/HasQueryAnnotationTest.java | 4 +-
.../rest/annotation/QueryAnnotationTest.java | 4 +-
.../juneau/rest/annotation/RestHookTest.java | 28 +--
.../rest/annotation/RestResourceMessagesTest.java | 4 +-
.../juneau/rest/headers/AcceptCharsetTest.java | 38 +--
.../juneau/rest/headers/AcceptEncodingTest.java | 4 +-
.../org/apache/juneau/rest/headers/AcceptTest.java | 58 ++---
.../juneau/rest/headers/ContentEncodingTest.java | 2 +-
.../juneau/rest/headers/ContentTypeTest.java | 42 ++--
.../apache/juneau/rest/headers/HeadersTest.java | 62 ++---
.../org/apache/juneau/rest/response/BasicTest.java | 140 +++++++++++
41 files changed, 658 insertions(+), 328 deletions(-)
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index ec3f74e..69a66d6 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -282,7 +282,7 @@
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestResource.AnnotationInheritance'>Annotation Inheritance</a></p>
</ol>
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestContext'>RestContext</a></p>
- <li><p class=''><a class='doclink' href='#juneau-rest-server.RestMethod'>@RestMethod</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-server.RestMethod'>@RestMethod</a></p>
<ol>
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestMethod.MethodParameters'>Java Method Parameters</a></p>
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestMethod.RestRequest'>RestRequest</a></p>
@@ -298,8 +298,9 @@
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestMethod.StreamResource'>StreamResource</a></p>
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestMethod.Redirect'>Redirect</a></p>
<li><p class=''><a class='doclink' href='#juneau-rest-server.RestMethod.RestMethodMatchers'>@RestMethod.matchers()</a></p>
- <li><p class='new'><a class='doclink' href='#juneau-rest-server.RestMethod.PredefinedHelperBeans'>Helper Beans</a></p>
- <li><p class='new'><a class='doclink' href='#juneau-rest-server.RestMethod.PredefinedThrowables'>Predefined Throwables</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-server.RestMethod.PredefinedResponses'>Predefined Responses</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-server.RestMethod.PredefinedExceptions'>Predefined Exceptions</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-server.RestMethod.PredefinedHelperBeans'>Predefined Helper Beans</a></p>
</ol>
<li><p class='new'><a class='doclink' href='#juneau-rest-server.OpenApiSchemaPartParsing'>OpenAPI Schema Part Parsing</a></p>
<li><p class='new'><a class='doclink' href='#juneau-rest-server.OpenApiSchemaPartSerializing'>OpenAPI Schema Part Serializing</a></p>
@@ -13105,7 +13106,7 @@ TODO(7.2.0)
<!-- ==================================================================================================== -->
-<h3 class='topic ' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod' id='juneau-rest-server.RestMethod'>7.6 - @RestMethod</a></h3>
+<h3 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod' id='juneau-rest-server.RestMethod'>7.6 - @RestMethod</a></h3>
<div class='topic'><!-- START: 7.6 - juneau-rest-server.RestMethod -->
<p>
REST Java methods are identified on REST servlets using the
@@ -13121,7 +13122,61 @@ TODO(7.2.0)
</p>
<p>
- There are no restrictions on the name of the Java method.
+ When the <code>name</code> and/or <code>path</code> values are not specified, their values are inferred
+ from the Java method name.
+</p>
+<p>
+ The HTTP method can be inferred from the Java method by starting the method name with any of the following:
+</p>
+<ul>
+ <li><code>get</code>
+ <li><code>put</code>
+ <li><code>post</code>
+ <li><code>delete</code>
+ <li><code>options</code>
+ <li><code>head</code>
+ <li><code>trace</code>
+ <li><code>patch</code>
+</ul>
+<p>
+ If <code>path</code> is not defined, it's inferred from the Java method name (minus the prefix above).
+</p>
+
+<h5 class='figure'>Examples:</h5>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/foo"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String getFoo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="DELETE", path="/foo"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String deleteFoo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/foo"</jc>
+ <jc>// "GET" is default</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String foo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/"</jc>
+ <ja>@RestMethod</ja>(path=<js>"/"</js>)
+ <jk>public</jk> String foo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String get() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="POST", path="/"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String post() {...}
+</p>
+
+<p>
+ If <code>name</code> and <code>path</code> are both specified, the Java method name can be anything.
</p>
<!-- ==================================================================================================== -->
@@ -13968,25 +14023,94 @@ TODO(7.2.0)
<!-- ==================================================================================================== -->
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod.PredefinedHelperBeans' id='juneau-rest-server.RestMethod.PredefinedHelperBeans'>7.6.15 - Helper Beans</a></h4>
-<div class='topic'><!-- START: 7.6.15 - juneau-rest-server.RestMethod.PredefinedHelperBeans -->
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod.PredefinedResponses' id='juneau-rest-server.RestMethod.PredefinedResponses'>7.6.15 - Predefined Responses</a></h4>
+<div class='topic'><!-- START: 7.6.15 - juneau-rest-server.RestMethod.PredefinedResponses -->
+<p>
+</p>
+</div><!-- END: 7.6.15 - juneau-rest-server.RestMethod.PredefinedResponses -->
+
+<!-- ==================================================================================================== -->
+
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod.PredefinedExceptions' id='juneau-rest-server.RestMethod.PredefinedExceptions'>7.6.16 - Predefined Exceptions</a></h4>
+<div class='topic'><!-- START: 7.6.16 - juneau-rest-server.RestMethod.PredefinedExceptions -->
+<p>
+ Exceptions are defined for all standardized HTTP responses.
+ These can be used to trigger HTTP errors simply by throwing an exception.
+</p>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
+ <jk>public</jk> String login(
+ <ja>@FormData</ja>(<js>"username"</js>) String username,
+ <ja>@FormData</ja>(<js>"password"</js>) String password,
+ ) <jk>throws</jk> Unauthorized
+ {
+ <jk>if</jk> (! isOK(username, password))
+ <jk>throw new</jk> Unauthorized();
+
+ <jk>return</jk> <js>"OK"</js>;
+ }
+</p>
+<ul class='doctree'>
+ <li class='jp'>{@link org.apache.juneau.rest.exception}
+ <ul>
+ <li class='jc'>{@link org.apache.juneau.rest.exception.BadRequest}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.Conflict}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.ExpectationFailed}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.FailedDependency}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.Forbidden}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.Gone}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.HttpVersionNotSupported}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.InsufficientStorage}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.InternalServerError}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.LengthRequired}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.Locked}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.LoopDetected}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.MethodNotAllowed}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.MisdirectedRequest}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.NetworkAuthenticationRequired}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.NotAcceptable}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.NotExtended}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.NotFound}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.NotImplemented}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.PayloadTooLarge}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.PreconditionFailed}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.PreconditionRequired}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.RangeNotSatisfiable}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.RequestHeaderFieldsTooLarge}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.ServiceUnavailable}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.TooManyRequests}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.Unauthorized}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.UnavailableForLegalReasons}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.UnprocessableEntity}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.UnsupportedMediaType}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.UpgradeRequired}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.UriTooLong}
+ <li class='jc'>{@link org.apache.juneau.rest.exception.VariantAlsoNegotiates}
+ </ul>
+</ul>
+</div><!-- END: 7.6.16 - juneau-rest-server.RestMethod.PredefinedExceptions -->
+
+<!-- ==================================================================================================== -->
+
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod.PredefinedHelperBeans' id='juneau-rest-server.RestMethod.PredefinedHelperBeans'>7.6.17 - Predefined Helper Beans</a></h4>
+<div class='topic'><!-- START: 7.6.17 - juneau-rest-server.RestMethod.PredefinedHelperBeans -->
<p>
- The {@link org.apache.juneau.rest.help} package contains several predefined beans to help when constructing
+ The {@link org.apache.juneau.rest.helper} package contains several predefined beans to help when constructing
REST interfaces.
</p>
<ul class='doctree'>
- <li class='jp'>{@link org.apache.juneau.rest.help}
+ <li class='jp'>{@link org.apache.juneau.rest.helper}
<ul>
- <li class='jc'>{@link org.apache.juneau.rest.help.BeanDescription}
- <li class='jc'>{@link org.apache.juneau.rest.help.ChildResourceDescriptions}
- <li class='jc'>{@link org.apache.juneau.rest.help.Ok}
- <li class='jc'>{@link org.apache.juneau.rest.help.ReaderResource}
- <li class='jc'>{@link org.apache.juneau.rest.help.ReaderResourceBuilder}
- <li class='jc'>{@link org.apache.juneau.rest.help.Redirect}
- <li class='jc'>{@link org.apache.juneau.rest.help.RedirectToServletRoot}
- <li class='jc'>{@link org.apache.juneau.rest.help.ResourceDescription}
- <li class='jc'>{@link org.apache.juneau.rest.help.StreamResource}
- <li class='jc'>{@link org.apache.juneau.rest.help.StreamResourceBuilder}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.BeanDescription}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.ChildResourceDescriptions}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.RedirectToServletRoot}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.ResourceDescription}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.StreamResource}
+ <li class='jc'>{@link org.apache.juneau.rest.helper.StreamResourceBuilder}
</ul>
</ul>
@@ -14081,69 +14205,7 @@ TODO(7.2.0)
<img class='bordered' src='doc-files/juneau-rest-server.PredefinedLabelBeans.3.png' style='width:92px'/>
<h5 class='topic'>ResourceDescription, BeanDescription, ChildResourceDescriptions</h5>
-</div><!-- END: 7.6.15 - juneau-rest-server.RestMethod.PredefinedHelperBeans -->
-
-<!-- ==================================================================================================== -->
-
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-server.RestMethod.PredefinedThrowables' id='juneau-rest-server.RestMethod.PredefinedThrowables'>7.6.16 - Predefined Throwables</a></h4>
-<div class='topic'><!-- START: 7.6.16 - juneau-rest-server.RestMethod.PredefinedThrowables -->
-<p>
- Exceptions are defined for all standardized HTTP responses.
- These can be used to trigger HTTP errors simply by throwing an exception.
-</p>
-<h5 class='figure'>Example:</h5>
-<p class='bpcode w800'>
- <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/user/login"</js>)
- <jk>public</jk> String login(
- <ja>@FormData</ja>(<js>"username"</js>) String username,
- <ja>@FormData</ja>(<js>"password"</js>) String password,
- ) <jk>throws</jk> Unauthorized
- {
- <jk>if</jk> (! isOK(username, password))
- <jk>throw new</jk> Unauthorized();
-
- <jk>return</jk> <js>"OK"</js>;
- }
-</p>
-<ul class='doctree'>
- <li class='jp'>{@link org.apache.juneau.rest.exception}
- <ul>
- <li class='jc'>{@link org.apache.juneau.rest.exception.BadRequest}
- <li class='jc'>{@link org.apache.juneau.rest.exception.Conflict}
- <li class='jc'>{@link org.apache.juneau.rest.exception.ExpectationFailed}
- <li class='jc'>{@link org.apache.juneau.rest.exception.FailedDependency}
- <li class='jc'>{@link org.apache.juneau.rest.exception.Forbidden}
- <li class='jc'>{@link org.apache.juneau.rest.exception.Gone}
- <li class='jc'>{@link org.apache.juneau.rest.exception.HttpVersionNotSupported}
- <li class='jc'>{@link org.apache.juneau.rest.exception.InsufficientStorage}
- <li class='jc'>{@link org.apache.juneau.rest.exception.InternalServerError}
- <li class='jc'>{@link org.apache.juneau.rest.exception.LengthRequired}
- <li class='jc'>{@link org.apache.juneau.rest.exception.Locked}
- <li class='jc'>{@link org.apache.juneau.rest.exception.LoopDetected}
- <li class='jc'>{@link org.apache.juneau.rest.exception.MethodNotAllowed}
- <li class='jc'>{@link org.apache.juneau.rest.exception.MisdirectedRequest}
- <li class='jc'>{@link org.apache.juneau.rest.exception.NetworkAuthenticationRequired}
- <li class='jc'>{@link org.apache.juneau.rest.exception.NotAcceptable}
- <li class='jc'>{@link org.apache.juneau.rest.exception.NotExtended}
- <li class='jc'>{@link org.apache.juneau.rest.exception.NotFound}
- <li class='jc'>{@link org.apache.juneau.rest.exception.NotImplemented}
- <li class='jc'>{@link org.apache.juneau.rest.exception.PayloadTooLarge}
- <li class='jc'>{@link org.apache.juneau.rest.exception.PreconditionFailed}
- <li class='jc'>{@link org.apache.juneau.rest.exception.PreconditionRequired}
- <li class='jc'>{@link org.apache.juneau.rest.exception.RangeNotSatisfiable}
- <li class='jc'>{@link org.apache.juneau.rest.exception.RequestHeaderFieldsTooLarge}
- <li class='jc'>{@link org.apache.juneau.rest.exception.ServiceUnavailable}
- <li class='jc'>{@link org.apache.juneau.rest.exception.TooManyRequests}
- <li class='jc'>{@link org.apache.juneau.rest.exception.Unauthorized}
- <li class='jc'>{@link org.apache.juneau.rest.exception.UnavailableForLegalReasons}
- <li class='jc'>{@link org.apache.juneau.rest.exception.UnprocessableEntity}
- <li class='jc'>{@link org.apache.juneau.rest.exception.UnsupportedMediaType}
- <li class='jc'>{@link org.apache.juneau.rest.exception.UpgradeRequired}
- <li class='jc'>{@link org.apache.juneau.rest.exception.UriTooLong}
- <li class='jc'>{@link org.apache.juneau.rest.exception.VariantAlsoNegotiates}
- </ul>
-</ul>
-</div><!-- END: 7.6.16 - juneau-rest-server.RestMethod.PredefinedThrowables -->
+</div><!-- END: 7.6.17 - juneau-rest-server.RestMethod.PredefinedHelperBeans -->
</div><!-- END: 7.6 - juneau-rest-server.RestMethod -->
<!-- ==================================================================================================== -->
@@ -30475,7 +30537,6 @@ TODO(7.2.0)
<ul>
<li class='jc'>{@link org.apache.juneau.rest.helper.BeanDescription}
<li class='jc'>{@link org.apache.juneau.rest.helper.ChildResourceDescriptions}
- <li class='jc'>{@link org.apache.juneau.rest.helper.Ok}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
<li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
@@ -30486,6 +30547,35 @@ TODO(7.2.0)
</ul>
</ul>
<li>
+ Predefined HTTP responses.
+ <ul class='doctree'>
+ <li class='jp'>{@link org.apache.juneau.rest.response}
+ <ul>
+ <li class='jc'>{@link org.apache.juneau.rest.response.Accepted}
+ <li class='jc'>{@link org.apache.juneau.rest.response.AlreadyReported}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Continue}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Created}
+ <li class='jc'>{@link org.apache.juneau.rest.response.EarlyHints}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Found}
+ <li class='jc'>{@link org.apache.juneau.rest.response.IMUsed}
+ <li class='jc'>{@link org.apache.juneau.rest.response.MovedPermanently}
+ <li class='jc'>{@link org.apache.juneau.rest.response.MultipleChoices}
+ <li class='jc'>{@link org.apache.juneau.rest.response.MultiStatus}
+ <li class='jc'>{@link org.apache.juneau.rest.response.NoContent}
+ <li class='jc'>{@link org.apache.juneau.rest.response.NonAuthoritiveInformation}
+ <li class='jc'>{@link org.apache.juneau.rest.response.NotModified}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Ok}
+ <li class='jc'>{@link org.apache.juneau.rest.response.PartialContent}
+ <li class='jc'>{@link org.apache.juneau.rest.response.PermanentRedirect}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Processing}
+ <li class='jc'>{@link org.apache.juneau.rest.response.ResetContent}
+ <li class='jc'>{@link org.apache.juneau.rest.response.SeeOther}
+ <li class='jc'>{@link org.apache.juneau.rest.response.SwitchingProtocols}
+ <li class='jc'>{@link org.apache.juneau.rest.response.TemporaryRedirect}
+ <li class='jc'>{@link org.apache.juneau.rest.response.UseProxy}
+ </ul>
+ </ul>
+ <li>
Predefined HTTP error throwables.
<br>When added to REST Java methods, reflected in generated Swagger documentation.
<ul class='doctree'>
@@ -30606,6 +30696,11 @@ TODO(7.2.0)
<li>
New/updated documentation:
<br>><a class="doclink" href="#juneau-rest-server.UnitTesting">Overview > juneau-rest-server > Serverless Unit Testing</a>
+ <li>
+ The behavior of the default values for {@link org.apache.juneau.rest.annotation.RestMethod#name()} and {@link org.apache.juneau.rest.annotation.RestMethod#path()}
+ have changed.
+ <br>If not specified, the values are inferred from the Java method name.
+ <br>See also:<a class="doclink" href="#juneau-rest-server.RestMethod">Overview > juneau-rest-server > @RestMethod</a>
</ul>
<h5 class='topic w800'>juneau-rest-client</h5>
diff --git a/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html b/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
index 35c088e..e8bff8f 100644
--- a/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
+++ b/juneau-doc/src/main/resources/ReleaseNotes/7.2.0.html
@@ -274,7 +274,6 @@
<ul>
<li class='jc'>{@link org.apache.juneau.rest.helper.BeanDescription}
<li class='jc'>{@link org.apache.juneau.rest.helper.ChildResourceDescriptions}
- <li class='jc'>{@link org.apache.juneau.rest.helper.Ok}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResource}
<li class='jc'>{@link org.apache.juneau.rest.helper.ReaderResourceBuilder}
<li class='jc'>{@link org.apache.juneau.rest.helper.Redirect}
@@ -285,6 +284,35 @@
</ul>
</ul>
<li>
+ Predefined HTTP responses.
+ <ul class='doctree'>
+ <li class='jp'>{@link org.apache.juneau.rest.response}
+ <ul>
+ <li class='jc'>{@link org.apache.juneau.rest.response.Accepted}
+ <li class='jc'>{@link org.apache.juneau.rest.response.AlreadyReported}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Continue}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Created}
+ <li class='jc'>{@link org.apache.juneau.rest.response.EarlyHints}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Found}
+ <li class='jc'>{@link org.apache.juneau.rest.response.IMUsed}
+ <li class='jc'>{@link org.apache.juneau.rest.response.MovedPermanently}
+ <li class='jc'>{@link org.apache.juneau.rest.response.MultipleChoices}
+ <li class='jc'>{@link org.apache.juneau.rest.response.MultiStatus}
+ <li class='jc'>{@link org.apache.juneau.rest.response.NoContent}
+ <li class='jc'>{@link org.apache.juneau.rest.response.NonAuthoritiveInformation}
+ <li class='jc'>{@link org.apache.juneau.rest.response.NotModified}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Ok}
+ <li class='jc'>{@link org.apache.juneau.rest.response.PartialContent}
+ <li class='jc'>{@link org.apache.juneau.rest.response.PermanentRedirect}
+ <li class='jc'>{@link org.apache.juneau.rest.response.Processing}
+ <li class='jc'>{@link org.apache.juneau.rest.response.ResetContent}
+ <li class='jc'>{@link org.apache.juneau.rest.response.SeeOther}
+ <li class='jc'>{@link org.apache.juneau.rest.response.SwitchingProtocols}
+ <li class='jc'>{@link org.apache.juneau.rest.response.TemporaryRedirect}
+ <li class='jc'>{@link org.apache.juneau.rest.response.UseProxy}
+ </ul>
+ </ul>
+ <li>
Predefined HTTP error throwables.
<br>When added to REST Java methods, reflected in generated Swagger documentation.
<ul class='doctree'>
@@ -405,6 +433,11 @@
<li>
New/updated documentation:
<br>><a class="doclink" href="#juneau-rest-server.UnitTesting">Overview > juneau-rest-server > Serverless Unit Testing</a>
+ <li>
+ The behavior of the default values for {@link org.apache.juneau.rest.annotation.RestMethod#name()} and {@link org.apache.juneau.rest.annotation.RestMethod#path()}
+ have changed.
+ <br>If not specified, the values are inferred from the Java method name.
+ <br>See also:<a class="doclink" href="#juneau-rest-server.RestMethod">Overview > juneau-rest-server > @RestMethod</a>
</ul>
<h5 class='topic w800'>juneau-rest-client</h5>
diff --git a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html
index b6baa30..4e3cc12 100644
--- a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html
+++ b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html
@@ -13,7 +13,7 @@
***************************************************************************************************************************/
-->
-@RestMethod
+{new} @RestMethod
<p>
REST Java methods are identified on REST servlets using the
@@ -29,5 +29,59 @@
</p>
<p>
- There are no restrictions on the name of the Java method.
+ When the <code>name</code> and/or <code>path</code> values are not specified, their values are inferred
+ from the Java method name.
+</p>
+<p>
+ The HTTP method can be inferred from the Java method by starting the method name with any of the following:
+</p>
+<ul>
+ <li><code>get</code>
+ <li><code>put</code>
+ <li><code>post</code>
+ <li><code>delete</code>
+ <li><code>options</code>
+ <li><code>head</code>
+ <li><code>trace</code>
+ <li><code>patch</code>
+</ul>
+<p>
+ If <code>path</code> is not defined, it's inferred from the Java method name (minus the prefix above).
+</p>
+
+<h5 class='figure'>Examples:</h5>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/foo"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String getFoo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="DELETE", path="/foo"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String deleteFoo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/foo"</jc>
+ <jc>// "GET" is default</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String foo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/"</jc>
+ <ja>@RestMethod</ja>(path=<js>"/"</js>)
+ <jk>public</jk> String foo() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="GET", path="/"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String get() {...}
+</p>
+<p class='bpcode w800'>
+ <jc>// Method="POST", path="/"</jc>
+ <ja>@RestMethod</ja>
+ <jk>public</jk> String post() {...}
+</p>
+
+<p>
+ If <code>name</code> and <code>path</code> are both specified, the Java method name can be anything.
</p>
diff --git a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/15.PredefinedResponses.html
similarity index 66%
copy from juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html
copy to juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/15.PredefinedResponses.html
index b6baa30..fdc4de7 100644
--- a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod.html
+++ b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/15.PredefinedResponses.html
@@ -13,21 +13,7 @@
***************************************************************************************************************************/
-->
-@RestMethod
+{todo} Predefined Responses
<p>
- REST Java methods are identified on REST servlets using the
- {@link org.apache.juneau.rest.annotation.RestMethod @RestMethod} annotation.
- <br>The annotation allows the framework to identify the available REST methods through reflection.
-</p>
-<h5 class='figure'>Example:</h5>
-<p class='bpcode w800'>
- <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/"</js>)
- <jk>public</jk> String sayHello() {
- <jk>return</jk> <js>"Hello world!"</js>;
- }
-</p>
-
-<p>
- There are no restrictions on the name of the Java method.
</p>
diff --git a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/16.PredefinedThrowables.html b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/16.PredefinedExceptions.html
similarity index 99%
rename from juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/16.PredefinedThrowables.html
rename to juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/16.PredefinedExceptions.html
index 4563534..3fdb030 100644
--- a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/16.PredefinedThrowables.html
+++ b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/16.PredefinedExceptions.html
@@ -13,7 +13,7 @@
***************************************************************************************************************************/
-->
-{new} Predefined Throwables
+{todo} Predefined Exceptions
<p>
Exceptions are defined for all standardized HTTP responses.
diff --git a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/15.PredefinedHelperBeans.html b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html
similarity index 99%
rename from juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/15.PredefinedHelperBeans.html
rename to juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html
index 1baf4c4..ed8145e 100644
--- a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/15.PredefinedHelperBeans.html
+++ b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/06.RestMethod/17.PredefinedHelperBeans.html
@@ -13,7 +13,7 @@
***************************************************************************************************************************/
-->
-{new} Helper Beans
+{todo} Predefined Helper Beans
<p>
The {@link org.apache.juneau.rest.helper} package contains several predefined beans to help when constructing
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
index 2380ce8..8003521 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/AtomFeedResource.java
@@ -13,7 +13,6 @@
package org.apache.juneau.examples.rest;
import static org.apache.juneau.dto.atom.AtomBuilder.*;
-import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.jena.RdfCommon.*;
import static org.apache.juneau.jena.RdfSerializer.*;
@@ -105,21 +104,17 @@ public class AtomFeedResource extends BasicRestServletJena {
}
@RestMethod(
- name=GET,
- path="/",
summary="Get the sample ATOM feed"
)
- public Feed getFeed() throws Exception {
+ public Feed get() throws Exception {
return feed;
}
@RestMethod(
- name=PUT,
- path="/",
summary="Overwrite the sample ATOM feed",
description="Replaces the feed with the specified content, and then mirrors it as the response."
)
- public Feed setFeed(@Body Feed feed) throws Exception {
+ public Feed put(@Body Feed feed) throws Exception {
this.feed = feed;
return feed;
}
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
index 338cdac..6810329 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/CodeFormatterResource.java
@@ -55,8 +55,8 @@ import org.apache.juneau.rest.annotation.*;
public class CodeFormatterResource extends BasicRestServlet {
/** [GET /] - Display query entry page. */
- @RestMethod(name=GET, path="/")
- public Div getQueryEntryPage(RestRequest req) {
+ @RestMethod
+ public Div get(RestRequest req) {
return div(
script("text/javascript",
"\n // Quick and dirty function to allow tabs in textarea."
@@ -101,8 +101,8 @@ public class CodeFormatterResource extends BasicRestServlet {
}
/** [POST /] - Add syntax highlighting to input. */
- @RestMethod(name=POST, path="/")
- public String executeQuery(@FormData("code") String code, @FormData("lang") String lang) throws Exception {
+ @RestMethod
+ public String post(@FormData("code") String code, @FormData("lang") String lang) throws Exception {
return highlight(code, lang);
}
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
index 548c6d8..2fa81fa 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.examples.rest;
-import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.rest.annotation.HookEvent.*;
import java.util.*;
@@ -75,8 +74,8 @@ public class DockerRegistryResource extends BasicRestServlet {
}
/** [GET /] - Show child resources. */
- @RestMethod(name=GET, path="/")
- public ResourceDescriptions getChildren(RestRequest req) {
+ @RestMethod
+ public ResourceDescriptions get(RestRequest req) {
return new ResourceDescriptions()
.append("search", "Search Registry")
;
@@ -86,8 +85,8 @@ public class DockerRegistryResource extends BasicRestServlet {
* PUT request handler.
* Replaces the feed with the specified content, and then mirrors it as the response.
*/
- @RestMethod(name=GET, path="/search")
- public QueryResults query(@Query("q") String q) throws Exception {
+ @RestMethod
+ public QueryResults search(@Query("q") String q) throws Exception {
String url = registryUrl + "/search" + (q == null ? "" : "?q=" + q);
synchronized(rc) {
return rc.doGet(url).getResponse(QueryResults.class);
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
index 1eed6ca..27a2bbd 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/JsonSchemaResource.java
@@ -13,7 +13,6 @@
package org.apache.juneau.examples.rest;
import static org.apache.juneau.BeanContext.*;
-import static org.apache.juneau.http.HttpMethodName.*;
import org.apache.juneau.dto.jsonschema.*;
import org.apache.juneau.http.annotation.*;
@@ -86,21 +85,17 @@ public class JsonSchemaResource extends BasicRestServletJena {
}
@RestMethod(
- name=GET,
- path="/",
summary="Get the JSON-Schema document"
)
- public JsonSchema getSchema() throws Exception {
+ public JsonSchema get() throws Exception {
return schema;
}
@RestMethod(
- name=PUT,
- path="/",
summary="Overwrite the JSON-Schema document",
description="Replaces the schema document with the specified content, and then mirrors it as the response."
)
- public JsonSchema setSchema(@Body JsonSchema schema) throws Exception {
+ public JsonSchema put(@Body JsonSchema schema) throws Exception {
this.schema = schema;
return schema;
}
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
index 24ea882..9cc560f 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/MethodExampleResource.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.examples.rest;
-import static org.apache.juneau.http.HttpMethodName.*;
-
import java.util.*;
import org.apache.juneau.http.*;
@@ -57,8 +55,8 @@ public class MethodExampleResource extends BasicRestServlet {
private static final String SAMPLE_UUID_STRING = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
/** Example GET request that redirects to our example method */
- @RestMethod(name=GET, path="/", summary="Top-level page")
- public ResourceDescriptions doExample() throws Exception {
+ @RestMethod(summary="Top-level page")
+ public ResourceDescriptions get() throws Exception {
return new ResourceDescriptions()
.append(
"example1/foo/123/"+SAMPLE_UUID+"/path-remainder?q1=456&q2=bar",
@@ -76,7 +74,7 @@ public class MethodExampleResource extends BasicRestServlet {
}
@RestMethod(
- name=GET, path="/example1/{p1}/{p2}/{p3}/*",
+ path="/example1/{p1}/{p2}/{p3}/*",
summary="GET request using annotated attributes",
description="This approach uses annotated parameters for retrieving input."
)
@@ -110,7 +108,7 @@ public class MethodExampleResource extends BasicRestServlet {
}
@RestMethod(
- name=GET, path="/example2/{p1}/{p2}/{p3}/*",
+ path="/example2/{p1}/{p2}/{p3}/*",
summary="GET request using methods on RestRequest and RestResponse",
description="This approach uses low-level request/response objects to perform the same as above."
)
@@ -159,7 +157,7 @@ public class MethodExampleResource extends BasicRestServlet {
}
@RestMethod(
- name=GET, path="/example3/{p1}/{p2}/{p3}/*",
+ path="/example3/{p1}/{p2}/{p3}/*",
summary="GET request using special objects",
description={
"This approach uses intermediate-level APIs.\n",
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PredefinedLabelsResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PredefinedLabelsResource.java
index 40bc6c9..689b597 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PredefinedLabelsResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PredefinedLabelsResource.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.examples.rest;
-import static org.apache.juneau.http.HttpMethodName.*;
-
import org.apache.juneau.dto.*;
import org.apache.juneau.examples.addressbook.*;
import org.apache.juneau.http.annotation.*;
@@ -53,21 +51,21 @@ import org.apache.juneau.rest.widget.*;
public class PredefinedLabelsResource extends BasicRestServlet {
private static final long serialVersionUID = 1L;
- @RestMethod(name=GET, path="/")
- public ResourceDescriptions getChildMethods() throws Exception {
+ @RestMethod
+ public ResourceDescriptions get() throws Exception {
return new ResourceDescriptions()
.append("beanDescription", "BeanDescription")
.append("htmlLinks", "HtmlLink")
;
}
- @RestMethod(name=GET, path="/beanDescription")
+ @RestMethod
public BeanDescription getBeanDescription() throws Exception {
return new BeanDescription(Person.class);
}
- @RestMethod(name=GET, path="/htmlLinks")
- public LinkString[] htmlLinks() throws Exception {
+ @RestMethod
+ public LinkString[] getHtmlLinks() throws Exception {
return new LinkString[] {
new LinkString("apache", "http://apache.org"),
new LinkString("juneau", "http://juneau.apache.org")
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
index 3369db2..a0507ea 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SqlQueryResource.java
@@ -93,11 +93,9 @@ public class SqlQueryResource extends BasicRestServlet {
}
@RestMethod(
- name=GET,
- path="/",
summary="Display the query entry page"
)
- public Div doGet(
+ public Div get(
@Query(name="sql", description="Text to prepopulate the SQL query field with.", example="select * from sys.systables") String sql
) {
@@ -142,8 +140,6 @@ public class SqlQueryResource extends BasicRestServlet {
}
@RestMethod(
- name=POST,
- path="/",
summary="Execute one or more queries",
swagger=@MethodSwagger(
responses={
@@ -151,7 +147,7 @@ public class SqlQueryResource extends BasicRestServlet {
}
)
)
- public List<Object> doPost(
+ public List<Object> post(
@Body(description="Query input", example="{sql:'select * from sys.systables',pos:1,limit:100}") PostInput in
) throws BadRequest {
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
index bff76ee..91cd718 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SystemPropertiesResource.java
@@ -94,7 +94,6 @@ public class SystemPropertiesResource extends BasicRestServlet {
private static final long serialVersionUID = 1L;
@RestMethod(
- name=GET, path="/",
summary="Show all system properties",
description="Returns all system properties defined in the JVM.",
swagger=@MethodSwagger(
@@ -104,7 +103,7 @@ public class SystemPropertiesResource extends BasicRestServlet {
)
)
@SuppressWarnings({"rawtypes", "unchecked"})
- public Map getSystemProperties(
+ public Map get(
@Query(name="sort", description="Sort results alphabetically", _default="false", example="true") boolean sort
) throws NotAcceptable {
@@ -146,12 +145,11 @@ public class SystemPropertiesResource extends BasicRestServlet {
}
@RestMethod(
- name=POST, path="/",
summary="Add an entire set of system properties",
description="Takes in a map of key/value pairs and creates a set of new system properties.",
guards=AdminGuard.class
)
- public RedirectToServletRoot setSystemProperties(
+ public RedirectToServletRoot post(
@Body(description="The new system property values", example="{key1:'val1',key2:123}") java.util.Properties newProperties
) throws UserNotAdminException, NotAcceptable, UnsupportedMediaType {
@@ -174,7 +172,6 @@ public class SystemPropertiesResource extends BasicRestServlet {
}
@RestMethod(
- name=GET, path="/formPage",
summary="Form entry page",
description="A form post page for setting a single system property value",
guards=AdminGuard.class,
@@ -204,12 +201,11 @@ public class SystemPropertiesResource extends BasicRestServlet {
}
@RestMethod(
- name=POST, path="/formPagePost",
summary="Form page post",
description="Accepts a simple form post of a system property name/value pair.",
guards=AdminGuard.class
)
- public RedirectToServletRoot formPagePost(
+ public RedirectToServletRoot postFormPagePost(
@FormData("name") String name,
@FormData("value") String value
) throws UserNotAdminException, NotAcceptable, UnsupportedMediaType {
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
index ef49509..5d0d300 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/TempDirResource.java
@@ -91,12 +91,10 @@ public class TempDirResource extends DirectoryResource {
}
@RestMethod(
- name=GET,
- path="/upload",
summary="Upload file form entry page",
description="Renders an example form page for uploading a file in multipart/form-data format to the temp directory."
)
- public Form getUploadForm() {
+ public Form getUpload() {
return
form().id("form").action("servlet:/upload").method(POST).enctype("multipart/form-data")
.children(
@@ -107,8 +105,6 @@ public class TempDirResource extends DirectoryResource {
}
@RestMethod(
- name=POST,
- path="/upload",
summary="Upload a file as a multipart form post",
description= {
"Shows how to use the Apache Commons ServletFileUpload class for handling multi-part form posts.\n",
@@ -116,7 +112,7 @@ public class TempDirResource extends DirectoryResource {
},
matchers=TempDirResource.MultipartFormDataMatcher.class
)
- public RedirectToServletRoot uploadFile(RestRequest req) throws Exception {
+ public RedirectToServletRoot postUpload(RestRequest req) throws Exception {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(req);
while (iter.hasNext()) {
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
index 2b8e79b..d030a35 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/UrlEncodedFormResource.java
@@ -62,8 +62,6 @@ public class UrlEncodedFormResource extends BasicRestServlet {
/** GET request handler */
@RestMethod(
- name=GET,
- path="/",
htmldoc=@HtmlDoc(
script={
"INHERIT",
@@ -76,7 +74,7 @@ public class UrlEncodedFormResource extends BasicRestServlet {
}
)
)
- public Div doGet(RestRequest req) {
+ public Div get(RestRequest req) {
return div(
form().id("form").action("servlet:/").method(POST).target("buff").children(
table(
@@ -106,8 +104,8 @@ public class UrlEncodedFormResource extends BasicRestServlet {
}
/** POST request handler */
- @RestMethod(name=POST, path="/")
- public Object doPost(@Body FormInputBean input) throws Exception {
+ @RestMethod
+ public Object post(@Body FormInputBean input) throws Exception {
// Just mirror back the request
return input;
}
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java
index dd1f7f1..bcfeb3c 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java
@@ -158,8 +158,6 @@ public class PetStoreResource extends BasicRestServletJena {
}
@RestMethod(
- name="POST",
- path="/pet",
summary="Add a new pet to the store",
swagger=@MethodSwagger(
tags="pet",
@@ -168,7 +166,7 @@ public class PetStoreResource extends BasicRestServletJena {
}
)
)
- public Ok addPet(
+ public Ok postPet(
@Body(description="Pet object to add to the store") PetCreate pet
) throws IdConflict, NotAcceptable, UnsupportedMediaType {
@@ -368,14 +366,12 @@ public class PetStoreResource extends BasicRestServletJena {
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@RestMethod(
- name="GET",
- path="/store",
summary="Store navigation page",
swagger=@MethodSwagger(
tags="store"
)
)
- public ResourceDescriptions getTopStorePage() {
+ public ResourceDescriptions getStore() {
return new ResourceDescriptions()
.append("store/order", "Petstore orders")
.append("store/inventory", "Petstore inventory")
@@ -517,15 +513,13 @@ public class PetStoreResource extends BasicRestServletJena {
}
@RestMethod(
- name="POST",
- path="/user",
summary="Create user",
description="This can only be done by the logged in user.",
swagger=@MethodSwagger(
tags="user"
)
)
- public Ok createUser(
+ public Ok postUser(
@Body(description="Created user object") User user
) throws InvalidUsername, IdConflict, NotAcceptable, UnsupportedMediaType {
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/CallbackStringsTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/CallbackStringsTest.java
index b3f865d..9bb33ae 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/CallbackStringsTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/CallbackStringsTest.java
@@ -34,11 +34,11 @@ public class CallbackStringsTest {
@RestResource
public static class A {
- @RestMethod(name=GET)
+ @RestMethod(name=GET,path="/*")
public ObjectMap get(RestRequest req) throws Exception {
return new ObjectMap().append("method","GET").append("headers", getFooHeaders(req)).append("content", req.getBody().asString());
}
- @RestMethod(name=PUT)
+ @RestMethod(name=PUT,path="/*")
public ObjectMap put(RestRequest req) throws Exception {
return new ObjectMap().append("method","PUT").append("headers", getFooHeaders(req)).append("content", req.getBody().asString());
}
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ClientFuturesTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ClientFuturesTest.java
index 1a5fad4..79812fa 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ClientFuturesTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ClientFuturesTest.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.test.client;
-import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.rest.testutils.TestUtils.*;
import static org.junit.Assert.*;
@@ -35,7 +34,7 @@ public class ClientFuturesTest {
@RestResource
public static class A {
- @RestMethod(name=GET)
+ @RestMethod
public ObjectMap get(RestRequest req) throws Exception {
return new ObjectMap().append("foo","bar");
}
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/FormDataTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/FormDataTest.java
index 5bd95fc..0ed3e18 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/FormDataTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/FormDataTest.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.test.client;
-import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.internal.IOUtils.*;
import static org.junit.Assert.*;
@@ -37,8 +36,8 @@ public class FormDataTest extends RestTestcase {
//=================================================================================================================
public static class A {
- @RestMethod(name=POST)
- public Reader test(RestRequest req) throws IOException {
+ @RestMethod
+ public Reader post(RestRequest req) throws IOException {
return new StringReader("Content-Type=["+req.getContentType()+"], contents=["+read(req.getReader())+"]");
}
}
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java
index fd10ef9..effcb16 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/RequestBeanProxyTest.java
@@ -901,7 +901,7 @@ public class RequestBeanProxyTest {
@RestResource
public static class G {
- @RestMethod(name=GET)
+ @RestMethod(name=GET,path="/*")
public String echoPath(RestRequest req) throws Exception {
return req.getPathMatch().getRemainder();
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
index 8021822..619d14b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
@@ -21,6 +21,7 @@ import static org.apache.juneau.internal.Utils.*;
import static org.apache.juneau.rest.RestContext.*;
import static org.apache.juneau.rest.util.RestUtils.*;
+import java.beans.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
@@ -189,17 +190,39 @@ public class RestJavaMethod implements Comparable<RestJavaMethod> {
pgb.append(mParsers);
}
+ String p = m.path();
+ if (isEmpty(p)) {
+ p = method.getName();
+ if (m.name().equals("")) {
+ for (String t : new String[]{"get","put","post","delete","options","head","connect","trace","patch"}) {
+ if (p.startsWith(t)) {
+ p = Introspector.decapitalize(p.substring(t.length()));
+ break;
+ }
+ }
+ if (p.equals(""))
+ p = "/";
+ }
+ }
+
httpMethod = m.name().toUpperCase(Locale.ENGLISH);
if (httpMethod.equals("") && method.getName().startsWith("do"))
httpMethod = method.getName().substring(2).toUpperCase(Locale.ENGLISH);
- if (httpMethod.equals(""))
+ if (httpMethod.equals("")) {
+ String mn = method.getName();
httpMethod = "GET";
+ for (String t : new String[]{"get","put","post","delete","options","head","connect","trace","patch"}) {
+ if (mn.startsWith(t)) {
+ httpMethod = t.toUpperCase();
+ break;
+ }
+ }
+ }
if (httpMethod.equals("METHOD"))
httpMethod = "*";
priority = m.priority();
- String p = m.path();
converters = new RestConverter[m.converters().length];
for (int i = 0; i < converters.length; i++)
converters[i] = beanContext.newInstance(RestConverter.class, m.converters()[i]);
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
index af7fa5d..497086c 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
@@ -570,21 +570,59 @@ public @interface RestMethod {
* pattern is not found.
*
* <p>
- * The path can contain variables that get resolved to {@link Path @Path} parameters:
+ * The path can contain variables that get resolved to {@link Path @Path} parameters.
+ *
+ * <h5 class='figure'>Examples:</h5>
* <p class='bcode w800'>
- * <jc>// Example 1</jc>
* <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/myurl/{foo}/{bar}/{baz}/*"</js>)
- *
- * <jc>// Example 2</jc>
+ * </p>
+ * <p class='bcode w800'>
* <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/myurl/{0}/{1}/{2}/*"</js>)
* </p>
*
+ * <p>
+ * If you do not specify a path name, then the path name is inferred from the Java method name.
+ *
+ * <h5 class='figure'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Path is assumed to be "/foo".</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>)
+ * <jk>public void</jk> foo() {...}
+ * </p>
+ *
+ * <p>
+ * If you also do not specify the {@link #name()} and the Java method name starts with <js>"get"</js>, <js>"put"</js>, <js>"post"</js>, or <js>"deleted"</js>,
+ * then the HTTP method name is stripped from the inferred path.
+ *
+ * <h5 class='figure'>Examples:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Method is GET, path is "/foo".</jc>
+ * <ja>@RestMethod</ja>
+ * <jk>public void</jk> getFoo() {...}
+ * </p>
+ * <p class='bcode w800'>
+ * <jc>// Method is DELETE, path is "/bar".</jc>
+ * <ja>@RestMethod</ja>
+ * <jk>public void</jk> deleteBar() {...}
+ * </p>
+ * <p class='bcode w800'>
+ * <jc>// Method is GET, path is "/foobar".</jc>
+ * <ja>@RestMethod</ja>
+ * <jk>public void</jk> foobar() {...}
+ * </p>
+ * <p class='bcode w800'>
+ * <jc>// Method is GET, path is "/".</jc>
+ * <ja>@RestMethod</ja>
+ * <jk>public void</jk> get() {...}
+ * </p>
+ *
+ *
* <h5 class='section'>See Also:</h5>
* <ul>
* <li class='ja'>{@link Path}
* </ul>
*/
- String path() default "/*";
+ String path() default "";
/**
* Sets the POJO swaps for the serializers and parsers defined on this method.
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java
index 60bb16d..19fb9ea 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java
@@ -29,6 +29,6 @@ public class UseProxy {
@Override /* Object */
public String toString() {
- return "OK";
+ return "Use Proxy";
}
}
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java
index 261906d..d392b86 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java
@@ -83,8 +83,8 @@ public class NlsTest {
@RestResource(title="test")
public static class B {
- @RestMethod(name=OPTIONS, description="foo")
- public Swagger testOptions(RestRequest req) {
+ @RestMethod(description="foo")
+ public Swagger options(RestRequest req) {
// Should get to the options page without errors
return req.getSwagger();
}
@@ -102,7 +102,7 @@ public class NlsTest {
@RestResource
public static class C {
- @RestMethod(name=GET)
+ @RestMethod
public String test(RestRequest req) {
// Missing resource bundle should cause {!!x} string.
return req.getMessage("bad", 1, 2, 3);
@@ -112,6 +112,6 @@ public class NlsTest {
@Test
public void c01_missingResourceBundle() throws Exception {
- c.get("/").execute().assertBody("{!!bad}");
+ c.get("/test").execute().assertBody("{!!bad}");
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/PathsTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/PathsTest.java
index 40fd1d6..026ef15 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/PathsTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/PathsTest.java
@@ -51,7 +51,7 @@ public class PathsTest {
@RestResource
public static class A {
- @RestMethod(name=GET)
+ @RestMethod(name=GET,path="/*")
public ObjectMap get(RestRequest req, @Path("/*") String r) {
return getPaths(req).append("pathRemainder2", r).append("method",1);
}
@@ -351,7 +351,7 @@ public class PathsTest {
@RestResource(path="/a")
public static class C01 {
- @RestMethod(name=GET)
+ @RestMethod(name=GET,path="/*")
public ObjectMap get(RestRequest req, @Path("/*") String r) {
return getPaths(req).append("pathRemainder2", r).append("method",3);
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/StatusCodesTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
index 026e24a..3e75a04 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/StatusCodesTest.java
@@ -44,7 +44,7 @@ public class StatusCodesTest {
@Test
public void a01a_OK() throws Exception {
- a.put("/", "foo").execute().assertStatus(200);
+ a.put("/a01", "foo").execute().assertStatus(200);
}
//=================================================================================================================
@@ -238,10 +238,10 @@ public class StatusCodesTest {
@Test
public void d01() throws Exception {
- d.get("/?noTrace=true").execute()
+ d.get("/d?noTrace=true").execute()
.assertStatus(412)
.assertBodyContains(
- "Method 'GET' not found on resource on path '/' with matching matcher."
+ "Method 'GET' not found on resource on path '/d' with matching matcher."
);
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java
index 2c82908..4076780 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/BodyAnnotationTest.java
@@ -691,7 +691,7 @@ public class BodyAnnotationTest {
@RestResource(serializers=UrlEncodingSerializer.class,parsers=UrlEncodingParser.class)
public static class G {
- @RestMethod(name=POST)
+ @RestMethod(name=POST,path="/")
public DTOs.C g(@Body DTOs.C content) throws Exception {
return content;
}
@@ -732,7 +732,7 @@ public class BodyAnnotationTest {
@RestResource(serializers=UrlEncodingSerializer.class,parsers=UrlEncodingParser.class)
public static class H {
- @RestMethod(name=POST,
+ @RestMethod(name=POST,path="/",
properties={
@Property(name=UrlEncodingSerializer.URLENC_expandedParams, value="true"),
@Property(name=UrlEncodingParser.URLENC_expandedParams, value="true")
@@ -776,7 +776,7 @@ public class BodyAnnotationTest {
@RestResource(serializers=JsonSerializer.class,parsers=JsonParser.class)
public static class I {
- @RestMethod(name=POST)
+ @RestMethod(name=POST,path="/")
public DTOs.B g(@Body(required=true) DTOs.B content) throws Exception {
return content;
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
index 5ba82e9..7426cd5 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/FormDataAnnotationTest.java
@@ -51,7 +51,7 @@ public class FormDataAnnotationTest {
@RestResource(parsers=UrlEncodingParser.class)
public static class A {
- @RestMethod(name=POST)
+ @RestMethod
public String post(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)+"]";
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasFormDataAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasFormDataAnnotationTest.java
index 44c8073..5440f6a 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasFormDataAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasFormDataAnnotationTest.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.annotation;
-import static org.apache.juneau.http.HttpMethodName.*;
-
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.mock.*;
@@ -33,7 +31,7 @@ public class HasFormDataAnnotationTest {
@RestResource
public static class A {
- @RestMethod(name=POST)
+ @RestMethod
public String post(RestRequest req, @HasFormData("p1") boolean p1, @HasFormData("p2") Boolean p2) throws Exception {
RequestFormData f = req.getFormData();
return "p1=["+p1+","+f.containsKey("p1")+"],p2=["+p2+","+f.containsKey("p2")+"]";
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasQueryAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasQueryAnnotationTest.java
index 9b7b652..7e59e20 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasQueryAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/HasQueryAnnotationTest.java
@@ -33,12 +33,12 @@ public class HasQueryAnnotationTest {
@RestResource
public static class A {
- @RestMethod(name=GET)
+ @RestMethod(name=GET,path="/")
public String get(RestRequest req, @HasQuery("p1") boolean p1, @HasQuery("p2") Boolean p2) throws Exception {
RequestQuery q = req.getQuery();
return "p1=["+p1+","+q.containsKey("p1")+"],p2=["+p2+","+q.containsKey("p2")+"]";
}
- @RestMethod(name=POST)
+ @RestMethod(name=POST,path="/")
public String post(RestRequest req, @HasQuery("p1") boolean p1, @HasQuery("p2") Boolean p2) throws Exception {
RequestQuery q = req.getQuery();
return "p1=["+p1+","+q.containsKey("p1")+"],p2=["+p2+","+q.containsKey("p2")+"]";
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
index 0106b41..ea28f9b 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/QueryAnnotationTest.java
@@ -52,12 +52,12 @@ public class QueryAnnotationTest {
@RestResource
public static class A {
- @RestMethod(name=GET)
+ @RestMethod
public String get(RestRequest req, @Query(name="p1",allowEmptyValue=true) String p1, @Query(name="p2",allowEmptyValue=true) int p2) throws Exception {
RequestQuery q = req.getQuery();
return "p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
}
- @RestMethod(name=POST)
+ @RestMethod
public String post(RestRequest req, @Query(name="p1",allowEmptyValue=true) String p1, @Query(name="p2",allowEmptyValue=true) int p2) throws Exception {
RequestQuery q = req.getQuery();
return "p1=["+p1+","+req.getQuery().getString("p1")+","+q.get("p1", String.class)+"],p2=["+p2+","+q.getString("p2")+","+q.get("p2", int.class)+"]";
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestHookTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestHookTest.java
index 489c0ea..3402a51 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestHookTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestHookTest.java
@@ -238,7 +238,7 @@ public class RestHookTest {
public void init2a() {
events.add("super-2a");
}
- @RestMethod(name=GET)
+ @RestMethod
public ObjectList getEvents() {
return events;
}
@@ -282,9 +282,9 @@ public class RestHookTest {
@Test
public void c01_init() throws Exception {
- c.get("/super").execute().assertBody("['super-1a','super-1b','super-1c','super-2a']");
- c.get("/sub").execute().assertBody("['sub-1a','sub-1b','sub-1c','super-2a','sub-2b']");
- c.get("/sub/child").execute().assertBody("['super-1a','super-1b','child-1c','super-2a','child-2b']");
+ c.get("/super/events").execute().assertBody("['super-1a','super-1b','super-1c','super-2a']");
+ c.get("/sub/events").execute().assertBody("['sub-1a','sub-1b','sub-1c','super-2a','sub-2b']");
+ c.get("/sub/child/events").execute().assertBody("['super-1a','super-1b','child-1c','super-2a','child-2b']");
}
//====================================================================================================
@@ -313,7 +313,7 @@ public class RestHookTest {
public void postInit2a() {
events.add("super-2a");
}
- @RestMethod(name=GET)
+ @RestMethod
public ObjectList getEvents() {
return events;
}
@@ -345,7 +345,7 @@ public class RestHookTest {
public void postInitOrderTestSub() {
LAST_CALLED = "PARENT";
}
- @RestMethod(name=GET, path="/lastCalled")
+ @RestMethod
public String getLastCalled() {
return LAST_CALLED;
}
@@ -370,9 +370,9 @@ public class RestHookTest {
@Test
public void d01_postInit() throws Exception {
- d.get("/super").execute().assertBody("['super-1a','super-1b','super-1c','super-2a']");
- d.get("/sub").execute().assertBody("['sub-1a','sub-1b','sub-1c','super-2a','sub-2b']");
- d.get("/sub/child").execute().assertBody("['super-1a','super-1b','child-1c','super-2a','child-2b']");
+ d.get("/super/events").execute().assertBody("['super-1a','super-1b','super-1c','super-2a']");
+ d.get("/sub/events").execute().assertBody("['sub-1a','sub-1b','sub-1c','super-2a','sub-2b']");
+ d.get("/sub/child/events").execute().assertBody("['super-1a','super-1b','child-1c','super-2a','child-2b']");
}
@Test
public void d02_postInit_order() throws Exception {
@@ -411,7 +411,7 @@ public class RestHookTest {
public void postInitChildFirst2a() {
events.add("super-2a");
}
- @RestMethod(name=GET)
+ @RestMethod
public ObjectList getPostInitChildFirstEvents() {
return events;
}
@@ -443,7 +443,7 @@ public class RestHookTest {
public void postInitChildFirstOrderTestSub() {
LAST_CALLED = "PARENT";
}
- @RestMethod(name=GET, path="/lastCalled")
+ @RestMethod
public String getLastCalled() {
return LAST_CALLED;
}
@@ -468,9 +468,9 @@ public class RestHookTest {
@Test
public void e01_postInitChildFirst() throws Exception {
- e.get("/super").execute().assertBody("['super-1a','super-1b','super-1c','super-2a']");
- e.get("/sub").execute().assertBody("['sub-1a','sub-1b','sub-1c','super-2a','sub-2b']");
- e.get("/sub/child").execute().assertBody("['super-1a','super-1b','child-1c','super-2a','child-2b']");
+ e.get("/super/postInitChildFirstEvents").execute().assertBody("['super-1a','super-1b','super-1c','super-2a']");
+ e.get("/sub/postInitChildFirstEvents").execute().assertBody("['sub-1a','sub-1b','sub-1c','super-2a','sub-2b']");
+ e.get("/sub/child/postInitChildFirstEvents").execute().assertBody("['super-1a','super-1b','child-1c','super-2a','child-2b']");
}
@Test
public void e02_postInitChildFirst_order() throws Exception {
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java
index 0d12205..0c252b9 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/annotation/RestResourceMessagesTest.java
@@ -55,7 +55,7 @@ public class RestResourceMessagesTest {
@Test
public void a01() throws Exception {
// Parent resource should just pick up values from its bundle.
- a.get("/").execute().assertBody("{key1:'value1a',key2:'value2a'}");
+ a.get("/test").execute().assertBody("{key1:'value1a',key2:'value2a'}");
}
//====================================================================================================
@@ -70,6 +70,6 @@ public class RestResourceMessagesTest {
public void b01() throws Exception {
// Child resource should pick up values from both parent and child,
// ordered child before parent.
- b.get("/").execute().assertBody("{key1:'value1a',key2:'value2b',key3:'value3b'}");
+ b.get("/test").execute().assertBody("{key1:'value1a',key2:'value2b',key3:'value3b'}");
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java
index 5a18705..9420ac0 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptCharsetTest.java
@@ -39,7 +39,7 @@ public class AcceptCharsetTest {
@RestResource(defaultCharset="utf-8",serializers=PlainTextSerializer.class)
public static class A {
- @RestMethod(name=GET)
+ @RestMethod
public String qValues() {
return "foo";
}
@@ -48,17 +48,17 @@ public class AcceptCharsetTest {
@Test
public void a01_qValues() throws Exception {
- a.get("/").accept("text/plain").acceptCharset("utf-8").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("iso-8859-1").execute().assertCharset("iso-8859-1");
- a.get("/").accept("text/plain").acceptCharset("bad,utf-8").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("utf-8,bad").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("bad;q=0.9,utf-8;q=0.1").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("bad;q=0.1,utf-8;q=0.9").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("utf-8;q=0.9,iso-8859-1;q=0.1").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("utf-8;q=0.1,iso-8859-1;q=0.9").execute().assertCharset("iso-8859-1");
- a.get("/").accept("text/plain").acceptCharset("*").execute().assertCharset("utf-8");
- a.get("/").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.5,*;q=0.1").execute().assertCharset("iso-8859-1");
- a.get("/").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.1,*;q=0.5").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("utf-8").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("iso-8859-1").execute().assertCharset("iso-8859-1");
+ a.get("/qValues").accept("text/plain").acceptCharset("bad,utf-8").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("utf-8,bad").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("bad;q=0.9,utf-8;q=0.1").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("bad;q=0.1,utf-8;q=0.9").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("utf-8;q=0.9,iso-8859-1;q=0.1").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("utf-8;q=0.1,iso-8859-1;q=0.9").execute().assertCharset("iso-8859-1");
+ a.get("/qValues").accept("text/plain").acceptCharset("*").execute().assertCharset("utf-8");
+ a.get("/qValues").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.5,*;q=0.1").execute().assertCharset("iso-8859-1");
+ a.get("/qValues").accept("text/plain").acceptCharset("bad,iso-8859-1;q=0.1,*;q=0.5").execute().assertCharset("utf-8");
}
//=================================================================================================================
@@ -110,12 +110,12 @@ public class AcceptCharsetTest {
@Test
public void b01_testCharsetOnResponse() throws Exception {
- b.put("/", null).plainText().execute().assertBody("utf-8/utf-8");
- b.put("/", null).plainText().acceptCharset("Shift_JIS").execute().assertBody("utf-8/Shift_JIS");
- b.put("?noTrace=true", null).plainText().acceptCharset("BAD").execute().assertStatus(406).assertBodyContains("No supported charsets in header 'Accept-Charset': 'BAD'");
- b.put("/", null).plainText().acceptCharset("UTF-8").execute().assertBody("utf-8/UTF-8");
- b.put("/", null).plainText().acceptCharset("bad,iso-8859-1").execute().assertBody("utf-8/iso-8859-1");
- b.put("/", null).plainText().acceptCharset("bad;q=0.9,iso-8859-1;q=0.1").execute().assertBody("utf-8/iso-8859-1");
- b.put("/", null).plainText().acceptCharset("bad;q=0.1,iso-8859-1;q=0.9").execute().assertBody("utf-8/iso-8859-1");
+ b.put("/charsetOnResponse", null).plainText().execute().assertBody("utf-8/utf-8");
+ b.put("/charsetOnResponse", null).plainText().acceptCharset("Shift_JIS").execute().assertBody("utf-8/Shift_JIS");
+ b.put("/charsetOnResponse?noTrace=true", null).plainText().acceptCharset("BAD").execute().assertStatus(406).assertBodyContains("No supported charsets in header 'Accept-Charset': 'BAD'");
+ b.put("/charsetOnResponse", null).plainText().acceptCharset("UTF-8").execute().assertBody("utf-8/UTF-8");
+ b.put("/charsetOnResponse", null).plainText().acceptCharset("bad,iso-8859-1").execute().assertBody("utf-8/iso-8859-1");
+ b.put("/charsetOnResponse", null).plainText().acceptCharset("bad;q=0.9,iso-8859-1;q=0.1").execute().assertBody("utf-8/iso-8859-1");
+ b.put("/charsetOnResponse", null).plainText().acceptCharset("bad;q=0.1,iso-8859-1;q=0.9").execute().assertBody("utf-8/iso-8859-1");
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
index acc90f0..adfd2cc 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptEncodingTest.java
@@ -49,7 +49,7 @@ public class AcceptEncodingTest {
@RestResource
public static class A {
- @RestMethod(name=GET)
+ @RestMethod
public String get() {
return "foo";
}
@@ -120,7 +120,7 @@ public class AcceptEncodingTest {
@RestResource(encoders=MyEncoder.class)
public static class B {
- @RestMethod(name=GET)
+ @RestMethod(name=GET,path="/")
public String test1() {
return "foo";
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
index 9dc3bec..c9483b8 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/AcceptTest.java
@@ -64,8 +64,8 @@ public class AcceptTest {
serializers={S1.class,S2.class}
)
public static class A {
- @RestMethod(name=PUT)
- public String a01(@Body String in) {
+ @RestMethod
+ public String putA01(@Body String in) {
return in;
}
}
@@ -73,14 +73,14 @@ public class AcceptTest {
@Test
public void a01_defaultHeadersOnServletAnnotation_valid() throws Exception {
- a.put("/", null).execute().assertBody("s2");
- a.put("/", null).accept("text/s1").execute().assertBody("s1");
- a.put("/", null).accept("text/s2").execute().assertBody("s2");
+ a.put("/a01", null).execute().assertBody("s2");
+ a.put("/a01", null).accept("text/s1").execute().assertBody("s1");
+ a.put("/a01", null).accept("text/s2").execute().assertBody("s2");
}
@Test
public void a02_defaultHeadersOnServletAnnotation_invalid() throws Exception {
- a.put("?noTrace=true", null).accept("text/s3").execute().assertStatus(406).assertBodyContains("Unsupported media-type in request header 'Accept': 'text/s3'");
+ a.put("/a01?noTrace=true", null).accept("text/s3").execute().assertStatus(406).assertBodyContains("Unsupported media-type in request header 'Accept': 'text/s3'");
}
//=================================================================================================================
@@ -102,12 +102,12 @@ public class AcceptTest {
@Test
public void b01_restMethodWithParsersSerializers_valid() throws Exception {
- b.put("/", null).accept("text/s3").execute().assertBody("s3");
+ b.put("/b", null).accept("text/s3").execute().assertBody("s3");
}
@Test
public void b02_restMethodWithParsersSerializers_invalid() throws Exception {
- b.put("?noTrace=true", null).accept("text/s4").execute()
+ b.put("/b?noTrace=true", null).accept("text/s4").execute()
.assertStatus(406)
.assertBodyContains(
"Unsupported media-type in request header 'Accept': 'text/s4'",
@@ -134,15 +134,15 @@ public class AcceptTest {
@Test
public void c01_restMethodAddParsersSerializersInherit() throws Exception {
- c.put("/", null).execute().assertBody("s2");
- c.put("/", null).accept("text/s1").execute().assertBody("s1");
- c.put("/", null).accept("text/s2").execute().assertBody("s2");
- c.put("/", null).accept("text/s3").execute().assertBody("s3");
+ c.put("/c", null).execute().assertBody("s2");
+ c.put("/c", null).accept("text/s1").execute().assertBody("s1");
+ c.put("/c", null).accept("text/s2").execute().assertBody("s2");
+ c.put("/c", null).accept("text/s3").execute().assertBody("s3");
}
@Test
public void c02_restMethodAddParsersSerializersInherit_invalid() throws Exception {
- c.put("?noTrace=true", null).accept("text/s4").execute()
+ c.put("/c?noTrace=true", null).accept("text/s4").execute()
.assertStatus(406)
.assertBodyContains(
"Unsupported media-type in request header 'Accept': 'text/s4'",
@@ -169,17 +169,17 @@ public class AcceptTest {
@Test
public void d01_accept_valid() throws Exception {
// "*/*" should match the first serializer, not the default serializer.
- d.put("/", null).accept("*/*").execute().assertBody("s1");
+ d.put("/d", null).accept("*/*").execute().assertBody("s1");
// "text/*" should match the first serializer, not the default serializer.
- d.put("/", null).accept("text/*").execute().assertBody("s1");
- d.put("/", null).accept("bad/*,text/*").execute().assertBody("s1");
- d.put("/", null).accept("text/*,bad/*").execute().assertBody("s1");
- d.put("/", null).accept("text/s1;q=0.5,text/s2").execute().assertBody("s2");
- d.put("/", null).accept("text/s1,text/s2;q=0.5").execute().assertBody("s1");
+ d.put("/d", null).accept("text/*").execute().assertBody("s1");
+ d.put("/d", null).accept("bad/*,text/*").execute().assertBody("s1");
+ d.put("/d", null).accept("text/*,bad/*").execute().assertBody("s1");
+ d.put("/d", null).accept("text/s1;q=0.5,text/s2").execute().assertBody("s2");
+ d.put("/d", null).accept("text/s1,text/s2;q=0.5").execute().assertBody("s1");
}
@Test
public void d02_accept_invalid() throws Exception {
- d.put("?noTrace=true", null).accept("bad/*").execute()
+ d.put("/d?noTrace=true", null).accept("bad/*").execute()
.assertStatus(406)
.assertBodyContains(
"Unsupported media-type in request header 'Accept': 'bad/*'",
@@ -198,7 +198,7 @@ public class AcceptTest {
)
public static class E {
@RestMethod(name=PUT, defaultRequestHeaders={"Accept: text/s3"}, serializers=S3.class)
- public String e(@Body String in) {
+ public String d(@Body String in) {
return in;
}
}
@@ -206,18 +206,18 @@ public class AcceptTest {
@Test
public void e01_restMethodParserSerializerAnnotations_valid() throws Exception {
- e.put("/", null).execute().assertBody("s3");
- e.put("/", null).accept("text/s3").execute().assertBody("s3");
+ e.put("/d", null).execute().assertBody("s3");
+ e.put("/d", null).accept("text/s3").execute().assertBody("s3");
}
@Test
public void e02_restMethodParserSerializerAnnotations_invalid() throws Exception {
- e.put("?noTrace=true", null).accept("text/s1").execute()
+ e.put("/d?noTrace=true", null).accept("text/s1").execute()
.assertStatus(406)
.assertBodyContains(
"Unsupported media-type in request header 'Accept': 'text/s1'",
"Supported media-types: ['text/s3']"
);
- e.put("?noTrace=true", null).accept("text/s2").execute()
+ e.put("/d?noTrace=true", null).accept("text/s2").execute()
.assertStatus(406)
.assertBodyContains(
"Unsupported media-type in request header 'Accept': 'text/s2'",
@@ -244,9 +244,9 @@ public class AcceptTest {
@Test
public void f01_restMethodAddParsersSerializersAnnotations_valid() throws Exception {
- f.put("/", null).execute().assertBody("s3");
- f.put("/", null).accept("text/s1").execute().assertBody("s1");
- f.put("/", null).accept("text/s2").execute().assertBody("s2");
- f.put("/", null).accept("text/s3").execute().assertBody("s3");
+ f.put("/f", null).execute().assertBody("s3");
+ f.put("/f", null).accept("text/s1").execute().assertBody("s1");
+ f.put("/f", null).accept("text/s2").execute().assertBody("s2");
+ f.put("/f", null).accept("text/s3").execute().assertBody("s3");
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java
index 71e95eb..2101d96 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentEncodingTest.java
@@ -46,7 +46,7 @@ public class ContentEncodingTest {
@RestResource
public static class A {
- @RestMethod(name=PUT)
+ @RestMethod
public String put(@Body String in) {
return in;
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
index b03a0b5..f760717 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/ContentTypeTest.java
@@ -75,14 +75,14 @@ public class ContentTypeTest {
@Test
public void a01_defaultHeadersOnServletAnnotation_valid() throws Exception {
- a.put("/", null).execute().assertBody("p2");
- a.put("/", null).contentType("text/p1").execute().assertBody("p1");
- a.put("/", null).contentType("text/p2").execute().assertBody("p2");
+ a.put("/a01", null).execute().assertBody("p2");
+ a.put("/a01", null).contentType("text/p1").execute().assertBody("p1");
+ a.put("/a01", null).contentType("text/p2").execute().assertBody("p2");
}
@Test
public void a02_defaultHeadersOnServletAnnotation_invalid() throws Exception {
- a.put("?noTrace=true", null).contentType("text/p3").execute().assertStatus(415).assertBodyContains("Unsupported media-type in request header 'Content-Type': 'text/p3'");
+ a.put("/a01?noTrace=true", null).contentType("text/p3").execute().assertStatus(415).assertBodyContains("Unsupported media-type in request header 'Content-Type': 'text/p3'");
}
//=================================================================================================================
@@ -104,24 +104,24 @@ public class ContentTypeTest {
@Test
public void b01_restMethodWithParsersSerializers_valid() throws Exception {
- b.put("/", null).contentType("text/p3").execute().assertBody("p3");
+ b.put("/b", null).contentType("text/p3").execute().assertBody("p3");
}
@Test
public void b02_restMethodWithParsersSerializers_invalid() throws Exception {
- b.put("?noTrace=true", null).execute()
+ b.put("/b?noTrace=true", null).execute()
.assertStatus(415)
.assertBodyContains(
"Unsupported media-type in request header 'Content-Type': 'text/p2'",
"Supported media-types: ['text/p3']"
);
- b.put("?noTrace=true", null).contentType("text/p1").execute()
+ b.put("/b?noTrace=true", null).contentType("text/p1").execute()
.assertStatus(415)
.assertBodyContains(
"Unsupported media-type in request header 'Content-Type': 'text/p1'",
"Supported media-types: ['text/p3']"
);
- b.put("?noTrace=true", null).contentType("text/p2").execute()
+ b.put("/b?noTrace=true", null).contentType("text/p2").execute()
.assertStatus(415)
.assertBodyContains(
"Unsupported media-type in request header 'Content-Type': 'text/p2'",
@@ -148,15 +148,15 @@ public class ContentTypeTest {
@Test
public void c01_restMethodAddParsersSerializersInherit() throws Exception {
- c.put("/", null).execute().assertBody("p2");
- c.put("/", null).contentType("text/p1").execute().assertBody("p1");
- c.put("/", null).contentType("text/p2").execute().assertBody("p2");
- c.put("/", null).contentType("text/p3").execute().assertBody("p3");
+ c.put("/c", null).execute().assertBody("p2");
+ c.put("/c", null).contentType("text/p1").execute().assertBody("p1");
+ c.put("/c", null).contentType("text/p2").execute().assertBody("p2");
+ c.put("/c", null).contentType("text/p3").execute().assertBody("p3");
}
@Test
public void c02_restMethodAddParsersSerializersInherit_invalid() throws Exception {
- c.put("?noTrace=true", null).contentType("text/p4").execute()
+ c.put("/c?noTrace=true", null).contentType("text/p4").execute()
.assertStatus(415)
.assertBodyContains(
"Unsupported media-type in request header 'Content-Type': 'text/p4'",
@@ -183,18 +183,18 @@ public class ContentTypeTest {
@Test
public void e01_restMethodParserSerializerAnnotations_valid() throws Exception {
- e.put("/", null).execute().assertBody("p3");
- e.put("/", null).contentType("text/p3").execute().assertBody("p3");
+ e.put("/e", null).execute().assertBody("p3");
+ e.put("/e", null).contentType("text/p3").execute().assertBody("p3");
}
@Test
public void e02_restMethodParserSerializerAnnotations_invalid() throws Exception {
- e.put("?noTrace=true", null).contentType("text/p1").execute()
+ e.put("/e?noTrace=true", null).contentType("text/p1").execute()
.assertStatus(415)
.assertBodyContains(
"Unsupported media-type in request header 'Content-Type': 'text/p1'",
"Supported media-types: ['text/p3']"
);
- e.put("?noTrace=true", null).contentType("text/p2").execute()
+ e.put("/e?noTrace=true", null).contentType("text/p2").execute()
.assertStatus(415)
.assertBodyContains(
"Unsupported media-type in request header 'Content-Type': 'text/p2'",
@@ -222,9 +222,9 @@ public class ContentTypeTest {
@Test
public void f01_restMethodAddParsersSerializersAnnotations_valid() throws Exception {
- f.put("/", null).execute().assertBody("p3");
- f.put("/", null).contentType("text/p1").execute().assertBody("p1");
- f.put("/", null).contentType("text/p2").execute().assertBody("p2");
- f.put("/", null).contentType("text/p3").execute().assertBody("p3");
+ f.put("/f", null).execute().assertBody("p3");
+ f.put("/f", null).contentType("text/p1").execute().assertBody("p1");
+ f.put("/f", null).contentType("text/p2").execute().assertBody("p2");
+ f.put("/f", null).contentType("text/p3").execute().assertBody("p3");
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java
index ced9a48..72318d6 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/headers/HeadersTest.java
@@ -411,7 +411,7 @@ public class HeadersTest {
@RestResource(paramResolvers=CustomHeaderParam.class)
public static class B {
- @RestMethod(name=GET)
+ @RestMethod
public String customHeader(CustomHeader customHeader) {
return customHeader.toString();
}
@@ -441,11 +441,11 @@ public class HeadersTest {
@Test
public void b01a_customHeader() throws Exception {
- b.get("/").header("Custom", "foo").execute().assertBody("foo");
+ b.get("/customHeader").header("Custom", "foo").execute().assertBody("foo");
}
@Test
public void b01b_customHeader_query() throws Exception {
- b.get("?Custom=foo").execute().assertBody("foo");
+ b.get("/customHeader?Custom=foo").execute().assertBody("foo");
}
//====================================================================================================
@@ -454,7 +454,7 @@ public class HeadersTest {
@RestResource
public static class C {
- @RestMethod(name=GET, defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ @RestMethod(defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
public ObjectMap c(RequestHeaders headers) {
return new ObjectMap()
.append("h1", headers.getString("H1"))
@@ -466,15 +466,15 @@ public class HeadersTest {
@Test
public void c01_defaultRequestHeaders_default() throws Exception {
- c.get("/").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
+ c.get("/c").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
}
@Test
public void c02_defaultRequestHeaders_override() throws Exception {
- c.get("/").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ c.get("/c").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void c03_defaultRequestHeaders_override_caseInsensitive() throws Exception {
- c.get("/").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ c.get("/c").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
//====================================================================================================
@@ -483,7 +483,7 @@ public class HeadersTest {
@RestResource
public static class D {
- @RestMethod(name=GET, defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ @RestMethod(defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
public ObjectMap d(RequestHeaders headers) {
return new ObjectMap()
.append("h1", headers.getString("h1"))
@@ -495,15 +495,15 @@ public class HeadersTest {
@Test
public void d01_defaultRequestHeadersCaseInsensitive_default() throws Exception {
- d.get("/").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
+ d.get("/d").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
}
@Test
public void d02_defaultRequestHeadersCaseInsensitive_override() throws Exception {
- d.get("/").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ d.get("/d").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void d03_defaultRequestHeadersCaseInsensitive_override_caseInsensitive() throws Exception {
- d.get("/").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ d.get("/d").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
//====================================================================================================
@@ -512,7 +512,7 @@ public class HeadersTest {
@RestResource
public static class E {
- @RestMethod(name=GET)
+ @RestMethod
public ObjectMap e(@Header(name="H1") String h1, @Header("H2") String h2, @Header("H3") String h3) {
return new ObjectMap()
.append("h1", h1)
@@ -524,15 +524,15 @@ public class HeadersTest {
@Test
public void e01_annotatedHeaders_default() throws Exception {
- e.get("/").execute().assertBody("{h1:null,h2:null,h3:null}");
+ e.get("/e").execute().assertBody("{h1:null,h2:null,h3:null}");
}
@Test
public void e02_annotatedHeaders_override() throws Exception {
- e.get("/").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ e.get("/e").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void e03_annotatedHeaders_override_caseInsensitive() throws Exception {
- e.get("/").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ e.get("/e").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
//====================================================================================================
@@ -541,7 +541,7 @@ public class HeadersTest {
@RestResource
public static class F {
- @RestMethod(name=GET)
+ @RestMethod
public ObjectMap f(@Header("h1") String h1, @Header("h2") String h2, @Header("h3") String h3) {
return new ObjectMap()
.append("h1", h1)
@@ -553,15 +553,15 @@ public class HeadersTest {
@Test
public void f01_annotatedHeadersCaseInsensitive_default() throws Exception {
- f.get("/").execute().assertBody("{h1:null,h2:null,h3:null}");
+ f.get("/f").execute().assertBody("{h1:null,h2:null,h3:null}");
}
@Test
public void f02_annotatedHeadersCaseInsensitive_override() throws Exception {
- f.get("/").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ f.get("/f").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void f03_annotatedHeadersCaseInsensitive_override_caseInsensitive() throws Exception {
- f.get("/").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ f.get("/f").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
//====================================================================================================
@@ -570,7 +570,7 @@ public class HeadersTest {
@RestResource
public static class G {
- @RestMethod(name=GET)
+ @RestMethod
public ObjectMap g(@Header(name="h1",_default="1") String h1, @Header(name="h2",_default="2") String h2, @Header(name="h3",_default="3") String h3) {
return new ObjectMap()
.append("h1", h1)
@@ -582,20 +582,20 @@ public class HeadersTest {
@Test
public void g01_annotatedHeadersDefault_default() throws Exception {
- g.get("/").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
+ g.get("/g").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
}
@Test
public void g02_annotatedHeadersDefault_override() throws Exception {
- g.get("/").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ g.get("/g").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void g03_annotatedHeadersDefault_override_caseInsensitive() throws Exception {
- g.get("/").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ g.get("/g").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@RestResource
public static class GB {
- @RestMethod(name=GET)
+ @RestMethod
public ObjectMap g(@Header(value="h1",_default="1") String h1, @Header(value="h2",_default="2") String h2, @Header(value="h3",_default="3") String h3) {
return new ObjectMap()
.append("h1", h1)
@@ -607,15 +607,15 @@ public class HeadersTest {
@Test
public void gb01_annotatedHeadersDefault_default() throws Exception {
- gb.get("/").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
+ gb.get("/g").execute().assertBody("{h1:'1',h2:'2',h3:'3'}");
}
@Test
public void gb02_annotatedHeadersDefault_override() throws Exception {
- gb.get("/").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ gb.get("/g").header("H1",4).header("H2",5).header("H3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void gb03_annotatedHeadersDefault_override_caseInsensitive() throws Exception {
- gb.get("/").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ gb.get("/g").header("h1",4).header("h2",5).header("h3",6).execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
//====================================================================================================
@@ -624,7 +624,7 @@ public class HeadersTest {
@RestResource
public static class H {
- @RestMethod(name=GET, defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ @RestMethod(defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
public ObjectMap h(@Header(value="h1",_default="4") String h1, @Header(value="h2",_default="5") String h2, @Header(value="h3",_default="6") String h3) {
return new ObjectMap()
.append("h1", h1)
@@ -636,14 +636,14 @@ public class HeadersTest {
@Test
public void h01_annotatedAndDefaultHeaders_default() throws Exception {
- h.get("/").execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
+ h.get("/h").execute().assertBody("{h1:'4',h2:'5',h3:'6'}");
}
@Test
public void h02_annotatedAndDefaultHeaders_override() throws Exception {
- h.get("/").header("H1",7).header("H2",8).header("H3",9).execute().assertBody("{h1:'7',h2:'8',h3:'9'}");
+ h.get("/h").header("H1",7).header("H2",8).header("H3",9).execute().assertBody("{h1:'7',h2:'8',h3:'9'}");
}
@Test
public void h03_annotatedAndDefaultHeaders_override_caseInsensitive() throws Exception {
- h.get("/").header("h1",7).header("h2",8).header("h3",9).execute().assertBody("{h1:'7',h2:'8',h3:'9'}");
+ h.get("/h").header("h1",7).header("h2",8).header("h3",9).execute().assertBody("{h1:'7',h2:'8',h3:'9'}");
}
}
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java
new file mode 100644
index 0000000..f301eaa
--- /dev/null
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java
@@ -0,0 +1,140 @@
+// ***************************************************************************************************************************
+// * 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.response;
+
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.mock.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class BasicTest {
+
+ @RestResource
+ 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(); }
+ }
+
+ static MockRest a = MockRest.create(A.class);
+
+ @Test
+ public void a01_accepted() throws Exception {
+ a.get("/accepted").execute().assertStatus(202).assertBody("Accepted");
+ }
+ @Test
+ public void a02_alreadyReported() throws Exception {
+ a.get("/alreadyReported").execute().assertStatus(208).assertBody("Already Reported");
+ }
+ @Test
+ public void a03_continue() throws Exception {
+ a.get("/continue").execute().assertStatus(100).assertBody("Continue");
+ }
+ @Test
+ public void a04_created() throws Exception {
+ a.get("/created").execute().assertStatus(201).assertBody("Created");
+ }
+ @Test
+ public void a05_earlyHints() throws Exception {
+ a.get("/earlyHints").execute().assertStatus(103).assertBody("Early Hints");
+ }
+ @Test
+ public void a06_found() throws Exception {
+ a.get("/found").execute().assertStatus(302).assertBody("Found");
+ }
+ @Test
+ public void a07_imUsed() throws Exception {
+ a.get("/imUsed").execute().assertStatus(226).assertBody("IM Used");
+ }
+ @Test
+ public void a08_movedPermanently() throws Exception {
+ a.get("/movedPermanently").execute().assertStatus(301).assertBody("Moved Permanently");
+ }
+ @Test
+ public void a09_multipleChoices() throws Exception {
+ a.get("/multipleChoices").execute().assertStatus(300).assertBody("Multiple Choices");
+ }
+ @Test
+ public void a10_multiStatus() throws Exception {
+ a.get("/multiStatus").execute().assertStatus(207).assertBody("Multi-Status");
+ }
+ @Test
+ public void a11_noContent() throws Exception {
+ a.get("/noContent").execute().assertStatus(204).assertBody("No Content");
+ }
+ @Test
+ public void a12_nonAuthoritiveInformation() throws Exception {
+ a.get("/nonAuthoritiveInformation").execute().assertStatus(203).assertBody("Non-Authoritative Information");
+ }
+ @Test
+ public void a13_notModified() throws Exception {
+ a.get("/notModified").execute().assertStatus(304).assertBody("Not Modified");
+ }
+ @Test
+ public void a14_ok() throws Exception {
+ a.get("/ok").execute().assertStatus(200).assertBody("OK");
+ }
+ @Test
+ public void a15_partialContent() throws Exception {
+ a.get("/partialContent").execute().assertStatus(206).assertBody("Partial Content");
+ }
+ @Test
+ public void a16_permanentRedirect() throws Exception {
+ a.get("/permanentRedirect").execute().assertStatus(308).assertBody("Permanent Redirect");
+ }
+ @Test
+ public void a17_processing() throws Exception {
+ a.get("/processing").execute().assertStatus(102).assertBody("Processing");
+ }
+ @Test
+ public void a18_resetContent() throws Exception {
+ a.get("/resetContent").execute().assertStatus(205).assertBody("Reset Content");
+ }
+ @Test
+ public void a19_seeOther() throws Exception {
+ a.get("/seeOther").execute().assertStatus(303).assertBody("See Other");
+ }
+ @Test
+ public void a20_switchingProtocols() throws Exception {
+ a.get("/switchingProtocols").execute().assertStatus(101).assertBody("Switching Protocols");
+ }
+ @Test
+ public void a21_temporaryRedirect() throws Exception {
+ a.get("/temporaryRedirect").execute().assertStatus(307).assertBody("Temporary Redirect");
+ }
+ @Test
+ public void a22_useProxy() throws Exception {
+ a.get("/useProxy").execute().assertStatus(305).assertBody("Use Proxy");
+ }
+}