From ad22cd8381a7ecb6513fd3091e1a138fbecf94e0 Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Tue, 13 Oct 2020 18:39:30 +0200 Subject: [PATCH 1/7] Create properties class for external properties Signed-off-by: tvallin --- .../glassfish/jersey/ExternalProperties.java | 221 ++++++++++++++++++ .../SystemPropertiesConfigurationModel.java | 1 + 2 files changed, 222 insertions(+) create mode 100644 core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java diff --git a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java new file mode 100644 index 0000000000..5ebb523fd7 --- /dev/null +++ b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java @@ -0,0 +1,221 @@ +package org.glassfish.jersey; + +import org.glassfish.jersey.internal.util.PropertiesClass; +import org.glassfish.jersey.internal.util.PropertiesHelper; + +import javax.ws.rs.RuntimeType; +import java.util.Map; + +@PropertiesClass +public final class ExternalProperties { + + // JDK Properties + + public static final String HTTP_PROXY_HOST = "http.proxyHost"; + + public static final String HTTP_PROXY_PORT = "http.proxyPort"; + + public static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts"; + + public static final String HTTP_AGENT = "http.agent"; + + public static final String HTTP_KEEPALIVE = "http.keepalive"; + + public static final String HTTP_MAX_CONNECTIONS = "http.maxConnections"; + + public static final String HTTP_MAX_REDIRECTS = "http.maxRedirects"; + + public static final String HTTP_AUTH_DIGEST_VALIDATE_SERVER = "http.auth.digest.validateServer"; + + public static final String HTTP_AUTH_DIGEST_VALIDATE_PROXY = "http.auth.digest.validateProxy"; + + public static final String HTTP_AUTH_DIGEST_CNONCE_REPEAT = "http.auth.digest.cnonceRepeat"; + + public static final String HTTP_AUTH_NTLM_DOMAIN = "http.auth.ntlm.domain"; + + public static final String HTTPS_PROXY_HOST = "https.ProxyHost"; + + public static final String HTTPS_PROXY_PORT = "https.ProxyPort"; + + public static final String FTP_PROXY_HOST = "ftp.proxyHost"; + + public static final String FTP_PROXY_PORT = "ftp.proxyPort"; + + public static final String FTP_NON_PROXY_HOSTS = "ftp.nonProxyHosts"; + + public static final String SOCKS_PROXY_HOST = "socksProxyHost"; + + public static final String SOCKS_PROXY_PORT = "socksProxyPort"; + + public static final String SOCKS_PROXY_VERSION = "socksProxyVersion"; + + public static final String JAVA_NET_SOCKS_USERNAME = "java.net.socks.username"; + + public static final String JAVA_NET_SOCKS_PASSWORD = "java.net.socks.password"; + + public static final String JAVA_NET_USE_SYSTEM_PROXIES = "java.net.useSystemProxies"; + + public static final String NETWORK_ADDRESS_CACHE_TTL = "networkaddress.cache.ttl"; + + public static final String NETWORK_ADDRESS_CACHE_NEGATIVE_TTL = "networkaddress.cache.negative.ttl"; + + // JAX-B Properties + + public static final String JAXB_CONTEXT_FACTORY = "jakarta.xml.bind.JAXBContextFactory"; + + public static final String JAXB_ENCODING = "jaxb.encoding"; + + public static final String JAXB_FORMATTED_OUTPUT = "jaxb.formatted.output"; + + public static final String JAXB_SCHEMA_LOCATION = "jaxb.schemaLocation"; + + public static final String JAXB_NO_NAMESPACE_SCHEMA_LOCATION = "jaxb.noNamespaceSchemaLocation"; + + public static final String JAXB_FRAGMENT = "jaxb.fragment"; + + // JSON-B Properties + + public static final String JSONB_FORMATTING = "jsonb.formatting"; + + public static final String JSONB_ENCODING = "jsonb.encoding"; + + public static final String JSONB_PROPERTY_NAMING_STRATEGY = "jsonb.property-naming-strategy"; + + public static final String JSONB_PROPERTY_ORDER_STRATEGY = "jsonb.property-order-strategy"; + + public static final String JSONB_NULL_VALUES = "jsonb.null-values"; + + public static final String JSONB_STRICT_IJSON = "jsonb.strict-ijson"; + + public static final String JSONB_PROPERTY_VISIBILITY_STRATEGY = "jsonb.property-visibility-strategy"; + + public static final String JSONB_ADAPTERS = "jsonb.adapters"; + + public static final String JSONB_SERIALIZERS = "jsonb.serializers"; + + public static final String JSONB_DESERIALIZERS = "jsonb.derializers"; + + public static final String JSONB_BINARY_DATA_STRATEGY = "jsonb.binary-data-strategy"; + + public static final String JSONB_DATE_FORMAT = "jsonb.date-format"; + + public static final String JSONB_LOCALE = "jsonb.locale"; + + /** + * Prevent instantiation. + */ + private ExternalProperties() { + } + + /** + * Get the value of the specified property. + * + * If the property is not set or the actual property value type is not compatible with the specified type, the method will + * return {@code null}. + * + * @param properties Map of properties to get the property value from. + * @param propertyName Name of the property. + * @param type Type to retrieve the value as. + * @return Value of the property or {@code null}. + * + * @since 2.8 + */ + public static Object getValue(final Map properties, final String propertyName, final Class type) { + return PropertiesHelper.getValue(properties, propertyName, type, null); + } + + /** + * Get the value of the specified property. + * + * If the property is not set or the real value type is not compatible with {@code defaultValue} type, + * the specified {@code defaultValue} is returned. Calling this method is equivalent to calling + * {@code CommonProperties.getValue(properties, key, defaultValue, (Class<T>) defaultValue.getClass())} + * + * @param properties Map of properties to get the property value from. + * @param propertyName Name of the property. + * @param defaultValue Default value if property is not registered + * @param Type of the property value. + * @return Value of the property or {@code null}. + * + * @since 2.8 + */ + public static T getValue(final Map properties, final String propertyName, final T defaultValue) { + return PropertiesHelper.getValue(properties, propertyName, defaultValue, null); + } + + /** + * Get the value of the specified property. + * + * If the property is not set or the real value type is not compatible with {@code defaultValue} type, + * the specified {@code defaultValue} is returned. Calling this method is equivalent to calling + * {@code CommonProperties.getValue(properties, runtimeType, key, defaultValue, (Class<T>) defaultValue.getClass())} + * + * @param properties Map of properties to get the property value from. + * @param runtime Runtime type which is used to check whether there is a property with the same + * {@code key} but post-fixed by runtime type (.server + * or {@code .client}) which would override the {@code key} property. + * @param propertyName Name of the property. + * @param defaultValue Default value if property is not registered + * @param Type of the property value. + * @return Value of the property or {@code null}. + * + * @since 2.8 + */ + public static T getValue(final Map properties, + final RuntimeType runtime, + final String propertyName, + final T defaultValue) { + return PropertiesHelper.getValue(properties, runtime, propertyName, defaultValue, null); + } + + /** + * Get the value of the specified property. + * + * If the property is not set or the real value type is not compatible with the specified value type, + * returns {@code defaultValue}. + * + * @param properties Map of properties to get the property value from. + * @param runtime Runtime type which is used to check whether there is a property with the same + * {@code key} but post-fixed by runtime type (.server + * or {@code .client}) which would override the {@code key} property. + * @param propertyName Name of the property. + * @param defaultValue Default value if property is not registered + * @param type Type to retrieve the value as. + * @param Type of the property value. + * @return Value of the property or {@code null}. + * + * @since 2.8 + */ + public static T getValue(final Map properties, + final RuntimeType runtime, + final String propertyName, + final T defaultValue, + final Class type) { + return PropertiesHelper.getValue(properties, runtime, propertyName, defaultValue, type, null); + } + + /** + * Get the value of the specified property. + * + * If the property is not set or the actual property value type is not compatible with the specified type, the method will + * return {@code null}. + * + * @param properties Map of properties to get the property value from. + * @param runtime Runtime type which is used to check whether there is a property with the same + * {@code key} but post-fixed by runtime type (.server + * or {@code .client}) which would override the {@code key} property. + * @param propertyName Name of the property. + * @param type Type to retrieve the value as. + * @param Type of the property value. + * @return Value of the property or {@code null}. + * + * @since 2.8 + */ + public static T getValue(final Map properties, + final RuntimeType runtime, + final String propertyName, + final Class type) { + return PropertiesHelper.getValue(properties, runtime, propertyName, type, null); + } + +} diff --git a/core-common/src/main/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModel.java b/core-common/src/main/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModel.java index 4dea8d844a..f870fabc98 100644 --- a/core-common/src/main/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModel.java +++ b/core-common/src/main/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModel.java @@ -44,6 +44,7 @@ class SystemPropertiesConfigurationModel implements ExternalConfigurationModel PROPERTY_CLASSES = Arrays.asList( + "org.glassfish.jersey.ExternalProperties", "org.glassfish.jersey.server.ServerProperties", "org.glassfish.jersey.client.ClientProperties", "org.glassfish.jersey.servlet.ServletProperties", From 87285bcb9f6320cf57e5b49b0a8df4604ad2fad9 Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Wed, 14 Oct 2020 10:18:31 +0200 Subject: [PATCH 2/7] Add javadoc Signed-off-by: tvallin --- .../glassfish/jersey/ExternalProperties.java | 165 +++++++++++++++++- 1 file changed, 159 insertions(+), 6 deletions(-) diff --git a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java index 5ebb523fd7..688a6ab914 100644 --- a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java +++ b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java @@ -9,96 +9,249 @@ @PropertiesClass public final class ExternalProperties { - // JDK Properties - + /** + * Property used to specify the hostname, or address, of the proxy server. + */ public static final String HTTP_PROXY_HOST = "http.proxyHost"; + /** + * Property used to specify the port number of the proxy server. + */ public static final String HTTP_PROXY_PORT = "http.proxyPort"; + /** + * Property used to indicates the hosts that should be accessed + * without going through the proxy. + */ public static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts"; + /** + * Property used to define the string sent in the User-Agent + * request header in http requests. + */ public static final String HTTP_AGENT = "http.agent"; + /** + * Property used to indicates if persistent connections should be supported. + */ public static final String HTTP_KEEPALIVE = "http.keepalive"; + /** + * If HTTP keepalive is enabled this value determines + * the maximum number of idle connections that will be simultaneously + * kept alive, per destination. + */ public static final String HTTP_MAX_CONNECTIONS = "http.maxConnections"; + /** + * This integer value determines the maximum number, for a given request, + * of HTTP redirects that will be automatically followed by the protocol handler. + */ public static final String HTTP_MAX_REDIRECTS = "http.maxRedirects"; + /** + * Property used to enforce authentication with an origin. + */ public static final String HTTP_AUTH_DIGEST_VALIDATE_SERVER = "http.auth.digest.validateServer"; + /** + * Property used to enforce authentication with a proxy server. + */ public static final String HTTP_AUTH_DIGEST_VALIDATE_PROXY = "http.auth.digest.validateProxy"; + /** + * This property determines how many times a cnonce value is re-used. + */ public static final String HTTP_AUTH_DIGEST_CNONCE_REPEAT = "http.auth.digest.cnonceRepeat"; + /** + * NTLM is another authentication scheme. It uses the java.net.Authenticator class + * to acquire usernames and passwords when they are needed. + */ public static final String HTTP_AUTH_NTLM_DOMAIN = "http.auth.ntlm.domain"; + /** + * Property used to specify the hostname, or address, of the proxy server + * used by https protocol. + */ public static final String HTTPS_PROXY_HOST = "https.ProxyHost"; + /** + * Property used to specify the port number of the proxy server + * used by https protocol. + */ public static final String HTTPS_PROXY_PORT = "https.ProxyPort"; + /** + * Property used to specify the hostname, or address, of the proxy server + * used by the FTP protocol handler. + */ public static final String FTP_PROXY_HOST = "ftp.proxyHost"; + /** + * Property used to specify the port number of the proxy server + * used by the FTP protocol handler. + */ public static final String FTP_PROXY_PORT = "ftp.proxyPort"; + /** + * Property used by the FTP protocol handler to indicates the hosts + * that should be accessed without going through the proxy. + */ public static final String FTP_NON_PROXY_HOSTS = "ftp.nonProxyHosts"; + /** + * Property used to specify the hostname, or address, of the proxy server. + */ public static final String SOCKS_PROXY_HOST = "socksProxyHost"; + /** + * Property used to specify the port number of the proxy server. + */ public static final String SOCKS_PROXY_PORT = "socksProxyPort"; + /** + * Property used to specify the version of the SOCKS protocol + * supported by the server. + */ public static final String SOCKS_PROXY_VERSION = "socksProxyVersion"; + /** + * Username to use if the SOCKSv5 server asks for authentication + * and no java.net.Authenticator instance was found. + */ public static final String JAVA_NET_SOCKS_USERNAME = "java.net.socks.username"; + /** + * Password to use if the SOCKSv5 server asks for authentication + * and no java.net.Authenticator instance was found. + */ public static final String JAVA_NET_SOCKS_PASSWORD = "java.net.socks.password"; + /** + * On recent Windows systems and on Gnome 2.x systems it is possible to tell the java.net stack, + * setting this property to true, to use the system proxy settings. + */ public static final String JAVA_NET_USE_SYSTEM_PROXIES = "java.net.useSystemProxies"; + /** + * Value is an integer corresponding to the number of seconds + * successful name lookups will be kept in the cache. + */ public static final String NETWORK_ADDRESS_CACHE_TTL = "networkaddress.cache.ttl"; + /** + * Value is an integer corresponding to the number of seconds + * an unsuccessful name lookup will be kept in the cache. + */ public static final String NETWORK_ADDRESS_CACHE_NEGATIVE_TTL = "networkaddress.cache.negative.ttl"; - // JAX-B Properties - + /** + * The name of the property that contains the name of the class capable + * of creating new {@code JAXBContext} objects. + */ public static final String JAXB_CONTEXT_FACTORY = "jakarta.xml.bind.JAXBContextFactory"; + /** + * The name of the property used to specify the output encoding in + * the marshalled XML data. + */ public static final String JAXB_ENCODING = "jaxb.encoding"; + /** + * The name of the property used to specify whether or not the marshalled + * XML data is formatted with linefeeds and indentation. + */ public static final String JAXB_FORMATTED_OUTPUT = "jaxb.formatted.output"; + /** + * The name of the property used to specify the xsi:schemaLocation + * attribute value to place in the marshalled XML output. + */ public static final String JAXB_SCHEMA_LOCATION = "jaxb.schemaLocation"; + /** + * The name of the property used to specify the + * xsi:noNamespaceSchemaLocation attribute value to place in the marshalled + * XML output. + */ public static final String JAXB_NO_NAMESPACE_SCHEMA_LOCATION = "jaxb.noNamespaceSchemaLocation"; + /** + * The name of the property used to specify whether or not the marshaller + * will generate document level events (ie calling startDocument or endDocument). + */ public static final String JAXB_FRAGMENT = "jaxb.fragment"; - // JSON-B Properties - + /** + * Property used to specify whether or not the serialized + * JSON data is formatted with line feeds and indentation. + */ public static final String JSONB_FORMATTING = "jsonb.formatting"; + /** + * The Jsonb serialization {@code toJson()} methods will default to this property + * for encoding of output JSON data. Default value is 'UTF-8'. + * + * The Jsonb deserialization {@code fromJson()} methods will default to this + * property encoding of input JSON data if the encoding cannot be detected + * automatically. + */ public static final String JSONB_ENCODING = "jsonb.encoding"; + /** + * Property used to specify custom naming strategy. + */ public static final String JSONB_PROPERTY_NAMING_STRATEGY = "jsonb.property-naming-strategy"; + /** + * Property used to specify custom order strategy. + */ public static final String JSONB_PROPERTY_ORDER_STRATEGY = "jsonb.property-order-strategy"; + /** + * Property used to specify null values serialization behavior. + */ public static final String JSONB_NULL_VALUES = "jsonb.null-values"; + /** + * Property used to specify strict I-JSON serialization compliance. + */ public static final String JSONB_STRICT_IJSON = "jsonb.strict-ijson"; + /** + * Property used to specify custom visibility strategy. + */ public static final String JSONB_PROPERTY_VISIBILITY_STRATEGY = "jsonb.property-visibility-strategy"; + /** + * Property used to specify custom mapping adapters for generic types. + */ public static final String JSONB_ADAPTERS = "jsonb.adapters"; + /** + * Property used to specify custom serializers. + */ public static final String JSONB_SERIALIZERS = "jsonb.serializers"; + /** + * Property used to specify custom deserializers. + */ public static final String JSONB_DESERIALIZERS = "jsonb.derializers"; + /** + * Property used to specify custom binary data strategy. + */ public static final String JSONB_BINARY_DATA_STRATEGY = "jsonb.binary-data-strategy"; + /** + * Property used to specify custom date format globally. + */ public static final String JSONB_DATE_FORMAT = "jsonb.date-format"; + /** + * Property used to specify locale globally. + */ public static final String JSONB_LOCALE = "jsonb.locale"; /** From 3d8ce3d33c76ff97afb8f86380091da0e55b762f Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Wed, 14 Oct 2020 10:22:24 +0200 Subject: [PATCH 3/7] Add copyright Signed-off-by: tvallin --- .../org/glassfish/jersey/ExternalProperties.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java index 688a6ab914..ee219f9d9b 100644 --- a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java +++ b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + package org.glassfish.jersey; import org.glassfish.jersey.internal.util.PropertiesClass; From 0d8030e5f2ee8a8a5a0eec37f7e0b6c96dc7653b Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Mon, 19 Oct 2020 15:54:26 +0200 Subject: [PATCH 4/7] Tests for http proxy properties + clean up Signed-off-by: tvallin --- .../glassfish/jersey/ExternalProperties.java | 344 ------------------ tests/e2e-core-common/pom.xml | 7 +- .../e2e/common/TestExternalProperties.java | 112 ++++++ 3 files changed, 118 insertions(+), 345 deletions(-) create mode 100644 tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestExternalProperties.java diff --git a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java index ee219f9d9b..04ef1bd323 100644 --- a/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java +++ b/core-common/src/main/java/org/glassfish/jersey/ExternalProperties.java @@ -17,10 +17,6 @@ package org.glassfish.jersey; import org.glassfish.jersey.internal.util.PropertiesClass; -import org.glassfish.jersey.internal.util.PropertiesHelper; - -import javax.ws.rs.RuntimeType; -import java.util.Map; @PropertiesClass public final class ExternalProperties { @@ -41,350 +37,10 @@ public final class ExternalProperties { */ public static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts"; - /** - * Property used to define the string sent in the User-Agent - * request header in http requests. - */ - public static final String HTTP_AGENT = "http.agent"; - - /** - * Property used to indicates if persistent connections should be supported. - */ - public static final String HTTP_KEEPALIVE = "http.keepalive"; - - /** - * If HTTP keepalive is enabled this value determines - * the maximum number of idle connections that will be simultaneously - * kept alive, per destination. - */ - public static final String HTTP_MAX_CONNECTIONS = "http.maxConnections"; - - /** - * This integer value determines the maximum number, for a given request, - * of HTTP redirects that will be automatically followed by the protocol handler. - */ - public static final String HTTP_MAX_REDIRECTS = "http.maxRedirects"; - - /** - * Property used to enforce authentication with an origin. - */ - public static final String HTTP_AUTH_DIGEST_VALIDATE_SERVER = "http.auth.digest.validateServer"; - - /** - * Property used to enforce authentication with a proxy server. - */ - public static final String HTTP_AUTH_DIGEST_VALIDATE_PROXY = "http.auth.digest.validateProxy"; - - /** - * This property determines how many times a cnonce value is re-used. - */ - public static final String HTTP_AUTH_DIGEST_CNONCE_REPEAT = "http.auth.digest.cnonceRepeat"; - - /** - * NTLM is another authentication scheme. It uses the java.net.Authenticator class - * to acquire usernames and passwords when they are needed. - */ - public static final String HTTP_AUTH_NTLM_DOMAIN = "http.auth.ntlm.domain"; - - /** - * Property used to specify the hostname, or address, of the proxy server - * used by https protocol. - */ - public static final String HTTPS_PROXY_HOST = "https.ProxyHost"; - - /** - * Property used to specify the port number of the proxy server - * used by https protocol. - */ - public static final String HTTPS_PROXY_PORT = "https.ProxyPort"; - - /** - * Property used to specify the hostname, or address, of the proxy server - * used by the FTP protocol handler. - */ - public static final String FTP_PROXY_HOST = "ftp.proxyHost"; - - /** - * Property used to specify the port number of the proxy server - * used by the FTP protocol handler. - */ - public static final String FTP_PROXY_PORT = "ftp.proxyPort"; - - /** - * Property used by the FTP protocol handler to indicates the hosts - * that should be accessed without going through the proxy. - */ - public static final String FTP_NON_PROXY_HOSTS = "ftp.nonProxyHosts"; - - /** - * Property used to specify the hostname, or address, of the proxy server. - */ - public static final String SOCKS_PROXY_HOST = "socksProxyHost"; - - /** - * Property used to specify the port number of the proxy server. - */ - public static final String SOCKS_PROXY_PORT = "socksProxyPort"; - - /** - * Property used to specify the version of the SOCKS protocol - * supported by the server. - */ - public static final String SOCKS_PROXY_VERSION = "socksProxyVersion"; - - /** - * Username to use if the SOCKSv5 server asks for authentication - * and no java.net.Authenticator instance was found. - */ - public static final String JAVA_NET_SOCKS_USERNAME = "java.net.socks.username"; - - /** - * Password to use if the SOCKSv5 server asks for authentication - * and no java.net.Authenticator instance was found. - */ - public static final String JAVA_NET_SOCKS_PASSWORD = "java.net.socks.password"; - - /** - * On recent Windows systems and on Gnome 2.x systems it is possible to tell the java.net stack, - * setting this property to true, to use the system proxy settings. - */ - public static final String JAVA_NET_USE_SYSTEM_PROXIES = "java.net.useSystemProxies"; - - /** - * Value is an integer corresponding to the number of seconds - * successful name lookups will be kept in the cache. - */ - public static final String NETWORK_ADDRESS_CACHE_TTL = "networkaddress.cache.ttl"; - - /** - * Value is an integer corresponding to the number of seconds - * an unsuccessful name lookup will be kept in the cache. - */ - public static final String NETWORK_ADDRESS_CACHE_NEGATIVE_TTL = "networkaddress.cache.negative.ttl"; - - /** - * The name of the property that contains the name of the class capable - * of creating new {@code JAXBContext} objects. - */ - public static final String JAXB_CONTEXT_FACTORY = "jakarta.xml.bind.JAXBContextFactory"; - - /** - * The name of the property used to specify the output encoding in - * the marshalled XML data. - */ - public static final String JAXB_ENCODING = "jaxb.encoding"; - - /** - * The name of the property used to specify whether or not the marshalled - * XML data is formatted with linefeeds and indentation. - */ - public static final String JAXB_FORMATTED_OUTPUT = "jaxb.formatted.output"; - - /** - * The name of the property used to specify the xsi:schemaLocation - * attribute value to place in the marshalled XML output. - */ - public static final String JAXB_SCHEMA_LOCATION = "jaxb.schemaLocation"; - - /** - * The name of the property used to specify the - * xsi:noNamespaceSchemaLocation attribute value to place in the marshalled - * XML output. - */ - public static final String JAXB_NO_NAMESPACE_SCHEMA_LOCATION = "jaxb.noNamespaceSchemaLocation"; - - /** - * The name of the property used to specify whether or not the marshaller - * will generate document level events (ie calling startDocument or endDocument). - */ - public static final String JAXB_FRAGMENT = "jaxb.fragment"; - - /** - * Property used to specify whether or not the serialized - * JSON data is formatted with line feeds and indentation. - */ - public static final String JSONB_FORMATTING = "jsonb.formatting"; - - /** - * The Jsonb serialization {@code toJson()} methods will default to this property - * for encoding of output JSON data. Default value is 'UTF-8'. - * - * The Jsonb deserialization {@code fromJson()} methods will default to this - * property encoding of input JSON data if the encoding cannot be detected - * automatically. - */ - public static final String JSONB_ENCODING = "jsonb.encoding"; - - /** - * Property used to specify custom naming strategy. - */ - public static final String JSONB_PROPERTY_NAMING_STRATEGY = "jsonb.property-naming-strategy"; - - /** - * Property used to specify custom order strategy. - */ - public static final String JSONB_PROPERTY_ORDER_STRATEGY = "jsonb.property-order-strategy"; - - /** - * Property used to specify null values serialization behavior. - */ - public static final String JSONB_NULL_VALUES = "jsonb.null-values"; - - /** - * Property used to specify strict I-JSON serialization compliance. - */ - public static final String JSONB_STRICT_IJSON = "jsonb.strict-ijson"; - - /** - * Property used to specify custom visibility strategy. - */ - public static final String JSONB_PROPERTY_VISIBILITY_STRATEGY = "jsonb.property-visibility-strategy"; - - /** - * Property used to specify custom mapping adapters for generic types. - */ - public static final String JSONB_ADAPTERS = "jsonb.adapters"; - - /** - * Property used to specify custom serializers. - */ - public static final String JSONB_SERIALIZERS = "jsonb.serializers"; - - /** - * Property used to specify custom deserializers. - */ - public static final String JSONB_DESERIALIZERS = "jsonb.derializers"; - - /** - * Property used to specify custom binary data strategy. - */ - public static final String JSONB_BINARY_DATA_STRATEGY = "jsonb.binary-data-strategy"; - - /** - * Property used to specify custom date format globally. - */ - public static final String JSONB_DATE_FORMAT = "jsonb.date-format"; - - /** - * Property used to specify locale globally. - */ - public static final String JSONB_LOCALE = "jsonb.locale"; - /** * Prevent instantiation. */ private ExternalProperties() { } - /** - * Get the value of the specified property. - * - * If the property is not set or the actual property value type is not compatible with the specified type, the method will - * return {@code null}. - * - * @param properties Map of properties to get the property value from. - * @param propertyName Name of the property. - * @param type Type to retrieve the value as. - * @return Value of the property or {@code null}. - * - * @since 2.8 - */ - public static Object getValue(final Map properties, final String propertyName, final Class type) { - return PropertiesHelper.getValue(properties, propertyName, type, null); - } - - /** - * Get the value of the specified property. - * - * If the property is not set or the real value type is not compatible with {@code defaultValue} type, - * the specified {@code defaultValue} is returned. Calling this method is equivalent to calling - * {@code CommonProperties.getValue(properties, key, defaultValue, (Class<T>) defaultValue.getClass())} - * - * @param properties Map of properties to get the property value from. - * @param propertyName Name of the property. - * @param defaultValue Default value if property is not registered - * @param Type of the property value. - * @return Value of the property or {@code null}. - * - * @since 2.8 - */ - public static T getValue(final Map properties, final String propertyName, final T defaultValue) { - return PropertiesHelper.getValue(properties, propertyName, defaultValue, null); - } - - /** - * Get the value of the specified property. - * - * If the property is not set or the real value type is not compatible with {@code defaultValue} type, - * the specified {@code defaultValue} is returned. Calling this method is equivalent to calling - * {@code CommonProperties.getValue(properties, runtimeType, key, defaultValue, (Class<T>) defaultValue.getClass())} - * - * @param properties Map of properties to get the property value from. - * @param runtime Runtime type which is used to check whether there is a property with the same - * {@code key} but post-fixed by runtime type (.server - * or {@code .client}) which would override the {@code key} property. - * @param propertyName Name of the property. - * @param defaultValue Default value if property is not registered - * @param Type of the property value. - * @return Value of the property or {@code null}. - * - * @since 2.8 - */ - public static T getValue(final Map properties, - final RuntimeType runtime, - final String propertyName, - final T defaultValue) { - return PropertiesHelper.getValue(properties, runtime, propertyName, defaultValue, null); - } - - /** - * Get the value of the specified property. - * - * If the property is not set or the real value type is not compatible with the specified value type, - * returns {@code defaultValue}. - * - * @param properties Map of properties to get the property value from. - * @param runtime Runtime type which is used to check whether there is a property with the same - * {@code key} but post-fixed by runtime type (.server - * or {@code .client}) which would override the {@code key} property. - * @param propertyName Name of the property. - * @param defaultValue Default value if property is not registered - * @param type Type to retrieve the value as. - * @param Type of the property value. - * @return Value of the property or {@code null}. - * - * @since 2.8 - */ - public static T getValue(final Map properties, - final RuntimeType runtime, - final String propertyName, - final T defaultValue, - final Class type) { - return PropertiesHelper.getValue(properties, runtime, propertyName, defaultValue, type, null); - } - - /** - * Get the value of the specified property. - * - * If the property is not set or the actual property value type is not compatible with the specified type, the method will - * return {@code null}. - * - * @param properties Map of properties to get the property value from. - * @param runtime Runtime type which is used to check whether there is a property with the same - * {@code key} but post-fixed by runtime type (.server - * or {@code .client}) which would override the {@code key} property. - * @param propertyName Name of the property. - * @param type Type to retrieve the value as. - * @param Type of the property value. - * @return Value of the property or {@code null}. - * - * @since 2.8 - */ - public static T getValue(final Map properties, - final RuntimeType runtime, - final String propertyName, - final Class type) { - return PropertiesHelper.getValue(properties, runtime, propertyName, type, null); - } - } diff --git a/tests/e2e-core-common/pom.xml b/tests/e2e-core-common/pom.xml index 0957c5477f..f6c243a958 100644 --- a/tests/e2e-core-common/pom.xml +++ b/tests/e2e-core-common/pom.xml @@ -1,7 +1,7 @@ + + + 4.0.0 + + org.glassfish.jersey.tests.integration + project + 2.33-SNAPSHOT + + + externalproperties + jar + jersey-tests-externalproperties + + Jersey tests external properties + + + + junit + junit + test + + + org.glassfish.jersey.test-framework.providers + jersey-test-framework-provider-jetty + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestExternalProperties.java b/tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java similarity index 93% rename from tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestExternalProperties.java rename to tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java index e6f3d28d39..2590dcc218 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestExternalProperties.java +++ b/tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package org.glassfish.jersey.tests.e2e.common; +package org.glassfish.jersey.tests.externalproperties; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; @@ -23,6 +23,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import javax.servlet.http.HttpServletRequest; @@ -32,7 +33,7 @@ import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; -public class TestExternalProperties extends JerseyTest { +public class HttpProxyTest extends JerseyTest { private static final String PROXY_HOST = "localhost"; private static final String PROXY_PORT = "9997"; @@ -53,10 +54,19 @@ protected Application configure() { return new ResourceConfig(ProxyTestResource.class); } + @Before + public void startFakeProxy() { + Server server = new Server(Integer.parseInt(PROXY_PORT)); + server.setHandler(new ProxyHandler(false)); + try { + server.start(); + } catch (Exception e) { + + } + } + @Test public void testProxy() { - startFakeProxy(); - System.setProperty(ExternalProperties.HTTP_PROXY_HOST, PROXY_HOST); System.setProperty(ExternalProperties.HTTP_PROXY_PORT, PROXY_PORT); System.setProperty(ExternalProperties.HTTP_NON_PROXY_HOSTS, ""); @@ -68,8 +78,6 @@ public void testProxy() { @Test public void testNonProxy() { - startFakeProxy(); - System.setProperty(ExternalProperties.HTTP_PROXY_HOST, PROXY_HOST); System.setProperty(ExternalProperties.HTTP_PROXY_PORT, PROXY_PORT); System.setProperty(ExternalProperties.HTTP_NON_PROXY_HOSTS, "localhost"); @@ -81,16 +89,6 @@ public void testNonProxy() { Assert.assertFalse(proxyHit); } - private void startFakeProxy() { - Server server = new Server(9997); - server.setHandler(new ProxyHandler(false)); - try { - server.start(); - } catch (Exception e) { - - } - } - class ProxyHandler extends AbstractHandler { @Override public void handle(String target, diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml index b4ca6b9b93..a04360758c 100644 --- a/tests/integration/pom.xml +++ b/tests/integration/pom.xml @@ -40,6 +40,7 @@ ejb-multimodule ejb-multimodule-reload ejb-test-webapp + externalproperties j-376 j-441 j-59 From 1b30f63eb315efc399174fc501fd03acc6d2eb1f Mon Sep 17 00:00:00 2001 From: Thibault Vallin Date: Wed, 21 Oct 2020 17:26:08 +0200 Subject: [PATCH 6/7] remove changes on e2e-core-common pom.xml Signed-off-by: tvallin --- tests/e2e-core-common/pom.xml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/e2e-core-common/pom.xml b/tests/e2e-core-common/pom.xml index f6c243a958..0957c5477f 100644 --- a/tests/e2e-core-common/pom.xml +++ b/tests/e2e-core-common/pom.xml @@ -1,7 +1,7 @@