Pax考试:使用包和包装捆绑包解决项目依赖性

时间:2015-02-04 23:18:50

标签: pax-exam

我知道这个答案:Pax Exam: provisioning bundle with all dependencies 但是,当我必须包含属于我项目外部的捆绑包的捆绑包时,我觉得我做错了。

以下是我遇到的错误:

java.lang.Exception: Could not start bundle wrap:mvn:org.apache.cxf/cxf-bundle-jaxrs/2.7.14 in feature(s) test-dependencies-0.0.0: Unresolved constraint in bundle org.apache.cxf.bundle-jaxrs [80]: Unable to resolve 80.0: missing requirement [80.0] osgi.wiring.package; (&(osgi.wiring.package=com.ctc.wstx.stax)(version>=4.4.0)(!(version>=5.0.0)))

以下是我的pax考试测试的配置代码:

@Configuration
public Option[] config() {
    MavenArtifactUrlReference karafUrl = maven()
        .groupId("org.apache.karaf")
        .artifactId("apache-karaf")
        .version(karafVersion())
        .type("tar.gz");
    MavenUrlReference karafStandardRepo = maven()
        .groupId("org.apache.karaf.features")
        .artifactId("standard")
        .classifier("features")
        .version(karafVersion())
        .type("xml");
    return new Option[] {
        // KarafDistributionOption.debugConfiguration("5005", true),
        karafDistributionConfiguration()
            .frameworkUrl(karafUrl)
            .unpackDirectory(new File("target/exam"))
            .useDeployFolder(false),
        keepRuntimeFolder(),
        KarafDistributionOption.features(karafStandardRepo , "scr"),

        //**Do I seriously need to do this?**
        wrappedBundle(mavenBundle("org.codehaus.woodstox", "wstx-lgpl")).noStart(),
        //**Why am I doing this?**
        wrappedBundle(mavenBundle("org.apache.cxf", "cxf-bundle-jaxrs").version("2.7.14")).noStart(),
        //**Some of my bundles use this so I guess this makes sense**
        wrappedBundle(mavenBundle("org.apache.commons", "commons-lang3")),
        mavenBundle("com.company.project", "common-core").versionAsInProject().start(),
        mavenBundle("com.company.project", "common-properties", "1.3.1").start(),
        mavenBundle("com.company.project", "rev-common-core", "1.3.1").start(),
        mavenBundle("com.company.project", "rev-common-properties", "1.3.1").start(),
        mavenBundle("com.company.project", "maintenance-core", "1.3.1").start(),
   };
}

所以我的问题是:为什么我得到关于未解决的约束的错误,我是否必须包括外部包,以及我需要做什么才能让我的测试运行?

1 个答案:

答案 0 :(得分:1)

是的,您必须包含所有必需的捆绑包,Karaf容器运行为空,您必须提供测试中所需的所有捆绑包。

您可以为要测试的模块创建一个功能,以提供所有必需的捆绑包。然后你可以在你的测试中使用它,例如:

KarafDistributionOption.features("mvn:group/artifact-id/version/xml", "feature-name")
相关问题