0

I'm aware of this answer: Pax Exam: provisioning bundle with all dependencies But it feels like I'm doing something wrong when I have to include bundles that are part of bundles that are external to my project.

Here is the error I'm getting:

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)))

Here is my configuration code for my pax exam test:

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

So my questions are: why am I getting the error about unresolved constraints, do I have to include even external bundles, and what do I need to do to get my tests to run?

4

1 回答 1

1

是的,你必须包含所有必需的包,Karaf 容器是空的,你必须提供测试中需要的所有包。

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

KarafDistributionOption.features("mvn:group/artifact-id/version/xml", "feature-name")
于 2015-02-06T19:37:28.123 回答