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?

Community
  • 1
  • 1
Hardy
  • 477
  • 9
  • 19

1 Answers1

1

Yes, you have to include all required bundles, Karaf container is running empty, you have to provide all bundles required in your test.

You can create a feature for the module you want to test as a way to supply all required bundles. Then you can use it in your test, e.g:

KarafDistributionOption.features("mvn:group/artifact-id/version/xml", "feature-name")
carlosvin
  • 979
  • 9
  • 22
  • I had to add a /features after the /xml to get it to pick up my local features project. I also had to include multiple "feature-name" strings since each project has multiple sub projects. – Hardy Feb 12 '15 at 17:06