diff --git a/bundles/tests/src/test/java/org/eclipse/persistence/testing/osgi/OSGITestHelper.java b/bundles/tests/src/test/java/org/eclipse/persistence/testing/osgi/OSGITestHelper.java index 56764f61638..2112153ea7f 100644 --- a/bundles/tests/src/test/java/org/eclipse/persistence/testing/osgi/OSGITestHelper.java +++ b/bundles/tests/src/test/java/org/eclipse/persistence/testing/osgi/OSGITestHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023 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 @@ -16,6 +16,9 @@ import org.ops4j.pax.exam.Option; +import java.net.MalformedURLException; +import java.nio.file.Path; + import static org.ops4j.pax.exam.CoreOptions.bundle; import static org.ops4j.pax.exam.CoreOptions.cleanCaches; import static org.ops4j.pax.exam.CoreOptions.junitBundles; @@ -41,10 +44,10 @@ public static Option[] getDefaultOptions() { return options( // JAXB API - bundle("file:" + PLUGINS_DIR + ACTIVATION_JAR), - bundle("file:" + PLUGINS_DIR + JAXB_API_JAR), + bundle(pathToUrl(PLUGINS_DIR + ACTIVATION_JAR)), + bundle(pathToUrl(PLUGINS_DIR + JAXB_API_JAR)), //JAXB_OSGI - bundle("file:" + PLUGINS_DIR + JAXB_OSGI), + bundle(pathToUrl(PLUGINS_DIR + JAXB_OSGI)), systemPackage("javax.rmi"), systemPackage("javax.rmi.CORBA"), @@ -52,12 +55,12 @@ public static Option[] getDefaultOptions() { systemPackage("org.omg.CORBA.portable"), systemPackage("org.omg.CORBA_2_3.portable"), // JAX-RS API - bundle("file:" + PLUGINS_DIR + JAXRS_JAR), + bundle(pathToUrl(PLUGINS_DIR + JAXRS_JAR)), // EclipseLink bundles - bundle("file:" + PLUGINS_DIR + "org.eclipse.persistence.moxy.jar"), - bundle("file:" + PLUGINS_DIR + "org.eclipse.persistence.core.jar"), - bundle("file:" + PLUGINS_DIR + ASM_JAR), + bundle(pathToUrl(PLUGINS_DIR + "org.eclipse.persistence.moxy.jar")), + bundle(pathToUrl(PLUGINS_DIR + "org.eclipse.persistence.core.jar")), + bundle(pathToUrl(PLUGINS_DIR + ASM_JAR)), cleanCaches(), junitBundles()); @@ -87,4 +90,12 @@ public static Option[] getOptionsWithBeanValidation() { junitBundles() ); } + + private static String pathToUrl(String path) { + try { + return Path.of(path).toUri().toURL().toExternalForm(); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } }