0

我正在尝试为我的包创建集成测试。基本上我想模仿我在普通网络应用程序项目中的设置(其中测试在 src/test 文件夹中)

我几乎就在那里,只是当捆绑包尝试激活时出现异常

本机容器异常

Running com.grundfos.wcm.impl.HelloWorldServiceImplIntegrationTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.196 sec <<< FAILURE! - in    com.grundfos.wcm.impl.HelloWorldServiceImplIntegrationTest
whenSuppliedNullNameThenThrowException(com.grundfos.wcm.impl.HelloWorldServiceImplIntegrationTest)       Time elapsed: 0.792 sec  <<< ERROR!
java.lang.AbstractMethodError: org.apache.felix.framework.BundleImpl.adapt(Ljava/lang/Class;)Ljava/lang/Object; at org.ops4j.pax.exam.nat.internal.NativeTestContainer.installAndStartBundles(NativeTestContainer.java:311)
at org.ops4j.pax.exam.nat.internal.NativeTestContainer.start(NativeTestContainer.java:177)
at org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:79)
at org.ops4j.pax.exam.junit.impl.ProbeRunner$2.evaluate(ProbeRunner.java:264)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
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:264)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

分叉容器异常

java.lang.ClassCastException: org.ops4j.pax.exam.inject.internal.Activator cannot be cast to org.osgi.framework.BundleActivator
    at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3814)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1899)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1822)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
    at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
    at java.lang.Thread.run(Thread.java:745)
java.lang.ClassCastException: org.ops4j.pax.exam.raw.extender.intern.Activator cannot be cast to org.osgi.framework.BundleActivator

我尝试向他们的官方 JIRA 委员会提交,但我无权这样做:

https://ops4j1.jira.com/browse/PAXEXAM/fixforversion/12880/?selectedTab=com.atlassian.jira.jira-projects-plugin:version-issues-panel

有人可以帮我解决我的问题吗?我已经走到尽头了:(

示例项目(如果项目文件不起作用,请告诉我):

http://www.mediafire.com/download/qnh2gzgygys9982/cq-training.zip

命令: mvn clean 验证

谢谢

4

2 回答 2

0

想要关注这个问题的朋友,请到他们的官方谷歌群组页面:

https://groups.google.com/forum/#!topic/ops4j/g43cPidOvng

发布的 JIRA 问题:

https://ops4j1.jira.com/browse/PAXRUNNER-443?filter=-2

于 2014-06-26T08:08:16.920 回答
0

看起来您的类路径上的 OSGi Core API 版本存在冲突。在运行时,您的 OSGi 框架(Felix 或 Equinox)应该是类路径上的唯一核心 API。

如果您有其他版本,例如org.osgi:org.osgi.core(传递)依赖项,请确保为其提供provided范围或排除依赖项。

于 2014-06-20T12:24:29.737 回答