Add Apache5 properties to be grabbed by config (#5536)
* Add Apache5 properties to be grabbed by config
Signed-off-by: jansupol <jan.supol@oracle.com>
diff --git a/core-common/src/main/java/org/glassfish/jersey/internal/config/JerseySystemPropertiesConfigurationModel.java b/core-common/src/main/java/org/glassfish/jersey/internal/config/JerseySystemPropertiesConfigurationModel.java
index 4d9606b..78a628d 100644
--- a/core-common/src/main/java/org/glassfish/jersey/internal/config/JerseySystemPropertiesConfigurationModel.java
+++ b/core-common/src/main/java/org/glassfish/jersey/internal/config/JerseySystemPropertiesConfigurationModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2024 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
@@ -29,6 +29,7 @@
"org.glassfish.jersey.servlet.ServletProperties",
"org.glassfish.jersey.message.MessageProperties",
"org.glassfish.jersey.apache.connector.ApacheClientProperties",
+ "org.glassfish.jersey.apache5.connector.Apache5ClientProperties",
"org.glassfish.jersey.helidon.connector.HelidonClientProperties",
"org.glassfish.jersey.jdk.connector.JdkConnectorProperties",
"org.glassfish.jersey.jetty.connector.JettyClientProperties",
diff --git a/tests/integration/property-check/pom.xml b/tests/integration/property-check/pom.xml
index 49bb960..40d35e9 100644
--- a/tests/integration/property-check/pom.xml
+++ b/tests/integration/property-check/pom.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2014, 2023 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2014, 2024 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
@@ -73,6 +73,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.glassfish.jersey.connectors</groupId>
+ <artifactId>jersey-apache5-connector</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.glassfish.jersey.security</groupId>
<artifactId>oauth1-server</artifactId>
<version>${project.version}</version>
@@ -108,28 +113,4 @@
</plugin>
</plugins>
</build>
-
- <profiles>
- <profile>
- <id>jdk19+</id>
- <activation>
- <jdk>[19,)</jdk>
- </activation>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/SystemPropertiesConfigurationModelTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- </profile>
- </profiles>
</project>
diff --git a/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java b/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java
index ddb8e08..916bf81 100644
--- a/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java
+++ b/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2024 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
@@ -32,6 +32,7 @@
import org.glassfish.jersey.CommonProperties;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
+import org.glassfish.jersey.apache5.connector.Apache5ClientProperties;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.internal.InternalProperties;
import org.glassfish.jersey.internal.util.JdkVersion;
@@ -79,8 +80,13 @@
@Test
public void propertyLoadedWhenSecurityException() {
final String TEST_STRING = "test";
- SecurityManager sm = System.getSecurityManager();
- String policy = System.getProperty("java.security.policy");
+ final boolean isSm = JdkVersion.getJdkVersion().getMajor() < 19;
+ SecurityManager sm = null;
+ String policy = null;
+ if (isSm) {
+ sm = System.getSecurityManager();
+ policy = System.getProperty("java.security.policy");
+ }
try {
System.setProperty(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, Boolean.TRUE.toString());
System.setProperty(ServerProperties.APPLICATION_NAME, TEST_STRING);
@@ -88,15 +94,20 @@
System.setProperty(ServletProperties.JAXRS_APPLICATION_CLASS, TEST_STRING);
System.setProperty(MessageProperties.IO_BUFFER_SIZE, TEST_STRING);
System.setProperty(ApacheClientProperties.DISABLE_COOKIES, TEST_STRING);
+ System.setProperty(Apache5ClientProperties.DISABLE_COOKIES, TEST_STRING);
System.setProperty(JettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATION, TEST_STRING);
System.setProperty(MultiPartProperties.TEMP_DIRECTORY, TEST_STRING);
System.setProperty(OAuth1ServerProperties.REALM, TEST_STRING);
JerseySystemPropertiesConfigurationModel model = new JerseySystemPropertiesConfigurationModel();
assertTrue(model.as(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, Boolean.class));
- String securityPolicy = SystemPropertiesConfigurationModelTest.class.getResource("/server.policy").getFile();
- System.setProperty("java.security.policy", securityPolicy);
- SecurityManager manager = new SecurityManager();
- System.setSecurityManager(manager);
+
+ if (isSm) {
+ String securityPolicy = SystemPropertiesConfigurationModelTest.class.getResource("/server.policy").getFile();
+ System.setProperty("java.security.policy", securityPolicy);
+ SecurityManager manager = new SecurityManager();
+ System.setSecurityManager(manager);
+ }
+
Map<String, Object> properties = model.getProperties();
assertEquals(TEST_STRING, properties.get(ServerProperties.APPLICATION_NAME));
assertEquals(Boolean.TRUE.toString(), properties.get(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER));
@@ -109,7 +120,9 @@
assertEquals(TEST_STRING, properties.get(MessageProperties.IO_BUFFER_SIZE));
assertFalse(properties.containsKey(MessageProperties.DEFLATE_WITHOUT_ZLIB));
assertEquals(TEST_STRING, properties.get(ApacheClientProperties.DISABLE_COOKIES));
+ assertEquals(TEST_STRING, properties.get(Apache5ClientProperties.DISABLE_COOKIES));
assertFalse(properties.containsKey(ApacheClientProperties.CONNECTION_MANAGER));
+ assertFalse(properties.containsKey(Apache5ClientProperties.CONNECTION_MANAGER));
assertEquals(TEST_STRING, properties.get(JettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATION));
assertFalse(properties.containsKey(JettyClientProperties.DISABLE_COOKIES));
assertEquals(TEST_STRING, properties.get(MultiPartProperties.TEMP_DIRECTORY));
@@ -120,7 +133,9 @@
if (policy != null) {
System.setProperty("java.security.policy", policy);
}
- System.setSecurityManager(sm);
+ if (isSm) {
+ System.setSecurityManager(sm);
+ }
}
}