0

I had been using the following code snippet for OSGi tests in EclipseLink project with Pax Exam 3.3.0:

@Configuration
public static Option[] config() {
    return options(
            repositories("http://repo1.maven.org/maven2"),
            mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version("4.3.0"),
            mavenBundle().groupId("org.eclipse.persistence").artifactId("org.eclipse.persistence.asm")
                    .version("2.5.1"),
            //JAXB API
            bundle("file:" + PLUGINS_DIR + "javax.xml.bind_2.2.12.v201410011542.jar"),
            //WS API
            bundle("file:" + PLUGINS_DIR + "javax.ws.rs_1.1.1.v20101004-1200.jar"),
            //EclipseLink bundles
            bundle("file:" + PLUGINS_DIR + "org.eclipse.persistence.moxy_2.7.0." + QUALIFIER + ".jar"),
            bundle("file:" + PLUGINS_DIR + "org.eclipse.persistence.core_2.7.0." + QUALIFIER + ".jar"),
            bundle("file:" + PLUGINS_DIR + "org.eclipse.persistence.asm_5.0.1.v201405080102.jar"),

            junitBundles(),
            felix());
}

Now, we switched the build to JDK 8 and I am using Pax Exam 4.4.0, because Pax Exam 3.x does not build with JDK 8. My issue is that Pax Exam 4 no longer provides the convenient org.ops4j.pax.exam.CoreOptions.felix() method. How can I go around this issue? My goal is to run OSGi tests with the least configuration possible.

If I remove the felix() method, I get the following error:

Running org.eclipse.persistence.testing.osgi.OSGiBundleTest
[main] INFO org.ops4j.pax.exam.spi.DefaultExamSystem - Pax Exam System (Version: 4.4.0) created.
[main] INFO org.ops4j.pax.exam.junit.impl.ProbeRunner - creating PaxExam runner for class org.eclipse.persistence.testing.osgi.OSGiBundleTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.167 sec <<< FAILURE!
initializationError(org.eclipse.persistence.testing.osgi.OSGiBundleTest)  Time elapsed: 0.01 sec  <<< ERROR!
org.ops4j.pax.exam.TestContainerException: No service org.osgi.framework.launch.FrameworkFactory found in META-INF/services on classpath

Thanks

marcelv3612
  • 663
  • 4
  • 10

1 Answers1

3

felix() and other framework options have been deprecated a long time ago, well before Pax Exam 3.3.0, if I remember correctly, so I'm a bit surprised by your version information.

Anyway, if you want to run your tests on Felix, simply make sure that Felix is the only OSGi implementation on your classpath, and that's it. No need for an explicit option.

Harald Wellmann
  • 12,615
  • 4
  • 41
  • 63
  • Hi , I am facing the same issue i upgraded recently and now I had to remove felix(), but I am getting different error `org.ops4j.pax.exam.TestContainerException: No TestContainer implementation in Classpath` please help me. My OSGi version is 4.3.1 and Pax Exam 4.4.0 – Amrit Raj Jun 04 '20 at 10:30