incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1075415 - in /sling/trunk/testing/samples/integration-tests: pom.xml src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
Date Mon, 28 Feb 2011 16:40:50 GMT
Author: bdelacretaz
Date: Mon Feb 28 16:40:50 2011
New Revision: 1075415

URL: http://svn.apache.org/viewvc?rev=1075415&view=rev
Log:
SLING-2001 - install additional bundles in a defined order, to make sure they all start

Modified:
    sling/trunk/testing/samples/integration-tests/pom.xml
    sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java

Modified: sling/trunk/testing/samples/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/pom.xml?rev=1075415&r1=1075414&r2=1075415&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/pom.xml (original)
+++ sling/trunk/testing/samples/integration-tests/pom.xml Mon Feb 28 16:40:50 2011
@@ -97,9 +97,9 @@
                     </execution>
                     <execution>
                         <!-- 
-                            Consider all "provided" dependencies 
-                            as additional bundles that need to be
-                            installed before running tests  
+                            Consider all dependencies as candidates to be installed
+                            as additional bundles. We use system properties to define
+                            which bundles to install in which order.  
                         -->
                         <id>copy-additional-bundles</id>
                         <goals>
@@ -108,9 +108,6 @@
                             <phase>process-resources</phase>
                         <configuration>
                             <outputDirectory>${project.build.directory}/sling/additional-bundles</outputDirectory>
-                            <includeArtifactIds>
-                                org.apache.sling.junit.core,org.apache.sling.testing.samples.sampletests,org.apache.sling.junit.core,org.apache.sling.testing.samples.failingtests,org.apache.sling.junit.scriptable,org.apache.sling.junit.remote
-                            </includeArtifactIds>
                             <excludeTransitive>true</excludeTransitive>
                             <overWriteReleases>false</overWriteReleases>
                             <overWriteSnapshots>false</overWriteSnapshots>
@@ -155,6 +152,17 @@
                         <server.ready.path.1>/:script src="system/sling.js"</server.ready.path.1>
                         <server.ready.path.2>/.explorer.html:href="/libs/sling/explorer/css/explorer.css"</server.ready.path.2>
                         <server.ready.path.3>/sling-test/sling/sling-test.html:Sling
client library tests</server.ready.path.3>
+                        
+                        <!-- 
+                            Define additional bundles to install by specifying the beginning
of their artifact name.
+                            The bundles are installed in lexical order of these property
names.
+                            All bundles must be listed as dependencies in this pom, or they
won't be installed. 
+                        -->
+                        <sling.additional.bundle.1>org.apache.sling.junit.core</sling.additional.bundle.1>
+                        <sling.additional.bundle.2>org.apache.sling.junit.scriptable</sling.additional.bundle.2>
+                        <sling.additional.bundle.3>org.apache.sling.testing.samples.sampletests</sling.additional.bundle.3>
+                        <sling.additional.bundle.4>org.apache.sling.testing.samples.failingtests</sling.additional.bundle.4>
+                        <sling.additional.bundle.5>org.apache.sling.junit.remote</sling.additional.bundle.5>
                     </systemPropertyVariables>
                 </configuration>
             </plugin>

Modified: sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java?rev=1075415&r1=1075414&r2=1075415&view=diff
==============================================================================
--- sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
(original)
+++ sling/trunk/testing/samples/integration-tests/src/test/java/org/apache/sling/testing/samples/testtools/SlingTestBase.java
Mon Feb 28 16:40:50 2011
@@ -21,7 +21,7 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
+import java.util.Iterator;
 import java.util.List;
 import java.util.TreeSet;
 
@@ -45,6 +45,7 @@ public class SlingTestBase {
     public static final String SERVER_READY_PROP_PREFIX = "server.ready.path";
     public static final String KEEP_JAR_RUNNING_PROP = "keepJarRunning";
     public static final String ADDITONAL_BUNDLES_PATH = "additional.bundles.path";
+    public static final String BUNDLE_TO_INSTALL_PREFIX = "sling.additional.bundle";
     public static final String ADMIN = "admin";
     
     protected static String serverBaseUrl;
@@ -187,24 +188,35 @@ public class SlingTestBase {
             return;
         }
         
-        int count = 0;
-        final List<File> bundlesToInstall = new ArrayList<File>();
+        // Collect all filenames of candidate bundles
+        final List<String> bundleNames = new ArrayList<String>();
         final String [] files = dir.list();
         if(files != null) {
             for(String file : files) {
                 if(file.endsWith(".jar")) {
-                    File f = new File(dir, file);
-                    bundlesToInstall.add(f);
-                    count++;
+                    bundleNames.add(file);
                 }
             }
         }
         
-        // Install bundles in a predictable order, to
-        // be as deterministic as possible
-        Collections.sort(bundlesToInstall);
-        for(File f : bundlesToInstall) {
-            installBundle(f);
+        // And install those that are specified by system properties, in order
+        int count = 0;
+        final List<String> sortedPropertyKeys = new ArrayList<String>();
+        for(Object key : System.getProperties().keySet()) {
+            final String str = key.toString();
+            if(str.startsWith(BUNDLE_TO_INSTALL_PREFIX)) {
+                sortedPropertyKeys.add(str);
+            }
+        }
+        Collections.sort(sortedPropertyKeys);
+        for(String key : sortedPropertyKeys) {
+            final String filenamePrefix = System.getProperty(key);
+            for(String bundleFilename : bundleNames) {
+                if(bundleFilename.startsWith(filenamePrefix)) {
+                    installBundle(new File(dir, bundleFilename));
+                    count++;
+                }
+            }
         }
         
         log.info("{} additional bundles installed from {}", count, dir.getAbsolutePath());



Mime
View raw message