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 2022/08/01 12:08:48 UTC
[juneau] branch jbFixRestNpe updated: @RestBean improvements
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch jbFixRestNpe
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/jbFixRestNpe by this push:
new 229731bf9 @RestBean improvements
229731bf9 is described below
commit 229731bf980953069338da2f0d1c71d16ce9ac12
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Mon Aug 1 08:07:59 2022 -0400
@RestBean improvements
---
.../org/apache/juneau/dto/openapi3/Contact.java | 4 +-
.../org/apache/juneau/dto/openapi3/Example.java | 4 +-
.../org/apache/juneau/dto/openapi3/HeaderInfo.java | 4 +-
.../java/org/apache/juneau/dto/openapi3/Info.java | 4 +-
.../java/org/apache/juneau/dto/openapi3/Items.java | 8 +-
.../org/apache/juneau/dto/openapi3/License.java | 4 +-
.../java/org/apache/juneau/dto/openapi3/Link.java | 4 +-
.../org/apache/juneau/dto/openapi3/OAuthFlow.java | 4 +-
.../org/apache/juneau/dto/openapi3/OAuthFlows.java | 4 +-
.../org/apache/juneau/dto/openapi3/SchemaInfo.java | 24 +-
.../juneau/dto/openapi3/SecuritySchemeInfo.java | 4 +-
.../apache/juneau/dto/openapi3/ServerVariable.java | 4 +-
.../java/org/apache/juneau/dto/openapi3/Tag.java | 4 +-
.../main/java/org/apache/juneau/BeanContext.java | 22 +-
.../java/org/apache/juneau/annotation/Named.java | 94 ++++---
.../java/org/apache/juneau/annotation/Schema.java | 2 +-
.../main/java/org/apache/juneau/cp/BeanStore.java | 6 +-
.../org/apache/juneau/http/annotation/Query.java | 2 +-
.../apache/juneau/internal/AnnotationUtils.java | 2 +
.../java/org/apache/juneau/reflect/FieldInfo.java | 30 ++-
juneau-doc/src/main/javadoc/javadoc.css | 10 +-
.../apache/juneau/rest/client/RestCallHandler.java | 2 +-
.../org/apache/juneau/rest/client/RestClient.java | 90 +++----
.../java/org/apache/juneau/rest/RestContext.java | 74 ++++--
.../java/org/apache/juneau/rest/RestOpContext.java | 3 +-
.../java/org/apache/juneau/rest/RestSession.java | 2 +-
.../apache/juneau/rest/annotation/RestBean.java | 90 +++++--
.../juneau/rest/annotation/RestBeanAnnotation.java | 196 +++++++++++++++
.../org/apache/juneau/rest/arg/DefaultArg.java | 19 +-
.../juneau/assertions/BooleanAssertion_Test.java | 4 +-
.../juneau/assertions/ByteArrayAssertion_Test.java | 4 +-
.../assertions/CollectionAssertion_Test.java | 4 +-
.../assertions/ComparableAssertion_Test.java | 4 +-
.../juneau/assertions/DateAssertion_Test.java | 4 +-
.../juneau/config/ConfigMapListenerTest.java | 62 ++---
.../org/apache/juneau/config/ConfigMapTest.java | 276 ++++++++++-----------
.../java/org/apache/juneau/cp/BeanStore_Test.java | 10 +-
.../apache/juneau/http/response/Conflict_Test.java | 4 +-
.../apache/juneau/http/response/Continue_Test.java | 4 +-
.../apache/juneau/http/response/Created_Test.java | 4 +-
.../juneau/rest/RestContext_Builder_Test.java | 61 ++++-
41 files changed, 769 insertions(+), 392 deletions(-)
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Contact.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Contact.java
index f63331c12..f6c19c7b2 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Contact.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Contact.java
@@ -28,7 +28,7 @@ import java.util.Set;
* Contact information for the exposed API.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Contact x = <jsm>contact</jsm>(<js>"API Support"</js>, <js>"http://www.swagger.io/support"</js>, <js>"support@swagger.io"</js>);
*
@@ -38,7 +38,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"name"</js>: <js>"API Support"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Example.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Example.java
index e9134bdaf..73363c538 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Example.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Example.java
@@ -25,7 +25,7 @@ import java.util.Set;
* information for Examples object.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Contact x = <jsm>contact</jsm>(<js>"API Support"</js>, <js>"http://www.swagger.io/support"</js>, <js>"support@swagger.io"</js>);
*
@@ -35,7 +35,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"name"</js>: <js>"API Support"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/HeaderInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/HeaderInfo.java
index 7f614169f..096059b65 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/HeaderInfo.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/HeaderInfo.java
@@ -26,7 +26,7 @@ import java.util.*;
* Describes a single HTTP header.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* HeaderInfo x = <jsm>headerInfo</jsm>(<js>"integer"</js>).description(<js>"The number of allowed requests in the current period"</js>);
*
@@ -36,7 +36,7 @@ import java.util.*;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"description"</js>: <js>"The number of allowed requests in the current period"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Info.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Info.java
index 8b47d74de..6450250c5 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Info.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Info.java
@@ -31,7 +31,7 @@ import java.util.Set;
* in the Swagger-UI for convenience.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Info x = <jsm>info</jsm>(<js>"Swagger Sample App"</js>, <js>"1.0.1"</js>)
* .description(<js>"This is a sample server Petstore server."</js>)
@@ -49,7 +49,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"title"</js>: <js>"Swagger Sample App"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Items.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Items.java
index d52259d5b..ecf53e24c 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Items.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Items.java
@@ -34,7 +34,7 @@ import static org.apache.juneau.internal.CollectionUtils.*;
* It is used by parameter definitions that are not located in "body".
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Items x = <jsm>items</jsm>(<js>"string"</js>).minLength(2);
*
@@ -44,7 +44,7 @@ import static org.apache.juneau.internal.CollectionUtils.*;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"type"</js>: <js>"string"</js>,
@@ -581,12 +581,12 @@ public class Items extends OpenApiElement {
* <li><code>Collection<Object></code>
* <li><code>String</code> - JSON array representation of <code>Collection<Object></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* _enum(<js>"['foo','bar']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* _enum(<js>"foo"</js>, <js>"bar"</js>);
* </p>
* </ul>
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/License.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/License.java
index 0dbc5f9f7..711be789d 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/License.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/License.java
@@ -27,7 +27,7 @@ import java.util.Set;
* License information for the exposed API.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* License x = <jsm>license</jsm>(<js>"Apache 2.0"</js>, <js>"http://www.apache.org/licenses/LICENSE-2.0.html"</js>);
*
@@ -37,7 +37,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"name"</js>: <js>"Apache 2.0"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Link.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Link.java
index aabcf7484..c756c1980 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Link.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Link.java
@@ -27,7 +27,7 @@ import java.util.Set;
* information for Link object.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Contact x = <jsm>contact</jsm>(<js>"API Support"</js>, <js>"http://www.swagger.io/support"</js>, <js>"support@swagger.io"</js>);
*
@@ -37,7 +37,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"name"</js>: <js>"API Support"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlow.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlow.java
index 76410340a..1f1eeb982 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlow.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlow.java
@@ -27,7 +27,7 @@ import java.util.Set;
* information for Link object.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Contact x = <jsm>contact</jsm>(<js>"API Support"</js>, <js>"http://www.swagger.io/support"</js>, <js>"support@swagger.io"</js>);
*
@@ -37,7 +37,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"name"</js>: <js>"API Support"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlows.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlows.java
index 484aa4ace..89435b17d 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlows.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/OAuthFlows.java
@@ -66,7 +66,7 @@ import static org.apache.juneau.internal.CollectionUtils.*;
* </ul>
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* ParameterInfo x = <jsm>parameterInfo</jsm>(<js>"query"</js>, <js>"foo"</js>);
*
@@ -76,7 +76,7 @@ import static org.apache.juneau.internal.CollectionUtils.*;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"in"</js>: <js>"query"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SchemaInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SchemaInfo.java
index 6ec79d6c2..49dc81486 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SchemaInfo.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SchemaInfo.java
@@ -37,7 +37,7 @@ import java.util.*;
* Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* SchemaInfo x = <jsm>schemaInfo</jsm>()
* .type("string")
@@ -49,7 +49,7 @@ import java.util.*;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"type"</js>: <js>"string"</js>,
@@ -633,12 +633,12 @@ public class SchemaInfo extends OpenApiElement {
* <li><code>Collection<String></code>
* <li><code>String</code> - JSON array representation of <code>Collection<String></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* schemes(<js>"['scheme1','scheme2']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* schemes(<js>"scheme1</js>, <js>"scheme2"</js>);
* </p>
* </ul>
@@ -682,12 +682,12 @@ public class SchemaInfo extends OpenApiElement {
* <li><code>Collection<Object></code>
* <li><code>String</code> - JSON array representation of <code>Collection<Object></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* _enum(<js>"['foo','bar']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* _enum(<js>"foo"</js>, <js>"bar"</js>);
* </p>
* </ul>
@@ -786,12 +786,12 @@ public class SchemaInfo extends OpenApiElement {
* <li><code>Collection<Object></code>
* <li><code>String</code> - JSON array representation of <code>Collection<Object></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* allOf(<js>"['foo','bar']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* allOf(<js>"foo"</js>, <js>"bar"</js>);
* </p>
* </ul>
@@ -836,12 +836,12 @@ public class SchemaInfo extends OpenApiElement {
* <li><code>Collection<Object></code>
* <li><code>String</code> - JSON array representation of <code>Collection<Object></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* allOf(<js>"['foo','bar']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* allOf(<js>"foo"</js>, <js>"bar"</js>);
* </p>
* </ul>
@@ -886,12 +886,12 @@ public class SchemaInfo extends OpenApiElement {
* <li><code>Collection<Object></code>
* <li><code>String</code> - JSON array representation of <code>Collection<Object></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* allOf(<js>"['foo','bar']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* allOf(<js>"foo"</js>, <js>"bar"</js>);
* </p>
* </ul>
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SecuritySchemeInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SecuritySchemeInfo.java
index c5a651c00..47539f1f8 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SecuritySchemeInfo.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/SecuritySchemeInfo.java
@@ -69,7 +69,7 @@ import static org.apache.juneau.internal.CollectionUtils.*;
* </ul>
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* ParameterInfo x = <jsm>parameterInfo</jsm>(<js>"query"</js>, <js>"foo"</js>);
*
@@ -79,7 +79,7 @@ import static org.apache.juneau.internal.CollectionUtils.*;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"in"</js>: <js>"query"</js>,
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/ServerVariable.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/ServerVariable.java
index 389767de2..7cd588c5a 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/ServerVariable.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/ServerVariable.java
@@ -99,12 +99,12 @@ public class ServerVariable extends OpenApiElement {
* <li><code>Collection<Object></code>
* <li><code>String</code> - JSON array representation of <code>Collection<Object></code>
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* _enum(<js>"['foo','bar']"</js>);
* </p>
* <li><code>String</code> - Individual values
* <h5 class='figure'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* _enum(<js>"foo"</js>, <js>"bar"</js>);
* </p>
* </ul>
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Tag.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Tag.java
index c45453cda..480d77b0c 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Tag.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/openapi3/Tag.java
@@ -29,7 +29,7 @@ import java.util.Set;
* It is not mandatory to have a Tag Object per tag used there.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Construct using SwaggerBuilder.</jc>
* Tag x = <jsm>tag</jsm>()
* .name(<js>"pet"</js>)
@@ -41,7 +41,7 @@ import java.util.Set;
* <jc>// Or just use toString() which does the same as above.</jc>
* String json = x.toString();
* </p>
- * <p class='bcode w800'>
+ * <p class='bcode'>
* <jc>// Output</jc>
* {
* <js>"name"</js>: <js>"pet"</js>,
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index aac36741c..499265ef9 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -40,7 +40,7 @@ import org.apache.juneau.utils.*;
/**
* Bean context.
*
- * <p class='w800'>
+ * <p>
* This class servers multiple purposes:
* <ul class='spaced-list'>
* <li>
@@ -50,16 +50,16 @@ import org.apache.juneau.utils.*;
* {@link PropertyNamer PropertyNamers}, etc... which are used to tailor how POJOs are serialized and parsed.
* </ul>
*
- * <p class='w800'>
+ * <p>
* All serializers and parsers use this context so that they can handle POJOs using a common framework.
*
* <h5 class='topic'>Bean Contexts</h5>
*
- * <p class='w800'>
+ * <p>
* Bean contexts are created through the {@link BeanContext#create() BeanContext.create()} and {@link Builder#build()} methods.
* <br>These context objects are read-only, reusable, and thread-safe.
*
- * <p class='w800'>
+ * <p>
* Each bean context maintains a cache of {@link ClassMeta} objects that describe information about classes encountered.
* These <c>ClassMeta</c> objects are time-consuming to construct.
* Therefore, instances of {@link BeanContext} that share the same <js>"BeanContext.*"</js> property values share
@@ -69,7 +69,7 @@ import org.apache.juneau.utils.*;
*
* <h5 class='topic'>Bean Sessions</h5>
*
- * <p class='w800'>
+ * <p>
* Whereas <c>BeanContext</c> objects are permanent, unchangeable, cached, and thread-safe,
* {@link BeanSession} objects are ephemeral and not thread-safe.
* They are meant to be used as quickly-constructed scratchpads for creating bean maps.
@@ -77,22 +77,22 @@ import org.apache.juneau.utils.*;
*
* <h5 class='topic'>BeanContext configuration properties</h5>
*
- * <p class='w800'>
+ * <p>
* <c>BeanContexts</c> have several configuration properties that can be used to tweak behavior on how beans are
* handled. These are denoted as the static <jsf>BEAN_*</jsf> fields on this class.
*
- * <p class='w800'>
+ * <p>
* Some settings (e.g. {@link Builder#beansRequireDefaultConstructor()}) are used to differentiate between bean
* and non-bean classes.
* Attempting to create a bean map around one of these objects will throw a {@link BeanRuntimeException}.
* The purpose for this behavior is so that the serializers can identify these non-bean classes and convert them to
* plain strings using the {@link Object#toString()} method.
*
- * <p class='w800'>
+ * <p>
* Some settings (e.g. {@link Builder#beanFieldVisibility(Visibility)}) are used to determine what kinds of properties are
* detected on beans.
*
- * <p class='w800'>
+ * <p>
* Some settings (e.g. {@link Builder#beanMapPutReturnsOldValue()}) change the runtime behavior of bean maps.
*
* <h5 class='section'>Example:</h5>
@@ -108,11 +108,11 @@ import org.apache.juneau.utils.*;
*
* <h5 class='topic'>Bean Maps</h5>
*
- * <p class='w800'>
+ * <p>
* {@link BeanMap BeanMaps} are wrappers around Java beans that allow properties to be retrieved and
* set using the common {@link Map#put(Object,Object)} and {@link Map#get(Object)} methods.
*
- * <p class='w800'>
+ * <p>
* Bean maps are created in two ways...
* <ol>
* <li>{@link BeanSession#toBeanMap(Object) BeanSession.toBeanMap()} - Wraps an existing bean inside a {@code Map}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Named.java
similarity index 61%
copy from juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Named.java
index ee1cb343a..2d002aca4 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Named.java
@@ -1,49 +1,45 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.http.response;
-
-import static org.apache.juneau.http.HttpResponses.*;
-import static org.junit.runners.MethodSorters.*;
-
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.mock.*;
-import org.junit.*;
-
-@FixMethodOrder(NAME_ASCENDING)
-public class Created_Test {
-
- @Rest
- public static class A {
- @RestGet public Created a1() { return CREATED; }
- @RestGet public Created a2() { return created().content("foo").build(); }
- @RestGet public Created a3() { return created().header("Foo","bar").build(); }
- }
-
- @Test
- public void a01_basic() throws Exception {
- MockRestClient client = MockRestClient.createLax(A.class).build();
-
- client.get("/a1")
- .run()
- .assertCode().is(201)
- .assertContent().is("Created");
- client.get("/a2")
- .run()
- .assertCode().is(201)
- .assertContent().is("foo");
- client.get("/a3")
- .run()
- .assertCode().is(201)
- .assertHeader("Foo").is("bar");
- }
-}
+// ***************************************************************************************************************************
+// * 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.annotation;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation that identifies a differentiating name for a bean.
+ *
+ * <p>
+ * Can be used in the following locations:
+ * <ul>
+ * <li>On <ja>@RestX</ja> annotated method parameters to identify injected parameters by name.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='extlink'>{@source}
+ * </ul>
+ */
+@Documented
+@Target({PARAMETER})
+@Retention(RUNTIME)
+@Inherited
+public @interface Named {
+
+ /**
+ * The injected bean name.
+ *
+ * @return The annotation value.
+ */
+ String value();
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java
index efeec6554..c2686d2e7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java
@@ -26,7 +26,7 @@ import org.apache.juneau.oapi.*;
/**
* Swagger schema annotation.
*
- * <p class='w800'>
+ * <p>
* The Schema Object allows the definition of input and output data types.
* These types can be objects, but also primitives and arrays.
* This object is based on the JSON Schema Specification Draft 4 and uses a predefined subset of it.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
index b1c115fd6..f58fa045b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java
@@ -26,6 +26,7 @@ import java.util.stream.*;
import org.apache.juneau.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.internal.*;
+import org.apache.juneau.marshaller.*;
import org.apache.juneau.reflect.*;
/**
@@ -655,7 +656,7 @@ public class BeanStore {
@Override /* Object */
public String toString() {
- return properties().asString();
+ return SimpleJson.of(properties());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -680,7 +681,7 @@ public class BeanStore {
// <FluentSetters>
- // </FluentSetters>
+ // </FluentSetters>
//-----------------------------------------------------------------------------------------------------------------
// Helper methods
@@ -700,6 +701,7 @@ public class BeanStore {
private JsonMap properties() {
Predicate<Boolean> nf = ObjectUtils::isTrue;
return filteredMap()
+ .append("identity", ObjectUtils.identity(this))
.append("entries", entries.stream().map(x -> x.properties()).collect(toList()))
.append("outer", ObjectUtils.identity(outer.orElse(null)))
.append("parent", parent.map(x->x.properties()).orElse(null))
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
index 05f1f4dd2..0e1d16d02 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
@@ -39,7 +39,7 @@ import org.apache.juneau.oapi.*;
* <p>
* Annotation that can be applied to a parameter of a <ja>@RestOp</ja>-annotated method to identify it as a URL query parameter.
*
- * <p class='w800'>
+ * <p>
* Unlike {@link FormData @FormData}, using this annotation does not result in the servlet reading the contents of
* URL-encoded form posts.
* Therefore, this annotation can be used in conjunction with the {@link Content @Content} annotation or
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
index 2165ba243..572a6ebb0 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/AnnotationUtils.java
@@ -79,6 +79,8 @@ public class AnnotationUtils {
private static int hashMember(String name, Object value) {
int part1 = name.hashCode() * 127;
+ if (value == null)
+ return part1;
if (value.getClass().isArray())
return part1 ^ arrayMemberHash(value.getClass().getComponentType(), value);
if (value instanceof Annotation)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
index f747c386f..2abdfaa95 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/FieldInfo.java
@@ -15,6 +15,7 @@ package org.apache.juneau.reflect;
import static org.apache.juneau.internal.ConsumerUtils.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
+import java.util.*;
import java.util.function.*;
import org.apache.juneau.*;
@@ -488,15 +489,27 @@ public final class FieldInfo implements Comparable<FieldInfo> {
* @return The field value.
* @throws BeanRuntimeException Field was not accessible or field does not belong to object.
*/
- public Object get(Object o) throws BeanRuntimeException {
+ @SuppressWarnings("unchecked")
+ public <T> T get(Object o) throws BeanRuntimeException {
try {
f.setAccessible(true);
- return f.get(o);
+ return (T)f.get(o);
} catch (Exception e) {
throw new BeanRuntimeException(e);
}
}
+ /**
+ * Same as {@link #get(Object)} but wraps the results in an {@link Optional}.
+ *
+ * @param o The object containing the field.
+ * @return The field value.
+ * @throws BeanRuntimeException Field was not accessible or field does not belong to object.
+ */
+ public <T> Optional<T> getOptional(Object o) throws BeanRuntimeException {
+ return Optional.ofNullable(get(o));
+ }
+
/**
* Sets the field value on the specified object.
*
@@ -512,4 +525,17 @@ public final class FieldInfo implements Comparable<FieldInfo> {
throw new BeanRuntimeException(e);
}
}
+
+ /**
+ * Sets the field value on the specified object if the value is <jk>null</jk>.
+ *
+ * @param o The object containing the field.
+ * @param value The new field value.
+ * @throws BeanRuntimeException Field was not accessible or field does not belong to object.
+ */
+ public void setIfNull(Object o, Object value) {
+ Object v = get(o);
+ if (v == null)
+ set(o, value);
+ }
}
diff --git a/juneau-doc/src/main/javadoc/javadoc.css b/juneau-doc/src/main/javadoc/javadoc.css
index 578802770..d441e73ea 100755
--- a/juneau-doc/src/main/javadoc/javadoc.css
+++ b/juneau-doc/src/main/javadoc/javadoc.css
@@ -30,9 +30,9 @@ body {
h1, h2, h3, h4, h5, h6 {
font-family: Montserrat,sans-serif;
- font-weight: 400;
- font-style: normal;
- text-rendering: optimizeLegibility;
+ font-weight: 400;
+ font-style: normal;
+ text-rendering: optimizeLegibility;
}
a:link,a:visited {
@@ -334,6 +334,10 @@ Page layout container styles
position: relative;
}
+.contentContainer p {
+ max-width: 900px;
+}
+
.indexContainer {
margin: 10px;
position: relative;
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCallHandler.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCallHandler.java
index 3a3c3b3fb..c532ce120 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCallHandler.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCallHandler.java
@@ -22,7 +22,7 @@ import org.apache.http.protocol.*;
/**
* Interface that allows you to override the handling of HTTP requests.
*
- * <p class='w900'>
+ * <p>
* Providing this implementation is the equivalent to overriding the {@link RestClient#execute(HttpHost,HttpRequest,HttpContext)}.
* <br>This can also be accomplished by providing your own {@link RestClient.Builder#connectionManager(org.apache.http.conn.HttpClientConnectionManager) connection manager}
* or subclassing {@link RestClient}, but this provides a simpler way of handling the requests yourself.
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 55e0a08bf..e7def59d4 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -95,7 +95,7 @@ import org.apache.juneau.xml.*;
/**
* Utility class for interfacing with remote REST interfaces.
*
- * <p class='w900'>
+ * <p>
* Built upon the feature-rich Apache HttpClient library, the Juneau RestClient API adds support for fluent-style
* REST calls and the ability to perform marshalling of POJOs to and from HTTP parts.
*
@@ -112,7 +112,7 @@ import org.apache.juneau.xml.*;
* .getContent().as(MyBean.<jk>class</jk>);
* </p>
*
- * <p class='w900'>
+ * <p>
* Breaking apart the fluent call, we can see the classes being used:
* <p class='bjava'>
* RestClient.Builder <jv>builder</jv> = RestClient.<jsm>create</jsm>().simpleJson();
@@ -128,7 +128,7 @@ import org.apache.juneau.xml.*;
* MyBean <jv>bean</jv> = <jv>content</jv>.as(MyBean.<jk>class</jk>);
* </p>
*
- * <p class='w900'>
+ * <p>
* It additionally provides support for creating remote proxy interfaces using REST as the transport medium.
*
* <h5 class='figure'>Example:</h5>
@@ -153,7 +153,7 @@ import org.apache.juneau.xml.*;
* Pet <jv>pet</jv> = <jv>store</jv>.addPet(<jv>createPet</jv>, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
* </p>
*
- * <p class='w900'>
+ * <p>
* The classes are closely tied to Apache HttpClient, yet provide lots of additional functionality:
* <ul class='javatree'>
* <li class='jc'>{@link RestClient} <jk>extends</jk> {@link HttpClient}, creates {@link RestRequest} objects.
@@ -164,11 +164,11 @@ import org.apache.juneau.xml.*;
* </ul>
*
*
- * <p class='w900'>
+ * <p>
* Instances of this class are built using the {@link Builder} class which can be constructed using
* the {@link #create() RestClient.create()} method as shown above.
*
- * <p class='w900'>
+ * <p>
* Clients are typically created with a root URI so that relative URIs can be used when making requests.
* This is done using the {@link Builder#rootUri(Object)} method.
*
@@ -181,7 +181,7 @@ import org.apache.juneau.xml.*;
* String <jv>body</jv> = <jv>client</jv>.get(<js>"/subpath"</js>).run().getContent().asString();
* </p>
*
- * <p class='w900'>
+ * <p>
* The {@link RestClient} class creates {@link RestRequest} objects using the following methods:
*
* <ul class='javatree'>
@@ -200,7 +200,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* The {@link RestRequest} class creates {@link RestResponse} objects using the following methods:
*
* <ul class='javatree'>
@@ -211,13 +211,13 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* The distinction between the two methods is that {@link RestRequest#complete() complete()} automatically consumes the response body and
* {@link RestRequest#run() run()} does not. Note that you must consume response bodies in order for HTTP connections to be freed up
* for reuse! The {@link InputStream InputStreams} returned by the {@link ResponseContent} object are auto-closing once
* they are exhausted, so it is often not necessary to explicitly close them.
*
- * <p class='w900'>
+ * <p>
* The following examples show the distinction between the two calls:
*
* <p class='bjava'>
@@ -231,7 +231,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>POJO Marshalling</h4>
*
- * <p class='w900'>
+ * <p>
* By default, JSON support is provided for HTTP request and response bodies.
* Other languages can be specified using any of the following builder methods:
* <ul class='javatree'>
@@ -268,7 +268,7 @@ import org.apache.juneau.xml.*;
* RestClient <jv>client2</jv> = RestClient.<jsm>create</jsm>().universal().build();
* </p>
*
- * <p class='w900'>
+ * <p>
* When using clients with multiple language support, you must specify the <c>Content-Type</c> header on requests
* with bodies to specify which serializer should be selected.
*
@@ -299,7 +299,7 @@ import org.apache.juneau.xml.*;
* </p>
*
*
- * <p class='w900'>
+ * <p>
* The {@link Builder} class provides convenience methods for setting common serializer and parser
* settings.
*
@@ -310,7 +310,7 @@ import org.apache.juneau.xml.*;
* RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().json().sq().ws().build();
* </p>
*
- * <p class='w900'>
+ * <p>
* Other methods are also provided for specifying the serializers and parsers used for lower-level marshalling support:
* <ul class='javatree'>
* <li class='jc'>{@link Builder}
@@ -321,7 +321,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* HTTP parts (headers, query parameters, form data...) are serialized and parsed using the {@link HttpPartSerializer}
* and {@link HttpPartParser} APIs. By default, clients are configured to use {@link OpenApiSerializer} and
* {@link OpenApiParser}. These can be overridden using the following methods:
@@ -335,7 +335,7 @@ import org.apache.juneau.xml.*;
*
*
* <h4 class='topic'>Request Headers</h4>
- * <p class='w900'>
+ * <p>
* Per-client or per-request headers can be specified using the following methods:
* <ul class='javatree'>
* <li class='jc'>{@link Builder}
@@ -355,7 +355,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* The supplier methods are particularly useful for header values whose values may change over time (such as <c>Authorization</c> headers
* which may need to change every few minutes).
* </p>
@@ -428,7 +428,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Request Form Data</h4>
*
- * <p class='w900'>
+ * <p>
* Per-client or per-request form-data parameters can be specified using the following methods:
* <ul class='javatree'>
* <li class='jc'>{@link Builder}
@@ -458,7 +458,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Request Body</h4>
*
- * <p class='w900'>
+ * <p>
* The request body can either be passed in with the client creator method (e.g. {@link RestClient#post(Object,Object) post(uri,body)}),
* or can be specified via the following methods:
*
@@ -470,7 +470,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* The request body can be any of the following types:
* <ul class='javatree'>
* <li class='jc'>
@@ -498,7 +498,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Response Status</h4>
*
- * <p class='w900'>
+ * <p>
* After execution using {@link RestRequest#run()} or {@link RestRequest#complete()}, the following methods can be used
* to get the response status:
*
@@ -518,7 +518,7 @@ import org.apache.juneau.xml.*;
* <jk>int</jk> <jv>statusCode</jv> = <jv>client</jv>.get(<jsf>URI</jsf>).complete().getStatusCode();
* </p>
*
- * <p class='w900'>
+ * <p>
* Equivalent methods with mutable parameters are provided to allow access to status values without breaking fluent call chains.
*
* <h5 class='figure'>Example:</h5>
@@ -537,7 +537,7 @@ import org.apache.juneau.xml.*;
* consume the response yourself.
* </ul>
*
- * <p class='w900'>
+ * <p>
* The assertion method is provided for quickly asserting status codes in fluent calls.
*
* <h5 class='figure'>Example:</h5>
@@ -558,7 +558,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Response Headers</h4>
*
- * <p class='w900'>
+ * <p>
* Response headers are accessed through the following methods:
*
* <ul class='javatree'>
@@ -573,7 +573,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* The {@link RestResponse#getFirstHeader(String)} and {@link RestResponse#getLastHeader(String)} methods return an empty {@link ResponseHeader} object instead of<jk>null</jk>.
* This allows it to be used more easily in fluent calls.
*
@@ -583,7 +583,7 @@ import org.apache.juneau.xml.*;
* <jk>boolean</jk> <jv>hasLocationHeader</jv> = <jv>client</jv>.get(<jsf>URI</jsf>).complete().getLastHeader(<js>"Location"</js>).exists();
* </p>
*
- * <p class='w900'>
+ * <p>
* The {@link ResponseHeader} class extends from the HttpClient {@link Header} class and provides several convenience
* methods:
*
@@ -647,7 +647,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Response Body</h4>
*
- * <p class='w900'>
+ * <p>
* The response body is accessed through the following method:
*
* <ul class='javatree'>
@@ -657,7 +657,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* The {@link ResponseContent} class extends from the HttpClient {@link HttpEntity} class and provides several convenience
* methods:
*
@@ -718,7 +718,7 @@ import org.apache.juneau.xml.*;
* .getContent().as(TreeMap.<jk>class</jk>, String.<jk>class</jk>, List.<jk>class</jk>, MyBean.<jk>class</jk>);
* </p>
*
- * <p class='w900'>
+ * <p>
* The response body can only be consumed once unless it has been cached into memory. In many cases, the body is
* automatically cached when using the assertions methods or methods such as {@link ResponseContent#asString()}.
* However, methods that involve reading directly from the input stream cannot be called twice.
@@ -773,7 +773,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Custom Call Handlers</h4>
*
- * <p class='w900'>
+ * <p>
* The {@link RestCallHandler} interface provides the ability to provide custom handling of requests.
*
* <ul class='javatree'>
@@ -787,7 +787,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* Note that there are other ways of accomplishing this such as extending the {@link RestClient} class and overriding
* the {@link #run(HttpHost,HttpRequest,HttpContext)} method
* or by defining your own {@link HttpRequestExecutor}. Using this interface is often simpler though.
@@ -795,7 +795,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Interceptors</h4>
*
- * <p class='w900'>
+ * <p>
* The {@link RestCallInterceptor} API provides a quick way of intercepting and manipulating requests and responses beyond
* the existing {@link HttpRequestInterceptor} and {@link HttpResponseInterceptor} APIs.
*
@@ -819,7 +819,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Logging / Debugging</h4>
*
- * <p class='w900'>
+ * <p>
* The following methods provide logging of requests and responses:
*
* <ul class='javatree'>
@@ -870,11 +870,11 @@ import org.apache.juneau.xml.*;
* </p>
*
*
- * <p class='notes w900'>
+ * <p class='notes'>
* It should be noted that if you enable request logging detail level {@link DetailLevel#FULL}, response bodies will be cached by default which may introduce
* a performance penalty.
*
- * <p class='w900'>
+ * <p>
* Additionally, the following method is also provided for enabling debug mode:
*
* <ul class='javatree'>
@@ -884,7 +884,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* Enabling debug mode has the following effects:
* <ul>
* <li>{@link org.apache.juneau.Context.Builder#debug()} is enabled.
@@ -895,7 +895,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>REST Proxies</h4>
*
- * <p class='w900'>
+ * <p>
* One of the more powerful features of the REST client class is the ability to produce Java interface proxies against
* arbitrary remote REST resources.
*
@@ -921,7 +921,7 @@ import org.apache.juneau.xml.*;
* Pet <jv>pet</jv> = <jv>store</jv>.addPet(<jv>createPet</jv>, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
* </p>
*
- * <p class='w900'>
+ * <p>
* The methods to retrieve remote interfaces are:
*
* <ul class='javatree'>
@@ -936,7 +936,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* Two basic types of remote interfaces are provided:
*
* <ul class='spaced-list'>
@@ -944,7 +944,7 @@ import org.apache.juneau.xml.*;
* <li>RPC-over-REST interfaces. These are Java interfaces that allow you to make method calls on server-side POJOs.
* </ul>
*
- * <p class='w900'>
+ * <p>
* Refer to the following documentation on both flavors:
*
* <ul class='doctree'>
@@ -953,10 +953,10 @@ import org.apache.juneau.xml.*;
* </ul>
*
* <br>
- * <hr class='w900'>
+ * <hr>
* <h4 class='topic'>Customizing Apache HttpClient</h4>
*
- * <p class='w900'>
+ * <p>
* Several methods are provided for customizing the underlying HTTP client and client builder classes:
* <ul class='javatree'>
* <li class='jc'>{@link Builder}
@@ -968,7 +968,7 @@ import org.apache.juneau.xml.*;
* </ul>
* </ul>
*
- * <p class='w900'>
+ * <p>
* Additionally, all methods on the <c>HttpClientBuilder</c> class have been extended with fluent setters.
*
* <h5 class='figure'>Example:</h5>
@@ -988,7 +988,7 @@ import org.apache.juneau.xml.*;
*
* <h4 class='topic'>Extending RestClient</h4>
*
- * <p class='w900'>
+ * <p>
* The <c>RestClient</c> API has been designed to allow for the ability to be easily extended.
* The following example that overrides the primary run method shows how this can be done.
*
@@ -1011,7 +1011,7 @@ import org.apache.juneau.xml.*;
* MyRestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().json().build(MyRestClient.<jk>class</jk>);
* </p>
*
- * <p class='w900'>
+ * <p>
* The {@link RestRequest} and {@link RestResponse} objects can also be extended and integrated by overriding the
* {@link RestClient#createRequest(URI,String,boolean)} and {@link RestClient#createResponse(RestRequest,HttpResponse,Parser)} methods.
*
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index d1743adab..f9a428e37 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -410,9 +410,21 @@ public class RestContext extends Context {
ClassInfo rci = ClassInfo.of(resourceClass);
+ // Get @RestBean fields initialized with values.
+ rci.forEachAllField(
+ x -> x.hasAnnotation(RestBean.class),
+ x -> x.getOptional(resource.get()).ifPresent(
+ y -> beanStore.add(
+ x.getType().inner(),
+ y,
+ RestBeanAnnotation.name(x.getAnnotation(RestBean.class))
+ )
+ )
+ );
+
rci.forEachMethod(x -> x.hasAnnotation(RestBean.class), x -> {
Class<Object> rt = x.getReturnType().inner();
- String name = x.getAnnotation(RestBean.class).name();
+ String name = RestBeanAnnotation.name(x.getAnnotation(RestBean.class));
if (! (DELAYED_INJECTION.contains(rt) || DELAYED_INJECTION_NAMES.contains(name))) {
beanStore
.createMethodFinder(rt)
@@ -432,9 +444,17 @@ public class RestContext extends Context {
runInitHooks(bs, resource());
- // Set @RestBean fields.
- // Note that these only get set on the first resource bean.
- rci.forEachAllField(x -> x.hasAnnotation(RestBean.class), x -> x.set(resource.get(), beanStore.getBean(x.getType().inner(), x.getAnnotation(RestBean.class).name()).orElse(null)));
+ // Set @RestBean fields not initialized with values.
+ rci.forEachAllField(
+ x -> x.hasAnnotation(RestBean.class),
+ x -> x.setIfNull(
+ resource.get(),
+ beanStore.getBean(
+ x.getType().inner(),
+ RestBeanAnnotation.name(x.getAnnotation(RestBean.class))
+ ).orElse(null)
+ )
+ );
return this;
}
@@ -780,7 +800,7 @@ public class RestContext extends Context {
);
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(VarResolver.class)
.ifPresent(x -> v.get().impl(x));
@@ -1148,7 +1168,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.get().type(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(ThrownStore.class)
.ifPresent(x->v.get().impl(x));
@@ -1191,7 +1211,7 @@ public class RestContext extends Context {
* Typically used to allow you to execute operations without breaking the fluent flow of the context builder.
*
* <h5 class='section'>Example:</h5>
- * <p class='bcodbjavae w800'>
+ * <p class='bjava'>
* RestContext <jv>context</jv> = RestContext
* .<jsm>create</jsm>(<jv>resourceClass</jv>, <jv>parentContext</jv>, <jv>servletConfig</jv>)
* .encoders(<jv>x</jv> -> <jv>x</jv>.add(MyEncoder.<jk>class</jk>))
@@ -1252,7 +1272,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.get().type(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(EncoderSet.class)
.ifPresent(x->v.get().impl(x));
@@ -1334,7 +1354,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.get().type(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(SerializerSet.class)
.ifPresent(x->v.get().impl(x));
@@ -1416,7 +1436,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.get().type(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(ParserSet.class)
.ifPresent(x->v.get().impl(x));
@@ -1497,7 +1517,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.get().type(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(MethodExecStore.class)
.ifPresent(x->v.get().impl(x));
@@ -1592,7 +1612,7 @@ public class RestContext extends Context {
* absolute path like <js>"com.foo.sample.nls.Messages"</js>
*
* <h5 class='section'>Examples:</h5>
- * <p class='jini w800'>
+ * <p class='bini'>
* <cc># Contents of org/apache/foo/nls/MyMessages.properties</cc>
*
* <ck>HelloMessage</ck> = <cv>Hello {0}!</cv>
@@ -1646,7 +1666,7 @@ public class RestContext extends Context {
);
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(Messages.class)
.ifPresent(x->v.get().impl(x));
@@ -1832,7 +1852,7 @@ public class RestContext extends Context {
);
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(ResponseProcessorList.class)
.ifPresent(x -> v.get().impl(x));
@@ -1991,7 +2011,7 @@ public class RestContext extends Context {
.get(CallLogger.class)
.ifPresent(x -> creator.type(x));
- rootBeanStore
+ beanStore
.getBean(CallLogger.class)
.ifPresent(x -> creator.impl(x));
@@ -2084,7 +2104,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.set(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(BeanContext.class)
.ifPresent(x -> v.get().impl(x));
@@ -2180,7 +2200,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.set(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(HttpPartSerializer.class)
.ifPresent(x -> v.get().impl(x));
@@ -2292,7 +2312,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.set(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(HttpPartParser.class)
.ifPresent(x -> v.get().impl(x));
@@ -2396,7 +2416,7 @@ public class RestContext extends Context {
.ifPresent(x -> v.set(x));
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(JsonSchemaGenerator.class)
.ifPresent(x -> v.get().impl(x));
@@ -2585,7 +2605,7 @@ public class RestContext extends Context {
.get(FileFinder.class)
.ifPresent(x -> creator.type(x));
- rootBeanStore
+ beanStore
.getBean(FileFinder.class)
.ifPresent(x -> creator.impl(x));
@@ -2738,7 +2758,7 @@ public class RestContext extends Context {
.get(StaticFiles.class)
.ifPresent(x -> creator.type(x));
- rootBeanStore
+ beanStore
.getBean(StaticFiles.class)
.ifPresent(x -> creator.impl(x));
@@ -2896,7 +2916,7 @@ public class RestContext extends Context {
);
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(HeaderList.class, "defaultRequestHeaders")
.ifPresent(x -> v.get().impl(x));
@@ -3028,7 +3048,7 @@ public class RestContext extends Context {
);
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(HeaderList.class, "defaultResponseHeaders")
.ifPresent(x -> v.get().impl(x));
@@ -3156,7 +3176,7 @@ public class RestContext extends Context {
NamedAttributeList.create()
);
- rootBeanStore
+ beanStore
.getBean(NamedAttributeList.class, "defaultRequestAttributes")
.ifPresent(x -> v.get().impl(x));
@@ -3348,7 +3368,7 @@ public class RestContext extends Context {
);
// Replace with bean from bean store.
- rootBeanStore
+ beanStore
.getBean(RestOpArgList.class)
.ifPresent(x -> v.get().impl(x));
@@ -3444,7 +3464,7 @@ public class RestContext extends Context {
.get(DebugEnablement.class)
.ifPresent(x -> creator.type(x));
- rootBeanStore
+ beanStore
.getBean(DebugEnablement.class)
.ifPresent(x -> creator.impl(x));
@@ -4206,7 +4226,7 @@ public class RestContext extends Context {
.get(SwaggerProvider.class)
.ifPresent(x -> creator.type(x));
- rootBeanStore
+ beanStore
.getBean(SwaggerProvider.class)
.ifPresent(x -> creator.impl(x));
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
index ef94a08d4..e6861794f 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
@@ -170,8 +170,9 @@ public class RestOpContext extends Context implements Comparable<RestOpContext>
this.restContext = context;
this.parent = context.builder;
this.restMethod = method;
+
this.beanStore = BeanStore
- .of(context.getRootBeanStore(), context.builder.resource().get())
+ .of(context.getBeanStore(), context.builder.resource().get())
.addBean(java.lang.reflect.Method.class, method);
MethodInfo mi = MethodInfo.of(context.getResourceClass(), method);
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
index 9806b536a..9fa1876ae 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestSession.java
@@ -226,7 +226,7 @@ public class RestSession extends ContextSession {
super(builder);
context = builder.ctx;
resource = builder.resource;
- beanStore = BeanStore.of(context.getRootBeanStore(), resource).addBean(RestContext.class, context);
+ beanStore = BeanStore.of(context.getBeanStore(), resource).addBean(RestContext.class, context);
req = beanStore.add(HttpServletRequest.class, builder.req);
res = beanStore.add(HttpServletResponse.class, builder.res);
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java
index d068e60ce..de6233a3f 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java
@@ -47,35 +47,89 @@ import org.apache.juneau.svl.*;
* Rest bean injection annotation.
*
* <p>
- * Used on methods of {@link Rest}-annotated classes to denote methods that override and customize beans
+ * Used on methods of {@link Rest}-annotated classes to denote methods and fields that override and customize beans
* used by the REST framework.
*
* <h5 class='figure'>Example</h5>
* <p class='bcode'>
+ * <jc>// Rest resource that uses a customized call logger.</jc>
* <ja>@Rest</ja>
* <jk>public class</jk> MyRest <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
*
- * <jc>// Use a customized call logger for the class.</jc>
+ * <jc>// Option #1: As a field.</jc>
+ * <ja>@RestBean</ja>
+ * CallLogger <jf>myCallLogger</jf> = CallLogger.<jsm>create</jsm>().logger(<js>"mylogger"</js>).build();
+ *
+ * <jc>// Option #2: As a method.</jc>
* <ja>@RestBean</ja>
* <jk>public</jk> CallLogger myCallLogger() {
* <jk>return</jk> CallLogger.<jsm>create</jsm>().logger(<js>"mylogger"</js>).build();
* }
+ * }
+ * </p>
*
- * <jc>// Set a default header on a specific REST method.</jc>
- * <jc>// Input parameter is the default header list builder with all annotations applied.</jc>
- * <ja>@RestBean</ja>(name=<js>"defaultRequestHeaders"</js>,methodScope=<js>"myRestMethod"</js>)
- * <jk>public</jk> HeaderList.Builder myRequestHeaders(HeaderList.Builder <jv>builder</jv>) {
- * <jk>return</jk> <jv>builder</jv>.set(ContentType.<jsf>TEXT_PLAIN</jsf>).build();
- * }
+ * <p>
+ * The {@link RestBean#name()}/{@link RestBean#value()} attributes are used to differentiate between named beans.
+ * </p>
+ * <h5 class='figure'>Example</h5>
+ * <p class='bcode'>
+ * <jc>// Customized default request headers.</jc>
+ * <ja>@RestBean</ja>(<js>"defaultRequestHeaders"</js>)
+ * HeaderList <jf>defaultRequestHeaders</jf> = HeaderList.<jsm>create</jsm>().set(ContentType.<jsf>TEXT_PLAIN</jsf>).build();
+ *
+ * <jc>// Customized default response headers.</jc>
+ * <ja>@RestBean</ja>(<js>"defaultResponseHeaders"</js>)
+ * HeaderList <jf>defaultResponseHeaders</jf> = HeaderList.<jsm>create</jsm>().set(ContentType.<jsf>TEXT_PLAIN</jsf>).build();
+ * </p>
+ *
+ * <p>
+ * The {@link RestBean#methodScope()} attribute is used to define beans in the scope of specific {@link RestOp}-annotated methods.
+ * </p>
+ * <h5 class='figure'>Example</h5>
+ * <p class='bcode'>
+ * <jc>// Set a default header on a specific REST method.</jc>
+ * <jc>// Input parameter is the default header list builder with all annotations applied.</jc>
+ * <ja>@RestBean</ja>(name=<js>"defaultRequestHeaders"</js>, methodScope=<js>"myRestMethod"</js>)
+ * <jk>public</jk> HeaderList.Builder myRequestHeaders(HeaderList.Builder <jv>builder</jv>) {
+ * <jk>return</jk> <jv>builder</jv>.set(ContentType.<jsf>TEXT_PLAIN</jsf>);
* }
+ *
+ * <jc>// Method that picks up default header defined above.</jc>
+ * <ja>@RestGet</ja>
+ * <jk>public</jk> Object myRestMethod(ContentType <jv>contentType</jv>) { ... }
+ * </p>
+ *
+ * <p>
+ * This annotation can also be used to inject arbitrary beans into the bean store which allows them to be
+ * passed as resolved parameters on {@link RestOp}-annotated methods.
+ * </p>
+ * <h5 class='figure'>Example</h5>
+ * <p class='bcode'>
+ * <jc>// Custom beans injected into the bean store.</jc>
+ * <ja>@RestBean</ja> MyBean <jv>myBean1</jv> = <jk>new</jk> MyBean();
+ * <ja>@RestBean</ja>(<js>"myBean2"</js>) MyBean <jv>myBean2</jv> = <jk>new</jk> MyBean();
+ *
+ * <jc>// Method that uses injected beans.</jc>
+ * <ja>@RestGet</ja>
+ * <jk>public</jk> Object doGet(MyBean <jv>myBean1</jv>, <ja>@Named</ja>(<js>"myBean2"</js>) MyBean <jv>myBean2</jv>) { ... }
+ * </p>
+ *
+ * <p>
+ * This annotation can also be used on uninitialized fields. When fields are uninitialized, they will
+ * be set during initialization based on beans found in the bean store.
+ * </p>
+ * <h5 class='figure'>Example</h5>
+ * <p class='bcode'>
+ * <jc>// Fields that get set during initialization based on beans found in the bean store.</jc>
+ * <ja>@RestBean</ja> CallLogger <jf>callLogger</jf>;
+ * <ja>@RestBean</ja> BeanStore <jf>beanStore</jf>; <jc>// Note that BeanStore itself can be accessed this way.</jc>
* </p>
*
- * <ul>
- * <li>Methods must be public.
- * <li>Methods can be static or non-static.
- * <li>Any injectable beans (including spring beans) can be passed as arguments into the method.
- * <li>Bean names are required when multiple beans of the same type exist in the bean store.
- * <li>By default, the injected bean scope is class-level (applies to the entire class). The
+ * <ul class='notes'>
+ * <li class='note'>Methods and fields can be static or non-static.
+ * <li class='note'>Any injectable beans (including spring beans) can be passed as arguments into methods.
+ * <li class='note'>Bean names are required when multiple beans of the same type exist in the bean store.
+ * <li class='note'>By default, the injected bean scope is class-level (applies to the entire class). The
* {@link RestBean#methodScope()} annotation can be used to apply to method-level only (when applicable).
* </ul>
*
@@ -133,6 +187,14 @@ public @interface RestBean {
*/
String name() default "";
+
+ /**
+ * Same as {@link #name()}.
+ *
+ * @return The bean name to use to distinguish beans of the same type for different purposes, or blank if bean type is unique.
+ */
+ String value() default "";
+
/**
* The short names of the methods that this annotation applies to.
*
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBeanAnnotation.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBeanAnnotation.java
new file mode 100644
index 000000000..bf8bad8cb
--- /dev/null
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBeanAnnotation.java
@@ -0,0 +1,196 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.annotation;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.*;
+
+import org.apache.juneau.annotation.*;
+
+/**
+ * Utility classes and methods for the {@link RestBean RestBean} annotation.
+ *
+ * <ul class='seealso'>
+ * <li class='extlink'>{@source}
+ * </ul>
+ */
+public class RestBeanAnnotation {
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Static
+ //-----------------------------------------------------------------------------------------------------------------
+
+ /** Default value */
+ public static final RestBean DEFAULT = create().build();
+
+ /**
+ * Instantiates a new builder for this class.
+ *
+ * @return A new builder object.
+ */
+ public static Builder create() {
+ return new Builder();
+ }
+
+ /**
+ * Pulls the name/value attribute from a {@link RestBean} annotation.
+ *
+ * @param a The annotation to check. Can be <jk>null</jk>.
+ * @return The annotation value, or an empty string if the annotation is <jk>null</jk>.
+ */
+ public static String name(RestBean a) {
+ if (a == null)
+ return "";
+ if (! a.name().isEmpty())
+ return a.name();
+ return a.value();
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Builder
+ //-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Builder class.
+ *
+ * <ul class='seealso'>
+ * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
+ * </ul>
+ */
+ public static class Builder extends TargetedAnnotationMBuilder {
+
+ String name, value;
+ String[] methodScope;
+
+ /**
+ * Constructor.
+ */
+ protected Builder() {
+ super(RestBean.class);
+ }
+
+ /**
+ * Instantiates a new {@link RestBean @RestBean} object initialized with this builder.
+ *
+ * @return A new {@link RestBean @RestBean} object.
+ */
+ public RestBean build() {
+ return new Impl(this);
+ }
+
+ /**
+ * Sets the {@link RestBean#name()} property on this annotation.
+ *
+ * @param value The new value for this property.
+ * @return This object.
+ */
+ public Builder name(String value) {
+ this.name = value;
+ return this;
+ }
+
+ /**
+ * Sets the {@link RestBean#value()} property on this annotation.
+ *
+ * @param value The new value for this property.
+ * @return This object.
+ */
+ public Builder value(String value) {
+ this.value = value;
+ return this;
+ }
+
+ /**
+ * Sets the {@link RestBean#methodScope()} property on this annotation.
+ *
+ * @param value The new value for this property.
+ * @return This object.
+ */
+ public Builder methodScope(String...value) {
+ this.methodScope = value;
+ return this;
+ }
+
+ // <FluentSetters>
+
+ @Override /* GENERATED - TargetedAnnotationBuilder */
+ public Builder on(String...values) {
+ super.on(values);
+ return this;
+ }
+
+ @Override /* GENERATED - TargetedAnnotationTMBuilder */
+ public Builder on(java.lang.reflect.Method...value) {
+ super.on(value);
+ return this;
+ }
+
+ // </FluentSetters>
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Implementation
+ //-----------------------------------------------------------------------------------------------------------------
+
+ private static class Impl extends TargetedAnnotationImpl implements RestBean {
+
+ private final String name, value;
+ private final String[] methodScope;
+
+ Impl(Builder b) {
+ super(b);
+ this.name = b.name;
+ this.value = b.value;
+ this.methodScope = b.methodScope;
+ postConstruct();
+ }
+
+ @Override /* RestBean */
+ public String name() {
+ return name;
+ }
+
+ @Override /* RestBean */
+ public String value() {
+ return value;
+ }
+
+ @Override /* RestBean */
+ public String[] methodScope() {
+ return methodScope;
+ }
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other
+ //-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * A collection of {@link RestBean @RestBean annotations}.
+ */
+ @Documented
+ @Target({FIELD,METHOD,TYPE})
+ @Retention(RUNTIME)
+ @Inherited
+ public static @interface Array {
+
+ /**
+ * The child annotations.
+ *
+ * @return The annotation value.
+ */
+ RestBean[] value();
+ }
+}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/DefaultArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/DefaultArg.java
index a9dd20043..5f840dac1 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/DefaultArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/DefaultArg.java
@@ -12,6 +12,10 @@
// ***************************************************************************************************************************
package org.apache.juneau.rest.arg;
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.lang.annotation.*;
+
import org.apache.juneau.cp.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.rest.*;
@@ -39,6 +43,7 @@ import org.apache.juneau.rest.annotation.*;
public class DefaultArg implements RestOpArg {
private final Class<?> type;
+ private final String name;
private final ParamInfo paramInfo;
/**
@@ -59,10 +64,22 @@ public class DefaultArg implements RestOpArg {
protected DefaultArg(ParamInfo paramInfo) {
this.type = paramInfo.getParameterType().inner();
this.paramInfo = paramInfo;
+ this.name = findBeanName(paramInfo);
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Helper methods
+ //-----------------------------------------------------------------------------------------------------------------
+ private String findBeanName(ParamInfo pi) {
+ Annotation n = pi.getAnnotation(Annotation.class, x -> x.annotationType().getSimpleName().equals("Named"));
+ if (n != null)
+ return AnnotationInfo.of((ClassInfo)null, n).getValue(String.class, "value", NOT_EMPTY).orElse(null);
+ return null;
}
@Override /* RestOpArg */
public Object resolve(RestOpSession opSession) throws Exception {
- return opSession.getBeanStore().getBean(type).orElseThrow(()->new ArgException(paramInfo, "Could not resolve bean type {0}", type.getName()));
+ System.err.println("beanStore2" + opSession.getBeanStore());
+ return opSession.getBeanStore().getBean(type, name).orElseThrow(()->new ArgException(paramInfo, "Could not resolve bean type {0}", type.getName()));
}
}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/assertions/BooleanAssertion_Test.java b/juneau-utest/src/test/java/org/apache/juneau/assertions/BooleanAssertion_Test.java
index faea44673..82d0903c7 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/assertions/BooleanAssertion_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/assertions/BooleanAssertion_Test.java
@@ -37,8 +37,8 @@ public class BooleanAssertion_Test {
@Test
public void a01_msg() throws Exception {
- assertThrown(()->test(null).setMsg("Foo {0}", 1).isExists()).asMessage().is("Foo 1");
- assertThrown(()->test(null).setMsg("Foo {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("Foo 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).isExists()).asMessage().is("A 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("A 1");
}
@Test
diff --git a/juneau-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java b/juneau-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java
index 3d4b5a74c..7c4f4290f 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/assertions/ByteArrayAssertion_Test.java
@@ -38,8 +38,8 @@ public class ByteArrayAssertion_Test {
@Test
public void a01_msg() throws Exception {
- assertThrown(()->test(null).setMsg("Foo {0}", 1).isExists()).asMessage().is("Foo 1");
- assertThrown(()->test(null).setMsg("Foo {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("Foo 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).isExists()).asMessage().is("A 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("A 1");
}
@Test
diff --git a/juneau-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java b/juneau-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java
index 8e591385a..5bf07adf0 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/assertions/CollectionAssertion_Test.java
@@ -41,8 +41,8 @@ public class CollectionAssertion_Test {
@Test
public void a01_msg() throws Exception {
- assertThrown(()->test(null).setMsg("Foo {0}", 1).isExists()).asMessage().is("Foo 1");
- assertThrown(()->test(null).setMsg("Foo {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("Foo 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).isExists()).asMessage().is("A 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("A 1");
}
@Test
diff --git a/juneau-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java b/juneau-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java
index 3f63f8b57..f3779c29b 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/assertions/ComparableAssertion_Test.java
@@ -37,8 +37,8 @@ public class ComparableAssertion_Test {
@Test
public void a01_msg() throws Exception {
- assertThrown(()->test(null).setMsg("Foo {0}", 1).isExists()).asMessage().is("Foo 1");
- assertThrown(()->test(null).setMsg("Foo {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("Foo 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).isExists()).asMessage().is("A 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("A 1");
}
@Test
diff --git a/juneau-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java b/juneau-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java
index 7171cd3fd..52db42f9f 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/assertions/DateAssertion_Test.java
@@ -53,8 +53,8 @@ public class DateAssertion_Test {
@Test
public void a01_msg() throws Exception {
- assertThrown(()->test(null).setMsg("Foo {0}", 1).isExists()).asMessage().is("Foo 1");
- assertThrown(()->test(null).setMsg("Foo {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("Foo 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).isExists()).asMessage().is("A 1");
+ assertThrown(()->test(null).setMsg("A {0}", 1).setThrowable(RuntimeException.class).isExists()).isExactType(RuntimeException.class).asMessage().is("A 1");
}
@Test
diff --git a/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapListenerTest.java b/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapListenerTest.java
index 3d3dc7f65..bf5c35661 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapListenerTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapListenerTest.java
@@ -33,7 +33,7 @@ public class ConfigMapListenerTest {
@Test
public void testBasicDefaultSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"foo=bar"
);
@@ -46,7 +46,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("", "foo", "baz", null, null, null);
cm.commit();
@@ -59,7 +59,7 @@ public class ConfigMapListenerTest {
@Test
public void testBasicNormalSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"foo=bar"
);
@@ -73,7 +73,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("S1", "foo", "baz", null, null, null);
cm.commit();
@@ -90,7 +90,7 @@ public class ConfigMapListenerTest {
@Test
public void testAddNewEntries() throws Exception {
- ConfigStore s = initStore("Foo.cfg"
+ ConfigStore s = initStore("A.cfg"
);
final CountDownLatch latch = new CountDownLatch(2);
@@ -102,7 +102,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("", "k", "vb", null, null, null);
cm.setEntry("S1", "k1", "v1b", null, null, null);
@@ -116,7 +116,7 @@ public class ConfigMapListenerTest {
@Test
public void testAddNewEntriesWithAttributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg"
+ ConfigStore s = initStore("A.cfg"
);
final CountDownLatch latch = new CountDownLatch(2);
@@ -128,7 +128,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("", "k", "kb", "^*", "C", Arrays.asList("#k"));
cm.setEntry("S1", "k1", "k1b", "^*", "C1", Arrays.asList("#k1"));
@@ -142,7 +142,7 @@ public class ConfigMapListenerTest {
@Test
public void testAddExistingEntriesWithAttributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#ka",
"k=va # Ca",
"#S1",
@@ -160,7 +160,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("", "k", "kb", "^*", "Cb", Arrays.asList("#kb"));
cm.setEntry("S1", "k1", "k1b", "^*", "Cb1", Arrays.asList("#k1b"));
@@ -178,7 +178,7 @@ public class ConfigMapListenerTest {
@Test
public void testRemoveExistingEntries() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"k=v",
"[S1]",
"k1=v1"
@@ -193,7 +193,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.removeEntry("", "k");
cm.removeEntry("S1", "k1");
@@ -207,7 +207,7 @@ public class ConfigMapListenerTest {
@Test
public void testRemoveExistingEntriesWithAttributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#ka",
"k=va # Ca",
"#S1",
@@ -225,7 +225,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.removeEntry("", "k");
cm.removeEntry("S1", "k1");
@@ -243,7 +243,7 @@ public class ConfigMapListenerTest {
@Test
public void testAddNewSections() throws Exception {
- ConfigStore s = initStore("Foo.cfg"
+ ConfigStore s = initStore("A.cfg"
);
final CountDownLatch latch = new CountDownLatch(1);
@@ -255,7 +255,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setSection("", Arrays.asList("#D1"));
cm.setSection("S1", Arrays.asList("#S1"));
@@ -272,7 +272,7 @@ public class ConfigMapListenerTest {
@Test
public void testModifyExistingSections() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#Da",
"",
"#S1a",
@@ -290,7 +290,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setSection("", Arrays.asList("#Db"));
cm.setSection("S1", Arrays.asList("#S1b"));
@@ -311,7 +311,7 @@ public class ConfigMapListenerTest {
@Test
public void testRemoveSections() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#Da",
"",
"k = v",
@@ -335,7 +335,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.removeSection("");
cm.removeSection("S1");
@@ -355,7 +355,7 @@ public class ConfigMapListenerTest {
@Test
public void testUpdateFromStore() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
final CountDownLatch latch = new CountDownLatch(3);
@@ -366,9 +366,9 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
- s.update("Foo.cfg",
+ s.update("A.cfg",
"#Da",
"",
"k = v # cv",
@@ -395,7 +395,7 @@ public class ConfigMapListenerTest {
@Test
public void testMergeNoOverwrite() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1a"
);
@@ -412,10 +412,10 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("S2", "k2", "v2b", null, null, null);
- s.update("Foo.cfg",
+ s.update("A.cfg",
"[S1]",
"k1 = v1b"
);
@@ -433,7 +433,7 @@ public class ConfigMapListenerTest {
@Test
public void testMergeWithOverwrite() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1a"
);
@@ -450,10 +450,10 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("S1", "k1", "v1c", null, null, null);
- s.update("Foo.cfg",
+ s.update("A.cfg",
"[S1]",
"k1 = v1b"
);
@@ -497,7 +497,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("S1", "k1", "v1c", null, null, null);
cm.commit();
@@ -543,7 +543,7 @@ public class ConfigMapListenerTest {
}
};
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.register(l);
cm.setEntry("S1", "k1", "v1c", null, null, null);
assertThrown(()->cm.commit()).asMessage().is("Unable to store contents of config to store.");
diff --git a/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapTest.java b/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapTest.java
index 6e8add4dc..dc2c70bf2 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/config/ConfigMapTest.java
@@ -35,7 +35,7 @@ public class ConfigMapTest {
@Test
public void testNonExistentConfig() throws Exception {
ConfigStore s = MemoryStore.create().build();
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertEquals("", cm.toString());
}
@@ -45,12 +45,12 @@ public class ConfigMapTest {
@Test
public void testBlankConfig() throws Exception {
- ConfigStore s = initStore("Foo.cfg", "");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg", "");
+ ConfigMap cm = s.getMap("A.cfg");
assertEquals("", cm.toString());
- s.update("Foo.cfg", " \n \n ");
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", " \n \n ");
+ cm = s.getMap("A.cfg");
}
//-----------------------------------------------------------------------------------------------------------------
@@ -58,10 +58,10 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSimpleOneLine() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"foo=bar"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("foo=bar|");
@@ -71,8 +71,8 @@ public class ConfigMapTest {
assertEquals("bar", cm.getEntry("", "foo").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("foo=bar|");
}
@@ -81,11 +81,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSimpleOneLineWithComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#comment",
"foo=bar"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#comment|foo=bar|");
@@ -95,8 +95,8 @@ public class ConfigMapTest {
assertEquals("bar", cm.getEntry("", "foo").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#comment|foo=bar|");
}
@@ -105,11 +105,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSimpleSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[MySection]",
"foo=bar"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[MySection]|foo=bar|");
@@ -120,8 +120,8 @@ public class ConfigMapTest {
assertEquals("bar", cm.getEntry("MySection", "foo").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[MySection]|foo=bar|");
}
@@ -130,11 +130,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testNonExistentValues() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[MySection]",
"foo=bar"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[MySection]|foo=bar|");
@@ -151,7 +151,7 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSimpleSectionWithComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#S1",
"[S1]",
"#k1",
@@ -161,7 +161,7 @@ public class ConfigMapTest {
"#k2",
"k2=v2"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#S1|[S1]|#k1|k1=v1|#S2|[S2]|#k2|k2=v2|");
assertEquals("", join(cm.getPreLines(""), '|'));
@@ -174,8 +174,8 @@ public class ConfigMapTest {
assertEquals("v2", cm.getEntry("S2", "k2").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#S1|[S1]|#k1|k1=v1|#S2|[S2]|#k2|k2=v2|");
}
@@ -184,7 +184,7 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSimpleAndDefaultSectionsWithComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#D",
"",
"#k",
@@ -194,7 +194,7 @@ public class ConfigMapTest {
"#k1",
"k1=v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#D||#k|k=v|#S1|[S1]|#k1|k1=v1|");
assertEquals("#D", join(cm.getPreLines(""), '|'));
@@ -206,8 +206,8 @@ public class ConfigMapTest {
assertEquals("v1", cm.getEntry("S1", "k1").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#D||#k|k=v|#S1|[S1]|#k1|k1=v1|");
}
@@ -216,7 +216,7 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSimpleAndDefaultSectionsWithCommentsAndExtraSpaces() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#Da",
"#Db",
"",
@@ -238,7 +238,7 @@ public class ConfigMapTest {
"",
"k1=v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#Da|#Db||#ka||#kb||k=v||#S1a||#S1b||[S1]||#k1a||#k1b||k1=v1|");
assertEquals("#Da|#Db", join(cm.getPreLines(""), '|'));
@@ -250,8 +250,8 @@ public class ConfigMapTest {
assertEquals("v1", cm.getEntry("S1", "k1").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#Da|#Db||#ka||#kb||k=v||#S1a||#S1b||[S1]||#k1a||#k1b||k1=v1|");
}
@@ -269,21 +269,21 @@ public class ConfigMapTest {
};
for (String t : test) {
- ConfigStore s = initStore("Foo.cfg", t);
- assertThrown(()->s.getMap("Foo.cfg")).asMessage().isContains("Invalid section name");
+ ConfigStore s = initStore("A.cfg", t);
+ assertThrown(()->s.getMap("A.cfg")).asMessage().isContains("Invalid section name");
}
}
@Test
public void testDuplicateSectionNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg", "[S1]", "[S1]");
- assertThrown(()->s.getMap("Foo.cfg")).asMessage().is("Duplicate section found in configuration: [S1]");
+ ConfigStore s = initStore("A.cfg", "[S1]", "[S1]");
+ assertThrown(()->s.getMap("A.cfg")).asMessage().is("Duplicate section found in configuration: [S1]");
}
@Test
public void testDuplicateEntryNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg", "[S1]", "foo=v1", "foo=v2");
- assertThrown(()->s.getMap("Foo.cfg")).asMessage().is("Duplicate entry found in section [S1] of configuration: foo");
+ ConfigStore s = initStore("A.cfg", "[S1]", "foo=v1", "foo=v2");
+ assertThrown(()->s.getMap("A.cfg")).asMessage().is("Duplicate entry found in section [S1] of configuration: foo");
}
//-----------------------------------------------------------------------------------------------------------------
@@ -291,7 +291,7 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testMultipleLines() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"k1 = v1a,",
"\tv1b,",
"\tv1c",
@@ -299,7 +299,7 @@ public class ConfigMapTest {
"\tv2b,",
"\tv2c"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertEquals("", join(cm.getEntry("", "k1").getPreLines(), '|'));
assertEquals("", join(cm.getEntry("", "k2").getPreLines(), '|'));
@@ -310,14 +310,14 @@ public class ConfigMapTest {
assertEquals("v2a,\nv2b,\nv2c", cm.getEntry("", "k2").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("k1 = v1a,|\tv1b,|\tv1c|k2 = v2a,|\tv2b,|\tv2c|");
}
@Test
public void testMultipleLinesWithSpacesAndComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"",
"#k1",
"",
@@ -331,7 +331,7 @@ public class ConfigMapTest {
"\tv2b,",
"\tv2c"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertEquals("|#k1|", join(cm.getEntry("", "k1").getPreLines(), '|'));
assertEquals("|#k2|", join(cm.getEntry("", "k2").getPreLines(), '|'));
@@ -342,14 +342,14 @@ public class ConfigMapTest {
assertEquals("v2a,\nv2b,\nv2c", cm.getEntry("", "k2").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("|#k1||k1 = v1a,| v1b,| v1c||#k2||k2 = v2a,| v2b,| v2c|");
}
@Test
public void testMultipleLinesInSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1a,",
"\tv1b,",
@@ -358,7 +358,7 @@ public class ConfigMapTest {
"\tv2b,",
"\tv2c"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertEquals("", join(cm.getEntry("S1", "k1").getPreLines(), '|'));
assertEquals("", join(cm.getEntry("S1", "k2").getPreLines(), '|'));
@@ -369,14 +369,14 @@ public class ConfigMapTest {
assertEquals("v2a,\nv2b,\nv2c", cm.getEntry("S1", "k2").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1a,|\tv1b,|\tv1c|k2 = v2a,|\tv2b,|\tv2c|");
}
@Test
public void testMultipleLinesInSectionWithSpacesAndPrelines() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"",
"#S1",
"",
@@ -394,7 +394,7 @@ public class ConfigMapTest {
"\tv2b,",
"\tv2c"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertEquals("|#S1|", join(cm.getPreLines("S1"), '|'));
assertEquals("|#k1|", join(cm.getEntry("S1", "k1").getPreLines(), '|'));
@@ -406,8 +406,8 @@ public class ConfigMapTest {
assertEquals("v2a,\nv2b,\nv2c", cm.getEntry("S1", "k2").getValue());
// Round trip.
- s.update("Foo.cfg", cm.toString());
- cm = s.getMap("Foo.cfg");
+ s.update("A.cfg", cm.toString());
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("|#S1||[S1]||#k1||k1 = v1a,| v1b,| v1c||#k2||k2 = v2a,| v2b,| v2c|");
}
@@ -416,11 +416,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testEntriesWithComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = foo # comment"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = foo # comment|");
assertEquals("foo", cm.getEntry("S1", "k1").getValue());
@@ -444,12 +444,12 @@ public class ConfigMapTest {
@Test
public void testEntriesWithOddComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = foo#",
"k2 = foo # "
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = foo#|k2 = foo # |");
assertEquals("", cm.getEntry("S1", "k1").getComment());
assertEquals("", cm.getEntry("S1", "k2").getComment());
@@ -457,13 +457,13 @@ public class ConfigMapTest {
@Test
public void testEntriesWithEscapedComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = foo\\#bar",
"k2 = foo \\# bar",
"k3 = foo \\# bar # real-comment"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = foo\\#bar|k2 = foo \\# bar|k3 = foo \\# bar # real-comment|");
assertEquals(null, cm.getEntry("S1", "k1").getComment());
@@ -476,12 +476,12 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSettingEntries() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1a",
"k2 = v2a"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", "v1b", null, null, null);
cm.setEntry("S1", "k2", null, null, null, null);
@@ -493,13 +493,13 @@ public class ConfigMapTest {
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1b|k2 = v2a|k3 = v3b|");
// Round trip.
- cm = s.getMap("Foo.cfg");
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1b|k2 = v2a|k3 = v3b|");
}
@Test
public void testSettingEntriesWithPreLines() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"",
"#S1",
"",
@@ -513,7 +513,7 @@ public class ConfigMapTest {
"",
"k2 = v2a"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", "v1b", null, null, null);
cm.setEntry("S1", "k2", null, null, null, null);
@@ -523,17 +523,17 @@ public class ConfigMapTest {
assertString(cm).asReplaceAll("\\r?\\n", "|").is("|#S1||[S1]||#k1||k1 = v1b||#k2||k2 = v2a|k3 = v3b||#k4||k4 = v4b|");
cm.commit();
- assertString(s.read("Foo.cfg")).asReplaceAll("\\r?\\n", "|").is("|#S1||[S1]||#k1||k1 = v1b||#k2||k2 = v2a|k3 = v3b||#k4||k4 = v4b|");
+ assertString(s.read("A.cfg")).asReplaceAll("\\r?\\n", "|").is("|#S1||[S1]||#k1||k1 = v1b||#k2||k2 = v2a|k3 = v3b||#k4||k4 = v4b|");
// Round trip.
- cm = s.getMap("Foo.cfg");
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("|#S1||[S1]||#k1||k1 = v1b||#k2||k2 = v2a|k3 = v3b||#k4||k4 = v4b|");
}
@Test
public void testSettingEntriesWithNewlines() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("", "k", "v1\nv2\nv3", null, null, null);
cm.setEntry("S1", "k1", "v1\nv2\nv3", null, null, null);
@@ -546,14 +546,14 @@ public class ConfigMapTest {
assertString(cm).asReplaceAll("\\r?\\n", "|").is("k = v1| v2| v3|[S1]|k1 = v1| v2| v3|");
// Round trip.
- cm = s.getMap("Foo.cfg");
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("k = v1| v2| v3|[S1]|k1 = v1| v2| v3|");
}
@Test
public void testSettingEntriesWithNewlinesAndSpaces() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("", "k", "v1 \n v2 \n v3", null, null, null);
cm.setEntry("S1", "k1", "v1\t\n\tv2\t\n\tv3", null, null, null);
@@ -566,7 +566,7 @@ public class ConfigMapTest {
assertString(cm).asReplaceAll("\\r?\\n", "|").is("k = v1 | v2 | v3|[S1]|k1 = v1 | v2 | v3|");
// Round trip.
- cm = s.getMap("Foo.cfg");
+ cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("k = v1 | v2 | v3|[S1]|k1 = v1 | v2 | v3|");
}
@@ -575,11 +575,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSetSectionOnExistingSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setSection("S1", Arrays.asList("#S1"));
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#S1|[S1]|k1 = v1|");
@@ -591,11 +591,11 @@ public class ConfigMapTest {
@Test
public void testSetSectionOnDefaultSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setSection("", Arrays.asList("#D"));
assertString(cm).asReplaceAll("\\r?\\n", "|").is("#D||[S1]|k1 = v1|");
@@ -607,11 +607,11 @@ public class ConfigMapTest {
@Test
public void testSetSectionOnNewSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setSection("S2", Arrays.asList("#S2"));
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|#S2|[S2]|");
@@ -623,8 +623,8 @@ public class ConfigMapTest {
@Test
public void testSetSectionBadNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
String[] test = {
"/", "[", "]",
@@ -640,8 +640,8 @@ public class ConfigMapTest {
@Test
public void testSetSectionOkNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
// These are all okay characters to use in section names.
String validChars = "~`!@#$%^&*()_-+={}|:;\"\'<,>.?";
@@ -664,14 +664,14 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testRemoveSectionOnExistingSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1",
"[S2]",
"k2 = v2"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.removeSection("S1");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S2]|k2 = v2|");
@@ -679,14 +679,14 @@ public class ConfigMapTest {
@Test
public void testRemoveSectionOnNonExistingSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1",
"[S2]",
"k2 = v2"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.removeSection("S3");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|[S2]|k2 = v2|");
@@ -696,7 +696,7 @@ public class ConfigMapTest {
@Test
public void testRemoveDefaultSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"k = v",
"[S1]",
"k1 = v1",
@@ -704,7 +704,7 @@ public class ConfigMapTest {
"k2 = v2"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.removeSection("");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|[S2]|k2 = v2|");
@@ -712,7 +712,7 @@ public class ConfigMapTest {
@Test
public void testRemoveDefaultSectionWithComments() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"#D",
"",
"#k",
@@ -723,7 +723,7 @@ public class ConfigMapTest {
"k2 = v2"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.removeSection("");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|[S2]|k2 = v2|");
@@ -734,11 +734,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSetPrelinesOnExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", null, null, null, Arrays.asList("#k1"));
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|#k1|k1 = v1|");
@@ -750,12 +750,12 @@ public class ConfigMapTest {
@Test
public void testSetPrelinesOnExistingEntryWithAtrributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"#k1a",
"k1 = v1 # comment"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", null, null, null, Arrays.asList("#k1b"));
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|#k1b|k1 = v1 # comment|");
@@ -763,11 +763,11 @@ public class ConfigMapTest {
@Test
public void testSetPrelinesOnNonExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k2", null, null, null, Arrays.asList("#k2"));
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|");
@@ -789,11 +789,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSetValueOnExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v2|");
@@ -801,12 +801,12 @@ public class ConfigMapTest {
@Test
public void testSetValueOnExistingEntryWithAttributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"#k1",
"k1 = v1 # comment"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|#k1|k1 = v2 # comment|");
@@ -814,11 +814,11 @@ public class ConfigMapTest {
@Test
public void testSetValueToNullOnExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", null, null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|");
@@ -826,11 +826,11 @@ public class ConfigMapTest {
@Test
public void testSetValueOnNonExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k2", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|k2 = v2|");
@@ -842,11 +842,11 @@ public class ConfigMapTest {
@Test
public void testSetValueOnNonExistingEntryOnNonExistentSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S2", "k2", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|[S2]|k2 = v2|");
@@ -854,8 +854,8 @@ public class ConfigMapTest {
@Test
public void testSetValueInvalidSectionNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
String[] test = {
"/", "[", "]",
@@ -871,8 +871,8 @@ public class ConfigMapTest {
@Test
public void testSetValueInvalidKeyNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
String[] test = {
"", " ", "\t",
@@ -892,11 +892,11 @@ public class ConfigMapTest {
@Test
public void testSetValueWithCommentChars() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
// If value has # in it, it should get escaped.
cm.setEntry("S1", "k1", "v1 # foo", null, null, null);
@@ -908,11 +908,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSetCommentOnExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", null, null, "c1", null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1 # c1|");
@@ -928,12 +928,12 @@ public class ConfigMapTest {
@Test
public void testSetCommentOnExistingEntryWithAttributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"#k1a",
"k1 = v1 # c1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", null, null, "c2", null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|#k1a|k1 = v1 # c2|");
@@ -941,11 +941,11 @@ public class ConfigMapTest {
@Test
public void testSetCommentOnNonExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k2", null, null, "foo", null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|");
@@ -963,11 +963,11 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testSetEntryOnExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v2|");
@@ -981,12 +981,12 @@ public class ConfigMapTest {
@Test
public void testSetEntryOnExistingEntryWithAttributes() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"#k1",
"k1 = v1 # comment"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|#k1|k1 = v2 # comment|");
@@ -1000,11 +1000,11 @@ public class ConfigMapTest {
@Test
public void testSetEntryToNullOnExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k1", null, null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|");
@@ -1012,11 +1012,11 @@ public class ConfigMapTest {
@Test
public void testSetEntryOnNonExistingEntry() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S1", "k2", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|k2 = v2|");
@@ -1028,11 +1028,11 @@ public class ConfigMapTest {
@Test
public void testSetEntryOnNonExistingEntryOnNonExistentSection() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
cm.setEntry("S2", "k2", "v2", null, null, null);
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1 = v1|[S2]|k2 = v2|");
@@ -1040,8 +1040,8 @@ public class ConfigMapTest {
@Test
public void testSetEntryInvalidSectionNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
String[] test = {
"/", "[", "]",
@@ -1057,8 +1057,8 @@ public class ConfigMapTest {
@Test
public void testSetEntryInvalidKeyNames() throws Exception {
- ConfigStore s = initStore("Foo.cfg");
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigStore s = initStore("A.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
String[] test = {
"", " ", "\t",
@@ -1078,11 +1078,11 @@ public class ConfigMapTest {
@Test
public void testSetEntryWithCommentChars() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1 = v1"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
// If value has # in it, it should get escaped.
cm.setEntry("S1", "k1", "v1 # foo", null, null, null);
@@ -1094,13 +1094,13 @@ public class ConfigMapTest {
//-----------------------------------------------------------------------------------------------------------------
@Test
public void testModifiers() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1<^> = v1",
"k2<*> = v2",
"k3<*^> = v3"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
assertString(cm).asReplaceAll("\\r?\\n", "|").is("[S1]|k1<^> = v1|k2<*> = v2|k3<*^> = v3|");
assertEquals("^", cm.getEntry("S1", "k1").getModifiers());
@@ -1113,13 +1113,13 @@ public class ConfigMapTest {
@Test
public void testInvalidModifier() throws Exception {
- ConfigStore s = initStore("Foo.cfg",
+ ConfigStore s = initStore("A.cfg",
"[S1]",
"k1^ = v1",
"k2* = v2",
"k3*^ = v3"
);
- ConfigMap cm = s.getMap("Foo.cfg");
+ ConfigMap cm = s.getMap("A.cfg");
// This is okay.
cm.setEntry("S1", "k1", "v1", "", null, null);
diff --git a/juneau-utest/src/test/java/org/apache/juneau/cp/BeanStore_Test.java b/juneau-utest/src/test/java/org/apache/juneau/cp/BeanStore_Test.java
index 0cb2dd0d7..4169d8fc8 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/cp/BeanStore_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/cp/BeanStore_Test.java
@@ -65,7 +65,7 @@ public class BeanStore_Test {
public void a01_builderCopyConstructor() {
BeanStore b1p = BeanStore.create().readOnly().threadSafe().build();
BeanStore b1c = BeanStore.create().parent(b1p).build();
- assertString(b1c.toString()).is("{parent:{readOnly:true,threadSafe:true}}");
+ assertString(b1c.toString()).isContains("readOnly:true","threadSafe:true");
}
@Test
@@ -161,10 +161,10 @@ public class BeanStore_Test {
assertList(b.stream(A2.class).map(BeanStoreEntry::get)).isHas(a2a);
}
- assertString(b1p.toString()).is("{entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}]}");
- assertString(b1c.toString()).is("{entries:[{type:'A2',bean:'"+identity(a2a)+"'}],parent:{entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}]}}");
- assertString(b2p.toString()).is("{entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}],threadSafe:true}");
- assertString(b2c.toString()).is("{entries:[{type:'A2',bean:'"+identity(a2a)+"'}],parent:{entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}],threadSafe:true},threadSafe:true}");
+ assertString(b1p.toString()).isMatches("{*,entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}]}");
+ assertString(b1c.toString()).isMatches("{*,entries:[{type:'A2',bean:'"+identity(a2a)+"'}],parent:{*,entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}]}}");
+ assertString(b2p.toString()).isMatches("{*,entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}],threadSafe:true}");
+ assertString(b2c.toString()).isMatches("{*,entries:[{type:'A2',bean:'"+identity(a2a)+"'}],parent:{*,entries:[{type:'A1',bean:'"+identity(a1b)+"'},{type:'A1',bean:'"+identity(a1a)+"'}],threadSafe:true},threadSafe:true}");
b1p.removeBean(A1.class);
b1c.clear().addBean(A1.class, a1a);
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/response/Conflict_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/response/Conflict_Test.java
index 536c35e4e..7ff9fa122 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/response/Conflict_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/response/Conflict_Test.java
@@ -44,7 +44,7 @@ public class Conflict_Test {
}
@RestGet
public void f5() throws Conflict {
- throw conflict().header("Foo", "bar").build();
+ throw conflict().header("A", "bar").build();
}
@RestGet
public void f6() throws Conflict {
@@ -71,7 +71,7 @@ public class Conflict_Test {
c.get("/f5").run()
.assertStatus().asCode().is(STATUS_CODE)
.assertContent().is(REASON_PHRASE)
- .assertHeader("Foo").is("bar");
+ .assertHeader("A").is("bar");
c.get("/f6").run()
.assertStatus().asCode().is(STATUS_CODE)
.assertContent().is("foo");
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/response/Continue_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/response/Continue_Test.java
index de662076a..b4b5dcb01 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/response/Continue_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/response/Continue_Test.java
@@ -26,7 +26,7 @@ public class Continue_Test {
public static class A {
@RestGet public Continue a1() { return CONTINUE; }
@RestGet public Continue a2() { return _continue().content("foo").build(); }
- @RestGet public Continue a3() { return _continue().header("Foo","bar").build(); }
+ @RestGet public Continue a3() { return _continue().header("A","bar").build(); }
}
@Test
@@ -44,6 +44,6 @@ public class Continue_Test {
client.get("/a3")
.run()
.assertCode().is(1100)
- .assertHeader("Foo").is("bar");
+ .assertHeader("A").is("bar");
}
}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java
index ee1cb343a..078d1c63d 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/response/Created_Test.java
@@ -26,7 +26,7 @@ public class Created_Test {
public static class A {
@RestGet public Created a1() { return CREATED; }
@RestGet public Created a2() { return created().content("foo").build(); }
- @RestGet public Created a3() { return created().header("Foo","bar").build(); }
+ @RestGet public Created a3() { return created().header("A","bar").build(); }
}
@Test
@@ -44,6 +44,6 @@ public class Created_Test {
client.get("/a3")
.run()
.assertCode().is(201)
- .assertHeader("Foo").is("bar");
+ .assertHeader("A").is("bar");
}
}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java b/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
index 3589dbdb7..2b9274404 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
@@ -15,8 +15,11 @@ package org.apache.juneau.rest;
import static org.apache.juneau.assertions.Assertions.*;
import static org.junit.runners.MethodSorters.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.cp.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.rest.config.*;
import org.apache.juneau.rest.mock.*;
import org.junit.*;
@@ -27,7 +30,7 @@ public class RestContext_Builder_Test {
// beanStore
//-----------------------------------------------------------------------------------------------------------------
- public static class Foo {}
+ public static class A {}
@Rest
public static class A1 {
@@ -42,7 +45,7 @@ public class RestContext_Builder_Test {
public static class MyBeanStore extends BeanStore {
protected MyBeanStore(Builder builder) {
- super(builder.parent(BeanStore.create().build().addBean(Foo.class, new Foo())));
+ super(builder.parent(BeanStore.create().build().addBean(A.class, new A())));
}
}
@@ -54,7 +57,7 @@ public class RestContext_Builder_Test {
@Test
public void a02_createBeanStore_annotation() {
MockRestClient.buildLax(A2.class);
- assertObject(A2.beanStore.getBean(Foo.class)).isNotNull();
+ assertObject(A2.beanStore.getBean(A.class)).isNotNull();
}
@Rest
@@ -69,7 +72,7 @@ public class RestContext_Builder_Test {
@Test
public void a03_createBeanStore_restBean1() {
MockRestClient.buildLax(A3.class);
- assertObject(A3.beanStore.getBean(Foo.class)).isNotNull();
+ assertObject(A3.beanStore.getBean(A.class)).isNotNull();
}
@Rest
@@ -84,6 +87,54 @@ public class RestContext_Builder_Test {
@Test
public void a04_createBeanStore_restBean2() {
MockRestClient.buildLax(A4.class);
- assertObject(A4.beanStore.getBean(Foo.class)).isNotNull();
+ assertObject(A4.beanStore.getBean(A.class)).isNotNull();
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // @RestBean on fields.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ public static class B {
+ public int id;
+
+ public B(int id) {
+ this.id = id;
+ }
+ }
+
+ @Rest
+ public static class B1a implements BasicJsonConfig {
+ @RestBean static B b1 = new B(1);
+ @RestBean(name="b2") B b2 = new B(2);
+
+ @RestBean static B b3;
+ @RestBean(name="b2") B b4;
+
+ @RestGet("/a1") public B a1(B b) { return b; }
+ @RestGet("/a2") public B a2(@Named("b2") B b) { return b; }
+ @RestGet("/a3") public B a3() { return b3; }
+ @RestGet("/a4") public B a4() { return b4; }
+ }
+
+ @Rest
+ public static class B1b extends B1a {
+ @RestGet("/a5") public B a5(B b) { return b; }
+ @RestGet("/a6") public B a6(@Named("b2") B b) { return b; }
+ @RestGet("/a7") public B a7() { return b3; }
+ @RestGet("/a8") public B a8() { return b4; }
+ }
+
+ static RestClient b1b = MockRestClient.createLax(B1b.class).simpleJson().build();
+
+ @Test
+ public void b01_RestBean_fields() throws Exception {
+ b1b.get("/a1").run().assertContent().is("{id:1}");
+ b1b.get("/a2").run().assertContent().is("{id:2}");
+ b1b.get("/a3").run().assertContent().is("{id:1}");
+ b1b.get("/a4").run().assertContent().is("{id:2}");
+ b1b.get("/a5").run().assertContent().is("{id:1}");
+ b1b.get("/a6").run().assertContent().is("{id:2}");
+ b1b.get("/a7").run().assertContent().is("{id:1}");
+ b1b.get("/a8").run().assertContent().is("{id:2}");
}
}