【问题标题】:Pax-exam 4 no felix() methodPax-exam 4 没有 felix() 方法
【发布时间】:2015-06-30 11:52:50
【问题描述】:

我一直在使用 Pax Exam 3.3.0 在 EclipseLink 项目中使用以下代码 sn-p 进行 OSGi 测试:

@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());
}

现在,我们将构建切换到 JDK 8,我正在使用 Pax Exam 4.4.0,因为 Pax Exam 3.x 不使用 JDK 8 构建。我的问题是 Pax Exam 4 不再提供方便的 org.ops4j .pax.exam.CoreOptions.felix() 方法。我该如何解决这个问题?我的目标是以尽可能少的配置运行 OSGi 测试。

如果我删除 felix() 方法,我会收到以下错误:

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

谢谢

【问题讨论】:

    标签: java maven osgi pax-exam


    【解决方案1】:

    felix() 和其他框架选项很久以前就被弃用了,如果我没记错的话,早在 Pax Exam 3.3.0 之前,所以我对你的版本信息有点惊讶。

    无论如何,如果您想在 Felix 上运行测试,只需确保 Felix 是您的类路径上唯一的 OSGi 实现,仅此而已。不需要明确的选项。

    【讨论】:

    • 嗨,我最近升级时遇到了同样的问题,现在我不得不删除 felix(),但我得到了不同的错误org.ops4j.pax.exam.TestContainerException: No TestContainer implementation in Classpath 请帮助我。我的 OSGi 版本是 4.3.1 和 Pax Exam 4.4.0
    猜你喜欢
    • 2012-08-23
    • 2015-03-22
    • 2016-02-28
    • 2012-08-06
    • 2012-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    相关资源
    最近更新 更多