Question

did someone ever tried to run PaxExam Junit tests with Bndtools and can give me some advices? I've tried it by myself, but without Maven it's a pain to download all the dependencies.

What I've done so far:

  1. Download PaxExam dependencies from Central Maven (are there any more easier ways?)
  2. Create property containing all dependencies in cnf/bnd.bnd
  3. Add property to buildpath where I want to write tests
  4. Executing tests fails, bc more dependencies are missing so back to 1. :D

I want to use PaxExam, bc its easier to use with Ant Junit task as the Integration Test of Bndtools since they only produce test reports but they are not really "Junit Tests".

Later scenario:

  1. Building projects with Hudson and Ant
  2. Hudson should also execute Junit Ant Task where failed tests should stop the building process as well

The above scenario already works with normal Junit4 tests without running an OSGi environment, but now I want to do integretion tests.

Can someone help me?

Greetings.

Was it helpful?

Solution

Even though you don't use Maven for building your project, you can still use it to download maven-artifacts and their transitive dependencies. To do this, you first have to install Maven. Then, you create an empty directory, and inside that directory, you create a file called pom.xml. For Pax Exam, this should look like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <properties>
        <exam.version>2.5.0</exam.version>
        <url.version>1.4.2</url.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-container-native</artifactId>
            <version>${exam.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-junit4</artifactId>
            <version>${exam.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-link-mvn</artifactId>
            <version>${exam.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-aether</artifactId>
            <version>${url.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <version>3.2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.29</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.29</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

I have taken the list of dependencies from the Pax Exam documentation. Then, you open the command-line, navigate to the directory in which you created your pom.xml, and execute the following command:

mvn dependencies:copy-dependencies

(this assumes that you have installed Maven such that the command mvn is available form the command-line). Now maven will fetch all transitive dependencies of the dependencies you have specified in the pom.xml, and store them in target/dependency by default.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top