FELIX-1735 provide bundle jar file name to the integration tests with a
system property and fall back to fixed name "target/scr.jar" if the
property is not set. Add "ide" build profile to generate the target/scr.jar
file in the package phase to run the integration tests from within the
IDE.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@824244 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/pom.xml b/scr/pom.xml
index a5ea855..9440163 100644
--- a/scr/pom.xml
+++ b/scr/pom.xml
@@ -36,6 +36,34 @@
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/scr</developerConnection>
<url>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/scr</url>
</scm>
+
+ <!--
+ A Note on Testing
+ =================
+
+ This project contains two kinds of tests: regular unit tests running
+ in the test phase and integration tests based on PAX Exam running
+ in the integration-test phase.
+
+ Basically the complete project is build using Java 1.3 source and target
+ compatibility (as inherited from the parent pom). The exception are the
+ unit tests in the "integration" packages. These have to be compiled with
+ Java 5 source and target compatibility because the employ annotations
+ and generics.
+
+ For running the integration tests from the console using Maven nothing
+ special has to be done as the tests run automatically. To run the tests
+ in your IDE, the project has to be built to the "package" phase with
+ the profile "ide" enabled:
+
+ $ mvn -Pide clean package
+
+ This creates the scr.jar file in the target folder, which is used by
+ the integration tests when run from the IDE. Alternatively the
+ "project.bundle.file" system property may be set to the bundle JAR
+ in the IDE launcher.
+ -->
+
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
@@ -180,38 +208,6 @@
</configuration>
</plugin>
- <!-- Provide bundle for integration tests -->
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.3</version>
- <executions>
- <execution>
- <id>configadmin-file-create</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <copy file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/scr.jar" />
- </tasks>
- </configuration>
- </execution>
- <execution>
- <id>configadmin-file-remove</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <delete file="${project.build.directory}/configadmin.jar" />
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
<!--
Exclude Integration tests in (default) unit tests and
conversely enable integration tests for integration testing
@@ -227,6 +223,12 @@
<goal>test</goal>
</goals>
<configuration>
+ <systemProperties>
+ <property>
+ <name>project.bundle.file</name>
+ <value>${project.build.directory}/${project.build.finalName}.jar</value>
+ </property>
+ </systemProperties>
<excludes>
<exclude>**/components/**</exclude>
</excludes>
@@ -247,7 +249,40 @@
</plugin>
</plugins>
</build>
-
+
+ <profiles>
+ <!--
+ copy the package such that IDEs may easily use it without
+ setting the system property
+ -->
+ <profile>
+ <id>ide</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>scr-file-create</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy file="${project.build.directory}/${project.build.finalName}.jar"
+ tofile="${project.build.directory}/scr.jar" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<!-- repositories for Pax Exam and BND tool -->
<repositories>
<repository>
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
index 7b4350f..963530d 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
@@ -67,6 +67,12 @@
protected ServiceTracker configAdminTracker;
+ // the name of the system property providing the bundle file to be installed and tested
+ protected static final String BUNDLE_JAR_SYS_PROP = "project.bundle.file";
+
+ // the default bundle jar file name
+ protected static final String BUNDLE_JAR_DEFAULT = "target/scr.jar";
+
protected static final String PROP_NAME = "theValue";
protected static final Dictionary<String, String> theConfig;
@@ -91,9 +97,17 @@
@Configuration
public static Option[] configuration()
{
+ final String bundleFileName = System.getProperty( BUNDLE_JAR_SYS_PROP, BUNDLE_JAR_DEFAULT );
+ final File bundleFile = new File( bundleFileName );
+ if ( !bundleFile.canRead() )
+ {
+ throw new IllegalArgumentException( "Cannot read from bundle file " + bundleFileName + " specified in the "
+ + BUNDLE_JAR_SYS_PROP + " system property" );
+ }
+
final Option[] base = options(
provision(
- CoreOptions.bundle( new File("target/scr.jar").toURI().toString() ),
+ CoreOptions.bundle( bundleFile.toURI().toString() ),
mavenBundle( "org.ops4j.pax.swissbox", "pax-swissbox-tinybundles", "1.0.0" ),
mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", "1.0.10" )
)