From 562ece3bed9396513351599c943b8ab90075fb00 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Wed, 23 Sep 2020 12:09:46 +0100 Subject: [PATCH] Apply formatter and import plugins. Signed-off-by: Roberto Cortez --- .../eclipse/microprofile/config/Config.java | 156 ++- .../microprofile/config/ConfigProvider.java | 29 +- .../microprofile/config/ConfigValue.java | 3 +- .../config/inject/ConfigProperties.java | 28 +- .../config/inject/ConfigProperty.java | 35 +- .../config/inject/package-info.java | 13 +- .../microprofile/config/package-info.java | 29 +- .../config/spi/ConfigBuilder.java | 47 +- .../config/spi/ConfigProviderResolver.java | 58 +- .../microprofile/config/spi/ConfigSource.java | 74 +- .../config/spi/ConfigSourceProvider.java | 11 +- .../microprofile/config/spi/Converter.java | 84 +- .../microprofile/config/spi/package-info.java | 4 +- .../config/tck/ArrayConverterBean.java | 2 +- .../config/tck/ArrayConverterTest.java | 1214 +++++++++-------- .../tck/AutoDiscoveredConfigSourceTest.java | 12 +- .../config/tck/CDIPlainInjectionTest.java | 62 +- .../tck/CDIPropertyExpressionsTest.java | 31 +- .../tck/CDIPropertyNameMatchingTest.java | 55 +- .../config/tck/CdiOptionalInjectionTest.java | 11 +- .../config/tck/ClassConverterBean.java | 10 +- .../config/tck/ClassConverterTest.java | 17 +- .../config/tck/ConfigPropertiesTest.java | 98 +- .../config/tck/ConfigProviderTest.java | 21 +- .../config/tck/ConfigValueTest.java | 36 +- .../config/tck/ConverterTest.java | 128 +- .../config/tck/CustomConfigSourceTest.java | 5 +- .../config/tck/CustomConverterTest.java | 31 +- .../config/tck/ImplicitConverterTest.java | 75 +- .../microprofile/config/tck/Location.java | 11 +- .../config/tck/OptionalValuesBean.java | 9 +- .../config/tck/ParseConverterInjection.java | 4 +- .../config/tck/PropertyExpressionsTest.java | 59 +- .../config/tck/SimpleValuesBean.java | 21 +- .../config/tck/WarPropertiesLocationTest.java | 4 +- .../config/tck/base/AbstractTest.java | 5 +- .../config/tck/broken/ConfigObserver.java | 15 +- .../config/tck/broken/ConfigOwner.java | 3 +- ...ropertiesMissingPropertyInjectionTest.java | 11 +- .../tck/broken/CustomConverterBean.java | 3 +- ...ssingConverterOnInstanceInjectionTest.java | 1 - .../MissingValueOnInstanceInjectionTest.java | 2 - ...ingValueOnObserverMethodInjectionTest.java | 12 +- ...WrongConverterOnInstanceInjectionTest.java | 2 - .../CustomConfigProfileConfigSource.java | 4 +- .../CustomConfigSourceProvider.java | 4 +- .../configsources/CustomDbConfigSource.java | 3 +- .../configsources/SampleYamlConfigSource.java | 2 +- .../config/tck/converters/Donald.java | 8 +- .../config/tck/converters/Duck.java | 1 - .../tck/converters/NullConvertersTest.java | 12 +- .../config/tck/converters/Pizza.java | 48 +- .../config/tck/converters/PizzaConverter.java | 2 +- .../converters/custom/BooleanConverter.java | 4 +- .../converters/custom/CharacterConverter.java | 4 +- .../converters/custom/DoubleConverter.java | 4 +- .../converters/custom/IntegerConverter.java | 4 +- .../tck/converters/custom/LongConverter.java | 4 +- .../ConvTestSequenceOfBeforeValueOf.java | 3 +- ...onvTestSequenceParseBeforeConstructor.java | 4 +- .../ConvTestSequenceValueOfBeforeParse.java | 4 +- .../ConvTestTypeWCharSequenceParse.java | 2 - .../implicit/SomeEnumToConvert.java | 5 +- .../tck/emptyvalue/EmptyValuesBean.java | 6 +- .../tck/emptyvalue/EmptyValuesTest.java | 4 +- .../EmptyValuesTestProgrammaticLookup.java | 49 +- .../tck/matchers/AdditionalMatchers.java | 9 +- .../ConfigPropertyFileProfileTest.java | 32 +- .../tck/profile/DevConfigProfileTest.java | 14 +- .../tck/profile/InvalidConfigProfileTest.java | 14 +- .../config/tck/profile/ProdProfileTest.java | 14 +- .../tck/profile/TestConfigProfileTest.java | 14 +- .../tck/profile/TestCustomConfigProfile.java | 17 +- 73 files changed, 1473 insertions(+), 1363 deletions(-) diff --git a/api/src/main/java/org/eclipse/microprofile/config/Config.java b/api/src/main/java/org/eclipse/microprofile/config/Config.java index 46117224..5ae68483 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/Config.java +++ b/api/src/main/java/org/eclipse/microprofile/config/Config.java @@ -30,8 +30,9 @@ * Additional reviews and feedback by Tomas Langer. */ package org.eclipse.microprofile.config; -import java.util.Arrays; + import java.lang.reflect.Array; +import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -60,9 +61,9 @@ * *
  * public void doSomething() {
- *   Config cfg = ConfigProvider.getConfig();
- *   String archiveUrl = cfg.getValue("my.project.archive.endpoint", String.class);
- *   Integer archivePort = cfg.getValue("my.project.archive.port", Integer.class);
+ *     Config cfg = ConfigProvider.getConfig();
+ *     String archiveUrl = cfg.getValue("my.project.archive.endpoint", String.class);
+ *     Integer archivePort = cfg.getValue("my.project.archive.port", Integer.class);
  * }
  * 
* @@ -71,8 +72,8 @@ * *
  * public class MyService {
- *   @Inject
- *   private Config config;
+ *     @Inject
+ *     private Config config;
  * }
  * 
* @@ -80,8 +81,8 @@ * See {@link #getValue(String, Class)} and {@link #getOptionalValue(String, Class)} for accessing a configured value. * *

- * Configured values can also be accessed via injection. - * See {@link org.eclipse.microprofile.config.inject.ConfigProperty} for more information. + * Configured values can also be accessed via injection. See + * {@link org.eclipse.microprofile.config.inject.ConfigProperty} for more information. * * @author Mark Struberg * @author Gerhard Petracek @@ -105,61 +106,70 @@ public interface Config { String PROPERTY_EXPRESSIONS_ENABLED = "mp.config.property.expressions.enabled"; /** - * Return the resolved property value with the specified type for the - * specified property name from the underlying {@linkplain ConfigSource configuration sources}. + * Return the resolved property value with the specified type for the specified property name from the underlying + * {@linkplain ConfigSource configuration sources}. *

- * The configuration value is not guaranteed to be cached by the implementation, and may be expensive - * to compute; therefore, if the returned value is intended to be frequently used, callers should consider storing - * rather than recomputing it. + * The configuration value is not guaranteed to be cached by the implementation, and may be expensive to compute; + * therefore, if the returned value is intended to be frequently used, callers should consider storing rather than + * recomputing it. *

- * The result of this method is identical to the result of calling {@code getOptionalValue(propertyName, propertyType).get()}. - * In particular, If the given property name or the value element of this property does not exist, - * the {@link java.util.NoSuchElementException} is thrown. This method never returns {@code null}. + * The result of this method is identical to the result of calling + * {@code getOptionalValue(propertyName, propertyType).get()}. In particular, If the given property name or the + * value element of this property does not exist, the {@link java.util.NoSuchElementException} is thrown. This + * method never returns {@code null}. * * @param - * The property type + * The property type * @param propertyName - * The configuration property name + * The configuration property name * @param propertyType - * The type into which the resolved property value should get converted + * The type into which the resolved property value should get converted * @return the resolved property value as an instance of the requested type (not {@code null}) - * @throws IllegalArgumentException if the property cannot be converted to the specified type - * @throws java.util.NoSuchElementException if the property is not defined or is defined as an empty string + * @throws IllegalArgumentException + * if the property cannot be converted to the specified type + * @throws java.util.NoSuchElementException + * if the property is not defined or is defined as an empty string */ T getValue(String propertyName, Class propertyType); /** - * Return the {@link ConfigValue} for the specified property name from the underlying - * {@linkplain ConfigSource configuration source}. The lookup of the configuration is performed immediatily, - * meaning that calls to {@link ConfigValue} will always yeld the same results. + * Return the {@link ConfigValue} for the specified property name from the underlying {@linkplain ConfigSource + * configuration source}. The lookup of the configuration is performed immediatily, meaning that calls to + * {@link ConfigValue} will always yeld the same results. *

- * The configuration value is not guaranteed to be cached by the implementation, and may be expensive - * to compute; therefore, if the returned value is intended to be frequently used, callers should consider storing - * rather than recomputing it. + * The configuration value is not guaranteed to be cached by the implementation, and may be expensive to compute; + * therefore, if the returned value is intended to be frequently used, callers should consider storing rather than + * recomputing it. *

* A {@link ConfigValue} is always returned even if a property name cannot be found. In this case, every method in * {@link ConfigValue} returns {@code null} except for {@link ConfigValue#getName()}, which includes the original * property name being looked up. * - * @param propertyName The configuration property name + * @param propertyName + * The configuration property name * @return the resolved property value as a {@link ConfigValue} */ ConfigValue getConfigValue(String propertyName); /** - * Return the resolved property values with the specified type for the - * specified property name from the underlying {@linkplain ConfigSource configuration sources}. + * Return the resolved property values with the specified type for the specified property name from the underlying + * {@linkplain ConfigSource configuration sources}. *

- * The configuration values are not guaranteed to be cached by the implementation, and may be expensive - * to compute; therefore, if the returned values are intended to be frequently used, callers should consider storing - * rather than recomputing them. + * The configuration values are not guaranteed to be cached by the implementation, and may be expensive to compute; + * therefore, if the returned values are intended to be frequently used, callers should consider storing rather than + * recomputing them. * - * @param The property type - * @param propertyName The configuration property name - * @param propertyType The type into which the resolved property values should get converted + * @param + * The property type + * @param propertyName + * The configuration property name + * @param propertyType + * The type into which the resolved property values should get converted * @return the resolved property values as a list of instances of the requested type - * @throws java.lang.IllegalArgumentException if the property values cannot be converted to the specified type - * @throws java.util.NoSuchElementException if the property isn't present in the configuration + * @throws java.lang.IllegalArgumentException + * if the property values cannot be converted to the specified type + * @throws java.util.NoSuchElementException + * if the property isn't present in the configuration */ default List getValues(String propertyName, Class propertyType) { @SuppressWarnings("unchecked") @@ -168,38 +178,46 @@ default List getValues(String propertyName, Class propertyType) { } /** - * Return the resolved property value with the specified type for the - * specified property name from the underlying {@linkplain ConfigSource configuration sources}. + * Return the resolved property value with the specified type for the specified property name from the underlying + * {@linkplain ConfigSource configuration sources}. *

- * The configuration value is not guaranteed to be cached by the implementation, and may be expensive - * to compute; therefore, if the returned value is intended to be frequently used, callers should consider storing - * rather than recomputing it. + * The configuration value is not guaranteed to be cached by the implementation, and may be expensive to compute; + * therefore, if the returned value is intended to be frequently used, callers should consider storing rather than + * recomputing it. *

* If this method is used very often then consider to locally store the configured value. * - * @param The property type - * @param propertyName The configuration property name - * @param propertyType The type into which the resolved property value should be converted + * @param + * The property type + * @param propertyName + * The configuration property name + * @param propertyType + * The type into which the resolved property value should be converted * @return The resolved property value as an {@code Optional} wrapping the requested type * - * @throws IllegalArgumentException if the property cannot be converted to the specified type + * @throws IllegalArgumentException + * if the property cannot be converted to the specified type */ Optional getOptionalValue(String propertyName, Class propertyType); /** - * Return the resolved property values with the specified type for the - * specified property name from the underlying {@linkplain ConfigSource configuration sources}. + * Return the resolved property values with the specified type for the specified property name from the underlying + * {@linkplain ConfigSource configuration sources}. *

- * The configuration values are not guaranteed to be cached by the implementation, and may be expensive - * to compute; therefore, if the returned values are intended to be frequently used, callers should consider storing - * rather than recomputing them. + * The configuration values are not guaranteed to be cached by the implementation, and may be expensive to compute; + * therefore, if the returned values are intended to be frequently used, callers should consider storing rather than + * recomputing them. * - * @param The property type - * @param propertyName The configuration property name - * @param propertyType The type into which the resolved property values should be converted + * @param + * The property type + * @param propertyName + * The configuration property name + * @param propertyType + * The type into which the resolved property values should be converted * @return The resolved property values as an {@code Optional} wrapping a list of the requested type * - * @throws java.lang.IllegalArgumentException if the property cannot be converted to the specified type + * @throws java.lang.IllegalArgumentException + * if the property cannot be converted to the specified type */ default Optional> getOptionalValues(String propertyName, Class propertyType) { @SuppressWarnings("unchecked") @@ -216,8 +234,8 @@ default Optional> getOptionalValues(String propertyName, Class pr * There is no guarantee about the completeness or currency of the names returned, nor is there any guarantee that a * name that is returned by the iterator will resolve to a non-empty value or be found in any configuration source * associated with the configuration; for example, it is allowed for this method to return an empty set always. - * However, the implementation should return a set of names that is useful to a - * user that wishes to browse the configuration. + * However, the implementation should return a set of names that is useful to a user that wishes to browse + * the configuration. *

* It is implementation-defined whether the returned names reflect a point-in-time "snapshot" of names, or an * aggregation of multiple point-in-time "snapshots", or a more dynamic view of the available property names. @@ -236,8 +254,9 @@ default Optional> getOptionalValues(String propertyName, Class pr * Return all of the currently registered {@linkplain ConfigSource configuration sources} for this configuration. *

* The returned sources will be sorted by descending ordinal value and name, which can be iterated in a thread-safe - * manner. The {@link java.lang.Iterable Iterable} contains a fixed number of {@linkplain ConfigSource configuration sources}, - * determined at application start time, and the config sources themselves may be static or dynamic. + * manner. The {@link java.lang.Iterable Iterable} contains a fixed number of {@linkplain ConfigSource configuration + * sources}, determined at application start time, and the config sources themselves may be static or dynamic. + * * @return the configuration sources */ Iterable getConfigSources(); @@ -245,10 +264,12 @@ default Optional> getOptionalValues(String propertyName, Class pr /** * Return the {@link Converter} used by this instance to produce instances of the specified type from string values. * - * @param the conversion type - * @param forType the type to be produced by the converter + * @param + * the conversion type + * @param forType + * the type to be produced by the converter * @return an {@link Optional} containing the converter, or empty if no converter is available for the specified - * type + * type */ Optional> getConverter(Class forType); @@ -260,10 +281,13 @@ default Optional> getOptionalValues(String propertyName, Class pr *

* Unwraping to the provider specific API may lead to non-portable behaviour. * - * @param type Class representing the type to unwrap to - * @param The type to unwrap to + * @param type + * Class representing the type to unwrap to + * @param + * The type to unwrap to * @return An instance of the given type - * @throws IllegalArgumentException If the current provider does not support unwrapping to the given type + * @throws IllegalArgumentException + * If the current provider does not support unwrapping to the given type */ T unwrap(Class type); } diff --git a/api/src/main/java/org/eclipse/microprofile/config/ConfigProvider.java b/api/src/main/java/org/eclipse/microprofile/config/ConfigProvider.java index da0f7254..960b9702 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/ConfigProvider.java +++ b/api/src/main/java/org/eclipse/microprofile/config/ConfigProvider.java @@ -36,22 +36,22 @@ * A {@link Config} provides access to the application's configuration. It may have been automatically discovered, or * manually created and registered. *

- * The default usage is to use {@link #getConfig()} to automatically pick up the - * configuration for the current thread's {@linkplain Thread#getContextClassLoader() context class loader}. + * The default usage is to use {@link #getConfig()} to automatically pick up the configuration for the current + * thread's {@linkplain Thread#getContextClassLoader() context class loader}. *

* A configuration consists of information collected from the registered * {@linkplain org.eclipse.microprofile.config.spi.ConfigSource configuration sources}, combined with the set - * of registered {@linkplain org.eclipse.microprofile.config.spi.Converter converters}. - * The configuration sources get sorted according to their - * {@linkplain org.eclipse.microprofile.config.spi.ConfigSource#getOrdinal() ordinal value}. - * Thus it is possible to override a lower-priority configuration source with a higher-priority one. + * of registered {@linkplain org.eclipse.microprofile.config.spi.Converter converters}. The configuration + * sources get sorted according to their + * {@linkplain org.eclipse.microprofile.config.spi.ConfigSource#getOrdinal() ordinal value}. Thus it is + * possible to override a lower-priority configuration source with a higher-priority one. *

- * It is also possible to register custom configuration sources to flexibly - * extend the configuration mechanism. For example, a configuration source could be provided which reads - * configuration values from a database table. + * It is also possible to register custom configuration sources to flexibly extend the configuration mechanism. + * For example, a configuration source could be provided which reads configuration values from a database table. * *

* Example: + * *

  * String restUrl = ConfigProvider.getConfig().getValue("myproject.some.remote.service.url", String.class);
  * Integer port = ConfigProvider.getConfig().getValue("myproject.some.remote.service.port", Integer.class);
@@ -71,8 +71,8 @@ private ConfigProvider() {
     }
 
     /**
-     * Get the {@linkplain Config configuration} corresponding to the current application, as defined by the
-     * calling thread's {@linkplain Thread#getContextClassLoader() context class loader}.
+     * Get the {@linkplain Config configuration} corresponding to the current application, as defined by the calling
+     * thread's {@linkplain Thread#getContextClassLoader() context class loader}.
      * 

* The {@link Config} instance will be created and registered to the context class loader if no such configuration * is already created and registered. @@ -88,12 +88,13 @@ public static Config getConfig() { /** * Get the {@linkplain Config configuration} for the application corresponding to the given class loader instance. *

- * The {@link Config} instance will be created and registered to the given class loader if no such configuration - * is already created and registered. + * The {@link Config} instance will be created and registered to the given class loader if no such configuration is + * already created and registered. *

* Each class loader corresponds to exactly one configuration. * - * @param cl the Classloader used to register the configuration instance + * @param cl + * the Classloader used to register the configuration instance * @return the configuration instance for the given class loader */ public static Config getConfig(ClassLoader cl) { diff --git a/api/src/main/java/org/eclipse/microprofile/config/ConfigValue.java b/api/src/main/java/org/eclipse/microprofile/config/ConfigValue.java index 6cd9ebbd..12d83e9d 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/ConfigValue.java +++ b/api/src/main/java/org/eclipse/microprofile/config/ConfigValue.java @@ -62,8 +62,7 @@ public interface ConfigValue { /** * The {@link org.eclipse.microprofile.config.spi.ConfigSource} ordinal that loaded the property lookup. * - * @return the ConfigSource ordinal that loaded the property lookup or {@code 0} if the property could not be - * found + * @return the ConfigSource ordinal that loaded the property lookup or {@code 0} if the property could not be found */ int getSourceOrdinal(); } diff --git a/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperties.java b/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperties.java index 896996f5..abc61c19 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperties.java +++ b/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperties.java @@ -18,10 +18,10 @@ */ package org.eclipse.microprofile.config.inject; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; @@ -33,22 +33,22 @@ import javax.inject.Qualifier; /** - * Retrieve a number of related configuration properties with the specified prefix into a property class. - * This class should contain a zero-arg constructor. Otherwise, non-portable behaviour occurs. + * Retrieve a number of related configuration properties with the specified prefix into a property class. This class + * should contain a zero-arg constructor. Otherwise, non-portable behaviour occurs. * *

Example

* *
- * @ConfigProperties(prefix="server")
+ * @ConfigProperties(prefix = "server")
  * public class MyServer {
- *   public String host;     //maps the property name server.host
- *   public int port;        //maps to the property name server.port
- *   private String context; //maps to the property name server.context
- *   @ConfigProperty(name="old.location")
- *   public String location; //maps to the property name server.old.location
- *   public String getContext() {
- *     return context;
- *   }
+ *     public String host; // maps the property name server.host
+ *     public int port; // maps to the property name server.port
+ *     private String context; // maps to the property name server.context
+ *     @ConfigProperty(name = "old.location")
+ *     public String location; // maps to the property name server.old.location
+ *     public String getContext() {
+ *         return context;
+ *     }
  * }
  * 
* @@ -81,7 +81,7 @@ public static Literal of(String prefix) { return new Literal(prefix); } - private Literal(String prefix){ + private Literal(String prefix) { this.prefix = prefix; } diff --git a/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java b/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java index a7d5ae03..4042ecf3 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java +++ b/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java @@ -56,26 +56,26 @@ * Injecting a native value is recommended for a mandatory property and its value does not change at runtime or used by * a bean with RequestScoped. *

- * A further recommendation is to use the built in {@code META-INF/microprofile-config.properties} file mechanism - * to provide default values inside an Application. If no configured value exists for this property, a + * A further recommendation is to use the built in {@code META-INF/microprofile-config.properties} file mechanism to + * provide default values inside an Application. If no configured value exists for this property, a * {@code DeploymentException} will be thrown during startup. * *

  * @Inject
- * @ConfigProperty(name="my.long.property")
+ * @ConfigProperty(name = "my.long.property")
  * private Long injectedLongValue;
  * 
* *

Injecting Optional Values

* *

- * Contrary to natively injecting, if the property is not specified, this will not lead to a DeploymentException. - * The following code injects a Long value to the {@code my.optional.long.property}. If the property does not exist, - * the value {@code 123} will be assigned. to {@code injectedLongValue}. + * Contrary to natively injecting, if the property is not specified, this will not lead to a DeploymentException. The + * following code injects a Long value to the {@code my.optional.long.property}. If the property does not exist, the + * value {@code 123} will be assigned. to {@code injectedLongValue}. * *

  * @Inject
- * @ConfigProperty(name="my.optional.long.property", defaultValue="123")
+ * @ConfigProperty(name = "my.optional.long.property", defaultValue = "123")
  * private Long injectedLongValue;
  * 
* @@ -114,22 +114,21 @@ @Retention(RUNTIME) @Target({METHOD, FIELD, PARAMETER, TYPE}) /* - * Two @Requirement annotations are defined so that the result is a _weak requirement_. - * One requirement is resolution:=optional which means that at runtime, if satisfied, - * it will be wired, otherwise it is simply ignored. Another requirement is - * effective:=active which means it is not visible at runtime, but applicable during - * assembly where an effectviness of _active_ is specified. + * Two @Requirement annotations are defined so that the result is a _weak requirement_. One requirement is + * resolution:=optional which means that at runtime, if satisfied, it will be wired, otherwise it is simply ignored. + * Another requirement is effective:=active which means it is not visible at runtime, but applicable during assembly + * where an effectviness of _active_ is specified. */ @Requirement(namespace = CDI_EXTENSION_PROPERTY, name = "org.eclipse.microprofile.config", effective = "active") @Requirement(namespace = CDI_EXTENSION_PROPERTY, name = "org.eclipse.microprofile.config", resolution = OPTIONAL) public @interface ConfigProperty { - String UNCONFIGURED_VALUE="org.eclipse.microprofile.config.configproperty.unconfigureddvalue"; + String UNCONFIGURED_VALUE = "org.eclipse.microprofile.config.configproperty.unconfigureddvalue"; /** * The key of the config property used to look up the configuration value. *

- * If it is not specified, it will be derived automatically as {@code .}, - * where {@code injection_point_name} is the field name or parameter name, {@code class_name} is the fully - * qualified name of the class being injected to. + * If it is not specified, it will be derived automatically as {@code .}, where + * {@code injection_point_name} is the field name or parameter name, {@code class_name} is the fully qualified name + * of the class being injected to. *

* If one of the {@code class_name} or {@code injection_point_name} cannot be determined, the value has to be * provided. @@ -140,8 +139,8 @@ String name() default ""; /** - * The default value if the configured property value does not exist. - * Empty string as the default value will be ignored, which is same as not setting the default value. + * The default value if the configured property value does not exist. Empty string as the default value will be + * ignored, which is same as not setting the default value. *

* If the target Type is not String a proper {@link org.eclipse.microprofile.config.spi.Converter} will get applied. * That means that any default value string should follow the formatting rules of the registered Converters. diff --git a/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java b/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java index 20576b8d..dfe45816 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java @@ -33,12 +33,12 @@ * The following types can be injected: * *

    - *
  • T where T is a Type where a {@link org.eclipse.microprofile.config.spi.Converter} exists and the - * property must exist.
  • - *
  • Optional<T> where T is a Type where a - * {@link org.eclipse.microprofile.config.spi.Converter} exists where the property may exist.
  • - *
  • Provider<T> where T is a Type where a - * {@link org.eclipse.microprofile.config.spi.Converter} exists where the property may exist.
  • + *
  • T where T is a Type where a {@link org.eclipse.microprofile.config.spi.Converter} exists and the + * property must exist.
  • + *
  • Optional<T> where T is a Type where a {@link org.eclipse.microprofile.config.spi.Converter} + * exists where the property may exist.
  • + *
  • Provider<T> where T is a Type where a {@link org.eclipse.microprofile.config.spi.Converter} + * exists where the property may exist.
  • *
* * @author Mark Struberg @@ -46,4 +46,3 @@ */ @org.osgi.annotation.versioning.Version("1.1") package org.eclipse.microprofile.config.inject; - diff --git a/api/src/main/java/org/eclipse/microprofile/config/package-info.java b/api/src/main/java/org/eclipse/microprofile/config/package-info.java index 01b3a008..ac545987 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/config/package-info.java @@ -23,30 +23,30 @@ *

Rationale

* *

- * For many project artifacts (e.g. WAR, EAR) it should be possible to build them only once - * and then install them at different customers, stages, etc. - * They need to target those different execution environments without the necessity of any repackaging. - * In other words: depending on the situation they need different configuration. + * For many project artifacts (e.g. WAR, EAR) it should be possible to build them only once and then install them at + * different customers, stages, etc. They need to target those different execution environments without the necessity of + * any repackaging. In other words: depending on the situation they need different configuration. * *

- * This is easily achievable by having a set of default configuration values inside the project artifact. - * But be able to overwrite those default values from external. + * This is easily achievable by having a set of default configuration values inside the project artifact. But be able to + * overwrite those default values from external. * *

How it works

* *

* A Configuration consists of the information collected from the registered - * {@link org.eclipse.microprofile.config.spi.ConfigSource ConfigSources}. - * These {@code ConfigSources} get sorted according to their ordinal. - * That way it is possible to overwrite configuration with lower importance from outside. + * {@link org.eclipse.microprofile.config.spi.ConfigSource ConfigSources}. These {@code ConfigSources} get sorted + * according to their ordinal. That way it is possible to overwrite configuration with lower importance from + * outside. * - *

By default there are 3 ConfigSources: + *

+ * By default there are 3 ConfigSources: * *

    - *
  • {@code System.getProperties()} (ordinal=400)
  • - *
  • {@code System.getenv()} (ordinal=300)
  • - *
  • all {@code META-INF/microprofile-config.properties} files on the ClassPath. - * (ordinal=100, separately configurable via a config_ordinal property inside each file)
  • + *
  • {@code System.getProperties()} (ordinal=400)
  • + *
  • {@code System.getenv()} (ordinal=300)
  • + *
  • all {@code META-INF/microprofile-config.properties} files on the ClassPath. (ordinal=100, separately configurable + * via a config_ordinal property inside each file)
  • *
* *

@@ -84,4 +84,3 @@ */ @org.osgi.annotation.versioning.Version("2.0.0") package org.eclipse.microprofile.config; - diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigBuilder.java b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigBuilder.java index bc137e6b..54166559 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigBuilder.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigBuilder.java @@ -40,24 +40,24 @@ @org.osgi.annotation.versioning.ProviderType public interface ConfigBuilder { /** - * Add the default configuration sources - * to the configuration being built. + * Add the default configuration sources to the + * configuration being built. * * @return this configuration builder instance */ ConfigBuilder addDefaultSources(); /** - * Add all configuration sources which can be discovered from - * this configuration builder's {@linkplain #forClassLoader(ClassLoader) class loader}. + * Add all configuration sources which can be discovered from this + * configuration builder's {@linkplain #forClassLoader(ClassLoader) class loader}. * * @return this configuration builder instance */ ConfigBuilder addDiscoveredSources(); /** - * Add all configuration converters which can be discovered from - * this configuration builder's {@linkplain #forClassLoader(ClassLoader) class loader}. + * Add all configuration converters which can be discovered from this + * configuration builder's {@linkplain #forClassLoader(ClassLoader) class loader}. * * @return this configuration builder instance */ @@ -66,7 +66,8 @@ public interface ConfigBuilder { /** * Specify the class loader for which this configuration is being built. * - * @param loader the class loader + * @param loader + * the class loader * @return this configuration builder instance */ ConfigBuilder forClassLoader(ClassLoader loader); @@ -74,7 +75,8 @@ public interface ConfigBuilder { /** * Add the specified {@link ConfigSource} instances to the configuration being built. * - * @param sources the configuration sources + * @param sources + * the configuration sources * @return this configuration builder instance */ ConfigBuilder withSources(ConfigSource... sources); @@ -82,17 +84,18 @@ public interface ConfigBuilder { /** * Add the specified {@link Converter} instances to the configuration being built. *

- * The implementation may use reflection to determine the target type of the converter. If the - * type cannot be determined reflectively, this method may fail with a runtime exception. + * The implementation may use reflection to determine the target type of the converter. If the type cannot be + * determined reflectively, this method may fail with a runtime exception. *

* When using lambda expressions for custom converters you should use the - * {@link #withConverter(Class, int, Converter)} method and pass the target type explicitly, - * since lambda expressions generally do not offer enough type information to the reflection API - * in order to determine the target converter type. + * {@link #withConverter(Class, int, Converter)} method and pass the target type explicitly, since lambda + * expressions generally do not offer enough type information to the reflection API in order to determine the target + * converter type. *

* The added converters will be given a priority of {@code 100}. * - * @param converters the converters to add + * @param converters + * the converters to add * @return this configuration builder instance */ ConfigBuilder withConverters(Converter... converters); @@ -100,15 +103,19 @@ public interface ConfigBuilder { /** * Add the specified {@link Converter} instance for the given type to the configuration being built. *

- * This method does not rely on reflection to determine the target type of the converter; - * therefore, lambda expressions may be used for the converter instance. + * This method does not rely on reflection to determine the target type of the converter; therefore, lambda + * expressions may be used for the converter instance. *

* The priority value of custom converters defaults to {@code 100} if not specified. * - * @param type the class of the type to convert - * @param priority the priority of the converter - * @param converter the converter (can not be {@code null}) - * @param the type to convert + * @param type + * the class of the type to convert + * @param priority + * the priority of the converter + * @param converter + * the converter (can not be {@code null}) + * @param + * the type to convert * @return this configuration builder instance */ ConfigBuilder withConverter(Class type, int priority, Converter converter); diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java index 61fe8158..8ef9bb3c 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java @@ -38,12 +38,10 @@ */ /* - * The @ServiceConsumer annotation adds support for Service Loader Mediator in - * order to support wiring of Service Loader providers to consumers in OSGi. - * However, the requirements generated are specified as effective:=active to - * prevent this from being a strict requirement. As such the API is usable in - * runtimes without a Service Loader Mediator implementation while allowing for - * such to be enabled when using the resolver during assembly. + * The @ServiceConsumer annotation adds support for Service Loader Mediator in order to support wiring of Service Loader + * providers to consumers in OSGi. However, the requirements generated are specified as effective:=active to prevent + * this from being a strict requirement. As such the API is usable in runtimes without a Service Loader Mediator + * implementation while allowing for such to be enabled when using the resolver during assembly. */ @ServiceConsumer(value = ConfigProviderResolver.class, effective = "active") public abstract class ConfigProviderResolver { @@ -67,7 +65,8 @@ protected ConfigProviderResolver() { * Get the configuration instance for the current application in the manner described by * {@link org.eclipse.microprofile.config.ConfigProvider#getConfig(ClassLoader)}. * - * @param loader the class loader identifying the application + * @param loader + * the class loader identifying the application * @return the configuration instance */ public abstract Config getConfig(ClassLoader loader); @@ -77,37 +76,42 @@ protected ConfigProviderResolver() { *

* The returned configuration builder must initially contain no registered configuration sources. *

- * The returned configuration builder must initially contain only - * built in converters. + * The returned configuration builder must initially contain only built + * in converters. * * @return a new configuration builder instance */ public abstract ConfigBuilder getBuilder(); /** - * Register the given {@link Config} instance to the application identified by the given class loader. - * If the class loader is {@code null}, then the current application (as identified by the + * Register the given {@link Config} instance to the application identified by the given class loader. If the class + * loader is {@code null}, then the current application (as identified by the * {@linkplain Thread#getContextClassLoader() thread context class loader}) will be used. * - * @param config the configuration to register - * @param classLoader the class loader identifying the application - * @throws IllegalStateException if there is already a configuration registered for the application + * @param config + * the configuration to register + * @param classLoader + * the class loader identifying the application + * @throws IllegalStateException + * if there is already a configuration registered for the application */ public abstract void registerConfig(Config config, ClassLoader classLoader); /** - * A {@link Config} normally gets released if the Application it is associated with gets destroyed. - * Invoke this method if you like to destroy the Config prematurely. + * A {@link Config} normally gets released if the Application it is associated with gets destroyed. Invoke this + * method if you like to destroy the Config prematurely. * * If the given Config is associated within an Application then it will be unregistered. - * @param config the config to be released + * + * @param config + * the config to be released */ public abstract void releaseConfig(Config config); /** - * Find and return the provider resolver instance. If the provider resolver instance was already found, - * or was manually specified, that instance is returned. Otherwise, {@link ServiceLoader} is used to - * locate the first implementation that is visible from the class loader that defined this class. + * Find and return the provider resolver instance. If the provider resolver instance was already found, or was + * manually specified, that instance is returned. Otherwise, {@link ServiceLoader} is used to locate the first + * implementation that is visible from the class loader that defined this class. * * @return the provider resolver instance */ @@ -126,25 +130,25 @@ public static ConfigProviderResolver instance() { private static ConfigProviderResolver loadSpi(ClassLoader cl) { ServiceLoader sl = ServiceLoader.load( - ConfigProviderResolver.class, cl); + ConfigProviderResolver.class, cl); final Iterator iterator = sl.iterator(); if (iterator.hasNext()) { return iterator.next(); } throw new IllegalStateException( - "No ConfigProviderResolver implementation found!"); + "No ConfigProviderResolver implementation found!"); } /** * Set the instance. It is used by OSGi environments that do not support - * the service loader - * pattern. + * the service loader pattern. *

* Note that calling this method after a different provider instance was {@linkplain #instance() already retrieved} - * can lead to inconsistent results. Mixing usage of this method with the service loader - * pattern is for this reason strongly discouraged. + * can lead to inconsistent results. Mixing usage of this method with the service loader pattern is for this reason + * strongly discouraged. * - * @param resolver the instance to set, or {@code null} to unset the instance + * @param resolver + * the instance to set, or {@code null} to unset the instance */ public static void setInstance(ConfigProviderResolver resolver) { instance = resolver; diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSource.java b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSource.java index d868ad84..8d8bab8c 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSource.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSource.java @@ -35,9 +35,9 @@ * configuration sources may include: * *

    - *
  • a JNDI-backed naming service
  • - *
  • a properties file
  • - *
  • a database table
  • + *
  • a JNDI-backed naming service
  • + *
  • a properties file
  • + *
  • a database table
  • *
* *

@@ -52,15 +52,15 @@ *

* Some configuration sources are known as default configuration sources. These configuration sources are * normally available in all automatically-created configurations, and can be - * {@linkplain ConfigBuilder#addDefaultSources() manually added} to manually-created configurations as well. The - * default configuration sources are: + * {@linkplain ConfigBuilder#addDefaultSources() manually added} to manually-created configurations as well. The default + * configuration sources are: * *

    - *
  1. {@linkplain System#getProperties() System properties}, with an {@linkplain #getOrdinal() ordinal value} of - * {@code 400}
  2. - *
  3. {@linkplain System#getenv() Environment properties}, with an ordinal value of {@code 300}
  4. - *
  5. The {@code /META-INF/microprofile-config.properties} {@linkplain ClassLoader#getResource(String) resource}, - * with an ordinal value of {@code 100}
  6. + *
  7. {@linkplain System#getProperties() System properties}, with an {@linkplain #getOrdinal() ordinal value} of + * {@code 400}
  8. + *
  9. {@linkplain System#getenv() Environment properties}, with an ordinal value of {@code 300}
  10. + *
  11. The {@code /META-INF/microprofile-config.properties} {@linkplain ClassLoader#getResource(String) resource}, with + * an ordinal value of {@code 100}
  12. *
* *

Environment variable name mapping rules

@@ -73,11 +73,11 @@ *

* Three environment variables are searched for a given property name (e.g. "{@code com.ACME.size}"): *

    - *
  1. The exact name (i.e. "{@code com.ACME.size}")
  2. - *
  3. The name, with each character that is neither alphanumeric nor _ replaced with _ - * (i.e. "{@code com_ACME_size}")
  4. - *
  5. The name, with each character that is neither alphanumeric nor _ replaced with _ and then converted to upper - * case (i.e. "{@code COM_ACME_SIZE}")
  6. + *
  7. The exact name (i.e. "{@code com.ACME.size}")
  8. + *
  9. The name, with each character that is neither alphanumeric nor _ replaced with _ (i.e. + * "{@code com_ACME_size}")
  10. + *
  11. The name, with each character that is neither alphanumeric nor _ replaced with _ and then converted to upper case + * (i.e. "{@code COM_ACME_SIZE}")
  12. *
* *

@@ -91,14 +91,14 @@ * which contains the fully qualified {@code ConfigSource} implementation class name as its content. * *

- * Configuration sources may also be added by defining - * {@link org.eclipse.microprofile.config.spi.ConfigSourceProvider} classes which are discoverable in this manner. + * Configuration sources may also be added by defining {@link org.eclipse.microprofile.config.spi.ConfigSourceProvider} + * classes which are discoverable in this manner. * *

Closing configuration sources

* *

- * If a configuration source implements the {@link AutoCloseable} interface, then its - * {@linkplain AutoCloseable#close() close method} will be called when the underlying configuration is released. + * If a configuration source implements the {@link AutoCloseable} interface, then its {@linkplain AutoCloseable#close() + * close method} will be called when the underlying configuration is released. * * @author Mark Struberg * @author Gerhard Petracek @@ -128,16 +128,16 @@ default Map getProperties() { } /** - * Gets all property names known to this configuration source, potentially without evaluating the values. - * The returned property names may be a subset of the names of the total set of retrievable properties in this - * config source. + * Gets all property names known to this configuration source, potentially without evaluating the values. The + * returned property names may be a subset of the names of the total set of retrievable properties in this config + * source. *

* The returned set is not required to allow concurrent or multi-threaded iteration; however, if the same set is * returned by multiple calls to this method, then the implementation must support concurrent and multi-threaded * iteration of that set. *

- * The set of keys returned may be a point-in-time snapshot, or may change over time (even - * during active iteration) to reflect dynamic changes to the available set of keys. + * The set of keys returned may be a point-in-time snapshot, or may change over time (even during + * active iteration) to reflect dynamic changes to the available set of keys. * * @return a set of property names that are known to this configuration source */ @@ -147,22 +147,22 @@ default Map getProperties() { * Return the ordinal priority value of this configuration source. *

* If a property is specified in multiple config sources, the value in the config source with the highest ordinal - * takes precedence. For configuration sources with the same ordinal value, the configuration source name will - * be used for sorting according to string sorting criteria. + * takes precedence. For configuration sources with the same ordinal value, the configuration source name will be + * used for sorting according to string sorting criteria. *

- * Note that this method is only evaluated during the construction of the configuration, and does not affect - * the ordering of configuration sources within a configuration after that time. + * Note that this method is only evaluated during the construction of the configuration, and does not affect the + * ordering of configuration sources within a configuration after that time. *

* The ordinal values for the default configuration sources can be found * above. *

* Any configuration source which is a part of an application will typically use an ordinal between 0 and 200. - * Configuration sources provided by the container or 'environment' typically use an ordinal higher than 200. - * A framework which intends have values overridden by the application will use ordinals between 0 and 100. + * Configuration sources provided by the container or 'environment' typically use an ordinal higher than 200. A + * framework which intends have values overridden by the application will use ordinals between 0 and 100. *

- * The default implementation of this method looks for a configuration property named - * "{@link #CONFIG_ORDINAL config_ordinal}" to determine the ordinal value for this configuration source. If the - * property is not found, then the {@linkplain #DEFAULT_ORDINAL default ordinal value} is used. + * The default implementation of this method looks for a configuration property named "{@link #CONFIG_ORDINAL + * config_ordinal}" to determine the ordinal value for this configuration source. If the property is not found, then + * the {@linkplain #DEFAULT_ORDINAL default ordinal value} is used. *

* This method may be overridden by configuration source implementations to provide a different behavior. * @@ -170,11 +170,10 @@ default Map getProperties() { */ default int getOrdinal() { String configOrdinal = getValue(CONFIG_ORDINAL); - if(configOrdinal != null) { + if (configOrdinal != null) { try { return Integer.parseInt(configOrdinal); - } - catch (NumberFormatException ignored) { + } catch (NumberFormatException ignored) { } } @@ -184,7 +183,8 @@ default int getOrdinal() { /** * Return the value for the specified property in this configuration source. * - * @param propertyName the property name + * @param propertyName + * the property name * @return the property value, or {@code null} if the property is not present */ String getValue(String propertyName); diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSourceProvider.java b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSourceProvider.java index c9c223de..519ddf79 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSourceProvider.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigSourceProvider.java @@ -44,12 +44,13 @@ */ public interface ConfigSourceProvider { /** - * Return the {@link ConfigSource} instances that are provided by this provider. - * The {@link java.lang.Iterable Iterable} contains a fixed number of {@linkplain ConfigSource configuration sources}, - * determined at application start time, and the config sources themselves may be static or dynamic. - * An empty {@link java.lang.Iterable Iterable} may be returned if no sources are to be provided. + * Return the {@link ConfigSource} instances that are provided by this provider. The {@link java.lang.Iterable + * Iterable} contains a fixed number of {@linkplain ConfigSource configuration sources}, determined at application + * start time, and the config sources themselves may be static or dynamic. An empty {@link java.lang.Iterable + * Iterable} may be returned if no sources are to be provided. * - * @param forClassLoader the class loader which should be used for discovery and resource loading purposes + * @param forClassLoader + * the class loader which should be used for discovery and resource loading purposes * @return the {@link ConfigSource} instances to register to the configuration */ Iterable getConfigSources(ClassLoader forClassLoader); diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/Converter.java b/api/src/main/java/org/eclipse/microprofile/config/spi/Converter.java index 134c41ee..f0a3ea2a 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/Converter.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/Converter.java @@ -46,29 +46,28 @@ * Global converters may be built in. Such converters are provided by the implementation. A compliant * implementation must provide build-in converters for at least the following types: *

    - *
  • {@code boolean} and {@code Boolean}, returning {@code true} for at least the following values (case insensitive): - *
      - *
    • {@code true}
    • - *
    • {@code yes}
    • - *
    • {@code y}
    • - *
    • {@code on}
    • - *
    • {@code 1}
    • - *
    - *
  • {@code byte} and {@code Byte}, accepting (at minimum) all values accepted by the - * {@link Byte#parseByte(String)} method
  • - *
  • {@code short} and {@code Short}, accepting (at minimum) all values accepted by the - * {@link Byte#parseByte(String)} method
  • - *
  • {@code int}, {@code Integer}, and {@code OptionalInt} accepting (at minimum) all values accepted by the - * {@link Integer#parseInt(String)} - * method
  • - *
  • {@code long}, {@code Long}, and {@code OptionalLong} accepting (at minimum) all values accepted by the - * {@link Long#parseLong(String)} method
  • - *
  • {@code float} and {@code Float}, accepting (at minimum) all values accepted by the - * {@link Float#parseFloat(String)} method
  • - *
  • {@code double}, {@code Double}, and {@code OptionalDouble} accepting (at minimum) all values accepted by the - * {@link Double#parseDouble(String)} method
  • - *
  • {@code java.lang.Class} based on the result of {@link java.lang.Class#forName}
  • - *
  • {@code java.lang.String}
  • + *
  • {@code boolean} and {@code Boolean}, returning {@code true} for at least the following values (case insensitive): + *
      + *
    • {@code true}
    • + *
    • {@code yes}
    • + *
    • {@code y}
    • + *
    • {@code on}
    • + *
    • {@code 1}
    • + *
    + *
  • {@code byte} and {@code Byte}, accepting (at minimum) all values accepted by the {@link Byte#parseByte(String)} + * method
  • + *
  • {@code short} and {@code Short}, accepting (at minimum) all values accepted by the {@link Byte#parseByte(String)} + * method
  • + *
  • {@code int}, {@code Integer}, and {@code OptionalInt} accepting (at minimum) all values accepted by the + * {@link Integer#parseInt(String)} method
  • + *
  • {@code long}, {@code Long}, and {@code OptionalLong} accepting (at minimum) all values accepted by the + * {@link Long#parseLong(String)} method
  • + *
  • {@code float} and {@code Float}, accepting (at minimum) all values accepted by the + * {@link Float#parseFloat(String)} method
  • + *
  • {@code double}, {@code Double}, and {@code OptionalDouble} accepting (at minimum) all values accepted by the + * {@link Double#parseDouble(String)} method
  • + *
  • {@code java.lang.Class} based on the result of {@link java.lang.Class#forName}
  • + *
  • {@code java.lang.String}
  • *
* *

Global converter discovery

@@ -90,13 +89,13 @@ * implicit converter if any of the following are true (in order): * *
    - *
  • the target type has a {@code public static T of(String)} method
  • - *
  • the target type has a {@code public static T valueOf(String)} method
  • - *
  • the target type has a {@code public static T parse(CharSequence)} method
  • - *
  • the target type has a public constructor with a single parameter of type {@code String}
  • - *
  • the target type is an array of any type corresponding to either a registered - * global converter or a - * built in or implicit converter
  • + *
  • the target type has a {@code public static T of(String)} method
  • + *
  • the target type has a {@code public static T valueOf(String)} method
  • + *
  • the target type has a {@code public static T parse(CharSequence)} method
  • + *
  • the target type has a public constructor with a single parameter of type {@code String}
  • + *
  • the target type is an array of any type corresponding to either a registered + * global converter or a built in + * or implicit converter
  • *
* *

Converter priority

@@ -116,21 +115,21 @@ * *

Empty values

* - * For all converters, the empty string {@code ""} must be considered an empty value. Some converters may - * consider other values to be empty as well. + * For all converters, the empty string {@code ""} must be considered an empty value. Some converters + * may consider other values to be empty as well. *

* Implementations may (but are not required to) implement {@code Config.getOptionalValue()} using a - * {@code Converter}. If so, this converter must return {@code Optional.empty()} for an empty input. + * {@code Converter}. If so, this converter must return {@code Optional.empty()} for an empty input. * *

Array conversion

* *

* A conforming implementation must support the automatic creation of an implicit converter for array types. - * This converter uses a comma ({@code U+002C ','}) as a delimiter. To allow a comma to be embedded within individual - * array element values, it may be escaped using a backslash ({@code U+005C '\'}) character. Any escaped comma character + * This converter uses a comma ({@code U+002C ','}) as a delimiter. To allow a comma to be embedded within individual + * array element values, it may be escaped using a backslash ({@code U+005C '\'}) character. Any escaped comma character * will be included as a plain comma within the single element (the backslash is discarded by the converter). *

- * Empty elements must not be included in the final array. An array which would consist of only empty values + * Empty elements must not be included in the final array. An array which would consist of only empty values * must be considered empty; the array converter must return {@code null} in this case. * * @author Ron Smeral @@ -140,13 +139,16 @@ */ public interface Converter extends Serializable { /** - * Convert the given string value to a specified type. Callers must not pass in {@code null} - * for {@code value}; doing so may result in a {@code NullPointerException} being thrown. + * Convert the given string value to a specified type. Callers must not pass in {@code null} for + * {@code value}; doing so may result in a {@code NullPointerException} being thrown. * - * @param value the string representation of a property value (must not be {@code null}) + * @param value + * the string representation of a property value (must not be {@code null}) * @return the converted value, or {@code null} if the value is empty - * @throws IllegalArgumentException if the value cannot be converted to the specified type - * @throws NullPointerException if the given value was {@code null} + * @throws IllegalArgumentException + * if the value cannot be converted to the specified type + * @throws NullPointerException + * if the given value was {@code null} */ T convert(String value) throws IllegalArgumentException, NullPointerException; } diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/package-info.java b/api/src/main/java/org/eclipse/microprofile/config/spi/package-info.java index 9044fa1d..12cb8be6 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/package-info.java @@ -25,8 +25,8 @@ * {@link org.eclipse.microprofile.config.spi.Converter} instances. Configuration instances may be set up and created * using the {@link org.eclipse.microprofile.config.spi.ConfigBuilder} API. *

- * The package also contains the class {@link org.eclipse.microprofile.config.spi.ConfigProviderResolver}, - * which is used to implement the specification itself. + * The package also contains the class {@link org.eclipse.microprofile.config.spi.ConfigProviderResolver}, which is used + * to implement the specification itself. * * @author Emily Jiang * @author Mark Struberg diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterBean.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterBean.java index aea9d2d5..ba3ba963 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterBean.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterBean.java @@ -315,7 +315,7 @@ public class ArrayConverterBean { @Inject @ConfigProperty(name = "tck.config.test.javaconfig.converter.instantvalue") private Set mySingleInstantSet; - + @Inject @ConfigProperty(name = "tck.config.test.javaconfig.converter.urlvalues") private URL[] myUrlArray; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterTest.java index 51fc5c07..7ed8e430 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ArrayConverterTest.java @@ -72,11 +72,11 @@ public static WebArchive deploy() { .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(Converter.class, PizzaConverter.class) .as(JavaArchive.class); - addFile(testJar, "META-INF/microprofile-config.properties"); - WebArchive war = ShrinkWrap + addFile(testJar, "META-INF/microprofile-config.properties"); + WebArchive war = ShrinkWrap .create(WebArchive.class, "arrayConverterTest.war") .addAsLibrary(testJar); - return war; + return war; } @Inject @@ -85,17 +85,17 @@ public static WebArchive deploy() { @Inject private ArrayConverterBean converterBean; - ///////////////////////////////////Test Boolean[] boolean[]////////////////////////// + /////////////////////////////////// Test Boolean[] boolean[]////////////////////////// @Test public void testBooleanArrayLookupProgrammatically() { Boolean[] value = config.getValue("tck.config.test.javaconfig.converter.booleanvalues", - Boolean[].class); + Boolean[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new Boolean[]{true, false, true}); Boolean[] single = config.getValue("tck.config.test.javaconfig.configvalue.boolean.true", - Boolean[].class); + Boolean[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new Boolean[]{true}); @@ -115,31 +115,33 @@ public void testGetBooleanArrayConverter() { @Test public void testOptionalBooleanArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.booleanvalues", - Boolean[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.booleanvalues", + Boolean[].class); Assert.assertTrue(optionalValue.isPresent()); Boolean[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new Boolean[]{true, false, true}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.configvalue.boolean.true", - Boolean[].class); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.configvalue.boolean.true", + Boolean[].class); Assert.assertTrue(optionalSingle.isPresent()); Boolean[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new Boolean[]{true}); - } + } @Test public void testBooleanListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.booleanvalues", - Boolean.class); + Boolean.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); Assert.assertEquals(values, Arrays.asList(true, false, true)); List single = config.getValues("tck.config.test.javaconfig.configvalue.boolean.true", - Boolean.class); + Boolean.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(true)); @@ -147,21 +149,23 @@ public void testBooleanListLookupProgrammatically() { @Test public void testOptionalBooleanListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.booleanvalues", - Boolean.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.booleanvalues", + Boolean.class); Assert.assertTrue(optionalValues.isPresent()); List value = optionalValues.get(); Assert.assertNotNull(value); Assert.assertEquals(value.size(), 3); Assert.assertEquals(value, Arrays.asList(true, false, true)); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.configvalue.boolean.true", - Boolean.class); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.configvalue.boolean.true", + Boolean.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(true)); - } + } @Test public void testBooleanArrayInjection() { @@ -171,7 +175,7 @@ public void testBooleanArrayInjection() { Assert.assertEquals(converterBean.getMySingleBooleanArray(), new Boolean[]{true}); } - //test boolean[] support + // test boolean[] support @Test public void testGetbooleanArrayConverter() { @@ -209,17 +213,17 @@ public void testbooleanSetInjection() { Assert.assertEquals(converterBean.getMySingleBooleanSet(), Collections.singleton(true)); } - ///////////////////////////////////Test String[] ////////////////////////// + /////////////////////////////////// Test String[] ////////////////////////// @Test public void testStringArrayLookupProgrammatically() { String[] value = config.getValue("tck.config.test.javaconfig.converter.stringvalues", - String[].class); + String[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 4); Assert.assertEquals(value, new String[]{"microservice", "microprofile", "m,f", "microservice"}); String[] single = config.getValue("tck.config.test.javaconfig.configvalue.key1", - String[].class); + String[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new String[]{"value1"}); @@ -227,7 +231,8 @@ public void testStringArrayLookupProgrammatically() { @Test public void testGetStringArrayConverter() { - String[] value = config.getConverter(String[].class).get().convert("microservice,microprofile,m\\,f,microservice"); + String[] value = + config.getConverter(String[].class).get().convert("microservice,microprofile,m\\,f,microservice"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 4); Assert.assertEquals(value, new String[]{"microservice", "microprofile", "m,f", "microservice"}); @@ -240,30 +245,30 @@ public void testGetStringArrayConverter() { @Test public void testOptionalStringArrayLookupProgrammatically() { Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.stringvalues", - String[].class); + String[].class); Assert.assertTrue(optionalValue.isPresent()); - String[] value = optionalValue.get(); + String[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 4); Assert.assertEquals(value, new String[]{"microservice", "microprofile", "m,f", "microservice"}); Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.configvalue.key1", - String[].class); + String[].class); Assert.assertTrue(optionalSingle.isPresent()); - String[] single = optionalSingle.get(); + String[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new String[]{"value1"}); - } + } @Test public void testStringListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.stringvalues", - String.class); + String.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 4); Assert.assertEquals(values, Arrays.asList("microservice", "microprofile", "m,f", "microservice")); List single = config.getValues("tck.config.test.javaconfig.configvalue.key1", - String.class); + String.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList("value1")); @@ -271,26 +276,28 @@ public void testStringListLookupProgrammatically() { @Test public void testOptionalStringListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.stringvalues", - String.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.stringvalues", + String.class); Assert.assertTrue(optionalValues.isPresent()); - List values = optionalValues.get(); + List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 4); Assert.assertEquals(values, Arrays.asList("microservice", "microprofile", "m,f", "microservice")); Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.configvalue.key1", - String.class); + String.class); Assert.assertTrue(optionalSingle.isPresent()); - List single = optionalSingle.get(); + List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList("value1")); - } + } @Test public void testStringArrayInjection() { Assert.assertEquals(converterBean.getMyStringArray().length, 4); - Assert.assertEquals(converterBean.getMyStringArray(), new String[]{"microservice", "microprofile", "m,f", "microservice"}); + Assert.assertEquals(converterBean.getMyStringArray(), + new String[]{"microservice", "microprofile", "m,f", "microservice"}); Assert.assertEquals(converterBean.getMySingleStringArray().length, 1); Assert.assertEquals(converterBean.getMySingleStringArray(), new String[]{"value1"}); } @@ -298,7 +305,8 @@ public void testStringArrayInjection() { @Test public void testStringListInjection() { Assert.assertEquals(converterBean.getMyStringList().size(), 4); - Assert.assertEquals(converterBean.getMyStringList(), Arrays.asList("microservice", "microprofile", "m,f", "microservice")); + Assert.assertEquals(converterBean.getMyStringList(), + Arrays.asList("microservice", "microprofile", "m,f", "microservice")); Assert.assertEquals(converterBean.getMySingleStringList().size(), 1); Assert.assertEquals(converterBean.getMySingleStringList(), Arrays.asList("value1")); } @@ -307,24 +315,24 @@ public void testStringListInjection() { public void testStringSetInjection() { Assert.assertEquals(converterBean.getMyStringSet().size(), 3); Assert.assertEquals(converterBean.getMyStringSet(), - new LinkedHashSet<>(Arrays.asList("microservice", "microprofile", "m,f", "microservice"))); + new LinkedHashSet<>(Arrays.asList("microservice", "microprofile", "m,f", "microservice"))); Assert.assertEquals(converterBean.getMySingleStringSet().size(), 1); Assert.assertEquals(converterBean.getMySingleStringSet(), Collections.singleton("value1")); } /////////////////////////////////////////////////////////////////// - //test Integer[] support - ///////////////////////////////////Test Integer[] int[]////////////////////////// + // test Integer[] support + /////////////////////////////////// Test Integer[] int[]////////////////////////// @Test public void testIntegerArrayLookupProgrammatically() { Integer[] value = config.getValue("tck.config.test.javaconfig.converter.integervalues", - Integer[].class); + Integer[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new Integer[]{1234, 9999}); Integer[] single = config.getValue("tck.config.test.javaconfig.converter.integervalue", - Integer[].class); + Integer[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new Integer[]{1234}); @@ -344,31 +352,33 @@ public void testGetIntegerArrayConverter() { @Test public void testOptionalIntegerArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.integervalues", - Integer[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.integervalues", + Integer[].class); Assert.assertTrue(optionalValue.isPresent()); Integer[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new Integer[]{1234, 9999}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.integervalue", - Integer[].class); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.integervalue", + Integer[].class); Assert.assertTrue(optionalSingle.isPresent()); Integer[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new Integer[]{1234}); - } + } @Test public void testIntegerListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.integervalues", - Integer.class); + Integer.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList(1234, 9999)); List single = config.getValues("tck.config.test.javaconfig.converter.integervalue", - Integer.class); + Integer.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(1234)); @@ -376,21 +386,23 @@ public void testIntegerListLookupProgrammatically() { @Test public void testOptionalIntegerListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.integervalues", - Integer.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.integervalues", + Integer.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList(1234, 9999)); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.integervalue", - Integer.class); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.integervalue", + Integer.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(1234)); - } + } @Test public void testIntArrayInjection() { @@ -400,7 +412,7 @@ public void testIntArrayInjection() { Assert.assertEquals(converterBean.getMySingleIntegerArray(), new Integer[]{1234}); } - //test int[] support + // test int[] support @Test public void testGetIntArrayConverter() { @@ -439,21 +451,21 @@ public void testIntSetInjection() { } /////////////////////////////////////////////////////////////////// - //////////////////Test Long[] long[]/////////////////////////////// - //test Long[] support + ////////////////// Test Long[] long[]/////////////////////////////// + // test Long[] support @Test public void testLongArrayLookupProgrammatically() { Long[] value = config.getValue("tck.config.test.javaconfig.converter.longvalues", - Long[].class); + Long[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Long[] {1234567890L, 1999999999L}); + Assert.assertEquals(value, new Long[]{1234567890L, 1999999999L}); Long[] single = config.getValue("tck.config.test.javaconfig.converter.longvalue", - Long[].class); + Long[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Long[] {1234567890L}); + Assert.assertEquals(single, new Long[]{1234567890L}); } @Test @@ -461,40 +473,40 @@ public void testGetLongArrayCoverter() { Long[] value = config.getConverter(Long[].class).get().convert("1234567890,1999999999"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Long[] {1234567890L, 1999999999L}); + Assert.assertEquals(value, new Long[]{1234567890L, 1999999999L}); Long[] single = config.getConverter(Long[].class).get().convert("1234567890"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Long[] {1234567890L}); + Assert.assertEquals(single, new Long[]{1234567890L}); } @Test public void testOptionalLongArrayLookupProgrammatically() { Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.longvalues", - Long[].class); + Long[].class); Assert.assertTrue(optionalValue.isPresent()); Long[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Long[] {1234567890L, 1999999999L}); + Assert.assertEquals(value, new Long[]{1234567890L, 1999999999L}); Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.longvalue", - Long[].class); + Long[].class); Assert.assertTrue(optionalSingle.isPresent()); Long[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Long[] {1234567890L}); - } + Assert.assertEquals(single, new Long[]{1234567890L}); + } @Test public void testLongListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.longvalues", - Long.class); + Long.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList(1234567890L, 1999999999L)); List single = config.getValues("tck.config.test.javaconfig.converter.longvalue", - Long.class); + Long.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(1234567890L)); @@ -502,50 +514,51 @@ public void testLongListLookupProgrammatically() { @Test public void testOptionalLongListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.longvalues", - Long.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.longvalues", + Long.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList(1234567890L, 1999999999L)); Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.longvalue", - Long.class); + Long.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(1234567890L)); - } + } @Test public void testLongArrayInjection() { Assert.assertEquals(converterBean.getMyLongArray().length, 2); - Assert.assertEquals(converterBean.getMyLongArray(), new Long[] {1234567890L, 1999999999L}); + Assert.assertEquals(converterBean.getMyLongArray(), new Long[]{1234567890L, 1999999999L}); Assert.assertEquals(converterBean.getMySingleLongArray().length, 1); - Assert.assertEquals(converterBean.getMySingleLongArray(), new Long[] {1234567890L}); + Assert.assertEquals(converterBean.getMySingleLongArray(), new Long[]{1234567890L}); } - //test long[] support + // test long[] support @Test public void testGetlongArrayCoverter() { long[] value = config.getConverter(long[].class).get().convert("1234567890,1999999999"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Long[] {1234567890L, 1999999999L}); + Assert.assertEquals(value, new Long[]{1234567890L, 1999999999L}); long[] single = config.getConverter(long[].class).get().convert("1234567890"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Long[] {1234567890L}); + Assert.assertEquals(single, new Long[]{1234567890L}); } @Test public void testlongArrayInjection() { Assert.assertEquals(converterBean.getMylongArray().length, 2); - Assert.assertEquals(converterBean.getMylongArray(), new long[] {1234567890L, 1999999999L}); + Assert.assertEquals(converterBean.getMylongArray(), new long[]{1234567890L, 1999999999L}); Assert.assertEquals(converterBean.getMySinglelongArray().length, 1); - Assert.assertEquals(converterBean.getMySinglelongArray(), new long[] {1234567890L}); + Assert.assertEquals(converterBean.getMySinglelongArray(), new long[]{1234567890L}); } @Test @@ -564,19 +577,19 @@ public void testLongSetInjection() { Assert.assertEquals(converterBean.getMySingleLongSet(), Collections.singleton(1234567890L)); } - ///////////////////////////////////Test Float[] float[]///////////////////// + /////////////////////////////////// Test Float[] float[]///////////////////// - //test Float[] support + // test Float[] support @Test public void testFloatArrayLookupProgrammatically() { Float[] value = config.getValue("tck.config.test.javaconfig.converter.floatvalues", - Float[].class); + Float[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new Float[]{12.34f, 99.99f}); Float[] single = config.getValue("tck.config.test.javaconfig.converter.floatvalue", - Float[].class); + Float[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new Float[]{12.34f}); @@ -597,30 +610,30 @@ public void testGetFloatArrayConverter() { @Test public void testOptionalFloatArrayLookupProgrammatically() { Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.floatvalues", - Float[].class); + Float[].class); Assert.assertTrue(optionalValue.isPresent()); Float[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new Float[]{12.34f, 99.99f}); Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.floatvalue", - Float[].class); + Float[].class); Assert.assertTrue(optionalSingle.isPresent()); Float[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); Assert.assertEquals(single, new Float[]{12.34f}); - } + } @Test public void testFloatListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.floatvalues", - Float.class); + Float.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList(12.34f, 99.99f)); List single = config.getValues("tck.config.test.javaconfig.converter.floatvalue", - Float.class); + Float.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(12.34f)); @@ -628,21 +641,23 @@ public void testFloatListLookupProgrammatically() { @Test public void testOptionalFloatListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.floatvalues", - Float.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.floatvalues", + Float.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList(12.34f, 99.99f)); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.floatvalue", - Float.class); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.floatvalue", + Float.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(12.34f)); - } + } @Test public void testFloatArrayInjection() { @@ -652,7 +667,7 @@ public void testFloatArrayInjection() { Assert.assertEquals(converterBean.getMySingleFloatArray(), new Float[]{12.34f}); } - //test float[] support + // test float[] support @Test public void testGetfloatArrayConverter() { @@ -692,20 +707,20 @@ public void testFloatSetInjection() { ////////////////////////////////////////////////////////////////////// - ///////////////////////////////////Test Double[] double[]///////////// + /////////////////////////////////// Test Double[] double[]///////////// @Test public void testDoubleArrayLookupProgrammatically() { Double[] value = config.getValue("tck.config.test.javaconfig.converter.doublevalues", - Double[].class); + Double[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Double[]{12.34d,99.9999d}); + Assert.assertEquals(value, new Double[]{12.34d, 99.9999d}); Double[] single = config.getValue("tck.config.test.javaconfig.converter.doublevalue", - Double[].class); + Double[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Double[]{12.34d}); + Assert.assertEquals(single, new Double[]{12.34d}); } @Test @@ -713,97 +728,99 @@ public void testGetDoubleArrayConverter() { Double[] value = config.getConverter(Double[].class).get().convert("12.34,99.9999"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Double[]{12.34d,99.9999d}); + Assert.assertEquals(value, new Double[]{12.34d, 99.9999d}); Double[] single = config.getConverter(Double[].class).get().convert("12.34"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Double[]{12.34d}); + Assert.assertEquals(single, new Double[]{12.34d}); } @Test public void testOptionalDoubleArrayLookupProgrammatically() { Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.doublevalues", - Double[].class); + Double[].class); Assert.assertTrue(optionalValue.isPresent()); Double[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Double[]{12.34d,99.9999d}); + Assert.assertEquals(value, new Double[]{12.34d, 99.9999d}); Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.doublevalue", - Double[].class); + Double[].class); Assert.assertTrue(optionalSingle.isPresent()); Double[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Double[]{12.34d}); - } + Assert.assertEquals(single, new Double[]{12.34d}); + } @Test public void testDoubleListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.doublevalues", - Double.class); + Double.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList(12.34d,99.9999d)); + Assert.assertEquals(values, Arrays.asList(12.34d, 99.9999d)); List single = config.getValues("tck.config.test.javaconfig.converter.doublevalue", - Double.class); + Double.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(12.34d)); + Assert.assertEquals(single, Arrays.asList(12.34d)); } @Test public void testOptionalDoubleListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.doublevalues", - Double.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.doublevalues", + Double.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList(12.34d,99.9999d)); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.doublevalue", - Double.class); + Assert.assertEquals(values, Arrays.asList(12.34d, 99.9999d)); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.doublevalue", + Double.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(12.34d)); - } + Assert.assertEquals(single, Arrays.asList(12.34d)); + } @Test public void testDoubleArrayInjection() { Assert.assertEquals(converterBean.getMyDoubleArray().length, 2); - Assert.assertEquals( converterBean.getMyDoubleArray(), new Double[]{12.34d,99.9999d}); + Assert.assertEquals(converterBean.getMyDoubleArray(), new Double[]{12.34d, 99.9999d}); Assert.assertEquals(converterBean.getMySingleDoubleArray().length, 1); - Assert.assertEquals( converterBean.getMySingleDoubleArray(), new Double[]{12.34d}); + Assert.assertEquals(converterBean.getMySingleDoubleArray(), new Double[]{12.34d}); } - //test double[] support + // test double[] support @Test public void testGetdoubleArrayConverter() { double[] value = config.getConverter(double[].class).get().convert("12.34,99.9999"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Double[]{12.34d,99.9999d}); + Assert.assertEquals(value, new Double[]{12.34d, 99.9999d}); double[] single = config.getConverter(double[].class).get().convert("12.34"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Double[]{12.34d}); + Assert.assertEquals(single, new Double[]{12.34d}); } @Test public void testdoubleArrayInjection() { Assert.assertEquals(converterBean.getMydoubleArray().length, 2); - Assert.assertEquals( converterBean.getMydoubleArray(), new double[]{12.34d,99.9999d}); + Assert.assertEquals(converterBean.getMydoubleArray(), new double[]{12.34d, 99.9999d}); Assert.assertEquals(converterBean.getMySingledoubleArray().length, 1); - Assert.assertEquals( converterBean.getMySingledoubleArray(), new double[]{12.34d}); + Assert.assertEquals(converterBean.getMySingledoubleArray(), new double[]{12.34d}); } @Test public void testDoubleListInjection() { Assert.assertEquals(converterBean.getMyDoubleList().size(), 2); - Assert.assertEquals(converterBean.getMyDoubleList(), Arrays.asList(12.34d,99.9999d)); + Assert.assertEquals(converterBean.getMyDoubleList(), Arrays.asList(12.34d, 99.9999d)); Assert.assertEquals(converterBean.getMySingleDoubleList().size(), 1); Assert.assertEquals(converterBean.getMySingleDoubleList(), Arrays.asList(12.34d)); } @@ -811,29 +828,29 @@ public void testDoubleListInjection() { @Test public void testDoubleSetInjection() { Assert.assertEquals(converterBean.getMyDoubleSet().size(), 2); - Assert.assertEquals(converterBean.getMyDoubleSet(), new LinkedHashSet<>(Arrays.asList(12.34d,99.9999d))); + Assert.assertEquals(converterBean.getMyDoubleSet(), new LinkedHashSet<>(Arrays.asList(12.34d, 99.9999d))); Assert.assertEquals(converterBean.getMySingleDoubleSet().size(), 1); - Assert.assertEquals(converterBean.getMySingleDoubleSet(),Collections.singleton(12.34d)); + Assert.assertEquals(converterBean.getMySingleDoubleSet(), Collections.singleton(12.34d)); } ////////////////////////////////////////////////////////////////////// // test duration - ///////////////////////////////////Test Duration///////////////////// + /////////////////////////////////// Test Duration///////////////////// @Test public void testDurationArrayLookupProgrammatically() { Duration[] value = config.getValue("tck.config.test.javaconfig.converter.durationvalues", - Duration[].class); + Duration[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Duration[]{ - Duration.parse("PT15M"), - Duration.parse("PT20M")}); + Assert.assertEquals(value, new Duration[]{ + Duration.parse("PT15M"), + Duration.parse("PT20M")}); Duration[] single = config.getValue("tck.config.test.javaconfig.converter.durationvalue", - Duration[].class); + Duration[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Duration[]{ Duration.parse("PT15M") }); + Assert.assertEquals(single, new Duration[]{Duration.parse("PT15M")}); } @Test @@ -841,87 +858,91 @@ public void testGetDurationArrayConverter() { Duration[] value = config.getConverter(Duration[].class).get().convert("PT15M,PT20M"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Duration[]{ - Duration.parse("PT15M"), - Duration.parse("PT20M")}); + Assert.assertEquals(value, new Duration[]{ + Duration.parse("PT15M"), + Duration.parse("PT20M")}); Duration[] single = config.getConverter(Duration[].class).get().convert("PT15M"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Duration[]{ Duration.parse("PT15M") }); + Assert.assertEquals(single, new Duration[]{Duration.parse("PT15M")}); } @Test public void testOptionalDurationArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.durationvalues", - Duration[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.durationvalues", + Duration[].class); Assert.assertTrue(optionalValue.isPresent()); Duration[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new Duration[]{ - Duration.parse("PT15M"), - Duration.parse("PT20M")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.durationvalue", - Duration[].class); + Assert.assertEquals(value, new Duration[]{ + Duration.parse("PT15M"), + Duration.parse("PT20M")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.durationvalue", + Duration[].class); Assert.assertTrue(optionalSingle.isPresent()); Duration[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new Duration[]{ Duration.parse("PT15M") }); - } + Assert.assertEquals(single, new Duration[]{Duration.parse("PT15M")}); + } @Test public void testDurationListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.durationvalues", - Duration.class); + Duration.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - Duration.parse("PT15M"), - Duration.parse("PT20M"))); + Assert.assertEquals(values, Arrays.asList( + Duration.parse("PT15M"), + Duration.parse("PT20M"))); List single = config.getValues("tck.config.test.javaconfig.converter.durationvalue", - Duration.class); + Duration.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(Duration.parse("PT15M"))); + Assert.assertEquals(single, Arrays.asList(Duration.parse("PT15M"))); } @Test public void testOptionalDurationListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.durationvalues", - Duration.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.durationvalues", + Duration.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - Duration.parse("PT15M"), - Duration.parse("PT20M"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.durationvalue", - Duration.class); + Assert.assertEquals(values, Arrays.asList( + Duration.parse("PT15M"), + Duration.parse("PT20M"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.durationvalue", + Duration.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(Duration.parse("PT15M"))); - } + Assert.assertEquals(single, Arrays.asList(Duration.parse("PT15M"))); + } @Test public void testDurationArrayInjection() { Assert.assertEquals(converterBean.getMyDurationArray().length, 2); Assert.assertEquals(converterBean.getMyDurationArray(), new Duration[]{ - Duration.parse("PT15M"), - Duration.parse("PT20M")}); + Duration.parse("PT15M"), + Duration.parse("PT20M")}); Assert.assertEquals(converterBean.getMySingleDurationArray().length, 1); - Assert.assertEquals(converterBean.getMySingleDurationArray(), new Duration[]{ Duration.parse("PT15M") }); + Assert.assertEquals(converterBean.getMySingleDurationArray(), new Duration[]{Duration.parse("PT15M")}); } @Test public void testDurationListInjection() { Assert.assertEquals(converterBean.getMyDurationList().size(), 2); Assert.assertEquals(converterBean.getMyDurationList(), Arrays.asList( - Duration.parse("PT15M"), - Duration.parse("PT20M"))); + Duration.parse("PT15M"), + Duration.parse("PT20M"))); Assert.assertEquals(converterBean.getMySingleDurationList().size(), 1); Assert.assertEquals(converterBean.getMySingleDurationList(), Arrays.asList(Duration.parse("PT15M"))); } @@ -930,30 +951,30 @@ public void testDurationListInjection() { public void testDurationSetInjection() { Assert.assertEquals(converterBean.getMyDurationSet().size(), 2); Assert.assertEquals(converterBean.getMyDurationSet(), new LinkedHashSet<>(Arrays.asList( - Duration.parse("PT15M"), - Duration.parse("PT20M")))); + Duration.parse("PT15M"), + Duration.parse("PT20M")))); Assert.assertEquals(converterBean.getMySingleDurationSet().size(), 1); Assert.assertEquals(converterBean.getMySingleDurationSet(), Collections.singleton(Duration.parse("PT15M"))); } ////////////////////////////////////////////////////////////////////// - //LocalTime - ///////////////////////////////////Test LocalTime///////////////////// + // LocalTime + /////////////////////////////////// Test LocalTime///////////////////// @Test public void testLocalTimeArrayLookupProgrammatically() { LocalTime[] value = config.getValue("tck.config.test.javaconfig.converter.localtimevalues", - LocalTime[].class); + LocalTime[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new LocalTime[]{ - LocalTime.parse("10:37"), - LocalTime.parse("11:44")}); + Assert.assertEquals(value, new LocalTime[]{ + LocalTime.parse("10:37"), + LocalTime.parse("11:44")}); LocalTime[] single = config.getValue("tck.config.test.javaconfig.converter.localtimevalue", - LocalTime[].class); + LocalTime[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new LocalTime[]{ LocalTime.parse("10:37") }); + Assert.assertEquals(single, new LocalTime[]{LocalTime.parse("10:37")}); } @Test @@ -961,87 +982,91 @@ public void testGetLocalTimeArrayConverter() { LocalTime[] value = config.getConverter(LocalTime[].class).get().convert("10:37,11:44"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new LocalTime[]{ - LocalTime.parse("10:37"), - LocalTime.parse("11:44")}); + Assert.assertEquals(value, new LocalTime[]{ + LocalTime.parse("10:37"), + LocalTime.parse("11:44")}); LocalTime[] single = config.getConverter(LocalTime[].class).get().convert("10:37"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new LocalTime[]{ LocalTime.parse("10:37") }); + Assert.assertEquals(single, new LocalTime[]{LocalTime.parse("10:37")}); } @Test public void testOptionalLocalTimeArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.localtimevalues", - LocalTime[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.localtimevalues", + LocalTime[].class); Assert.assertTrue(optionalValue.isPresent()); LocalTime[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new LocalTime[]{ - LocalTime.parse("10:37"), - LocalTime.parse("11:44")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.localtimevalue", - LocalTime[].class); + Assert.assertEquals(value, new LocalTime[]{ + LocalTime.parse("10:37"), + LocalTime.parse("11:44")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.localtimevalue", + LocalTime[].class); Assert.assertTrue(optionalSingle.isPresent()); LocalTime[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new LocalTime[]{ LocalTime.parse("10:37") }); - } + Assert.assertEquals(single, new LocalTime[]{LocalTime.parse("10:37")}); + } @Test public void testLocalTimeListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.localtimevalues", - LocalTime.class); + LocalTime.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - LocalTime.parse("10:37"), - LocalTime.parse("11:44"))); + Assert.assertEquals(values, Arrays.asList( + LocalTime.parse("10:37"), + LocalTime.parse("11:44"))); List single = config.getValues("tck.config.test.javaconfig.converter.localtimevalue", - LocalTime.class); + LocalTime.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(LocalTime.parse("10:37"))); + Assert.assertEquals(single, Arrays.asList(LocalTime.parse("10:37"))); } @Test public void testOptionalLocalTimeListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.localtimevalues", - LocalTime.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.localtimevalues", + LocalTime.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - LocalTime.parse("10:37"), - LocalTime.parse("11:44"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.localtimevalue", - LocalTime.class); + Assert.assertEquals(values, Arrays.asList( + LocalTime.parse("10:37"), + LocalTime.parse("11:44"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.localtimevalue", + LocalTime.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(LocalTime.parse("10:37"))); - } + Assert.assertEquals(single, Arrays.asList(LocalTime.parse("10:37"))); + } @Test public void testLocalTimeArrayInjection() { Assert.assertEquals(converterBean.getMyLocaltimeArray().length, 2); Assert.assertEquals(converterBean.getMyLocaltimeArray(), new LocalTime[]{ - LocalTime.parse("10:37"), - LocalTime.parse("11:44")}); + LocalTime.parse("10:37"), + LocalTime.parse("11:44")}); Assert.assertEquals(converterBean.getMySingleLocaltimeArray().length, 1); - Assert.assertEquals(converterBean.getMySingleLocaltimeArray(), new LocalTime[]{ LocalTime.parse("10:37") }); + Assert.assertEquals(converterBean.getMySingleLocaltimeArray(), new LocalTime[]{LocalTime.parse("10:37")}); } @Test public void testLocalTimeListInjection() { Assert.assertEquals(converterBean.getMyLocalTimeList().size(), 2); Assert.assertEquals(converterBean.getMyLocalTimeList(), Arrays.asList( - LocalTime.parse("10:37"), - LocalTime.parse("11:44"))); + LocalTime.parse("10:37"), + LocalTime.parse("11:44"))); Assert.assertEquals(converterBean.getMySingleLocalTimeList().size(), 1); Assert.assertEquals(converterBean.getMySingleLocalTimeList(), Arrays.asList(LocalTime.parse("10:37"))); } @@ -1050,29 +1075,29 @@ public void testLocalTimeListInjection() { public void testLocalTimeSetInjection() { Assert.assertEquals(converterBean.getMyLocalTimeSet().size(), 2); Assert.assertEquals(converterBean.getMyLocalTimeSet(), new LinkedHashSet<>(Arrays.asList( - LocalTime.parse("10:37"), - LocalTime.parse("11:44")))); + LocalTime.parse("10:37"), + LocalTime.parse("11:44")))); Assert.assertEquals(converterBean.getMySingleLocalTimeSet().size(), 1); Assert.assertEquals(converterBean.getMySingleLocalTimeSet(), Collections.singleton(LocalTime.parse("10:37"))); } ////////////////////////////////////////////////////////////////////// - ///////////////////////////Test LocalDate//////////////////////////// + /////////////////////////// Test LocalDate//////////////////////////// @Test public void testLocalDateArrayLookupProgrammatically() { LocalDate[] value = config.getValue("tck.config.test.javaconfig.converter.localdatevalues", - LocalDate[].class); + LocalDate[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new LocalDate[]{ - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29")}); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29")}); LocalDate[] single = config.getValue("tck.config.test.javaconfig.converter.localdatevalue", - LocalDate[].class); + LocalDate[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new LocalDate[]{ LocalDate.parse("2017-12-24") }); + Assert.assertEquals(single, new LocalDate[]{LocalDate.parse("2017-12-24")}); } @Test @@ -1081,45 +1106,47 @@ public void testGetLocalDateArrayConverter() { Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new LocalDate[]{ - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29")}); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29")}); LocalDate[] single = config.getConverter(LocalDate[].class).get().convert("2017-12-24"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new LocalDate[]{ LocalDate.parse("2017-12-24") }); + Assert.assertEquals(single, new LocalDate[]{LocalDate.parse("2017-12-24")}); } @Test public void testOptionalLocalDateArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.localdatevalues", - LocalDate[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.localdatevalues", + LocalDate[].class); Assert.assertTrue(optionalValue.isPresent()); LocalDate[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); Assert.assertEquals(value, new LocalDate[]{ - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.localdatevalue", - LocalDate[].class); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.localdatevalue", + LocalDate[].class); Assert.assertTrue(optionalSingle.isPresent()); LocalDate[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new LocalDate[]{ LocalDate.parse("2017-12-24") }); - } + Assert.assertEquals(single, new LocalDate[]{LocalDate.parse("2017-12-24")}); + } @Test public void testLocalDateListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.localdatevalues", - LocalDate.class); + LocalDate.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList( - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29"))); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29"))); List single = config.getValues("tck.config.test.javaconfig.converter.localdatevalue", - LocalDate.class); + LocalDate.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(LocalDate.parse("2017-12-24"))); @@ -1127,40 +1154,42 @@ public void testLocalDateListLookupProgrammatically() { @Test public void testOptionalLocalDateListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.localdatevalues", - LocalDate.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.localdatevalues", + LocalDate.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList( - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.localdatevalue", - LocalDate.class); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.localdatevalue", + LocalDate.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(LocalDate.parse("2017-12-24"))); - } + } @Test public void testLocalDateArrayInjection() { Assert.assertEquals(converterBean.getMyLocalDateArray().length, 2); Assert.assertEquals(converterBean.getMyLocalDateArray(), new LocalDate[]{ - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29")}); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29")}); Assert.assertEquals(converterBean.getMySingleLocalDateArray().length, 1); - Assert.assertEquals(converterBean.getMySingleLocalDateArray(), new LocalDate[]{ LocalDate.parse("2017-12-24") }); + Assert.assertEquals(converterBean.getMySingleLocalDateArray(), new LocalDate[]{LocalDate.parse("2017-12-24")}); } @Test public void testLocalDateListInjection() { Assert.assertEquals(converterBean.getMyLocalDateList().size(), 2); Assert.assertEquals(converterBean.getMyLocalDateList(), Arrays.asList( - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29"))); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29"))); Assert.assertEquals(converterBean.getMySingleLocalDateList().size(), 1); Assert.assertEquals(converterBean.getMySingleLocalDateList(), Arrays.asList(LocalDate.parse("2017-12-24"))); } @@ -1169,133 +1198,142 @@ public void testLocalDateListInjection() { public void testLocalDateSetInjection() { Assert.assertEquals(converterBean.getMyLocalDateSet().size(), 2); Assert.assertEquals(converterBean.getMyLocalDateSet(), new LinkedHashSet<>(Arrays.asList( - LocalDate.parse("2017-12-24"), - LocalDate.parse("2017-11-29")))); + LocalDate.parse("2017-12-24"), + LocalDate.parse("2017-11-29")))); Assert.assertEquals(converterBean.getMySingleLocalDateSet().size(), 1); - Assert.assertEquals(converterBean.getMySingleLocalDateSet(), Collections.singleton(LocalDate.parse("2017-12-24"))); + Assert.assertEquals(converterBean.getMySingleLocalDateSet(), + Collections.singleton(LocalDate.parse("2017-12-24"))); } ////////////////////////////////////////////////////////////////////// - ////////////////////////Test LocalDateTime//////////////////////////// + //////////////////////// Test LocalDateTime//////////////////////////// @Test public void testLocalDateTimeArrayLookupProgrammatically() { LocalDateTime[] value = config.getValue("tck.config.test.javaconfig.converter.localdatetimevalues", - LocalDateTime[].class); + LocalDateTime[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new LocalDateTime[]{ - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33")}); + Assert.assertEquals(value, new LocalDateTime[]{ + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33")}); LocalDateTime[] single = config.getValue("tck.config.test.javaconfig.converter.localdatetimevalue", - LocalDateTime[].class); + LocalDateTime[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new LocalDateTime[]{ LocalDateTime.parse("2017-12-24T10:25:30") }); + Assert.assertEquals(single, new LocalDateTime[]{LocalDateTime.parse("2017-12-24T10:25:30")}); } @Test public void testGetLocalDateTimeArrayConverter() { - LocalDateTime[] value = config.getConverter(LocalDateTime[].class).get().convert("2017-12-24T10:25:30,2017-12-24T10:25:33"); + LocalDateTime[] value = + config.getConverter(LocalDateTime[].class).get().convert("2017-12-24T10:25:30,2017-12-24T10:25:33"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new LocalDateTime[]{ - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33")}); + Assert.assertEquals(value, new LocalDateTime[]{ + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33")}); LocalDateTime[] single = config.getConverter(LocalDateTime[].class).get().convert("2017-12-24T10:25:30"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new LocalDateTime[]{ LocalDateTime.parse("2017-12-24T10:25:30") }); + Assert.assertEquals(single, new LocalDateTime[]{LocalDateTime.parse("2017-12-24T10:25:30")}); } @Test public void testOptionalLocalDateTimeArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.localdatetimevalues", - LocalDateTime[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.localdatetimevalues", + LocalDateTime[].class); Assert.assertTrue(optionalValue.isPresent()); LocalDateTime[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new LocalDateTime[]{ - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.localdatetimevalue", - LocalDateTime[].class); + Assert.assertEquals(value, new LocalDateTime[]{ + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.localdatetimevalue", + LocalDateTime[].class); Assert.assertTrue(optionalSingle.isPresent()); LocalDateTime[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new LocalDateTime[]{ LocalDateTime.parse("2017-12-24T10:25:30") }); - } + Assert.assertEquals(single, new LocalDateTime[]{LocalDateTime.parse("2017-12-24T10:25:30")}); + } @Test public void testLocalDateTimeListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.localdatetimevalues", - LocalDateTime.class); + LocalDateTime.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33"))); + Assert.assertEquals(values, Arrays.asList( + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33"))); List single = config.getValues("tck.config.test.javaconfig.converter.localdatetimevalue", - LocalDateTime.class); + LocalDateTime.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(LocalDateTime.parse("2017-12-24T10:25:30"))); + Assert.assertEquals(single, Arrays.asList(LocalDateTime.parse("2017-12-24T10:25:30"))); } @Test public void testOptionalLocalDateTimeListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.localdatetimevalues", - LocalDateTime.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.localdatetimevalues", + LocalDateTime.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.localdatetimevalue", - LocalDateTime.class); + Assert.assertEquals(values, Arrays.asList( + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.localdatetimevalue", + LocalDateTime.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(LocalDateTime.parse("2017-12-24T10:25:30"))); - } + Assert.assertEquals(single, Arrays.asList(LocalDateTime.parse("2017-12-24T10:25:30"))); + } @Test public void testLocalDateTimeArrayInjection() { Assert.assertEquals(converterBean.getMyLocalDateTimeArray().length, 2); Assert.assertEquals(converterBean.getMyLocalDateTimeArray(), new LocalDateTime[]{ - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33")}); + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33")}); Assert.assertEquals(converterBean.getMySingleLocalDateTimeArray().length, 1); - Assert.assertEquals(converterBean.getMySingleLocalDateTimeArray(), new LocalDateTime[]{ LocalDateTime.parse("2017-12-24T10:25:30") }); + Assert.assertEquals(converterBean.getMySingleLocalDateTimeArray(), + new LocalDateTime[]{LocalDateTime.parse("2017-12-24T10:25:30")}); } @Test public void testLocalDateTimeListInjection() { Assert.assertEquals(converterBean.getMyLocalDateTimeList().size(), 2); Assert.assertEquals(converterBean.getMyLocalDateTimeList(), Arrays.asList( - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33"))); + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33"))); Assert.assertEquals(converterBean.getMySingleLocalDateTimeList().size(), 1); - Assert.assertEquals(converterBean.getMySingleLocalDateTimeList(), Arrays.asList(LocalDateTime.parse("2017-12-24T10:25:30"))); + Assert.assertEquals(converterBean.getMySingleLocalDateTimeList(), + Arrays.asList(LocalDateTime.parse("2017-12-24T10:25:30"))); } @Test public void testLocalDateTimeSetInjection() { - Assert.assertEquals(converterBean.getMyLocalDateTimeSet().size(), 2); - Assert.assertEquals(converterBean.getMyLocalDateTimeSet(), new LinkedHashSet<>(Arrays.asList( - LocalDateTime.parse("2017-12-24T10:25:30"), - LocalDateTime.parse("2017-12-24T10:25:33")))); - Assert.assertEquals(converterBean.getMySingleLocalDateTimeSet().size(), 1); - Assert.assertEquals(converterBean.getMySingleLocalDateTimeSet(), Collections.singleton(LocalDateTime.parse("2017-12-24T10:25:30"))); + Assert.assertEquals(converterBean.getMyLocalDateTimeSet().size(), 2); + Assert.assertEquals(converterBean.getMyLocalDateTimeSet(), new LinkedHashSet<>(Arrays.asList( + LocalDateTime.parse("2017-12-24T10:25:30"), + LocalDateTime.parse("2017-12-24T10:25:33")))); + Assert.assertEquals(converterBean.getMySingleLocalDateTimeSet().size(), 1); + Assert.assertEquals(converterBean.getMySingleLocalDateTimeSet(), + Collections.singleton(LocalDateTime.parse("2017-12-24T10:25:30"))); } ////////////////////////////////////////////////////////////////////// - ////////////////////////Test OffsetDateTime//////////////////////////// + //////////////////////// Test OffsetDateTime//////////////////////////// @Test public void testOffsetDateTimeArrayLookupProgrammatically() { @@ -1303,49 +1341,53 @@ public void testOffsetDateTimeArrayLookupProgrammatically() { OffsetDateTime[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new OffsetDateTime[] { - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); + Assert.assertEquals(value, new OffsetDateTime[]{ + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); OffsetDateTime[] single = config.getValue("tck.config.test.javaconfig.converter.offsetdatetimevalue", OffsetDateTime[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new OffsetDateTime[] { OffsetDateTime.parse("2007-12-03T10:15:30+01:00") }); + Assert.assertEquals(single, new OffsetDateTime[]{OffsetDateTime.parse("2007-12-03T10:15:30+01:00")}); } @Test public void testGetOffsetDateTimeArrayConverter() { - OffsetDateTime[] value = config.getConverter(OffsetDateTime[].class).get().convert("2007-12-03T10:15:30+01:00,2007-12-03T10:15:30+02:00"); + OffsetDateTime[] value = config.getConverter(OffsetDateTime[].class).get() + .convert("2007-12-03T10:15:30+01:00,2007-12-03T10:15:30+02:00"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new OffsetDateTime[] { - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); - OffsetDateTime[] single = config.getConverter(OffsetDateTime[].class).get().convert("2007-12-03T10:15:30+01:00"); + Assert.assertEquals(value, new OffsetDateTime[]{ + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); + OffsetDateTime[] single = + config.getConverter(OffsetDateTime[].class).get().convert("2007-12-03T10:15:30+01:00"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new OffsetDateTime[] { OffsetDateTime.parse("2007-12-03T10:15:30+01:00") }); + Assert.assertEquals(single, new OffsetDateTime[]{OffsetDateTime.parse("2007-12-03T10:15:30+01:00")}); } @Test public void testOptionalOffsetDateTimeArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.offsetdatetimevalues", - OffsetDateTime[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.offsetdatetimevalues", + OffsetDateTime[].class); Assert.assertTrue(optionalValue.isPresent()); OffsetDateTime[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new OffsetDateTime[] { - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.offsetdatetimevalue", - OffsetDateTime[].class); + Assert.assertEquals(value, new OffsetDateTime[]{ + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.offsetdatetimevalue", + OffsetDateTime[].class); Assert.assertTrue(optionalSingle.isPresent()); OffsetDateTime[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new OffsetDateTime[] { OffsetDateTime.parse("2007-12-03T10:15:30+01:00") }); - } + Assert.assertEquals(single, new OffsetDateTime[]{OffsetDateTime.parse("2007-12-03T10:15:30+01:00")}); + } @Test public void testOffsetDateTimeListLookupProgrammatically() { @@ -1353,252 +1395,266 @@ public void testOffsetDateTimeListLookupProgrammatically() { OffsetDateTime.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00"))); + Assert.assertEquals(values, Arrays.asList( + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00"))); List single = config.getValues("tck.config.test.javaconfig.converter.offsetdatetimevalue", OffsetDateTime.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); + Assert.assertEquals(single, Arrays.asList(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); } @Test public void testOptionalOffsetDateTimeListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.offsetdatetimevalues", - OffsetDateTime.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.offsetdatetimevalues", + OffsetDateTime.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.offsetdatetimevalue", - OffsetDateTime.class); + Assert.assertEquals(values, Arrays.asList( + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.offsetdatetimevalue", + OffsetDateTime.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); - } + Assert.assertEquals(single, Arrays.asList(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); + } @Test public void testOffsetDateTimeArrayInjection() { Assert.assertEquals(converterBean.getMyOffsetDateTimeArray().length, 2); - Assert.assertEquals( converterBean.getMyOffsetDateTimeArray(), new OffsetDateTime[] { - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); + Assert.assertEquals(converterBean.getMyOffsetDateTimeArray(), new OffsetDateTime[]{ + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00")}); Assert.assertEquals(converterBean.getMySingleOffsetDateTimeArray().length, 1); - Assert.assertEquals( converterBean.getMySingleOffsetDateTimeArray(), new OffsetDateTime[] { - OffsetDateTime.parse("2007-12-03T10:15:30+01:00")}); + Assert.assertEquals(converterBean.getMySingleOffsetDateTimeArray(), new OffsetDateTime[]{ + OffsetDateTime.parse("2007-12-03T10:15:30+01:00")}); } @Test public void testOffsetDateTimeListInjection() { Assert.assertEquals(converterBean.getMyOffsetDateTimeList().size(), 2); - Assert.assertEquals( converterBean.getMyOffsetDateTimeList(), Arrays.asList( - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00"))); + Assert.assertEquals(converterBean.getMyOffsetDateTimeList(), Arrays.asList( + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00"))); Assert.assertEquals(converterBean.getMySingleOffsetDateTimeList().size(), 1); - Assert.assertEquals( converterBean.getMySingleOffsetDateTimeList(), Arrays.asList(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); + Assert.assertEquals(converterBean.getMySingleOffsetDateTimeList(), + Arrays.asList(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); } @Test public void testOffsetDateTimeSetInjection() { - Assert.assertEquals(converterBean.getMyOffsetDateTimeSet().size(), 2); - Assert.assertEquals( converterBean.getMyOffsetDateTimeSet(), new LinkedHashSet<>(Arrays.asList( - OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), - OffsetDateTime.parse("2007-12-03T10:15:30+02:00")))); - Assert.assertEquals(converterBean.getMySingleOffsetDateTimeSet().size(), 1); - Assert.assertEquals( converterBean.getMySingleOffsetDateTimeSet(), Collections.singleton(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); + Assert.assertEquals(converterBean.getMyOffsetDateTimeSet().size(), 2); + Assert.assertEquals(converterBean.getMyOffsetDateTimeSet(), new LinkedHashSet<>(Arrays.asList( + OffsetDateTime.parse("2007-12-03T10:15:30+01:00"), + OffsetDateTime.parse("2007-12-03T10:15:30+02:00")))); + Assert.assertEquals(converterBean.getMySingleOffsetDateTimeSet().size(), 1); + Assert.assertEquals(converterBean.getMySingleOffsetDateTimeSet(), + Collections.singleton(OffsetDateTime.parse("2007-12-03T10:15:30+01:00"))); } ////////////////////////////////////////////////////////////////////// - ////////////////////////Test OffsetTime//////////////////////////// + //////////////////////// Test OffsetTime//////////////////////////// @Test public void testOffsetTimeArrayLookupProgrammatically() { OffsetTime[] value = config.getValue("tck.config.test.javaconfig.converter.offsettimevalues", - OffsetTime[].class); + OffsetTime[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new OffsetTime[]{ - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00")}); + Assert.assertEquals(value, new OffsetTime[]{ + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00")}); OffsetTime[] single = config.getValue("tck.config.test.javaconfig.converter.offsettimevalue", - OffsetTime[].class); + OffsetTime[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new OffsetTime[]{ OffsetTime.parse("13:45:30.123456789+02:00") }); + Assert.assertEquals(single, new OffsetTime[]{OffsetTime.parse("13:45:30.123456789+02:00")}); } @Test public void testGetOffsetTimeArrayConverter() { - OffsetTime[] value = config.getConverter(OffsetTime[].class).get().convert("13:45:30.123456789+02:00,13:45:30.123456789+03:00"); + OffsetTime[] value = config.getConverter(OffsetTime[].class).get() + .convert("13:45:30.123456789+02:00,13:45:30.123456789+03:00"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new OffsetTime[]{ - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00")}); + Assert.assertEquals(value, new OffsetTime[]{ + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00")}); OffsetTime[] single = config.getConverter(OffsetTime[].class).get().convert("13:45:30.123456789+02:00"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new OffsetTime[]{ OffsetTime.parse("13:45:30.123456789+02:00") }); + Assert.assertEquals(single, new OffsetTime[]{OffsetTime.parse("13:45:30.123456789+02:00")}); } @Test public void testOptionalOffsetTimeArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.offsettimevalues", - OffsetTime[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.offsettimevalues", + OffsetTime[].class); Assert.assertTrue(optionalValue.isPresent()); OffsetTime[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals( value, new OffsetTime[]{ - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.offsettimevalue", - OffsetTime[].class); + Assert.assertEquals(value, new OffsetTime[]{ + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.offsettimevalue", + OffsetTime[].class); Assert.assertTrue(optionalSingle.isPresent()); OffsetTime[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals( single, new OffsetTime[]{ OffsetTime.parse("13:45:30.123456789+02:00") }); - } + Assert.assertEquals(single, new OffsetTime[]{OffsetTime.parse("13:45:30.123456789+02:00")}); + } @Test public void testOffsetTimeListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.offsettimevalues", - OffsetTime.class); + OffsetTime.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00"))); + Assert.assertEquals(values, Arrays.asList( + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00"))); List single = config.getValues("tck.config.test.javaconfig.converter.offsettimevalue", - OffsetTime.class); + OffsetTime.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(OffsetTime.parse("13:45:30.123456789+02:00"))); + Assert.assertEquals(single, Arrays.asList(OffsetTime.parse("13:45:30.123456789+02:00"))); } @Test public void testOptionalOffsetTimeListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.offsettimevalues", - OffsetTime.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.offsettimevalues", + OffsetTime.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); - Assert.assertEquals( values, Arrays.asList( - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.offsettimevalue", - OffsetTime.class); + Assert.assertEquals(values, Arrays.asList( + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.offsettimevalue", + OffsetTime.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); - Assert.assertEquals( single, Arrays.asList(OffsetTime.parse("13:45:30.123456789+02:00"))); - } + Assert.assertEquals(single, Arrays.asList(OffsetTime.parse("13:45:30.123456789+02:00"))); + } @Test public void testOffsetTimeArrayInjection() { Assert.assertEquals(converterBean.getMyOffsetTimeArray().length, 2); Assert.assertEquals(converterBean.getMyOffsetTimeArray(), new OffsetTime[]{ - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00")}); + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00")}); Assert.assertEquals(converterBean.getMySingleOffsetTimeArray().length, 1); - Assert.assertEquals(converterBean.getMySingleOffsetTimeArray(), new OffsetTime[]{ OffsetTime.parse("13:45:30.123456789+02:00") }); + Assert.assertEquals(converterBean.getMySingleOffsetTimeArray(), + new OffsetTime[]{OffsetTime.parse("13:45:30.123456789+02:00")}); } @Test public void testOffsetTimeListInjection() { Assert.assertEquals(converterBean.getMyOffsetTimeList().size(), 2); Assert.assertEquals(converterBean.getMyOffsetTimeList(), Arrays.asList( - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00"))); + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00"))); Assert.assertEquals(converterBean.getMySingleOffsetTimeList().size(), 1); - Assert.assertEquals(converterBean.getMySingleOffsetTimeList(), Arrays.asList(OffsetTime.parse("13:45:30.123456789+02:00"))); + Assert.assertEquals(converterBean.getMySingleOffsetTimeList(), + Arrays.asList(OffsetTime.parse("13:45:30.123456789+02:00"))); } @Test public void testOffsetTimeSetInjection() { - Assert.assertEquals(converterBean.getMyOffsetTimeSet().size(), 2); - Assert.assertEquals(converterBean.getMyOffsetTimeSet(), new LinkedHashSet<>(Arrays.asList( - OffsetTime.parse("13:45:30.123456789+02:00"), - OffsetTime.parse("13:45:30.123456789+03:00")))); - Assert.assertEquals(converterBean.getMySingleOffsetTimeSet().size(), 1); - Assert.assertEquals(converterBean.getMySingleOffsetTimeSet(), Collections.singleton(OffsetTime.parse("13:45:30.123456789+02:00"))); + Assert.assertEquals(converterBean.getMyOffsetTimeSet().size(), 2); + Assert.assertEquals(converterBean.getMyOffsetTimeSet(), new LinkedHashSet<>(Arrays.asList( + OffsetTime.parse("13:45:30.123456789+02:00"), + OffsetTime.parse("13:45:30.123456789+03:00")))); + Assert.assertEquals(converterBean.getMySingleOffsetTimeSet().size(), 1); + Assert.assertEquals(converterBean.getMySingleOffsetTimeSet(), + Collections.singleton(OffsetTime.parse("13:45:30.123456789+02:00"))); } ////////////////////////////////////////////////////////////////////// - ////////////////////////Test instant//////////////////////////// - + //////////////////////// Test instant//////////////////////////// @Test public void testInstantArrayLookupProgrammatically() { Instant[] value = config.getValue("tck.config.test.javaconfig.converter.instantvalues", - Instant[].class); + Instant[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Instant[]{ - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z")}); + Assert.assertEquals(value, new Instant[]{ + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z")}); Instant[] single = config.getValue("tck.config.test.javaconfig.converter.instantvalue", - Instant[].class); + Instant[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Instant[]{ Instant.parse("2015-06-02T21:34:33.616Z") }); + Assert.assertEquals(single, new Instant[]{Instant.parse("2015-06-02T21:34:33.616Z")}); } @Test public void testGetInstantArrayConverter() { - Instant[] value = config.getConverter(Instant[].class).get().convert("2015-06-02T21:34:33.616Z,2017-06-02T21:34:33.616Z"); + Instant[] value = + config.getConverter(Instant[].class).get().convert("2015-06-02T21:34:33.616Z,2017-06-02T21:34:33.616Z"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Instant[]{ - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z")}); + Assert.assertEquals(value, new Instant[]{ + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z")}); Instant[] single = config.getConverter(Instant[].class).get().convert("2015-06-02T21:34:33.616Z"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Instant[]{ Instant.parse("2015-06-02T21:34:33.616Z") }); + Assert.assertEquals(single, new Instant[]{Instant.parse("2015-06-02T21:34:33.616Z")}); } @Test public void testOptionalInstantArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.instantvalues", - Instant[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.instantvalues", + Instant[].class); Assert.assertTrue(optionalValue.isPresent()); Instant[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 2); - Assert.assertEquals(value, new Instant[]{ - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.instantvalue", - Instant[].class); + Assert.assertEquals(value, new Instant[]{ + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.instantvalue", + Instant[].class); Assert.assertTrue(optionalSingle.isPresent()); Instant[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Instant[]{ Instant.parse("2015-06-02T21:34:33.616Z") }); - } + Assert.assertEquals(single, new Instant[]{Instant.parse("2015-06-02T21:34:33.616Z")}); + } @Test public void testInstantListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.instantvalues", - Instant.class); + Instant.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList( - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z"))); + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z"))); List single = config.getValues("tck.config.test.javaconfig.converter.instantvalue", - Instant.class); + Instant.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(Instant.parse("2015-06-02T21:34:33.616Z"))); @@ -1606,130 +1662,135 @@ public void testInstantListLookupProgrammatically() { @Test public void testOptionalInstantListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.instantvalues", - Instant.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.instantvalues", + Instant.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 2); Assert.assertEquals(values, Arrays.asList( - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.instantvalue", - Instant.class); + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.instantvalue", + Instant.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(Instant.parse("2015-06-02T21:34:33.616Z"))); - } + } @Test public void testInstantArrayInjection() { Assert.assertEquals(converterBean.getMyInstantArray().length, 2); - Assert.assertEquals(converterBean.getMyInstantArray(), new Instant[]{ - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z")}); + Assert.assertEquals(converterBean.getMyInstantArray(), new Instant[]{ + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z")}); Assert.assertEquals(converterBean.getMySingleInstantArray().length, 1); - Assert.assertEquals(converterBean.getMySingleInstantArray(), new Instant[]{ Instant.parse("2015-06-02T21:34:33.616Z") }); + Assert.assertEquals(converterBean.getMySingleInstantArray(), + new Instant[]{Instant.parse("2015-06-02T21:34:33.616Z")}); } @Test public void testInstantListInjection() { Assert.assertEquals(converterBean.getMyInstantList().size(), 2); Assert.assertEquals(converterBean.getMyInstantList(), Arrays.asList( - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z"))); + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z"))); Assert.assertEquals(converterBean.getMySingleInstantList().size(), 1); - Assert.assertEquals(converterBean.getMySingleInstantList(), Arrays.asList(Instant.parse("2015-06-02T21:34:33.616Z"))); + Assert.assertEquals(converterBean.getMySingleInstantList(), + Arrays.asList(Instant.parse("2015-06-02T21:34:33.616Z"))); } @Test public void testInstantSetInjection() { - Assert.assertEquals(converterBean.getMyInstantSet().size(), 2); - Assert.assertEquals(converterBean.getMyInstantList(), new LinkedHashSet<>(Arrays.asList( - Instant.parse("2015-06-02T21:34:33.616Z"), - Instant.parse("2017-06-02T21:34:33.616Z")))); - Assert.assertEquals(converterBean.getMySingleInstantSet().size(), 1); - Assert.assertEquals(converterBean.getMySingleInstantSet(), Collections.singleton(Instant.parse("2015-06-02T21:34:33.616Z"))); + Assert.assertEquals(converterBean.getMyInstantSet().size(), 2); + Assert.assertEquals(converterBean.getMyInstantList(), new LinkedHashSet<>(Arrays.asList( + Instant.parse("2015-06-02T21:34:33.616Z"), + Instant.parse("2017-06-02T21:34:33.616Z")))); + Assert.assertEquals(converterBean.getMySingleInstantSet().size(), 1); + Assert.assertEquals(converterBean.getMySingleInstantSet(), + Collections.singleton(Instant.parse("2015-06-02T21:34:33.616Z"))); } ////////////////////////////////////////////////////////////////////// - ///////////////////////////////////Test URL[] ////////////////////////// - + /////////////////////////////////// Test URL[] ////////////////////////// private void assertURLArrayEquals(URL[] value, URL[] expectedValue) throws MalformedURLException { assertURLListEquals(Arrays.asList(value), Arrays.asList(expectedValue)); } private void assertURLListEquals(List value, List expectedValue) throws MalformedURLException { - + Assert.assertTrue(IntStream.range(0, expectedValue.size()).allMatch(i -> { - try { + try { return expectedValue.get(i).toURI().equals(value.get(i).toURI()); - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { e.printStackTrace(); - } - return false; + } + return false; })); } - @Test public void testUrlArrayLookupProgrammatically() throws MalformedURLException, URISyntaxException { URL[] value = config.getValue("tck.config.test.javaconfig.converter.urlvalues", URL[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); URL[] expectedValue = new URL[]{ - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")}; + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")}; assertURLArrayEquals(value, expectedValue); URL[] single = config.getValue("tck.config.test.javaconfig.converter.urlvalue", URL[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single[0].toURI(), new URL[]{ new URL("http://microprofile.io") }[0].toURI()); + Assert.assertEquals(single[0].toURI(), new URL[]{new URL("http://microprofile.io")}[0].toURI()); } @Test public void testGetUrlArrayConverter() throws MalformedURLException, URISyntaxException { - URL[] value = config.getConverter(URL[].class).get().convert("http://microprofile.io,http://openliberty.io,http://microprofile.io"); + URL[] value = config.getConverter(URL[].class).get() + .convert("http://microprofile.io,http://openliberty.io,http://microprofile.io"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); URL[] expectedValue = new URL[]{ - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")}; + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")}; assertURLArrayEquals(value, expectedValue); URL[] single = config.getConverter(URL[].class).get().convert("http://microprofile.io"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); URL[] expectedSingleValue = new URL[]{ - new URL("http://microprofile.io")}; - assertURLArrayEquals(single, expectedSingleValue); + new URL("http://microprofile.io")}; + assertURLArrayEquals(single, expectedSingleValue); } @Test public void testOptionalUrlArrayLookupProgrammatically() throws MalformedURLException, URISyntaxException { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalues", URL[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalues", URL[].class); Assert.assertTrue(optionalValue.isPresent()); URL[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); URL[] expectedValue = new URL[]{ - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")}; + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")}; assertURLArrayEquals(value, expectedValue); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalue", URL[].class); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalue", URL[].class); Assert.assertTrue(optionalSingle.isPresent()); URL[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); URL[] expectedSingleValue = new URL[]{ - new URL("http://microprofile.io")}; + new URL("http://microprofile.io")}; assertURLArrayEquals(single, expectedSingleValue); } @@ -1739,10 +1800,10 @@ public void testUrlListLookupProgrammatically() throws MalformedURLException, UR Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); List expectedValue = Arrays.asList( - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")); - assertURLListEquals(values, expectedValue); + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")); + assertURLListEquals(values, expectedValue); List single = config.getValues("tck.config.test.javaconfig.converter.urlvalue", URL.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); @@ -1752,17 +1813,19 @@ public void testUrlListLookupProgrammatically() throws MalformedURLException, UR @Test public void testOptionalUrlListLookupProgrammatically() throws MalformedURLException, URISyntaxException { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalues", URL.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalues", URL.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); List expectedValue = Arrays.asList( - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")); - assertURLListEquals(values, expectedValue); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalue", URL.class); + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")); + assertURLListEquals(values, expectedValue); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalue", URL.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); @@ -1771,19 +1834,18 @@ public void testOptionalUrlListLookupProgrammatically() throws MalformedURLExcep Assert.assertEquals(single, expectedSingleValue); } - @Test public void testUrlArrayInjection() throws MalformedURLException, URISyntaxException { URL[] values = converterBean.getMyUrlArray(); Assert.assertEquals(values.length, 3); URL[] expectedValue = new URL[]{ - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")}; + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")}; assertURLArrayEquals(values, expectedValue); Assert.assertEquals(converterBean.getMySingleUrlArray().length, 1); URL[] expectedSingleValue = new URL[]{ - new URL("http://microprofile.io")}; + new URL("http://microprofile.io")}; assertURLArrayEquals(converterBean.getMySingleUrlArray(), expectedSingleValue); } @@ -1792,17 +1854,18 @@ public void testURLListInjection() throws MalformedURLException, URISyntaxExcept List values = converterBean.getMyUrlList(); Assert.assertEquals(values.size(), 3); List expectedValue = Arrays.asList( - new URL("http://microprofile.io"), - new URL("http://openliberty.io"), - new URL("http://microprofile.io")); + new URL("http://microprofile.io"), + new URL("http://openliberty.io"), + new URL("http://microprofile.io")); assertURLListEquals(values, expectedValue); Assert.assertEquals(converterBean.getMySingleUrlList().size(), 1); List expectedSingleValue = Arrays.asList(new URL("http://microprofile.io")); Assert.assertEquals(converterBean.getMySingleUrlList(), expectedSingleValue); } - private boolean assertURLSetEquals(Set valueSet, Set expectedURLSet) throws MalformedURLException, URISyntaxException { - if (valueSet.size()!= expectedURLSet.size()) { + private boolean assertURLSetEquals(Set valueSet, Set expectedURLSet) + throws MalformedURLException, URISyntaxException { + if (valueSet.size() != expectedURLSet.size()) { return false; } Iterator it = valueSet.iterator(); @@ -1810,7 +1873,7 @@ private boolean assertURLSetEquals(Set valueSet, Set expectedURLSet) t while (it.hasNext()) { boolean found = false; URL url = it.next(); - for (URL thisURL : expectedURLSet) { + for (URL thisURL : expectedURLSet) { if (thisURL.toURI().equals(url.toURI())) { found = true; break; @@ -1822,23 +1885,23 @@ private boolean assertURLSetEquals(Set valueSet, Set expectedURLSet) t } } return isEquals; - + } @Test public void testURLSetInjection() throws MalformedURLException, URISyntaxException { Set values = converterBean.getMyUrlSet(); Assert.assertEquals(values.size(), 2); Set expectedURLSet = new LinkedHashSet<>(Arrays.asList( - new URL("http://openliberty.io"), - new URL("http://microprofile.io"))); + new URL("http://openliberty.io"), + new URL("http://microprofile.io"))); Assert.assertTrue(assertURLSetEquals(values, expectedURLSet)); - + Assert.assertEquals(converterBean.getMySingleUrlSet().size(), 1); Set expectedSingleUrlSet = Collections.singleton(new URL("http://microprofile.io")); - Assert.assertTrue(assertURLSetEquals(converterBean.getMySingleUrlSet(), expectedSingleUrlSet)); + Assert.assertTrue(assertURLSetEquals(converterBean.getMySingleUrlSet(), expectedSingleUrlSet)); } - ///////////////////////////////////Test URI[] ////////////////////////// + /////////////////////////////////// Test URI[] ////////////////////////// @Test public void testUriArrayLookupProgrammatically() { @@ -1846,48 +1909,51 @@ public void testUriArrayLookupProgrammatically() { Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new URI[]{ - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io")}); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io")}); URI[] single = config.getValue("tck.config.test.javaconfig.converter.urlvalue", URI[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new URI[]{ URI.create("http://microprofile.io") }); + Assert.assertEquals(single, new URI[]{URI.create("http://microprofile.io")}); } @Test public void testGetUriArrayConverter() { - URI[] value = config.getConverter(URI[].class).get().convert("http://microprofile.io,http://openliberty.io,http://microprofile.io"); + URI[] value = config.getConverter(URI[].class).get() + .convert("http://microprofile.io,http://openliberty.io,http://microprofile.io"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new URI[]{ - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io")}); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io")}); URI[] single = config.getConverter(URI[].class).get().convert("http://microprofile.io"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new URI[]{ URI.create("http://microprofile.io") }); + Assert.assertEquals(single, new URI[]{URI.create("http://microprofile.io")}); } @Test public void testOptionalUriArrayLookupProgrammatically() { - Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalues", URI[].class); + Optional optionalValue = + config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalues", URI[].class); Assert.assertTrue(optionalValue.isPresent()); URI[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new URI[]{ - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io")}); - Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalue", URI[].class); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io")}); + Optional optionalSingle = + config.getOptionalValue("tck.config.test.javaconfig.converter.urlvalue", URI[].class); Assert.assertTrue(optionalSingle.isPresent()); URI[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new URI[]{ URI.create("http://microprofile.io") }); - } + Assert.assertEquals(single, new URI[]{URI.create("http://microprofile.io")}); + } @Test public void testUriListLookupProgrammatically() { @@ -1895,9 +1961,9 @@ public void testUriListLookupProgrammatically() { Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); Assert.assertEquals(values, Arrays.asList( - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io"))); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io"))); List single = config.getValues("tck.config.test.javaconfig.converter.urlvalue", URI.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); @@ -1906,41 +1972,43 @@ public void testUriListLookupProgrammatically() { @Test public void testOptionalUriListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalues", URI.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalues", URI.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); Assert.assertEquals(values, Arrays.asList( - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io"))); - Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalue", URI.class); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io"))); + Optional> optionalSingle = + config.getOptionalValues("tck.config.test.javaconfig.converter.urlvalue", URI.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(URI.create("http://microprofile.io"))); - } + } @Test public void testUriArrayInjection() { Assert.assertEquals(converterBean.getMyUriArray().length, 3); Assert.assertEquals(converterBean.getMyUriArray(), new URI[]{ - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io")}); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io")}); Assert.assertEquals(converterBean.getMySingleUriArray().length, 1); - Assert.assertEquals(converterBean.getMySingleUriArray(), new URI[]{ URI.create("http://microprofile.io") }); + Assert.assertEquals(converterBean.getMySingleUriArray(), new URI[]{URI.create("http://microprofile.io")}); } @Test public void testUriListInjection() { Assert.assertEquals(converterBean.getMyUriList().size(), 3); Assert.assertEquals(converterBean.getMyUriList(), Arrays.asList( - URI.create("http://microprofile.io"), - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io"))); + URI.create("http://microprofile.io"), + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io"))); Assert.assertEquals(converterBean.getMySingleUriList().size(), 1); Assert.assertEquals(converterBean.getMySingleUriList(), Arrays.asList(URI.create("http://microprofile.io"))); } @@ -1949,82 +2017,82 @@ public void testUriListInjection() { public void testUriSetInjection() { Assert.assertEquals(converterBean.getMyUriSet().size(), 2); Assert.assertEquals(converterBean.getMyUriSet(), new LinkedHashSet<>(Arrays.asList( - URI.create("http://openliberty.io"), - URI.create("http://microprofile.io")))); + URI.create("http://openliberty.io"), + URI.create("http://microprofile.io")))); Assert.assertEquals(converterBean.getMySingleUriSet().size(), 1); - Assert.assertEquals(converterBean.getMySingleUriSet(), Collections.singleton(URI.create("http://microprofile.io"))); + Assert.assertEquals(converterBean.getMySingleUriSet(), + Collections.singleton(URI.create("http://microprofile.io"))); } - /////////////////////////////////////////////////////////////////// - //test custom class array support - + // test custom class array support @Test public void testCustomTypeArrayLookupProgrammatically() { Pizza[] value = config.getValue("tck.config.test.javaconfig.converter.array.pizza", - Pizza[].class); + Pizza[].class); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new Pizza[]{ - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small")}); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small")}); Pizza[] single = config.getValue("tck.config.test.javaconfig.converter.pizza", - Pizza[].class); + Pizza[].class); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Pizza[]{ new Pizza("cheese,mushroom", "large") }); + Assert.assertEquals(single, new Pizza[]{new Pizza("cheese,mushroom", "large")}); } @Test public void testGetCustomTypeArrayConverter() { - Pizza[] value = config.getConverter(Pizza[].class).get().convert("large:cheese\\,mushroom,medium:chicken,small:pepperoni"); + Pizza[] value = config.getConverter(Pizza[].class).get() + .convert("large:cheese\\,mushroom,medium:chicken,small:pepperoni"); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new Pizza[]{ - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small")}); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small")}); Pizza[] single = config.getConverter(Pizza[].class).get().convert("large:cheese\\,mushroom"); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Pizza[]{ new Pizza("cheese,mushroom", "large") }); + Assert.assertEquals(single, new Pizza[]{new Pizza("cheese,mushroom", "large")}); } @Test public void testOptionalCustomTypeArrayLookupProgrammatically() { Optional optionalValue = config.getOptionalValue("tck.config.test.javaconfig.converter.array.pizza", - Pizza[].class); + Pizza[].class); Assert.assertTrue(optionalValue.isPresent()); Pizza[] value = optionalValue.get(); Assert.assertNotNull(value); Assert.assertEquals(value.length, 3); Assert.assertEquals(value, new Pizza[]{ - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small")}); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small")}); Optional optionalSingle = config.getOptionalValue("tck.config.test.javaconfig.converter.pizza", - Pizza[].class); + Pizza[].class); Assert.assertTrue(optionalSingle.isPresent()); Pizza[] single = optionalSingle.get(); Assert.assertNotNull(single); Assert.assertEquals(single.length, 1); - Assert.assertEquals(single, new Pizza[]{ new Pizza("cheese,mushroom", "large") }); + Assert.assertEquals(single, new Pizza[]{new Pizza("cheese,mushroom", "large")}); } @Test public void testCustomTypeListLookupProgrammatically() { List values = config.getValues("tck.config.test.javaconfig.converter.array.pizza", - Pizza.class); + Pizza.class); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); Assert.assertEquals(values, Arrays.asList( - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small"))); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small"))); List single = config.getValues("tck.config.test.javaconfig.converter.pizza", - Pizza.class); + Pizza.class); Assert.assertNotNull(single); Assert.assertEquals(single.size(), 1); Assert.assertEquals(single, Arrays.asList(new Pizza("cheese,mushroom", "large"))); @@ -2032,18 +2100,19 @@ public void testCustomTypeListLookupProgrammatically() { @Test public void testOptionalCustomTypeListLookupProgrammatically() { - Optional> optionalValues = config.getOptionalValues("tck.config.test.javaconfig.converter.array.pizza", - Pizza.class); + Optional> optionalValues = + config.getOptionalValues("tck.config.test.javaconfig.converter.array.pizza", + Pizza.class); Assert.assertTrue(optionalValues.isPresent()); List values = optionalValues.get(); Assert.assertNotNull(values); Assert.assertEquals(values.size(), 3); Assert.assertEquals(values, Arrays.asList( - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small"))); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small"))); Optional> optionalSingle = config.getOptionalValues("tck.config.test.javaconfig.converter.pizza", - Pizza.class); + Pizza.class); Assert.assertTrue(optionalSingle.isPresent()); List single = optionalSingle.get(); Assert.assertNotNull(single); @@ -2055,33 +2124,34 @@ public void testOptionalCustomTypeListLookupProgrammatically() { public void testCustomTypeArrayInjection() { Assert.assertEquals(converterBean.getMyPizzaArray().length, 3); Assert.assertEquals(converterBean.getMyPizzaArray(), new Pizza[]{ - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small")}); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small")}); Assert.assertEquals(converterBean.getMySinglePizzaArray().length, 1); - Assert.assertEquals(converterBean.getMySinglePizzaArray(), new Pizza[]{ new Pizza("cheese,mushroom", "large") }); + Assert.assertEquals(converterBean.getMySinglePizzaArray(), new Pizza[]{new Pizza("cheese,mushroom", "large")}); } @Test - public void testCustomTypeListInjection() { + public void testCustomTypeListInjection() { Assert.assertEquals(converterBean.getMyPizzaList().size(), 3); Assert.assertEquals(converterBean.getMyPizzaList(), Arrays.asList( - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small"))); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small"))); Assert.assertEquals(converterBean.getMySinglePizzaList().size(), 1); Assert.assertEquals(converterBean.getMySinglePizzaList(), Arrays.asList(new Pizza("cheese,mushroom", "large"))); } @Test - public void testCustomTypeSetInjection() { + public void testCustomTypeSetInjection() { Assert.assertEquals(converterBean.getMyPizzaSet().size(), 3); Assert.assertEquals(converterBean.getMyPizzaSet(), new LinkedHashSet<>(Arrays.asList( - new Pizza("cheese,mushroom", "large"), - new Pizza("chicken", "medium"), - new Pizza("pepperoni", "small")))); + new Pizza("cheese,mushroom", "large"), + new Pizza("chicken", "medium"), + new Pizza("pepperoni", "small")))); Assert.assertEquals(converterBean.getMySinglePizzaSet().size(), 1); - Assert.assertEquals(converterBean.getMySinglePizzaSet(), Collections.singleton(new Pizza("cheese,mushroom", "large"))); + Assert.assertEquals(converterBean.getMySinglePizzaSet(), + Collections.singleton(new Pizza("cheese,mushroom", "large"))); } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/AutoDiscoveredConfigSourceTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/AutoDiscoveredConfigSourceTest.java index 84363a72..e1aea4d4 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/AutoDiscoveredConfigSourceTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/AutoDiscoveredConfigSourceTest.java @@ -47,7 +47,8 @@ public class AutoDiscoveredConfigSourceTest extends Arquillian { public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "customConfigSourceTest.jar") - .addClasses(AutoDiscoveredConfigSourceTest.class, CustomDbConfigSource.class, Pizza.class, PizzaConverter.class) + .addClasses(AutoDiscoveredConfigSourceTest.class, CustomDbConfigSource.class, Pizza.class, + PizzaConverter.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(ConfigSource.class, CustomDbConfigSource.class) .addAsServiceProvider(Converter.class, PizzaConverter.class) @@ -61,13 +62,15 @@ public static WebArchive deploy() { @Test public void testAutoDiscoveredConfigureSources() { - Config config = ConfigProviderResolver.instance().getBuilder().addDefaultSources().addDiscoveredSources().build(); + Config config = + ConfigProviderResolver.instance().getBuilder().addDefaultSources().addDiscoveredSources().build(); Assert.assertEquals(config.getValue("tck.config.test.customDbConfig.key1", String.class), "valueFromDb1"); } @Test public void testAutoDiscoveredConverterManuallyAdded() { - Config config = ConfigProviderResolver.instance().getBuilder().addDefaultSources().addDiscoveredSources().addDiscoveredConverters().build(); + Config config = ConfigProviderResolver.instance().getBuilder().addDefaultSources().addDiscoveredSources() + .addDiscoveredConverters().build(); Pizza dVaule = config.getValue("tck.config.test.customDbConfig.key3", Pizza.class); Assert.assertEquals(dVaule.getSize(), "big"); Assert.assertEquals(dVaule.getFlavor(), "cheese"); @@ -75,7 +78,8 @@ public void testAutoDiscoveredConverterManuallyAdded() { @Test(expectedExceptions = IllegalArgumentException.class) public void testAutoDiscoveredConverterNotAddedAutomatically() { - Config config = ConfigProviderResolver.instance().getBuilder().addDefaultSources().addDiscoveredSources().build(); + Config config = + ConfigProviderResolver.instance().getBuilder().addDefaultSources().addDiscoveredSources().build(); Pizza dVaule = config.getValue("tck.config.test.customDbConfig.key3", Pizza.class); Assert.fail("The auto discovered converter should not be added automatically."); } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPlainInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPlainInjectionTest.java index 9e159d4d..308a02f2 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPlainInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPlainInjectionTest.java @@ -27,15 +27,15 @@ import java.util.HashMap; import java.util.Map; -import java.util.function.Supplier; import java.util.Set; +import java.util.function.Supplier; import javax.enterprise.context.Dependent; import javax.enterprise.inject.spi.CDI; import javax.inject.Inject; import javax.inject.Provider; -import org.eclipse.microprofile.config.ConfigProvider; +import org.eclipse.microprofile.config.ConfigProvider; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.tck.matchers.AdditionalMatchers; @@ -49,8 +49,8 @@ import org.testng.annotations.Test; /** - * Test cases for CDI-based API that test retrieving values from the configuration. - * The tests depend only on CDI 1.2. + * Test cases for CDI-based API that test retrieving values from the configuration. The tests depend only on CDI 1.2. + * * @author Ondrej Mihalyi */ public class CDIPlainInjectionTest extends Arquillian { @@ -79,8 +79,8 @@ public void canInjectSimpleValuesWhenDefined() { assertThat(bean.stringProperty, is(equalTo("text"))); assertThat(bean.booleanProperty, is(true)); - assertThat(bean.byteProperty, is(equalTo((byte)127))); - assertThat(bean.shortProperty, is(equalTo((short)32767))); + assertThat(bean.byteProperty, is(equalTo((byte) 127))); + assertThat(bean.shortProperty, is(equalTo((short) 32767))); assertThat(bean.intProperty, is(equalTo(5))); assertThat(bean.longProperty, is(equalTo(10L))); assertThat(bean.floatProperty, is(floatCloseTo(10.5f, 0.1f))); @@ -88,8 +88,8 @@ public void canInjectSimpleValuesWhenDefined() { assertThat(bean.charProperty, is(equalTo('c'))); assertThat(bean.booleanObjProperty, is(true)); - assertThat(bean.byteObjProperty, is(equalTo(Byte.valueOf((byte)127)))); - assertThat(bean.shortObjProperty, is(equalTo(Short.valueOf((short)32767)))); + assertThat(bean.byteObjProperty, is(equalTo(Byte.valueOf((byte) 127)))); + assertThat(bean.shortObjProperty, is(equalTo(Short.valueOf((short) 32767)))); assertThat(bean.integerProperty, is(equalTo(5))); assertThat(bean.longObjProperty, is(equalTo(10L))); assertThat(bean.floatObjProperty, is(floatCloseTo(10.5f, 0.1f))); @@ -127,7 +127,8 @@ public void injectedValuesAreEqualToProgrammaticValues() { assertThat(bean.doublePropertyWithDefaultValue, is(closeTo( ConfigProvider.getConfig().getOptionalValue("my.not.configured.double.property", Double.class) - .orElse(3.1415), 0.1))); + .orElse(3.1415), + 0.1))); } @Test @@ -135,7 +136,8 @@ public void canInjectDynamicValuesViaCdiProvider() { DynamicValuesBean bean = getBeanOfType(DynamicValuesBean.class); - //X TODO clarify how Provider and Supplier should behave for missing values assertThat(bean.getIntProperty(), is(nullValue())); + // X TODO clarify how Provider and Supplier should behave for missing values + // assertThat(bean.getIntProperty(), is(nullValue())); assertThat(bean.getIntProperty(), is(equalTo(5))); assertThat(bean.getStringSupplierProperty(), is(equalTo("text"))); @@ -182,77 +184,77 @@ private T getBeanOfType(Class beanClass) { public static class SimpleValuesBean { @Inject - @ConfigProperty(name="my.string.property") + @ConfigProperty(name = "my.string.property") private String stringProperty; @Inject - @ConfigProperty(name="my.boolean.property") + @ConfigProperty(name = "my.boolean.property") private Boolean booleanObjProperty; @Inject - @ConfigProperty(name="my.boolean.property") + @ConfigProperty(name = "my.boolean.property") private boolean booleanProperty; @Inject - @ConfigProperty(name="my.byte.property") + @ConfigProperty(name = "my.byte.property") private Byte byteObjProperty; @Inject - @ConfigProperty(name="my.byte.property") + @ConfigProperty(name = "my.byte.property") private byte byteProperty; @Inject - @ConfigProperty(name="my.short.property") + @ConfigProperty(name = "my.short.property") private Short shortObjProperty; @Inject - @ConfigProperty(name="my.short.property") + @ConfigProperty(name = "my.short.property") private short shortProperty; @Inject - @ConfigProperty(name="my.int.property") + @ConfigProperty(name = "my.int.property") private Integer integerProperty; @Inject - @ConfigProperty(name="my.int.property") + @ConfigProperty(name = "my.int.property") private int intProperty; @Inject - @ConfigProperty(name="my.long.property") + @ConfigProperty(name = "my.long.property") private Long longObjProperty; @Inject - @ConfigProperty(name="my.long.property") + @ConfigProperty(name = "my.long.property") private long longProperty; @Inject - @ConfigProperty(name="my.float.property") + @ConfigProperty(name = "my.float.property") private Float floatObjProperty; @Inject - @ConfigProperty(name="my.float.property") + @ConfigProperty(name = "my.float.property") private float floatProperty; @Inject - @ConfigProperty(name="my.double.property") + @ConfigProperty(name = "my.double.property") private Double doubleObjProperty; @Inject - @ConfigProperty(name="my.double.property") + @ConfigProperty(name = "my.double.property") private double doubleProperty; @Inject - @ConfigProperty(name="my.char.property") + @ConfigProperty(name = "my.char.property") private Character characterProperty; @Inject - @ConfigProperty(name="my.char.property") + @ConfigProperty(name = "my.char.property") private char charProperty; // the property is not configured in any ConfigSource but its defaultValue will // be used to set the field. @Inject - @ConfigProperty(name="my.not.configured.double.property", defaultValue = "3.1415") + @ConfigProperty(name = "my.not.configured.double.property", defaultValue = "3.1415") private Double doublePropertyWithDefaultValue; } @@ -261,11 +263,11 @@ public static class SimpleValuesBean { public static class DynamicValuesBean { @Inject - @ConfigProperty(name="my.int.property") + @ConfigProperty(name = "my.int.property") private Provider intPropertyProvider; @Inject - @ConfigProperty(name="my.string.property") + @ConfigProperty(name = "my.string.property") private Supplier stringPropertySupplier; public Integer getIntProperty() { diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyExpressionsTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyExpressionsTest.java index 1b1470fb..2cf85ebb 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyExpressionsTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyExpressionsTest.java @@ -18,6 +18,15 @@ */ package org.eclipse.microprofile.config.tck; +import static org.testng.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.enterprise.context.Dependent; +import javax.inject.Inject; + import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.spi.ConfigSource; @@ -30,27 +39,19 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; -import javax.enterprise.context.Dependent; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import static org.testng.Assert.assertEquals; - public class CDIPropertyExpressionsTest extends Arquillian { @Deployment public static Archive deployment() { JavaArchive testJar = ShrinkWrap - .create(JavaArchive.class, "CDIPropertyExpressionsTest.jar") - .addClasses(PropertyExpressionBean.class) - .addAsServiceProvider(ConfigSource.class, PropertyExpressionConfigSource.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .as(JavaArchive.class); + .create(JavaArchive.class, "CDIPropertyExpressionsTest.jar") + .addClasses(PropertyExpressionBean.class) + .addAsServiceProvider(ConfigSource.class, PropertyExpressionConfigSource.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .as(JavaArchive.class); return ShrinkWrap - .create(WebArchive.class, "CDIPropertyExpressionsTest.war") - .addAsLibrary(testJar); + .create(WebArchive.class, "CDIPropertyExpressionsTest.war") + .addAsLibrary(testJar); } @Inject diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyNameMatchingTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyNameMatchingTest.java index ebd90078..64b288ee 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyNameMatchingTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/CDIPropertyNameMatchingTest.java @@ -19,13 +19,14 @@ package org.eclipse.microprofile.config.tck; -import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; -import javax.inject.Inject; import javax.enterprise.inject.spi.CDI; +import javax.inject.Inject; + import org.eclipse.microprofile.config.Config; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.testng.Arquillian; @@ -41,12 +42,10 @@ /** * Test cases for the statement in configsources.asciidoc#default_configsources.env.mapping * - * Prerequisite: - * The following environment variables must be set prior to running this test: - * "my_int_property" with the value of "45" - * "MY_BOOLEAN_PROPERTY" with the value of "true" - * "my_string_property" with the value of "haha" + * Prerequisite: The following environment variables must be set prior to running this test: "my_int_property" with the + * value of "45" "MY_BOOLEAN_PROPERTY" with the value of "true" "my_string_property" with the value of "haha" * "MY_STRING_PROPERTY" with the value of "woohoo" + * * @author Emily Jiang */ public class CDIPropertyNameMatchingTest extends Arquillian { @@ -56,44 +55,45 @@ public class CDIPropertyNameMatchingTest extends Arquillian { @Deployment public static Archive deployment() { JavaArchive testJar = ShrinkWrap - .create(JavaArchive.class, "CDIPropertyNameMatchingTest.jar") - .addClasses(CDIPropertyNameMatchingTest.class, SimpleValuesBean.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .as(JavaArchive.class); + .create(JavaArchive.class, "CDIPropertyNameMatchingTest.jar") + .addClasses(CDIPropertyNameMatchingTest.class, SimpleValuesBean.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .as(JavaArchive.class); WebArchive war = ShrinkWrap - .create(WebArchive.class, "CDIPropertyNameMatchingTest.war") - .addAsLibrary(testJar); + .create(WebArchive.class, "CDIPropertyNameMatchingTest.war") + .addAsLibrary(testJar); return war; } @BeforeClass public void checkSetup() { - //check whether the environment variables were populated by the executor correctly + // check whether the environment variables were populated by the executor correctly if (!"45".equals(System.getenv("my_int_property"))) { - Assert.fail("Before running this test, the environment variable \"my_int_property\" must be set with the value of 45"); + Assert.fail( + "Before running this test, the environment variable \"my_int_property\" must be set with the value of 45"); } if (!"true".equals(System.getenv("MY_BOOLEAN_PROPERTY"))) { - Assert.fail("Before running this test, the environment variable \"MY_BOOLEAN_Property\" must be set with the value of true"); + Assert.fail( + "Before running this test, the environment variable \"MY_BOOLEAN_Property\" must be set with the value of true"); } // Environment variables are case insensitive on Windows platforms - if(System.getProperty("os.name").contains("Windows")) { + if (System.getProperty("os.name").contains("Windows")) { String myStringProp = System.getenv("MY_STRING_PROPERTY"); if (!"woohoo".equals(myStringProp) && !"haha".equals(myStringProp)) { Assert.fail("Before running this test on a Windows platform, " + - "the environment variable \"MY_STRING_PROPERTY\" must be set with the value of woohoo or haha"); + "the environment variable \"MY_STRING_PROPERTY\" must be set with the value of woohoo or haha"); } - } - else { // Not operating on Windows platform + } else { // Not operating on Windows platform if (!"haha".equals(System.getenv("my_string_property"))) { Assert.fail("Before running this test on a non-Windows platform, " + - "the environment variable \"my_string_property\" must be set with the value of haha"); + "the environment variable \"my_string_property\" must be set with the value of haha"); } if (!"woohoo".equals(System.getenv("MY_STRING_PROPERTY"))) { Assert.fail("Before running this test on a non-Windows platform, " + - "the environment variable \"MY_STRING_PROPERTY\" must be set with the value of woohoo"); + "the environment variable \"MY_STRING_PROPERTY\" must be set with the value of woohoo"); } } @@ -105,10 +105,9 @@ public void testPropertyFromEnvironmentVariables() { // Environment variables are case insensitive on Windows platforms, use Config to // retrieve the "os.name" System property. - if(config.getValue("os.name", String.class).contains("Windows")) { - assertThat(bean.getStringProperty(), anyOf(equalTo("haha"),equalTo("woohoo")) ); - } - else { // non-Windows + if (config.getValue("os.name", String.class).contains("Windows")) { + assertThat(bean.getStringProperty(), anyOf(equalTo("haha"), equalTo("woohoo"))); + } else { // non-Windows assertThat(bean.getStringProperty(), is(equalTo("haha"))); } @@ -116,9 +115,7 @@ public void testPropertyFromEnvironmentVariables() { assertThat(bean.getIntProperty(), is(equalTo(45))); } - - private T getBeanOfType(Class beanClass) { return CDI.current().select(beanClass).get(); } - } +} diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/CdiOptionalInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/CdiOptionalInjectionTest.java index 67b6fcd5..12553417 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/CdiOptionalInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/CdiOptionalInjectionTest.java @@ -46,11 +46,11 @@ public static WebArchive deploy() { .create(JavaArchive.class, "cdiOptionalInjectionTest.jar") .addClasses(CdiOptionalInjectionTest.class, OptionalValuesBean.class) .addAsManifestResource( - new StringAsset( - "my.optional.int.property=1234\n" + - "my.optional.long.property=1234\n" + - "my.optional.double.property=1234.5\n" + - "my.optional.string.property=hello"), + new StringAsset( + "my.optional.int.property=1234\n" + + "my.optional.long.property=1234\n" + + "my.optional.double.property=1234.5\n" + + "my.optional.string.property=hello"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -61,7 +61,6 @@ public static WebArchive deploy() { return war; } - @Test public void testOptionalInjection() { Assert.assertTrue(optionalValuesBean.getIntProperty().isPresent()); diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterBean.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterBean.java index 29e8fdc6..adeeedd8 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterBean.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterBean.java @@ -44,20 +44,20 @@ public class ClassConverterBean { @Inject @ConfigProperty(name = "tck.config.test.javaconfig.converter.class.array") private List testClassList; - - public Class getTestClass(){ + + public Class getTestClass() { return testClass; } - public Class[] getTestClasses(){ + public Class[] getTestClasses() { return testClasses; } - public Set getTestClassSet(){ + public Set getTestClassSet() { return testClassSet; } - public List getTestClassList(){ + public List getTestClassList() { return testClassList; } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterTest.java index 233504c7..d84efe61 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ClassConverterTest.java @@ -47,17 +47,17 @@ public class ClassConverterTest extends Arquillian { public static WebArchive deploy() { String archiveName = ClassConverterTest.class.getSimpleName(); JavaArchive testJar = ShrinkWrap - .create(JavaArchive.class, archiveName+".jar") + .create(JavaArchive.class, archiveName + ".jar") .addClasses(ClassConverterBean.class, ClassConverterTest.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); - addFile(testJar, "META-INF/microprofile-config.properties"); + addFile(testJar, "META-INF/microprofile-config.properties"); - WebArchive war = ShrinkWrap - .create(WebArchive.class, archiveName+".war") + WebArchive war = ShrinkWrap + .create(WebArchive.class, archiveName + ".war") .addAsLibrary(testJar); - return war; + return war; } @Inject @@ -78,10 +78,10 @@ public void testClassConverterWithLookup() { @Test public void testGetClassConverter() { Class testClass = config.getConverter(Class.class).get() - .convert("org.eclipse.microprofile.config.tck.ClassConverterTest"); + .convert("org.eclipse.microprofile.config.tck.ClassConverterTest"); assertEquals(testClass, ClassConverterTest.class); Class[] testClasses = config.getConverter(Class[].class).get() - .convert("org.eclipse.microprofile.config.tck.ClassConverterTest,java.lang.String"); + .convert("org.eclipse.microprofile.config.tck.ClassConverterTest,java.lang.String"); assertEquals(testClasses.length, 2); assertEquals(testClasses, new Class[]{ClassConverterTest.class, String.class}); } @@ -92,7 +92,8 @@ public void testConverterForClassLoadedInBean() { assertEquals(classConverterBean.getTestClasses().length, 2); assertEquals(classConverterBean.getTestClasses(), new Class[]{ClassConverterTest.class, String.class}); assertEquals(classConverterBean.getTestClassSet().size(), 2); - assertEquals(classConverterBean.getTestClassSet(), new LinkedHashSet<>(Arrays.asList(ClassConverterTest.class, String.class))); + assertEquals(classConverterBean.getTestClassSet(), + new LinkedHashSet<>(Arrays.asList(ClassConverterTest.class, String.class))); assertEquals(classConverterBean.getTestClassList().size(), 2); assertEquals(classConverterBean.getTestClassList(), Arrays.asList(ClassConverterTest.class, String.class)); } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigPropertiesTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigPropertiesTest.java index 250e5fac..424b96c6 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigPropertiesTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigPropertiesTest.java @@ -46,11 +46,11 @@ public class ConfigPropertiesTest extends Arquillian { private @Inject BeanOne customerBeanOne; - private @Inject @ConfigProperties(prefix="client") BeanOne clientBeanOne; + private @Inject @ConfigProperties(prefix = "client") BeanOne clientBeanOne; private @Inject @ConfigProperties BeanOne beanOne; private @Inject BeanTwo beanTwo; - private @Inject @ConfigProperties(prefix="my") BeanTwo myBeanTwo; + private @Inject @ConfigProperties(prefix = "my") BeanTwo myBeanTwo; private @Inject BeanFour myBeanFour; private @Inject BeanThree beanThree; @@ -58,35 +58,35 @@ public class ConfigPropertiesTest extends Arquillian { public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "ConfigPropertiesTest.jar") - .addClasses(ConfigPropertiesTest.class, BeanOne.class, BeanTwo.class, BeanThree.class, BeanFour.class, Location.class) + .addClasses(ConfigPropertiesTest.class, BeanOne.class, BeanTwo.class, BeanThree.class, BeanFour.class, + Location.class) .addAsManifestResource( - new StringAsset( - "customer.name=Bob\n" + - "customer.age=24\n" + - "customer.location=2 Hook Road, Winchester, Hampshire, SO21 2JN, UK\n" + - "customer.job=Developer\n" + - "customer.new.hobbies=Badminton,Tennis\n" + - "client.name=Rob\n" + - "client.age=25\n" + - "client.location=22 Hook Road, Winchester, Hampshire, SO21 2JN, UK\n" + - "client.job=Engineer\n" + - "client.new.hobbies=Football,Tennis\n" + - "name=Harry\n" + - "age=21\n" + - "nationality=UK\n" + - "location=222 Hook Road, Winchester, Hampshire, SO21 2JN, UK\n" + - "job=Plumber\n" + - "new.hobbies=Volleyball\n" + - "host=localhost\n" + - "port=9080\n"+ - "endpoint=woof\n" + - "my.host=myhost\n" + - "my.port=9081\n"+ - "my.endpoint=poof\n" + - "other.name=Holly\n" + - "other.age=20\n" + - "other.nationality=USA\n" - ), + new StringAsset( + "customer.name=Bob\n" + + "customer.age=24\n" + + "customer.location=2 Hook Road, Winchester, Hampshire, SO21 2JN, UK\n" + + "customer.job=Developer\n" + + "customer.new.hobbies=Badminton,Tennis\n" + + "client.name=Rob\n" + + "client.age=25\n" + + "client.location=22 Hook Road, Winchester, Hampshire, SO21 2JN, UK\n" + + "client.job=Engineer\n" + + "client.new.hobbies=Football,Tennis\n" + + "name=Harry\n" + + "age=21\n" + + "nationality=UK\n" + + "location=222 Hook Road, Winchester, Hampshire, SO21 2JN, UK\n" + + "job=Plumber\n" + + "new.hobbies=Volleyball\n" + + "host=localhost\n" + + "port=9080\n" + + "endpoint=woof\n" + + "my.host=myhost\n" + + "my.port=9081\n" + + "my.endpoint=poof\n" + + "other.name=Holly\n" + + "other.age=20\n" + + "other.nationality=USA\n"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -100,7 +100,7 @@ public void testConfigPropertiesPlainInjection() { Assert.assertEquals("Bob", customerBeanOne.getName()); Assert.assertEquals(24, customerBeanOne.age); Assert.assertEquals("Developer", customerBeanOne.job); - Assert.assertEquals(new String[] {"Badminton", "Tennis"}, customerBeanOne.hobbies); + Assert.assertEquals(new String[]{"Badminton", "Tennis"}, customerBeanOne.hobbies); Assert.assertEquals(new Location("2 Hook Road, Winchester, Hampshire, SO21 2JN, UK"), customerBeanOne.location); } @Test @@ -108,15 +108,15 @@ public void testConfigPropertiesWithPrefix() { Assert.assertEquals("Rob", clientBeanOne.getName()); Assert.assertEquals(25, clientBeanOne.age); Assert.assertEquals("Engineer", clientBeanOne.job); - Assert.assertEquals(new String[] {"Football", "Tennis"}, clientBeanOne.hobbies); + Assert.assertEquals(new String[]{"Football", "Tennis"}, clientBeanOne.hobbies); Assert.assertEquals(new Location("22 Hook Road, Winchester, Hampshire, SO21 2JN, UK"), clientBeanOne.location); - //programmatic lookup of the beans - BeanOne bo= CDI.current().select(BeanOne.class, ConfigProperties.Literal.of("client")).get(); + // programmatic lookup of the beans + BeanOne bo = CDI.current().select(BeanOne.class, ConfigProperties.Literal.of("client")).get(); Assert.assertEquals("Rob", bo.getName()); Assert.assertEquals(25, bo.age); Assert.assertEquals("Engineer", bo.job); - Assert.assertEquals(new String[] {"Football", "Tennis"}, bo.hobbies); + Assert.assertEquals(new String[]{"Football", "Tennis"}, bo.hobbies); Assert.assertEquals(new Location("22 Hook Road, Winchester, Hampshire, SO21 2JN, UK"), bo.location); } @Test @@ -124,15 +124,15 @@ public void testConfigPropertiesWithoutPrefix() { Assert.assertEquals("Harry", beanOne.getName()); Assert.assertEquals(21, beanOne.age); Assert.assertEquals("Plumber", beanOne.job); - Assert.assertEquals(new String[] {"Volleyball"}, beanOne.hobbies); + Assert.assertEquals(new String[]{"Volleyball"}, beanOne.hobbies); Assert.assertEquals(new Location("222 Hook Road, Winchester, Hampshire, SO21 2JN, UK"), beanOne.location); - //programmatic lookup of the beans - BeanOne bo= CDI.current().select(BeanOne.class, ConfigProperties.Literal.NO_PREFIX).get(); + // programmatic lookup of the beans + BeanOne bo = CDI.current().select(BeanOne.class, ConfigProperties.Literal.NO_PREFIX).get(); Assert.assertEquals("Harry", bo.getName()); Assert.assertEquals(21, bo.age); Assert.assertEquals("Plumber", bo.job); - Assert.assertEquals(new String[] {"Volleyball"}, bo.hobbies); + Assert.assertEquals(new String[]{"Volleyball"}, bo.hobbies); Assert.assertEquals(new Location("222 Hook Road, Winchester, Hampshire, SO21 2JN, UK"), bo.location); } @@ -152,9 +152,9 @@ public void testConfigPropertiesNoPrefixOnBeanThenSupplyPrefix() { @Test public void testNoConfigPropertiesAnnotationInjection() { - //The fields on beanThree are not resolved to config properties, + // The fields on beanThree are not resolved to config properties, // as the bean class has no ConfigProperties annotation. - Assert.assertNull( beanThree.name); + Assert.assertNull(beanThree.name); Assert.assertEquals(0, beanThree.age); Assert.assertNull(beanThree.getNationality()); } @@ -166,13 +166,13 @@ public void testConfigPropertiesDefaultOnBean() { Assert.assertFalse(myBeanFour.location.isPresent()); } - @ConfigProperties(prefix="customer") + @ConfigProperties(prefix = "customer") public static class BeanOne { private String name; int age; public Location location; protected String job; - @ConfigProperty(name="new.hobbies") + @ConfigProperty(name = "new.hobbies") public String[] hobbies; /** @@ -190,8 +190,8 @@ public static class BeanTwo { int port; String endpoint; /** - * @return String return the host - */ + * @return String return the host + */ public String getHost() { return host; } @@ -202,16 +202,16 @@ public static class BeanThree { public int age; private String nationality; /** - * @return String return the host - */ + * @return String return the host + */ public String getNationality() { return nationality; } } - @ConfigProperties(prefix="cloud") + @ConfigProperties(prefix = "cloud") public static class BeanFour { - @ConfigProperty(name="a.host", defaultValue="mycloud.org") + @ConfigProperty(name = "a.host", defaultValue = "mycloud.org") private String host; public int port = 9080; public String getHost() { diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigProviderTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigProviderTest.java index eacc5496..d18e3909 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigProviderTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigProviderTest.java @@ -70,20 +70,20 @@ public static WebArchive deploy() { } @BeforeClass - public static void setupCheck(){ - //check that there is at least one property which is unique to the environment and not also a system property + public static void setupCheck() { + // check that there is at least one property which is unique to the environment and not also a system property boolean checkOK = false; Map env = System.getenv(); Properties properties = System.getProperties(); for (Map.Entry envEntry : env.entrySet()) { String key = envEntry.getKey(); - if(!properties.containsKey(key)) { + if (!properties.containsKey(key)) { checkOK = true; break; } } - Assert.assertTrue(checkOK, "Ensure that there is at least one property which is unique to "+ - "the environment variables and not also a system property."); + Assert.assertTrue(checkOK, "Ensure that there is at least one property which is unique to " + + "the environment variables and not also a system property."); } @Test @@ -151,10 +151,13 @@ public void testInjectedConfigSerializable() { Assert.fail("Injected config should be serializable, but could not serialize it", ex); } Object readObject = null; - try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))) { + try (ObjectInputStream in = + new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))) { readObject = in.readObject(); } catch (IOException | ClassNotFoundException ex) { - Assert.fail("Injected config should be serializable, but could not deserialize a previously serialized instance", ex); + Assert.fail( + "Injected config should be serializable, but could not deserialize a previously serialized instance", + ex); } MatcherAssert.assertThat("Deserialized object", readObject, CoreMatchers.instanceOf(Config.class)); } @@ -166,11 +169,11 @@ public void testGetPropertyNames() { System.setProperty(configKey, configValue); AtomicBoolean foundKey = new AtomicBoolean(false); config.getConfigSources().forEach(c -> { - if(c.getPropertyNames().contains(configKey)) { + if (c.getPropertyNames().contains(configKey)) { foundKey.set(true); } }); - Assert.assertTrue(foundKey.get(), "Unable to find property "+configKey); + Assert.assertTrue(foundKey.get(), "Unable to find property " + configKey); } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigValueTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigValueTest.java index ed128e3e..7c401ba4 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigValueTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigValueTest.java @@ -18,6 +18,17 @@ */ package org.eclipse.microprofile.config.tck; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.enterprise.context.Dependent; +import javax.inject.Inject; + import org.eclipse.microprofile.config.ConfigProvider; import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -31,29 +42,20 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; -import javax.enterprise.context.Dependent; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - public class ConfigValueTest extends Arquillian { @Deployment public static Archive deployment() { JavaArchive testJar = ShrinkWrap - .create(JavaArchive.class, "ConfigValueTest.jar") - .addClasses(ConfigValueBean.class) - .addAsServiceProvider(ConfigSource.class, ConfigValueConfigSource.class, ConfigValueLowerConfigSource.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .as(JavaArchive.class); + .create(JavaArchive.class, "ConfigValueTest.jar") + .addClasses(ConfigValueBean.class) + .addAsServiceProvider(ConfigSource.class, ConfigValueConfigSource.class, + ConfigValueLowerConfigSource.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .as(JavaArchive.class); return ShrinkWrap - .create(WebArchive.class, "ConfigValueTest.war") - .addAsLibrary(testJar); + .create(WebArchive.class, "ConfigValueTest.war") + .addAsLibrary(testJar); } @Test diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConverterTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConverterTest.java index 1847866d..a2f9ec33 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ConverterTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ConverterTest.java @@ -109,8 +109,8 @@ public void testNoDonaldConverterByDefault() { @Test public void testDonaldConversionWithLambdaConverter() { Config newConfig = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) - .build(); + .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) + .build(); Donald donald = newConfig.getValue("tck.config.test.javaconfig.converter.donaldname", Donald.class); Assert.assertNotNull(donald); Assert.assertEquals(donald.getName(), "Duck"); @@ -119,8 +119,8 @@ public void testDonaldConversionWithLambdaConverter() { @Test public void testGetDonaldConverterWithLambdaConverter() { Config newConfig = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) - .build(); + .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) + .build(); Donald donald = newConfig.getConverter(Donald.class).get().convert("Duck"); Assert.assertNotNull(donald); Assert.assertEquals(donald.getName(), "Duck"); @@ -131,22 +131,22 @@ public void testDonaldConversionWithMultipleLambdaConverters() { // defines 2 config with the lambda converters defined in different orders. // Order must not matter, the lambda with the upper case must always be used as it has the highest priority Config config1 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) - .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) - .build(); + .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) + .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) + .build(); Config config2 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) - .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) - .build(); + .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) + .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) + .build(); Donald donald = config1.getConverter(Donald.class).get().convert("Duck"); Assert.assertNotNull(donald); Assert.assertEquals(donald.getName(), "DUCK", - "The converter with the highest priority (using upper case) must be used."); + "The converter with the highest priority (using upper case) must be used."); donald = config2.getConverter(Donald.class).get().convert("Duck"); Assert.assertNotNull(donald); Assert.assertEquals(donald.getName(), "DUCK", - "The converter with the highest priority (using upper case) must be used."); + "The converter with the highest priority (using upper case) must be used."); } @Test @@ -154,34 +154,34 @@ public void testGetDonaldConverterWithMultipleLambdaConverters() { // defines 2 config with the lambda converters defined in different orders. // Order must not matter, the lambda with the upper case must always be used as it has the highest priority Config config1 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) - .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) - .build(); + .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) + .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) + .build(); Config config2 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) - .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) - .build(); + .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s)) + .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase())) + .build(); Donald donald = config1.getValue("tck.config.test.javaconfig.converter.donaldname", Donald.class); Assert.assertNotNull(donald); Assert.assertEquals(donald.getName(), "DUCK", - "The converter with the highest priority (using upper case) must be used."); + "The converter with the highest priority (using upper case) must be used."); donald = config2.getValue("tck.config.test.javaconfig.converter.donaldname", Donald.class); Assert.assertNotNull(donald); Assert.assertEquals(donald.getName(), "DUCK", - "The converter with the highest priority (using upper case) must be used."); + "The converter with the highest priority (using upper case) must be used."); } @Test public void testByte() { Byte value = config.getValue("tck.config.test.javaconfig.converter.bytevalue", Byte.class); - Assert.assertEquals(value, Byte.valueOf((byte)123)); + Assert.assertEquals(value, Byte.valueOf((byte) 123)); } @Test public void testbyte() { byte value = config.getValue("tck.config.test.javaconfig.converter.bytevalue", byte.class); - Assert.assertEquals(value, (byte)123); + Assert.assertEquals(value, (byte) 123); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -192,13 +192,13 @@ public void testByte_Broken() { @Test public void testGetByteConverter() { Byte value = config.getConverter(Byte.class).get().convert("123"); - Assert.assertEquals(value, Byte.valueOf((byte)123)); + Assert.assertEquals(value, Byte.valueOf((byte) 123)); } @Test public void testGetbyteConverter() { byte value = config.getConverter(byte.class).get().convert("123"); - Assert.assertEquals(value, (byte)123); + Assert.assertEquals(value, (byte) 123); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -209,13 +209,13 @@ public void testGetByteConverter_Broken() { @Test public void testShort() { Short value = config.getValue("tck.config.test.javaconfig.converter.shortvalue", Short.class); - Assert.assertEquals(value, Short.valueOf((short)1234)); + Assert.assertEquals(value, Short.valueOf((short) 1234)); } @Test public void testshort() { short value = config.getValue("tck.config.test.javaconfig.converter.shortvalue", short.class); - Assert.assertEquals(value, (short)1234); + Assert.assertEquals(value, (short) 1234); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -226,13 +226,13 @@ public void testShort_Broken() { @Test public void testGetShortConverter() { Short value = config.getConverter(Short.class).get().convert("1234"); - Assert.assertEquals(value, Short.valueOf((short)1234)); + Assert.assertEquals(value, Short.valueOf((short) 1234)); } @Test public void testGetshortConverter() { short value = config.getConverter(short.class).get().convert("1234"); - Assert.assertEquals(value, (short)1234); + Assert.assertEquals(value, (short) 1234); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -351,7 +351,7 @@ public void testDouble() { @Test public void testdouble() { double value = config.getValue("tck.config.test.javaconfig.converter.doublevalue", double.class); - Assert.assertEquals(value,12.34d); + Assert.assertEquals(value, 12.34d); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -368,7 +368,7 @@ public void testGetDoubleConverter() { @Test public void testGetdoubleConverter() { double value = config.getConverter(double.class).get().convert("12.34"); - Assert.assertEquals(value,12.34d); + Assert.assertEquals(value, 12.34d); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -478,7 +478,8 @@ public void testGetLocalDateConverter_Broken() { @Test public void testLocalDateTime() { - LocalDateTime value = config.getValue("tck.config.test.javaconfig.converter.localdatetimevalue", LocalDateTime.class); + LocalDateTime value = + config.getValue("tck.config.test.javaconfig.converter.localdatetimevalue", LocalDateTime.class); Assert.assertEquals(value, LocalDateTime.parse("2017-12-24T10:25:30")); } @@ -500,7 +501,8 @@ public void testGetLocalDateTimeConverter_Broken() { @Test public void testOffsetDateTime() { - OffsetDateTime value = config.getValue("tck.config.test.javaconfig.converter.offsetdatetimevalue", OffsetDateTime.class); + OffsetDateTime value = + config.getValue("tck.config.test.javaconfig.converter.offsetdatetimevalue", OffsetDateTime.class); Assert.assertEquals(value, OffsetDateTime.parse("2007-12-03T10:15:30+01:00")); } @@ -594,8 +596,10 @@ public void testGetInstantConverter_Broken() { public void testBoolean() { Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.true", Boolean.class)); Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.true", boolean.class)); - Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.true_uppercase", Boolean.class)); - Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.true_mixedcase", Boolean.class)); + Assert.assertTrue( + config.getValue("tck.config.test.javaconfig.configvalue.boolean.true_uppercase", Boolean.class)); + Assert.assertTrue( + config.getValue("tck.config.test.javaconfig.configvalue.boolean.true_mixedcase", Boolean.class)); Assert.assertFalse(config.getValue("tck.config.test.javaconfig.configvalue.boolean.false", Boolean.class)); Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.one", Boolean.class)); @@ -603,8 +607,10 @@ public void testBoolean() { Assert.assertFalse(config.getValue("tck.config.test.javaconfig.configvalue.boolean.seventeen", Boolean.class)); Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.yes", Boolean.class)); - Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.yes_uppercase", Boolean.class)); - Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.yes_mixedcase", Boolean.class)); + Assert.assertTrue( + config.getValue("tck.config.test.javaconfig.configvalue.boolean.yes_uppercase", Boolean.class)); + Assert.assertTrue( + config.getValue("tck.config.test.javaconfig.configvalue.boolean.yes_mixedcase", Boolean.class)); Assert.assertFalse(config.getValue("tck.config.test.javaconfig.configvalue.boolean.no", Boolean.class)); Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.y", Boolean.class)); @@ -612,8 +618,10 @@ public void testBoolean() { Assert.assertFalse(config.getValue("tck.config.test.javaconfig.configvalue.boolean.n", Boolean.class)); Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.on", Boolean.class)); - Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.on_uppercase", Boolean.class)); - Assert.assertTrue(config.getValue("tck.config.test.javaconfig.configvalue.boolean.on_mixedcase", Boolean.class)); + Assert.assertTrue( + config.getValue("tck.config.test.javaconfig.configvalue.boolean.on_uppercase", Boolean.class)); + Assert.assertTrue( + config.getValue("tck.config.test.javaconfig.configvalue.boolean.on_mixedcase", Boolean.class)); Assert.assertFalse(config.getValue("tck.config.test.javaconfig.configvalue.boolean.off", Boolean.class)); Assert.assertFalse(config.getValue("tck.config.test.javaconfig.configvalue.boolean.off", boolean.class)); } @@ -622,7 +630,7 @@ public void testBoolean() { public void testGetBooleanConverter() { Converter converter = config.getConverter(Boolean.class).get(); Converter primitiveConverter = config.getConverter(boolean.class).get(); - + Assert.assertTrue(converter.convert("true")); Assert.assertTrue(primitiveConverter.convert("true")); Assert.assertTrue(converter.convert("TRUE")); @@ -664,22 +672,22 @@ public void testDuckConversionWithMultipleConverters() { // defines 2 config with the converters defined in different orders. // Order must not matter, the UpperCaseDuckConverter must always be used as it has the highest priority Config config1 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverters(new UpperCaseDuckConverter(), new DuckConverter()) - .build(); + .withConverters(new UpperCaseDuckConverter(), new DuckConverter()) + .build(); Config config2 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverters(new DuckConverter(), new UpperCaseDuckConverter()) - .build(); + .withConverters(new DuckConverter(), new UpperCaseDuckConverter()) + .build(); Duck duck = config1.getValue("tck.config.test.javaconfig.converter.duckname", Duck.class); Assert.assertNotNull(duck); Assert.assertEquals(duck.getName(), "HANNELORE", - "The converter with the highest priority (UpperCaseDuckConverter) must be used."); + "The converter with the highest priority (UpperCaseDuckConverter) must be used."); duck = config2.getValue("tck.config.test.javaconfig.converter.duckname", Duck.class); Assert.assertNotNull(duck); // the UpperCaseDuckConverter has highest priority Assert.assertEquals(duck.getName(), "HANNELORE", - "The converter with the highest priority (UpperCaseDuckConverter) must be used."); + "The converter with the highest priority (UpperCaseDuckConverter) must be used."); } @Test @@ -687,22 +695,22 @@ public void testGetDuckConverterWithMultipleConverters() { // defines 2 config with the converters defined in different orders. // Order must not matter, the UpperCaseDuckConverter must always be used as it has the highest priority Config config1 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverters(new UpperCaseDuckConverter(), new DuckConverter()) - .build(); + .withConverters(new UpperCaseDuckConverter(), new DuckConverter()) + .build(); Config config2 = ConfigProviderResolver.instance().getBuilder().addDefaultSources() - .withConverters(new DuckConverter(), new UpperCaseDuckConverter()) - .build(); + .withConverters(new DuckConverter(), new UpperCaseDuckConverter()) + .build(); Duck duck = config1.getConverter(Duck.class).get().convert("Hannelore"); Assert.assertNotNull(duck); Assert.assertEquals(duck.getName(), "HANNELORE", - "The converter with the highest priority (UpperCaseDuckConverter) must be used."); + "The converter with the highest priority (UpperCaseDuckConverter) must be used."); duck = config2.getConverter(Duck.class).get().convert("Hannelore"); Assert.assertNotNull(duck); // the UpperCaseDuckConverter has highest priority Assert.assertEquals(duck.getName(), "HANNELORE", - "The converter with the highest priority (UpperCaseDuckConverter) must be used."); + "The converter with the highest priority (UpperCaseDuckConverter) must be used."); } @Test @@ -759,13 +767,16 @@ public void testConverterSerialization() { Assert.fail("Converter instance should be serializable, but could not serialize it", ex); } Object readObject = null; - try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))) { + try (ObjectInputStream in = + new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))) { readObject = in.readObject(); } catch (IOException | ClassNotFoundException ex) { - Assert.fail("Converter instance should be serializable, but could not deserialize a previously serialized instance", ex); + Assert.fail( + "Converter instance should be serializable, but could not deserialize a previously serialized instance", + ex); } Assert.assertEquals(((DuckConverter) ((Converter) readObject)).convert("Donald").getName(), - original.convert("Donald").getName(),"Converted values to be equal"); + original.convert("Donald").getName(), "Converted values to be equal"); } @Test @@ -779,12 +790,15 @@ public void testGetConverterSerialization() { Assert.fail("Converter instance should be serializable, but could not serialize it", ex); } Object readObject = null; - try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))) { + try (ObjectInputStream in = + new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()))) { readObject = in.readObject(); } catch (IOException | ClassNotFoundException ex) { - Assert.fail("Converter instance should be serializable, but could not deserialize a previously serialized instance", ex); + Assert.fail( + "Converter instance should be serializable, but could not deserialize a previously serialized instance", + ex); } Assert.assertEquals(((Converter) readObject).convert("Donald").getName(), - original.convert("Donald").getName(),"Converted values to be equal"); + original.convert("Donald").getName(), "Converted values to be equal"); } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConfigSourceTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConfigSourceTest.java index a90c64e6..af748447 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConfigSourceTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConfigSourceTest.java @@ -19,6 +19,8 @@ */ package org.eclipse.microprofile.config.tck; +import static org.eclipse.microprofile.config.tck.base.AbstractTest.addFile; + import javax.inject.Inject; import org.eclipse.microprofile.config.Config; @@ -35,8 +37,6 @@ import org.testng.Assert; import org.testng.annotations.Test; -import static org.eclipse.microprofile.config.tck.base.AbstractTest.addFile; - /** * @author Mark Struberg */ @@ -62,7 +62,6 @@ public static WebArchive deploy() { return war; } - @Test public void testConfigSourceProvider() { Assert.assertEquals(config.getValue("tck.config.test.customDbConfig.key1", String.class), "valueFromDb1"); diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConverterTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConverterTest.java index 9f2e34e0..9132a23d 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConverterTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/CustomConverterTest.java @@ -19,6 +19,8 @@ */ package org.eclipse.microprofile.config.tck; +import javax.inject.Inject; + import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.spi.Converter; import org.eclipse.microprofile.config.tck.base.AbstractTest; @@ -36,31 +38,30 @@ import org.testng.Assert; import org.testng.annotations.Test; -import javax.inject.Inject; - public class CustomConverterTest extends Arquillian { private @Inject Config config; @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap - .create(JavaArchive.class, "customConverterTest.jar") - .addClass(CustomConverterTest.class) - .addClass(IntegerConverter.class) - .addClass(LongConverter.class) - .addClass(DoubleConverter.class) - .addClass(BooleanConverter.class) - .addClass(CharacterConverter.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .addAsServiceProvider(Converter.class, IntegerConverter.class, LongConverter.class, DoubleConverter.class, - BooleanConverter.class, CharacterConverter.class) - .as(JavaArchive.class); + .create(JavaArchive.class, "customConverterTest.jar") + .addClass(CustomConverterTest.class) + .addClass(IntegerConverter.class) + .addClass(LongConverter.class) + .addClass(DoubleConverter.class) + .addClass(BooleanConverter.class) + .addClass(CharacterConverter.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .addAsServiceProvider(Converter.class, IntegerConverter.class, LongConverter.class, + DoubleConverter.class, + BooleanConverter.class, CharacterConverter.class) + .as(JavaArchive.class); AbstractTest.addFile(testJar, "META-INF/microprofile-config.properties"); return ShrinkWrap - .create(WebArchive.class, "customConverterTest.war") - .addAsLibrary(testJar); + .create(WebArchive.class, "customConverterTest.war") + .addAsLibrary(testJar); } @Test diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ImplicitConverterTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ImplicitConverterTest.java index bb3e7740..28fef2a7 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ImplicitConverterTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ImplicitConverterTest.java @@ -56,63 +56,63 @@ public class ImplicitConverterTest extends Arquillian { @Deployment public static WebArchive deploy() { JavaArchive testJar = ShrinkWrap - .create(JavaArchive.class, "implicitConverterTest.jar") - .addPackage(ConvTestTypeWStringCt.class.getPackage()) - .addClasses(ParseConverterInjection.class, ImplicitConverterTest.class) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .as(JavaArchive.class); + .create(JavaArchive.class, "implicitConverterTest.jar") + .addPackage(ConvTestTypeWStringCt.class.getPackage()) + .addClasses(ParseConverterInjection.class, ImplicitConverterTest.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .as(JavaArchive.class); addFile(testJar, "META-INF/microprofile-config.properties"); WebArchive war = ShrinkWrap - .create(WebArchive.class, "implicitConverterTest.war") - .addAsLibrary(testJar); + .create(WebArchive.class, "implicitConverterTest.war") + .addAsLibrary(testJar); return war; } - private @Inject Config config; private @Inject ParseConverterInjection parserConverterInjection; - @Test public void testImplicitConverterStringCt() { ConvTestTypeWStringCt value = config.getValue("tck.config.test.javaconfig.converter.implicit.stringCt", - ConvTestTypeWStringCt.class); + ConvTestTypeWStringCt.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "stringCt"); } @Test public void testImplicitConverterStringValueOf() { - ConvTestTypeWStringValueOf value = config.getValue("tck.config.test.javaconfig.converter.implicit.stringValueOf", - ConvTestTypeWStringValueOf.class); + ConvTestTypeWStringValueOf value = + config.getValue("tck.config.test.javaconfig.converter.implicit.stringValueOf", + ConvTestTypeWStringValueOf.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "stringValueOf"); } @Test public void testImplicitConverterStringOf() { ConvTestTypeWStringOf value = config.getValue("tck.config.test.javaconfig.converter.implicit.stringOf", - ConvTestTypeWStringOf.class); + ConvTestTypeWStringOf.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "stringOf"); } - + @Test public void testImplicitConverterCharSequenceParse() { - ConvTestTypeWCharSequenceParse value = config.getValue("tck.config.test.javaconfig.converter.implicit.charSequenceParse", - ConvTestTypeWCharSequenceParse.class); + ConvTestTypeWCharSequenceParse value = + config.getValue("tck.config.test.javaconfig.converter.implicit.charSequenceParse", + ConvTestTypeWCharSequenceParse.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "charSequenceParse"); } @Test public void testImplicitConverterCharSequenceParseJavaTime() { - YearMonth value = config.getValue("tck.config.test.javaconfig.converter.implicit.charSequenceParse.yearmonth", - YearMonth.class); + YearMonth value = config.getValue("tck.config.test.javaconfig.converter.implicit.charSequenceParse.yearmonth", + YearMonth.class); Assert.assertNotNull(value); Assert.assertEquals(value, YearMonth.parse("2017-12")); } - + @Test public void testImplicitConverterCharSequenceParseJavaTimeInjection() { Assert.assertNotNull(parserConverterInjection.getYearMonth()); @@ -122,7 +122,7 @@ public void testImplicitConverterCharSequenceParseJavaTimeInjection() { @Test public void testImplicitConverterEnumValueOf() { SomeEnumToConvert value = config.getValue("tck.config.test.javaconfig.converter.implicit.enumValueOf", - SomeEnumToConvert.class); + SomeEnumToConvert.class); Assert.assertNotNull(value); Assert.assertEquals(value, SomeEnumToConvert.BAZ); Assert.assertEquals(value.name(), "BAZ"); @@ -130,26 +130,26 @@ public void testImplicitConverterEnumValueOf() { @Test public void testImplicitConverterSquenceOfBeforeValueOf() { - ConvTestSequenceOfBeforeValueOf value = config.getValue - ("tck.config.test.javaconfig.converter.implicit.sequence.ofBeforeValueOf", - ConvTestSequenceOfBeforeValueOf.class); + ConvTestSequenceOfBeforeValueOf value = + config.getValue("tck.config.test.javaconfig.converter.implicit.sequence.ofBeforeValueOf", + ConvTestSequenceOfBeforeValueOf.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "ofBeforeValueOf"); } @Test public void testImplicitConverterSquenceValueOfBeforeParse() { - ConvTestSequenceValueOfBeforeParse value = config.getValue - ("tck.config.test.javaconfig.converter.implicit.sequence.valueOfBeforeParse", - ConvTestSequenceValueOfBeforeParse.class); + ConvTestSequenceValueOfBeforeParse value = + config.getValue("tck.config.test.javaconfig.converter.implicit.sequence.valueOfBeforeParse", + ConvTestSequenceValueOfBeforeParse.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "valueOfBeforeParse"); } @Test public void testImplicitConverterSquenceParseBeforeConstructor() { - ConvTestSequenceParseBeforeConstructor value = config.getValue - ("tck.config.test.javaconfig.converter.implicit.sequence.parseBeforeConstructor", - ConvTestSequenceParseBeforeConstructor.class); + ConvTestSequenceParseBeforeConstructor value = + config.getValue("tck.config.test.javaconfig.converter.implicit.sequence.parseBeforeConstructor", + ConvTestSequenceParseBeforeConstructor.class); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "parseBeforeConstructor"); } @@ -164,7 +164,7 @@ public void testGetImplicitConverterStringCtConverter() { @Test public void testGetImplicitConverterStringValueOfConverter() { ConvTestTypeWStringValueOf value = config.getConverter(ConvTestTypeWStringValueOf.class).get() - .convert("stringValueOf"); + .convert("stringValueOf"); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "stringValueOf"); } @@ -174,11 +174,11 @@ public void testGetImplicitConverterStringOfConverter() { Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "stringOf"); } - + @Test public void testGetImplicitConverterCharSequenceParseConverter() { ConvTestTypeWCharSequenceParse value = config.getConverter(ConvTestTypeWCharSequenceParse.class).get() - .convert("charSequenceParse"); + .convert("charSequenceParse"); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "charSequenceParse"); } @@ -188,7 +188,7 @@ public void testGetImplicitConverterCharSequenceParseJavaTimeConverter() { Assert.assertNotNull(value); Assert.assertEquals(value, YearMonth.parse("2017-12")); } - + @Test public void testGetImplicitConverterEnumValueOfConverter() { SomeEnumToConvert value = config.getConverter(SomeEnumToConvert.class).get().convert("BAZ"); @@ -200,7 +200,7 @@ public void testGetImplicitConverterEnumValueOfConverter() { @Test public void testGetImplicitConverterSquenceOfBeforeValueOfConverter() { ConvTestSequenceOfBeforeValueOf value = config.getConverter(ConvTestSequenceOfBeforeValueOf.class).get() - .convert("ofBeforeValueOf"); + .convert("ofBeforeValueOf"); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "ofBeforeValueOf"); } @@ -208,14 +208,15 @@ public void testGetImplicitConverterSquenceOfBeforeValueOfConverter() { @Test public void testGetImplicitConverterSquenceValueOfBeforeParseConverter() { ConvTestSequenceValueOfBeforeParse value = config.getConverter(ConvTestSequenceValueOfBeforeParse.class).get() - .convert("valueOfBeforeParse"); + .convert("valueOfBeforeParse"); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "valueOfBeforeParse"); } @Test public void testGetImplicitConverterSquenceParseBeforeConstructorConverter() { - ConvTestSequenceParseBeforeConstructor value = config.getConverter(ConvTestSequenceParseBeforeConstructor.class).get() - .convert("parseBeforeConstructor"); + ConvTestSequenceParseBeforeConstructor value = + config.getConverter(ConvTestSequenceParseBeforeConstructor.class).get() + .convert("parseBeforeConstructor"); Assert.assertNotNull(value); Assert.assertEquals(value.getVal(), "parseBeforeConstructor"); } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/Location.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/Location.java index 2e12e227..5ed848ec 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/Location.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/Location.java @@ -33,11 +33,10 @@ public Location(String loc) { this.road = parts[0]; this.city = parts[1]; this.county = parts[2]; - this.postcode=parts[3]; - this.country=parts[4]; + this.postcode = parts[3]; + this.country = parts[4]; } - /** * @return String return the road */ @@ -82,8 +81,9 @@ public boolean equals(Object o) { return false; } Location location = (Location) o; - return Objects.equals(road, location.road) && Objects.equals(city, location.city) - && Objects.equals(county, location.county) && Objects.equals(postcode, location.postcode) && Objects.equals(country, location.country); + return Objects.equals(road, location.road) && Objects.equals(city, location.city) + && Objects.equals(county, location.county) && Objects.equals(postcode, location.postcode) + && Objects.equals(country, location.country); } @Override @@ -91,5 +91,4 @@ public int hashCode() { return Objects.hash(road, city, county, postcode, country); } - } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/OptionalValuesBean.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/OptionalValuesBean.java index de00c980..6d26ed42 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/OptionalValuesBean.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/OptionalValuesBean.java @@ -19,15 +19,16 @@ */ package org.eclipse.microprofile.config.tck; -import org.eclipse.microprofile.config.inject.ConfigProperty; - -import javax.enterprise.context.Dependent; -import javax.inject.Inject; import java.util.Optional; import java.util.OptionalDouble; import java.util.OptionalInt; import java.util.OptionalLong; +import javax.enterprise.context.Dependent; +import javax.inject.Inject; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + /** * Declare a bean for config property injections. * diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/ParseConverterInjection.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/ParseConverterInjection.java index 1eff5bb2..9d50ff03 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/ParseConverterInjection.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/ParseConverterInjection.java @@ -30,9 +30,7 @@ public class ParseConverterInjection { private @Inject @ConfigProperty(name = "tck.config.test.javaconfig.converter.implicit.charSequenceParse.yearmonth") YearMonth yearMonth; - public YearMonth getYearMonth(){ + public YearMonth getYearMonth() { return yearMonth; } } - - diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/PropertyExpressionsTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/PropertyExpressionsTest.java index 26f0808b..e8ef5259 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/PropertyExpressionsTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/PropertyExpressionsTest.java @@ -18,12 +18,10 @@ */ package org.eclipse.microprofile.config.tck; -import org.eclipse.microprofile.config.Config; -import org.eclipse.microprofile.config.ConfigProvider; -import org.eclipse.microprofile.config.spi.ConfigProviderResolver; -import org.eclipse.microprofile.config.spi.ConfigSource; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import static java.util.stream.Collectors.toList; +import static org.eclipse.microprofile.config.Config.PROPERTY_EXPRESSIONS_ENABLED; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertThrows; import java.util.HashMap; import java.util.List; @@ -32,10 +30,12 @@ import java.util.Set; import java.util.stream.Stream; -import static java.util.stream.Collectors.toList; -import static org.eclipse.microprofile.config.Config.PROPERTY_EXPRESSIONS_ENABLED; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.eclipse.microprofile.config.spi.ConfigProviderResolver; +import org.eclipse.microprofile.config.spi.ConfigSource; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; public class PropertyExpressionsTest { @AfterMethod @@ -109,7 +109,7 @@ public void noExpressionComposed() { @Test public void multipleExpansions() { Config config = buildConfig("my.prop", "1234", "my.prop.two", "${my.prop}", "my.prop.three", - "${my.prop.two}", "my.prop.four", "${my.prop.three}"); + "${my.prop.two}", "my.prop.four", "${my.prop.three}"); assertEquals("1234", config.getValue("my.prop", String.class)); assertEquals("1234", config.getValue("my.prop.two", String.class)); @@ -126,7 +126,8 @@ public void infiniteExpansion() { @Test public void withoutExpansion() { - Config config = buildConfig("my.prop", "1234", "expression", "${my.prop}", PROPERTY_EXPRESSIONS_ENABLED, "false"); + Config config = + buildConfig("my.prop", "1234", "expression", "${my.prop}", PROPERTY_EXPRESSIONS_ENABLED, "false"); assertEquals("${my.prop}", config.getValue("expression", String.class)); } @@ -170,22 +171,22 @@ private static Config buildConfig(String... keyValues) { } return ConfigProviderResolver.instance().getBuilder() - .withSources(new ConfigSource() { - @Override - public Set getPropertyNames() { - return properties.keySet(); - } - - @Override - public String getValue(String propertyName) { - return properties.get(propertyName); - } - - @Override - public String getName() { - return "test"; - } - }) - .build(); + .withSources(new ConfigSource() { + @Override + public Set getPropertyNames() { + return properties.keySet(); + } + + @Override + public String getValue(String propertyName) { + return properties.get(propertyName); + } + + @Override + public String getName() { + return "test"; + } + }) + .build(); } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/SimpleValuesBean.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/SimpleValuesBean.java index fee2d09d..81e1835b 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/SimpleValuesBean.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/SimpleValuesBean.java @@ -19,34 +19,35 @@ package org.eclipse.microprofile.config.tck; -import org.eclipse.microprofile.config.inject.ConfigProperty; import javax.enterprise.context.Dependent; import javax.inject.Inject; +import org.eclipse.microprofile.config.inject.ConfigProperty; + @Dependent public class SimpleValuesBean { @Inject - @ConfigProperty(name="my.string/property") + @ConfigProperty(name = "my.string/property") private String stringProperty; @Inject - @ConfigProperty(name="my.boolean.property") + @ConfigProperty(name = "my.boolean.property") private boolean booleanProperty; @Inject - @ConfigProperty(name="my.int/property") + @ConfigProperty(name = "my.int/property") private int intProperty; - public String getStringProperty(){ - return this.stringProperty; + public String getStringProperty() { + return this.stringProperty; } - public boolean getBooleanProperty(){ - return this.booleanProperty; + public boolean getBooleanProperty() { + return this.booleanProperty; } - public int getIntProperty(){ - return this.intProperty; + public int getIntProperty() { + return this.intProperty; } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/WarPropertiesLocationTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/WarPropertiesLocationTest.java index 213d1b51..88274b97 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/WarPropertiesLocationTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/WarPropertiesLocationTest.java @@ -19,6 +19,8 @@ */ package org.eclipse.microprofile.config.tck; +import static org.testng.Assert.assertEquals; + import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.testng.Arquillian; @@ -27,8 +29,6 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; - public class WarPropertiesLocationTest extends Arquillian { private static final String SOME_KEY = "org.eclipse.microprofile.config.test.internal.somekey"; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/base/AbstractTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/base/AbstractTest.java index 0a22efc3..ff741dbd 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/base/AbstractTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/base/AbstractTest.java @@ -23,15 +23,14 @@ import org.jboss.shrinkwrap.api.asset.UrlAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; - /** * @author Mark Struberg */ public class AbstractTest extends Arquillian { - public static void addFile(JavaArchive archive, String originalPath) { - archive.addAsResource(new UrlAsset(Thread.currentThread().getContextClassLoader().getResource("internal/" + originalPath)), + archive.addAsResource( + new UrlAsset(Thread.currentThread().getContextClassLoader().getResource("internal/" + originalPath)), originalPath); } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigObserver.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigObserver.java index 1673aaa3..f0ec3301 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigObserver.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigObserver.java @@ -26,13 +26,10 @@ import org.eclipse.microprofile.config.inject.ConfigProperty; /** - * A bean supporting the {@link - * MissingValueOnObserverMethodInjectionTest} test that injects a - * non-existent configuration property in a container lifecycle event - * observer method. + * A bean supporting the {@link MissingValueOnObserverMethodInjectionTest} test that injects a non-existent + * configuration property in a container lifecycle event observer method. * - * @author Laird Nelson + * @author Laird Nelson * * @see MissingValueOnObserverMethodInjectionTest */ @@ -43,10 +40,8 @@ private ConfigObserver() { super(); } - private static final void onStartup(@Observes @Initialized(ApplicationScoped.class) - final Object event, - @ConfigProperty(name = "this.property.does.not.exist") - final String nonExistentConfigurationPropertyValue) { + private static final void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event, + @ConfigProperty(name = "this.property.does.not.exist") final String nonExistentConfigurationPropertyValue) { } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigOwner.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigOwner.java index f1c6f369..cf66d746 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigOwner.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigOwner.java @@ -23,6 +23,7 @@ import javax.inject.Inject; import org.eclipse.microprofile.config.inject.ConfigProperty; + /** * A bean contains a config property injection * @@ -33,6 +34,6 @@ public class ConfigOwner { @Inject - @ConfigProperty(name="my.long.value") + @ConfigProperty(name = "my.long.value") private Long configValue; } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigPropertiesMissingPropertyInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigPropertiesMissingPropertyInjectionTest.java index 2e18d8e6..258c4387 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigPropertiesMissingPropertyInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/ConfigPropertiesMissingPropertyInjectionTest.java @@ -49,10 +49,9 @@ public static WebArchive deploy() { .create(JavaArchive.class, "ConfigPropertiesTest.jar") .addClasses(ConfigPropertiesMissingPropertyInjectionTest.class, BeanOne.class) .addAsManifestResource( - new StringAsset( - "customer.name=Bob\n" + - "customer.age=24\n" - ), + new StringAsset( + "customer.name=Bob\n" + + "customer.age=24\n"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -66,11 +65,11 @@ public static WebArchive deploy() { public void test() { } - @ConfigProperties(prefix="customer") + @ConfigProperties(prefix = "customer") public static class BeanOne { private String name; public int age; - public String nationality; //no corresponding config property customer.nationality exists + public String nationality; // no corresponding config property customer.nationality exists /** * @return String return the name diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/CustomConverterBean.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/CustomConverterBean.java index 85acdaf2..bd76181c 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/CustomConverterBean.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/CustomConverterBean.java @@ -23,6 +23,7 @@ import javax.inject.Inject; import org.eclipse.microprofile.config.inject.ConfigProperty; + /** * A bean contains a config property injection, which converts to CustomType * @@ -36,7 +37,7 @@ public class CustomConverterBean { public static class ConfigOwner { @Inject - @ConfigProperty(name="my.customtype.value") + @ConfigProperty(name = "my.customtype.value") private CustomType configValue; } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingConverterOnInstanceInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingConverterOnInstanceInjectionTest.java index 07f91798..862f041a 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingConverterOnInstanceInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingConverterOnInstanceInjectionTest.java @@ -58,5 +58,4 @@ public static WebArchive deploy() { public void test() { } - } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnInstanceInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnInstanceInjectionTest.java index 188aa2e0..bdd135f1 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnInstanceInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnInstanceInjectionTest.java @@ -56,6 +56,4 @@ public static WebArchive deploy() { public void test() { } - - } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnObserverMethodInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnObserverMethodInjectionTest.java index 73347546..dd160bc5 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnObserverMethodInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/MissingValueOnObserverMethodInjectionTest.java @@ -31,15 +31,11 @@ import org.testng.annotations.Test; /** - * A test to verify that a {@link - * org.eclipse.microprofile.config.inject.ConfigProperty}-annotated - * injection point in an observer method with a payload that is not an - * instance of {@link java.util.Optional} that does not have a - * corresponding configuration property value set will cause a {@link - * DeploymentException} to be thrown. + * A test to verify that a {@link org.eclipse.microprofile.config.inject.ConfigProperty}-annotated injection point in an + * observer method with a payload that is not an instance of {@link java.util.Optional} that does not have a + * corresponding configuration property value set will cause a {@link DeploymentException} to be thrown. * - * @author Laird Nelson + * @author Laird Nelson */ public class MissingValueOnObserverMethodInjectionTest extends Arquillian { diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/WrongConverterOnInstanceInjectionTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/WrongConverterOnInstanceInjectionTest.java index 5409f590..afca2dee 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/WrongConverterOnInstanceInjectionTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/broken/WrongConverterOnInstanceInjectionTest.java @@ -58,6 +58,4 @@ public static WebArchive deploy() { public void test() { } - - } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigProfileConfigSource.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigProfileConfigSource.java index c6249585..60820454 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigProfileConfigSource.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigProfileConfigSource.java @@ -19,14 +19,14 @@ */ package org.eclipse.microprofile.config.tck.configsources; +import static org.eclipse.microprofile.config.Config.PROFILE; + import java.util.HashMap; import java.util.Map; import java.util.Set; import org.eclipse.microprofile.config.spi.ConfigSource; -import static org.eclipse.microprofile.config.Config.PROFILE; - /** * @author Emily Jiang */ diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigSourceProvider.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigSourceProvider.java index 669a26c2..cbff62b7 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigSourceProvider.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomConfigSourceProvider.java @@ -28,7 +28,6 @@ import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.ConfigSourceProvider; - /** * @author Mark Struberg */ @@ -41,8 +40,7 @@ public Iterable getConfigSources(ClassLoader forClassLoader) { Enumeration yamlFiles = null; try { yamlFiles = forClassLoader.getResources("sampleconfig.yaml"); - } - catch (IOException e) { + } catch (IOException e) { throw new RuntimeException(e); } while (yamlFiles.hasMoreElements()) { diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomDbConfigSource.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomDbConfigSource.java index 470db48c..69f54e02 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomDbConfigSource.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/CustomDbConfigSource.java @@ -58,9 +58,8 @@ private String readPropertyFromDb(String key) { @Override public Set getPropertyNames() { - + return configValues.keySet(); } - } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/SampleYamlConfigSource.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/SampleYamlConfigSource.java index b1fa4478..3168daa5 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/SampleYamlConfigSource.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/configsources/SampleYamlConfigSource.java @@ -53,7 +53,7 @@ public String getName() { @Override public Set getPropertyNames() { - + return config.keySet(); } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Donald.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Donald.java index b7f0588a..e5cb1da3 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Donald.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Donald.java @@ -37,14 +37,16 @@ private Donald(String name, boolean bool) { /** * Ensure constructor cannot be auto-detected/auto-constructed. - * @param name the name, not null + * + * @param name + * the name, not null * @return a new instance, never null. */ - public static Donald iLikeDonald(String name){ + public static Donald iLikeDonald(String name) { return new Donald(name, true); } - public String getName(){ + public String getName() { return name; } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Duck.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Duck.java index f658a1cc..b464b939 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Duck.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Duck.java @@ -25,7 +25,6 @@ public class Duck { private final String name; - public Duck(String name) { this.name = name; } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/NullConvertersTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/NullConvertersTest.java index 45876e08..922f4ca0 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/NullConvertersTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/NullConvertersTest.java @@ -18,16 +18,16 @@ */ package org.eclipse.microprofile.config.tck.converters; -import org.eclipse.microprofile.config.Config; -import org.eclipse.microprofile.config.ConfigProvider; -import org.junit.Test; +import static org.testng.Assert.assertThrows; import java.util.NoSuchElementException; import java.util.OptionalDouble; import java.util.OptionalInt; import java.util.OptionalLong; -import static org.testng.Assert.assertThrows; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; +import org.junit.Test; public class NullConvertersTest { @Test @@ -50,7 +50,7 @@ public void nulls() { private static void convertNull(Config config, Class converterType) { config.getConverter(converterType) - .map(converter -> converter.convert(null)) - .orElseThrow(NoSuchElementException::new); + .map(converter -> converter.convert(null)) + .orElseThrow(NoSuchElementException::new); } } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Pizza.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Pizza.java index 48fa296e..a851c6a8 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Pizza.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/Pizza.java @@ -26,7 +26,6 @@ public class Pizza { private String flavor; private String size; - public Pizza(String flavour, String size) { this.flavor = flavour; this.size = size; @@ -40,24 +39,28 @@ public String getFlavor() { return flavor; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((flavor == null) ? 0 : flavor.hashCode()); - result = prime * result + ((size == null) ? 0 : size.hashCode()); - return result; + final int prime = 31; + int result = 1; + result = prime * result + ((flavor == null) ? 0 : flavor.hashCode()); + result = prime * result + ((size == null) ? 0 : size.hashCode()); + return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object obj) { - if (this == obj){ + if (this == obj) { return true; } if (obj == null) { @@ -69,23 +72,20 @@ public boolean equals(Object obj) { Pizza other = (Pizza) obj; if (flavor == null) { - if (other.flavor != null) { - return false; - } - } - else if (!flavor.equals(other.flavor)) { - return false; + if (other.flavor != null) { + return false; + } + } else if (!flavor.equals(other.flavor)) { + return false; } if (size == null) { - if (other.size != null) { - return false; - } - } - else if (!size.equals(other.size)) { + if (other.size != null) { + return false; + } + } else if (!size.equals(other.size)) { return false; } return true; } - - + } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/PizzaConverter.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/PizzaConverter.java index e200a1f6..93cdcf46 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/PizzaConverter.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/PizzaConverter.java @@ -29,7 +29,7 @@ public class PizzaConverter implements Converter { @Override public Pizza convert(String value) { String[] parts = value.split(":"); - if (parts.length ==2) { + if (parts.length == 2) { String size = parts[0]; String flavor = parts[1]; return new Pizza(flavor, size); diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/BooleanConverter.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/BooleanConverter.java index 4f58493a..e764853b 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/BooleanConverter.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/BooleanConverter.java @@ -19,10 +19,10 @@ */ package org.eclipse.microprofile.config.tck.converters.custom; -import org.eclipse.microprofile.config.spi.Converter; - import javax.annotation.Priority; +import org.eclipse.microprofile.config.spi.Converter; + @Priority(101) public class BooleanConverter implements Converter { @Override diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/CharacterConverter.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/CharacterConverter.java index f816b2c0..d4bdf7fd 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/CharacterConverter.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/CharacterConverter.java @@ -19,10 +19,10 @@ */ package org.eclipse.microprofile.config.tck.converters.custom; -import org.eclipse.microprofile.config.spi.Converter; - import javax.annotation.Priority; +import org.eclipse.microprofile.config.spi.Converter; + @Priority(101) public class CharacterConverter implements Converter { @Override diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/DoubleConverter.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/DoubleConverter.java index 9a012ef4..f848d084 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/DoubleConverter.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/DoubleConverter.java @@ -19,10 +19,10 @@ */ package org.eclipse.microprofile.config.tck.converters.custom; -import org.eclipse.microprofile.config.spi.Converter; - import javax.annotation.Priority; +import org.eclipse.microprofile.config.spi.Converter; + @Priority(101) public class DoubleConverter implements Converter { @Override diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/IntegerConverter.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/IntegerConverter.java index 82860271..aec0a7da 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/IntegerConverter.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/IntegerConverter.java @@ -19,10 +19,10 @@ */ package org.eclipse.microprofile.config.tck.converters.custom; -import org.eclipse.microprofile.config.spi.Converter; - import javax.annotation.Priority; +import org.eclipse.microprofile.config.spi.Converter; + @Priority(101) public class IntegerConverter implements Converter { @Override diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/LongConverter.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/LongConverter.java index f0ad42f5..85e4090e 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/LongConverter.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/custom/LongConverter.java @@ -19,10 +19,10 @@ */ package org.eclipse.microprofile.config.tck.converters.custom; -import org.eclipse.microprofile.config.spi.Converter; - import javax.annotation.Priority; +import org.eclipse.microprofile.config.spi.Converter; + @Priority(101) public class LongConverter implements Converter { @Override diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceOfBeforeValueOf.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceOfBeforeValueOf.java index b242ca24..e616dccc 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceOfBeforeValueOf.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceOfBeforeValueOf.java @@ -21,8 +21,7 @@ /** * Part of the implicit Converter test. * - * Sample class which has a of(String) and valueOf(String) method. - * The method of() should be used instead of valueOf(). + * Sample class which has a of(String) and valueOf(String) method. The method of() should be used instead of valueOf(). * * @author Emily Jiang */ diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceParseBeforeConstructor.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceParseBeforeConstructor.java index 87395146..aaa54ae0 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceParseBeforeConstructor.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceParseBeforeConstructor.java @@ -21,8 +21,8 @@ /** * Part of the implicit Converter test. * - * Sample class which has a parse(CharSequence) and Constructor(String) method. - * The method parse(CharSequence) should be used instead of constructor(String). + * Sample class which has a parse(CharSequence) and Constructor(String) method. The method parse(CharSequence) should be + * used instead of constructor(String). * * @author Emily Jiang */ diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceValueOfBeforeParse.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceValueOfBeforeParse.java index 9f8a90ca..9f83668d 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceValueOfBeforeParse.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestSequenceValueOfBeforeParse.java @@ -21,8 +21,8 @@ /** * Part of the implicit Converter test. * - * Sample class which has a parse(CharSequence) and valueOf(String) method. - * The method valueOf(String) should be used instead of the parse(Charsequence) method. + * Sample class which has a parse(CharSequence) and valueOf(String) method. The method valueOf(String) should be used + * instead of the parse(Charsequence) method. * * @author Emily Jiang */ diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestTypeWCharSequenceParse.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestTypeWCharSequenceParse.java index b027c2b1..879c10c2 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestTypeWCharSequenceParse.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/ConvTestTypeWCharSequenceParse.java @@ -26,8 +26,6 @@ * @author Mark Struberg */ - - public class ConvTestTypeWCharSequenceParse { private String val; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/SomeEnumToConvert.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/SomeEnumToConvert.java index ab8a46b3..3d47bed6 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/SomeEnumToConvert.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/converters/implicit/SomeEnumToConvert.java @@ -20,10 +20,9 @@ /** * Sample enum to test implicit Converter Rules + * * @author Mark Struberg */ public enum SomeEnumToConvert { - FOO, - BAR, - BAZ + FOO, BAR, BAZ } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesBean.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesBean.java index 00998fff..3a50ec8b 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesBean.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesBean.java @@ -19,15 +19,15 @@ */ package org.eclipse.microprofile.config.tck.emptyvalue; -import org.eclipse.microprofile.config.inject.ConfigProperty; - import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; +import org.eclipse.microprofile.config.inject.ConfigProperty; + @ApplicationScoped public class EmptyValuesBean { @Inject - @ConfigProperty(name="my.unset.property", defaultValue = "") + @ConfigProperty(name = "my.unset.property", defaultValue = "") private String stringValue; public String getStringValue() { diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTest.java index 66161a91..f15c84f8 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTest.java @@ -20,6 +20,8 @@ package org.eclipse.microprofile.config.tck.emptyvalue; import javax.enterprise.inject.spi.DeploymentException; +import javax.inject.Inject; + import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.ShouldThrowException; import org.jboss.arquillian.testng.Arquillian; @@ -31,8 +33,6 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; -import javax.inject.Inject; - public class EmptyValuesTest extends Arquillian { private static final String EMPTY_PROPERTY = "my.empty.property"; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTestProgrammaticLookup.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTestProgrammaticLookup.java index 426996b6..bef850d3 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTestProgrammaticLookup.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/emptyvalue/EmptyValuesTestProgrammaticLookup.java @@ -22,6 +22,8 @@ import java.util.Arrays; import java.util.NoSuchElementException; +import javax.inject.Inject; + import org.eclipse.microprofile.config.Config; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.testng.Arquillian; @@ -34,8 +36,6 @@ import org.testng.Assert; import org.testng.annotations.Test; -import javax.inject.Inject; - public class EmptyValuesTestProgrammaticLookup extends Arquillian { @Deployment @@ -43,16 +43,15 @@ public static Archive deployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "emptyValues.jar") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsManifestResource(new StringAsset( - "empty.string=" + "\n" + - "comma.string=," + "\n" + - "backslash.comma.string=\\\\," + "\n" + - "double.comma.string=,," + "\n" + - "foo.bar.string=foo,bar"+ "\n" + - "foo.comma.string=foo,"+ "\n" + - "comma.bar.string=,bar" + "\n" + - "space.string=\\u0020" - ), - "microprofile-config.properties"); + "empty.string=" + "\n" + + "comma.string=," + "\n" + + "backslash.comma.string=\\\\," + "\n" + + "double.comma.string=,," + "\n" + + "foo.bar.string=foo,bar" + "\n" + + "foo.comma.string=foo," + "\n" + + "comma.bar.string=,bar" + "\n" + + "space.string=\\u0020"), + "microprofile-config.properties"); return ShrinkWrap.create(WebArchive.class) .addAsLibrary(jar) @@ -92,7 +91,7 @@ public void testEmptyStringGetOptionalValue() { assertConfigurationNotPresentForOptional("empty.string"); assertConfigurationNotPresentForOptionalMultiple("empty.string"); } - + @Test(expectedExceptions = NoSuchElementException.class) public void testCommaStringGetValueArray() { String[] values = config.getValue("comma.string", String[].class); @@ -147,7 +146,7 @@ public void testDoubleCommaStringGetOptionalValues() { @Test public void testFooBarStringGetValueArray() { String[] values = config.getValue("foo.bar.string", String[].class); - Assert.assertEquals(values, new String[] {"foo", "bar"}); + Assert.assertEquals(values, new String[]{"foo", "bar"}); } @@ -160,14 +159,16 @@ public void testFooBarStringGetValue() { @Test public void testFooBarStringGetOptionalValues() { Assert.assertEquals(config.getOptionalValue("foo.bar.string", String.class).get(), "foo,bar"); - Assert.assertEquals(config.getOptionalValue("foo.bar.string", String[].class).get(), new String[] {"foo", "bar"}); - Assert.assertEquals(config.getOptionalValues("foo.bar.string", String.class).get(), Arrays.asList("foo", "bar")); - + Assert.assertEquals(config.getOptionalValue("foo.bar.string", String[].class).get(), + new String[]{"foo", "bar"}); + Assert.assertEquals(config.getOptionalValues("foo.bar.string", String.class).get(), + Arrays.asList("foo", "bar")); + } @Test public void testFooCommaStringGetValueArray() { String[] values = config.getValue("foo.comma.string", String[].class); - Assert.assertEquals(values, new String[] {"foo"}); + Assert.assertEquals(values, new String[]{"foo"}); } @Test @@ -179,14 +180,14 @@ public void testFooCommaStringGetValue() { @Test public void testFooCommaStringGetOptionalValues() { Assert.assertEquals(config.getOptionalValue("foo.comma.string", String.class).get(), "foo,"); - Assert.assertEquals(config.getOptionalValue("foo.comma.string", String[].class).get(), new String[] {"foo"}); + Assert.assertEquals(config.getOptionalValue("foo.comma.string", String[].class).get(), new String[]{"foo"}); Assert.assertEquals(config.getOptionalValues("foo.comma.string", String.class).get(), Arrays.asList("foo")); } @Test public void testCommaBarStringGetValueArray() { String[] values = config.getValue("comma.bar.string", String[].class); - Assert.assertEquals(values, new String[] {"bar"}); + Assert.assertEquals(values, new String[]{"bar"}); } @Test @@ -198,14 +199,14 @@ public void testCommaBarStringGetValue() { @Test public void testCommaBarStringGetOptionalValues() { Assert.assertEquals(config.getOptionalValue("comma.bar.string", String.class).get(), ",bar"); - Assert.assertEquals(config.getOptionalValue("comma.bar.string", String[].class).get(), new String[] {"bar"}); - Assert.assertEquals(config.getOptionalValues("comma.bar.string", String.class).get(), Arrays.asList("bar")); + Assert.assertEquals(config.getOptionalValue("comma.bar.string", String[].class).get(), new String[]{"bar"}); + Assert.assertEquals(config.getOptionalValues("comma.bar.string", String.class).get(), Arrays.asList("bar")); } @Test public void testSpaceStringGetValueArray() { String[] values = config.getValue("space.string", String[].class); - Assert.assertEquals(values, new String[] {" "}); + Assert.assertEquals(values, new String[]{" "}); } @Test @@ -217,7 +218,7 @@ public void testSpaceStringGetValue() { @Test public void testSpaceStringGetOptionalValue() { Assert.assertEquals(config.getOptionalValue("space.string", String.class).get(), " "); - Assert.assertEquals(config.getOptionalValue("space.string", String[].class).get(), new String[] {" "}); + Assert.assertEquals(config.getOptionalValue("space.string", String[].class).get(), new String[]{" "}); Assert.assertEquals(config.getOptionalValues("space.string", String.class).get(), Arrays.asList(" ")); } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/matchers/AdditionalMatchers.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/matchers/AdditionalMatchers.java index f2d32e3a..b671d6b2 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/matchers/AdditionalMatchers.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/matchers/AdditionalMatchers.java @@ -19,10 +19,11 @@ package org.eclipse.microprofile.config.tck.matchers; +import static org.hamcrest.Matchers.closeTo; + import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; -import static org.hamcrest.Matchers.closeTo; /** * @@ -42,9 +43,8 @@ public static Matcher floatCloseTo(float value, float range) { @Override public boolean matches(Object item) { if (item instanceof Float) { - return (doubleMatcher = closeTo(value, range)).matches(((Float)item).doubleValue()); - } - else { + return (doubleMatcher = closeTo(value, range)).matches(((Float) item).doubleValue()); + } else { return (doubleMatcher = closeTo(value, range)).matches(item); } } @@ -61,5 +61,4 @@ public void describeMismatch(Object item, Description mismatchDescription) { }; } - } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ConfigPropertyFileProfileTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ConfigPropertyFileProfileTest.java index 1eb7a4b7..937d2ff2 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ConfigPropertyFileProfileTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ConfigPropertyFileProfileTest.java @@ -52,18 +52,18 @@ public static Archive deployment() { .create(JavaArchive.class, "ConfigPropertyFileProfileTest.jar") .addClasses(ConfigPropertyFileProfileTest.class, ProfilePropertyBean.class) .addAsManifestResource( - new StringAsset( - "mp.config.profile=dev\n" + - "vehicle.name=car\n" + - "vehicle.colour=red"), + new StringAsset( + "mp.config.profile=dev\n" + + "vehicle.name=car\n" + + "vehicle.colour=red"), "microprofile-config.properties") .addAsManifestResource(new StringAsset( - "vehicle.name=bike\n" + - "vehicle.owner=Bob"), - "microprofile-config-dev.properties") + "vehicle.name=bike\n" + + "vehicle.owner=Bob"), + "microprofile-config-dev.properties") .addAsManifestResource(new StringAsset( - "vehicle.name=bike\n" + - "vehicle.age=5"), + "vehicle.name=bike\n" + + "vehicle.age=5"), "microprofile-config-prod.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -76,8 +76,8 @@ public static Archive deployment() { } /** - * Check both the file microprofile-config.properties and microprofile-config-dev.properties - * are loaded as config sources but the file microprofile-config-prod.properties is ignored. + * Check both the file microprofile-config.properties and microprofile-config-dev.properties are loaded as config + * sources but the file microprofile-config-prod.properties is ignored. */ @Test public void testConfigProfileWithDev() { @@ -95,19 +95,19 @@ public void testConfigProfileWithDev() { @Dependent public static class ProfilePropertyBean { @Inject - @ConfigProperty(name="vehicle.name") + @ConfigProperty(name = "vehicle.name") private String name; @Inject - @ConfigProperty(name="vehicle.age", defaultValue="10") + @ConfigProperty(name = "vehicle.age", defaultValue = "10") private int age; @Inject - @ConfigProperty(name="vehicle.colour", defaultValue="black") + @ConfigProperty(name = "vehicle.colour", defaultValue = "black") private String colour; @Inject - @ConfigProperty(name="vehicle.owner", defaultValue="Jane") + @ConfigProperty(name = "vehicle.owner", defaultValue = "Jane") private String owner; public String getName() { @@ -126,5 +126,5 @@ public String getOwner() { return owner; } } - + } diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/DevConfigProfileTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/DevConfigProfileTest.java index dc7760b4..671d6450 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/DevConfigProfileTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/DevConfigProfileTest.java @@ -50,12 +50,12 @@ public static Archive deployment() { .create(JavaArchive.class, "DevConfigProfileTest.jar") .addClasses(DevConfigProfileTest.class, ProfilePropertyBean.class) .addAsManifestResource( - new StringAsset( - "mp.config.profile=dev\n" + - "%dev.vehicle.name=bike\n" + - "%prod.vehicle.name=bus\n" + - "%test.vehicle.name=van\n" + - "vehicle.name=car"), + new StringAsset( + "mp.config.profile=dev\n" + + "%dev.vehicle.name=bike\n" + + "%prod.vehicle.name=bus\n" + + "%test.vehicle.name=van\n" + + "vehicle.name=car"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -77,7 +77,7 @@ public void testConfigProfileWithDev() { @Dependent public static class ProfilePropertyBean { @Inject - @ConfigProperty(name="vehicle.name") + @ConfigProperty(name = "vehicle.name") private String vehicleName; public String getConfigProperty() { return vehicleName; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/InvalidConfigProfileTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/InvalidConfigProfileTest.java index 92122b15..91d3bad7 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/InvalidConfigProfileTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/InvalidConfigProfileTest.java @@ -50,12 +50,12 @@ public static Archive deployment() { .create(JavaArchive.class, "InvalidConfigProfileTest.jar") .addClasses(InvalidConfigProfileTest.class, ProfilePropertyBean.class) .addAsManifestResource( - new StringAsset( - "mp.config.profile=invalid\n" + - "%dev.vehicle.name=bike\n" + - "%prod.vehicle.name=bus\n" + - "%test.vehicle.name=van\n" + - "vehicle.name=car"), + new StringAsset( + "mp.config.profile=invalid\n" + + "%dev.vehicle.name=bike\n" + + "%prod.vehicle.name=bus\n" + + "%test.vehicle.name=van\n" + + "vehicle.name=car"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -76,7 +76,7 @@ public void testConfigProfileWithDev() { @Dependent public static class ProfilePropertyBean { @Inject - @ConfigProperty(name="vehicle.name") + @ConfigProperty(name = "vehicle.name") private String vehicleName; public String getConfigProperty() { return vehicleName; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ProdProfileTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ProdProfileTest.java index a5ac2321..cc2abec6 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ProdProfileTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/ProdProfileTest.java @@ -50,12 +50,12 @@ public static Archive deployment() { .create(JavaArchive.class, "ProdProfileTest.jar") .addClasses(ProdProfileTest.class, ProfilePropertyBean.class) .addAsManifestResource( - new StringAsset( - "mp.config.profile=prod\n" + - "%dev.vehicle.name=bike\n" + - "%prod.vehicle.name=bus\n" + - "%test.vehicle.name=van\n" + - "vehicle.name=car"), + new StringAsset( + "mp.config.profile=prod\n" + + "%dev.vehicle.name=bike\n" + + "%prod.vehicle.name=bus\n" + + "%test.vehicle.name=van\n" + + "vehicle.name=car"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -76,7 +76,7 @@ public void testConfigProfileWithDev() { @Dependent public static class ProfilePropertyBean { @Inject - @ConfigProperty(name="vehicle.name") + @ConfigProperty(name = "vehicle.name") private String vehicleName; public String getConfigProperty() { return vehicleName; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestConfigProfileTest.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestConfigProfileTest.java index 37d8b91a..00a73324 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestConfigProfileTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestConfigProfileTest.java @@ -50,12 +50,12 @@ public static Archive deployment() { .create(JavaArchive.class, "TestConfigProfileTest.jar") .addClasses(TestConfigProfileTest.class, ProfilePropertyBean.class) .addAsManifestResource( - new StringAsset( - "mp.config.profile=test\n" + - "%dev.vehicle.name=bike\n" + - "%prod.vehicle.name=bus\n" + - "%test.vehicle.name=van\n" + - "vehicle.name=car"), + new StringAsset( + "mp.config.profile=test\n" + + "%dev.vehicle.name=bike\n" + + "%prod.vehicle.name=bus\n" + + "%test.vehicle.name=van\n" + + "vehicle.name=car"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -76,7 +76,7 @@ public void testConfigProfileWithDev() { @Dependent public static class ProfilePropertyBean { @Inject - @ConfigProperty(name="vehicle.name") + @ConfigProperty(name = "vehicle.name") private String vehicleName; public String getConfigProperty() { return vehicleName; diff --git a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestCustomConfigProfile.java b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestCustomConfigProfile.java index aaa8e8b7..ab5ee0f1 100644 --- a/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestCustomConfigProfile.java +++ b/tck/src/main/java/org/eclipse/microprofile/config/tck/profile/TestCustomConfigProfile.java @@ -50,15 +50,16 @@ public class TestCustomConfigProfile extends Arquillian { public static Archive deployment() { JavaArchive testJar = ShrinkWrap .create(JavaArchive.class, "TestConfigProfileTest.jar") - .addClasses(TestCustomConfigProfile.class, ProfilePropertyBean.class, CustomConfigProfileConfigSource.class) + .addClasses(TestCustomConfigProfile.class, ProfilePropertyBean.class, + CustomConfigProfileConfigSource.class) .addAsServiceProvider(ConfigSource.class, CustomConfigProfileConfigSource.class) .addAsManifestResource( - new StringAsset( - "mp.config.profile=prod\n" + - "%dev.vehicle.name=bus\n" + - "%prod.vehicle.name=bike\n" + - "%test.vehicle.name=coach\n" + - "vehicle.name=car"), + new StringAsset( + "mp.config.profile=prod\n" + + "%dev.vehicle.name=bus\n" + + "%prod.vehicle.name=bike\n" + + "%test.vehicle.name=coach\n" + + "vehicle.name=car"), "microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .as(JavaArchive.class); @@ -79,7 +80,7 @@ public void testConfigProfileWithDev() { @Dependent public static class ProfilePropertyBean { @Inject - @ConfigProperty(name="vehicle.name") + @ConfigProperty(name = "vehicle.name") private String vehicleName; public String getConfigProperty() { return vehicleName;