Skip to content

Commit e84b5e8

Browse files
jansupolsenivam
authored andcommitted
Fix OSGi tests on JDK 17
Signed-off-by: jansupol <[email protected]>
1 parent 7212b01 commit e84b5e8

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

examples/osgi-helloworld-webapp/functional-test/src/test/java/org/glassfish/jersey/examples/helloworld/test/AbstractWebAppTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -122,6 +122,11 @@ public List<Option> genericOsgiOptions() {
122122

123123
// do not remove the following line
124124
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("FINEST"),
125+
126+
JdkVersion.getJdkVersion().getMajor() > 16
127+
? vmOption("--add-opens=java.base/java.net=ALL-UNNAMED")
128+
: null,
129+
125130
// uncomment the following 4 lines should you need to debug from th felix console
126131
// mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.runtime").version(gogoVersion),
127132
// mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.shell").version(gogoVersion),

examples/osgi-http-service/functional-test/src/test/java/org/glassfish/jersey/examples/osgihttpservice/test/AbstractHttpServiceTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -47,6 +47,7 @@
4747
import static org.ops4j.pax.exam.CoreOptions.options;
4848
import static org.ops4j.pax.exam.CoreOptions.systemPackage;
4949
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
50+
import static org.ops4j.pax.exam.CoreOptions.vmOption;
5051

5152
/**
5253
* @author Jakub Podlesak
@@ -86,6 +87,10 @@ public List<Option> genericOsgiOptions() {
8687
systemProperty("jersey.config.test.container.port").value(String.valueOf(port)),
8788
systemProperty("org.osgi.framework.system.packages.extra").value("jakarta.annotation"),
8889

90+
JdkVersion.getJdkVersion().getMajor() > 16
91+
? vmOption("--add-opens=java.base/java.net=ALL-UNNAMED")
92+
: null,
93+
8994
// do not remove the following line
9095
// systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("FINEST"),
9196

tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/PackageScanningTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,6 +27,8 @@
2727

2828
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
2929
import org.glassfish.jersey.grizzly2.servlet.GrizzlyWebContainerFactory;
30+
import org.glassfish.jersey.internal.Version;
31+
import org.glassfish.jersey.internal.util.JdkVersion;
3032
import org.glassfish.jersey.osgi.test.util.Helper;
3133
import org.glassfish.jersey.server.ResourceConfig;
3234
import org.glassfish.jersey.server.ServerProperties;
@@ -41,10 +43,9 @@
4143
import org.ops4j.pax.exam.junit.PaxExam;
4244
import static org.junit.Assert.assertEquals;
4345
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
46+
import static org.ops4j.pax.exam.CoreOptions.vmOption;
4447

4548
/**
46-
* NOTE: This test is excluded on JDK6 as it requires Servlet 3.1 API that is built against JDK 7.
47-
*
4849
* @author Jakub Podlesak
4950
* @author Michal Gajdos
5051
*/
@@ -64,6 +65,9 @@ public static Option[] configuration() {
6465

6566
options.addAll(Helper.expandedList(
6667
// vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
68+
JdkVersion.getJdkVersion().getMajor() > 16
69+
? vmOption("--add-opens=java.base/java.net=ALL-UNNAMED")
70+
: null,
6771

6872
mavenBundle().groupId("org.glassfish.jersey.media").artifactId("jersey-media-sse").versionAsInProject(),
6973

0 commit comments

Comments
 (0)