使用 OSGi R6 框架(Equinox 3.10.x、Felix 4.6.x)的 Pax Exam 测试失败

Pax Exam tests fail with OSGi R6 frameworks (Equinox 3.10.x, Felix 4.6.x)

我使用 Equinox 3.10.1.v20140909-1633 和 Felix 4.6.1 将我的构建迁移到 OSGi R6。不幸的是,Pax Exam 测试在这两个框架中都失败了。我正在使用 Pax 考试 4.4.0.

在 Equinox 3.10.1.v20140909-1633 上执行的测试:

org.osgi.framework.BundleException: Error while renaming bundle file to final location: C:\Temp28560128319-0\org.eclipse.osgi[=12=]\bundleFile
        at org.eclipse.osgi.storage.Storage.getContentFile0(Storage.java:765)
        at org.eclipse.osgi.storage.Storage.getContentFile(Storage.java:741)
        at org.eclipse.osgi.storage.Storage.install(Storage.java:506)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:146)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:139)
        at org.ops4j.pax.swissbox.framework.RemoteFrameworkImpl.installBundle(RemoteFrameworkImpl.java:120)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
        at sun.rmi.transport.Transport.run(Transport.java:178)
        at sun.rmi.transport.Transport.run(Transport.java:175)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
        at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
        at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
        at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
        at com.sun.proxy.$Proxy8.installBundle(Unknown Source)
        at org.ops4j.pax.exam.forked.ForkedTestContainer.installAndStartBundles(ForkedTestContainer.java:282)
        at org.ops4j.pax.exam.forked.ForkedTestContainer.start(ForkedTestContainer.java:165)
        at org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:79)
        at org.ops4j.pax.exam.junit.impl.ProbeRunner.evaluate(ProbeRunner.java:267)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access[=12=]0(ParentRunner.java:53)
        at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:98)
        at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

在 Felix 4.6.1 上执行的测试:

ERROR: Error reloading cached bundle, removing it: C:\TEMP28560514273-0\bundle1 (java.io.FileNotFoundException: C:\TEMP28560514273-0\bundle1\bundle.location (Das System kann
die angegebene Datei nicht finden))
java.io.FileNotFoundException: C:\TEMP28560514273-0\bundle1\bundle.location (Das System kann die angegebene Datei nicht finden)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at org.apache.felix.framework.util.SecureAction.getFileInputStream(SecureAction.java:453)
        at org.apache.felix.framework.cache.BundleArchive.readLocation(BundleArchive.java:1107)
        at org.apache.felix.framework.cache.BundleArchive.readBundleInfo(BundleArchive.java:973)
        at org.apache.felix.framework.cache.BundleArchive.<init>(BundleArchive.java:182)
        at org.apache.felix.framework.cache.BundleCache.getArchives(BundleCache.java:247)
        at org.apache.felix.framework.Felix.init(Felix.java:754)
        at org.apache.felix.framework.Felix.init(Felix.java:624)
        at org.ops4j.pax.swissbox.framework.RemoteFrameworkImpl.init(RemoteFrameworkImpl.java:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
        at sun.rmi.transport.Transport.run(Transport.java:178)
        at sun.rmi.transport.Transport.run(Transport.java:175)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

我恢复了更改并使用 Equinox 3.9.1.v20130814-1242 和 Felix 4.4.1 使用 OSGi R5 执行了 Pax Exam 测试。一切都按预期进行。

Pax 考试是否存在 OSGi R6 框架实施方面的问题?

更新

我正在使用 @ExamReactorStrategy(PerMethod.class),除第一个外,所有 运行 都失败了。第一个 运行 总是成功。我已经尝试了 keepCachescleanCaches 选项,但没有帮助。为什么问题只出现在 R6 框架实现中?是否有修复或解决方法?

问题被跟踪为 PAXEXAM-701。将在 Pax 考试 4.5.0 中修复。