incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1539355 - in /sling/whiteboard/bdelacretaz/sling-pax-util: ./ src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
Date Wed, 06 Nov 2013 14:54:25 GMT
Author: bdelacretaz
Date: Wed Nov  6 14:54:25 2013
New Revision: 1539355

URL: http://svn.apache.org/r1539355
Log:
Take sling.run.modes into account

Modified:
    sling/whiteboard/bdelacretaz/sling-pax-util/   (props changed)
    sling/whiteboard/bdelacretaz/sling-pax-util/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
    sling/whiteboard/bdelacretaz/sling-pax-util/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java

Propchange: sling/whiteboard/bdelacretaz/sling-pax-util/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov  6 14:54:25 2013
@@ -10,3 +10,4 @@ bin
 maven-eclipse.xml
 derby.log
 jackrabbit
+oak

Modified: sling/whiteboard/bdelacretaz/sling-pax-util/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/sling-pax-util/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java?rev=1539355&r1=1539354&r2=1539355&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/sling-pax-util/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
(original)
+++ sling/whiteboard/bdelacretaz/sling-pax-util/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
Wed Nov  6 14:54:25 2013
@@ -30,6 +30,8 @@ import java.io.OutputStream;
 import java.net.ServerSocket;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.sling.maven.projectsupport.BundleListUtils;
@@ -52,6 +54,7 @@ public class SlingPaxOptions {
     public static final int DEFAULT_SLING_START_LEVEL = 30;
     public static final String PROP_TELNET_PORT = "osgi.shell.telnet.port";
     public static final String PROP_HTTP_PORT = "org.osgi.service.http.port";
+    public static final String DEFAULT_RUN_MODES = "jackrabbit";
     
     private static int getAvailablePort() {
         int result = Integer.MIN_VALUE;
@@ -64,6 +67,12 @@ public class SlingPaxOptions {
         return result;
     }
     
+    /** Get run modes to use for our tests, as set by the sling.run.modes property */
+    public static Collection<String> getTestRunModes() {
+        final String runModes = System.getProperty("sling.run.modes", DEFAULT_RUN_MODES);
+        return Arrays.asList(runModes.split(","));
+    }
+    
     public static CompositeOption defaultLaunchpadOptions() {
         final String paxLogLevel = System.getProperty("pax.exam.log.level", "INFO");
         
@@ -106,6 +115,7 @@ public class SlingPaxOptions {
         // TODO BundleList should take an InputStream - for now copy to a tmp file for parsing
         log.info("Getting bundle list {}", paxUrl);
         File tmp = null;
+        final Collection<String> testRunModes = getTestRunModes();
         try {
             tmp = dumpMvnUrlToTmpFile(paxUrl);
             final BundleList list = BundleListUtils.readBundleList(tmp);
@@ -124,10 +134,21 @@ public class SlingPaxOptions {
                     KNOWN_FRAGMENTS.add("org.apache.sling.extensions.webconsolebranding");
                     final boolean isFragment = b.getArtifactId().contains("fragment") ||
KNOWN_FRAGMENTS.contains(b.getArtifactId());
                     
-                    // TODO need to handle sling run modes 
-                    if(b.getArtifactId().contains("oak")) {
-                        log.warn("Ignoring bundle due to hard-coded TODO condition: {}",
b.getArtifactId());
-                        continue;
+                    // Ignore bundles with run modes that do not match ours 
+                    final String bundleRunModes = b.getRunModes();
+                    if(bundleRunModes != null && bundleRunModes.length() > 0)
{
+                        boolean active = false;
+                        for(String m : bundleRunModes.split(",")) {
+                            if(testRunModes.contains(m)) {
+                                active = true;
+                                break;
+                            }
+                        }
+                        if(!active) {
+                            log.info("Ignoring bundle {} as none of its run modes [{}] are
active in this test run {}", 
+                                    new Object[] { b.getArtifactId(), bundleRunModes, testRunModes}
);
+                            continue;
+                        }
                     }
                     
                     if(isFragment) {

Modified: sling/whiteboard/bdelacretaz/sling-pax-util/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/sling-pax-util/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java?rev=1539355&r1=1539354&r2=1539355&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/sling-pax-util/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
(original)
+++ sling/whiteboard/bdelacretaz/sling-pax-util/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
Wed Nov  6 14:54:25 2013
@@ -47,7 +47,14 @@ public class SlingRepositoryTest {
 
     @Test
     public void testNameDescriptor() {
-        assertEquals("Jackrabbit", repository.getDescriptor("jcr.repository.name"));
+        // We could use JUnit categories to select tests, as we
+        // do in our integration, but let's avoid a dependency on 
+        // that in this module
+        if(System.getProperty("sling.run.modes", "").contains("oak")) {
+            assertEquals("Apache Jackrabbit Oak", repository.getDescriptor("jcr.repository.name"));
+        } else {
+            assertEquals("Jackrabbit", repository.getDescriptor("jcr.repository.name"));
+        }
     }
     
     @Test



Mime
View raw message