OSGi testing with Pax-Exam Fails with "no container found error".
This happened because I upgraded form java 7 to java 8 and with that I had to change pax-exam-2.3.0.jar (which is not compatible with java 8) to pax-exam-4.4.0.jar. And their other dependency. Earlier in config we used to write felix() but that is changed now.
How to start felix container now?
Config:
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class GibsonMiniAGLTest
{
@Configuration
public Option[] config() {
return options(
vmOption("-Dcom.sun.management.jmxremote"),
systemPackages("sun.misc",
"sun.security.util",
"sun.security.x509",
"com.sun.media.imageioimpl.plugins.jpeg2000"
),
bootDelegationPackages(
"sun.misc.*",
"com.sun.*"
),
bundle("abc.jar"),
junitBundles()
);
}
}
Ant File:
<target name="run_STOSGI">
<property file="build/jamunTimeOut.properties"/>
<echo message="Calculated TimeOut for Jamun_Tests in MilliSeconds = ..........." />
<echo message="${timeout}" />
<junit printsummary="yes" showoutput="yes" timeout="${timeout}" haltonfailure="on" maxmemory="256M" fork="on">
<jvmarg value="-Dorg.xml.sax.driver=${saxParser}" />
<classpath>
<pathelement path="${jamun.path}" />
<pathelement path="${junit.path}" />
<pathelement path="${jar}/core.jar" />
</classpath>
<formatter type="xml" />
<sysproperty key="BAT_PLUGIN" value="${BAT_PLUGIN}"/>
<test name="com.adobe.gibsontests.SmokeTestOSGIosgi" />
</junit>
<move todir="${smokeTest_Location}" failonerror="false" overwrite="true" >
<fileset dir="${smoketest_temp}"/>
</move>
</target>
Stack trace:
<testcase classname="com.adobe.gibsontests.SmokeTestOSGIosgi" name="initializationError" time="0.004">
<error message="No TestContainer implementation in Classpath" type="org.ops4j.pax.exam.TestContainerException">org.ops4j.pax.exam.TestContainerException: No TestContainer implementation in Classpath
at org.ops4j.pax.exam.spi.PaxExamRuntime.sanityCheck(PaxExamRuntime.java:266)
at org.ops4j.pax.exam.spi.PaxExamRuntime.getTestContainerFactory(PaxExamRuntime.java:79)
at org.ops4j.pax.exam.spi.reactors.ReactorManager.createsTestContainerFactory(ReactorManager.java:325)
at org.ops4j.pax.exam.spi.reactors.ReactorManager.createReactor(ReactorManager.java:302)
at org.ops4j.pax.exam.spi.reactors.ReactorManager.prepareReactor(ReactorManager.java:181)
at org.ops4j.pax.exam.junit.impl.ProbeRunner.<init>(ProbeRunner.java:78)
at org.ops4j.pax.exam.junit.PaxExam.createDelegate(PaxExam.java:82)
at org.ops4j.pax.exam.junit.PaxExam.<init>(PaxExam.java:73)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
Can somebody point out what I am missing?
I tried running pax-exam in standalone and it failed there too with error: org.ops4j.pax.exam.TestContainerException: No service org.osgi.framework.launch.FrameworkFactory found in META-INF/services on classpath