felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r824244 - in /felix/trunk/scr: pom.xml src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
Date Mon, 12 Oct 2009 07:16:08 GMT
Author: fmeschbe
Date: Mon Oct 12 07:16:08 2009
New Revision: 824244

URL: http://svn.apache.org/viewvc?rev=824244&view=rev
Log:
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.

Modified:
    felix/trunk/scr/pom.xml
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java

Modified: felix/trunk/scr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/pom.xml?rev=824244&r1=824243&r2=824244&view=diff
==============================================================================
--- felix/trunk/scr/pom.xml (original)
+++ felix/trunk/scr/pom.xml Mon Oct 12 07:16:08 2009
@@ -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>

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=824244&r1=824243&r2=824244&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
Mon Oct 12 07:16:08 2009
@@ -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"
)
              )



Mime
View raw message