You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:56:27 UTC

[sling-org-apache-sling-paxexam-util] annotated tag org.apache.sling.paxexam.util-1.0.2 created (now 4560532)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git.


      at 4560532  (tag)
 tagging 0cac1dac62ae8a05e5f0d11fdd4a91daa305105b (commit)
      by Bertrand Delacretaz
      on Fri Jan 24 13:10:22 2014 +0000

- Log -----------------------------------------------------------------
org.apache.sling.paxexam.util-1.0.2
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new a2c690a  Playing with pax exam bundle provisioning driven by Sling bundle lists - still quite rough
     new 1c36770  Sling pax utilities - SlingRepositoryTest demonstrates a simple launchpad-based test
     new f2653fb  Take sling.run.modes into account
     new 3482129  Use specific launchpad version
     new 2393110  SLING-3147 - move sling-pax-util under contrib
     new ba53539  Cannot logout if session is null...
     new bd3205f  Explain how to create such tests
     new 09971e2  SLING-2788 - move sling-pax-util under testing
     new 0f39771  SLING-2788 - move sling-pax-util under testing
     new 3d6a06f  SLING-2788 - prepare for release
     new 038bd42  SLING-2788 - explain this better
     new ddedcb9  [maven-release-plugin] prepare release org.apache.sling.paxexam.util-1.0.2
     new f04d875  SLING-2788 - add missing <scm> section
     new 71c6989  [maven-release-plugin] prepare release org.apache.sling.paxexam.util-1.0.2
     new 0cac1da  [maven-release-plugin]  copy for tag org.apache.sling.paxexam.util-1.0.2

The 15 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-paxexam-util] 07/15: Explain how to create such tests

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit bd3205f964fd1e7bb8ad931a13877d4655028b42
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jan 6 16:33:27 2014 +0000

    Explain how to create such tests
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/sling-pax-util@1555898 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/paxexam/util/SlingRepositoryTest.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
index fc7de75..c1a14c8 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -32,7 +32,13 @@ import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
 /** Verify that our tests have access to a functional Sling instance,
- *  and demonstrate how a simple test is setup
+ *  and demonstrate how a simple test is setup.
+ *  
+ *  To create a test like this that runs against a full Sling launchpad 
+ *  instance, one only needs the pax exam setup in the pom and a test 
+ *  like this one that runs with @RunWith PaxExam, that provides a 
+ *  Configuration method and can access services or the BundleContext
+ *  using @Inject. 
  */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 10/15: SLING-2788 - prepare for release

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 3d6a06f328a0296c47b14263dffc8fa693ae8ede
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 11:03:20 2014 +0000

    SLING-2788 - prepare for release
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560941 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                               | 17 ++++++++++++++++-
 .../sling/paxexam/util/SlingRepositoryTest.java       |  4 ++--
 .../org/apache/sling/paxexam/util/SlingSetupTest.java | 19 ++-----------------
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/pom.xml b/pom.xml
index b4b08bf..a69e323 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,21 @@
     <build>
         <plugins>
             <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>${basedir}</directory>
+                            <includes>
+                                <include>derby.log</include>
+                                <include>jackrabbit/**</include>
+                                <include>coverage.ec</include>
+                            </includes>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
@@ -95,7 +110,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>maven-launchpad-plugin</artifactId>
-            <version>2.2.1-SNAPSHOT</version>
+            <version>2.2.0</version>
             <type>maven-plugin</type>
         </dependency>
         <dependency>
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
index c1a14c8..b436511 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -48,7 +48,7 @@ public class SlingRepositoryTest {
     
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        return SlingPaxOptions.defaultLaunchpadOptions("7-SNAPSHOT").getOptions();
+        return SlingPaxOptions.defaultLaunchpadOptions("6").getOptions();
     }
 
     @Test
@@ -69,4 +69,4 @@ public class SlingRepositoryTest {
         assertNotNull(s);
         s.logout();
     }
- }
\ No newline at end of file
+ }
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
index cc7cfe2..f11cd16 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
@@ -45,7 +45,7 @@ public class SlingSetupTest {
     
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        return SlingPaxOptions.defaultLaunchpadOptions("7-SNAPSHOT").getOptions();
+        return SlingPaxOptions.defaultLaunchpadOptions("6").getOptions();
     }
 
     private void assertBundleActive(String symbolicName) {
@@ -98,47 +98,32 @@ public class SlingSetupTest {
                 "org.apache.sling.commons.classloader",
                 "org.apache.sling.commons.json",
                 "org.apache.sling.commons.log",
-                "org.apache.sling.commons.logservice",
                 "org.apache.sling.commons.mime",
                 "org.apache.sling.commons.osgi",
                 "org.apache.sling.commons.scheduler",
                 "org.apache.sling.commons.threads",
-                "org.apache.sling.discovery.api",
-                "org.apache.sling.discovery.impl",
-                "org.apache.sling.discovery.support",
                 "org.apache.sling.engine",
                 "org.apache.sling.event",
                 "org.apache.sling.extensions.explorer",
-                "org.apache.sling.extensions.groovy",
                 "org.apache.sling.extensions.threaddump",
                 "org.apache.sling.extensions.webconsolebranding",
                 "org.apache.sling.extensions.webconsolesecurityprovider",
-                "org.apache.sling.fragment.transaction",
-                "org.apache.sling.fragment.ws",
-                "org.apache.sling.fragment.xml",
                 "org.apache.sling.fsresource",
-                "org.apache.sling.installer.console",
                 "org.apache.sling.installer.core",
-                "org.apache.sling.installer.factory.configuration",
                 "org.apache.sling.installer.provider.file",
                 "org.apache.sling.installer.provider.jcr",
-                "org.apache.sling.jcr.jcr-wrapper",
                 "org.apache.sling.jcr.api",
                 "org.apache.sling.jcr.base",
                 "org.apache.sling.jcr.classloader",
                 "org.apache.sling.jcr.contentloader",
-                "org.apache.sling.jcr.davex",
                 "org.apache.sling.jcr.jackrabbit.accessmanager",
                 "org.apache.sling.jcr.jackrabbit.server",
                 "org.apache.sling.jcr.jackrabbit.usermanager",
                 "org.apache.sling.jcr.ocm",
-                "org.apache.sling.jcr.registration",
                 "org.apache.sling.jcr.resource",
                 "org.apache.sling.jcr.webconsole",
-                "org.apache.sling.jcr.webdav",
                 "org.apache.sling.launchpad.content",
                 "org.apache.sling.launchpad.installer",
-                "org.apache.sling.resourceresolver",
                 "org.apache.sling.scripting.api",
                 "org.apache.sling.scripting.core",
                 "org.apache.sling.scripting.javascript",
@@ -187,4 +172,4 @@ public class SlingSetupTest {
             fail("Some required services are missing:" + missing);
         }
     }
-}
\ No newline at end of file
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 14/15: [maven-release-plugin] prepare release org.apache.sling.paxexam.util-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 71c6989d41afe3167282079431e4351b30bc9940
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 13:10:03 2014 +0000

    [maven-release-plugin] prepare release org.apache.sling.paxexam.util-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560982 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index ea8ffe0..ad9784d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.paxexam.util</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2</version>
     <packaging>jar</packaging>
 
     <name>Apache Sling Pax Exam Utilities</name>
@@ -40,9 +40,9 @@
     </properties>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util</connection>
-        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/testing/sling-pax-util</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.paxexam.util-1.0.2</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 04/15: Use specific launchpad version

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 34821295bfbe3c7e20debc4cf75333ef44413b2f
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Nov 6 15:43:16 2013 +0000

    Use specific launchpad version
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/sling-pax-util@1539371 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java     | 5 +++--
 src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java | 2 +-
 src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java      | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
index acbf777..9b1dcef 100644
--- a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
+++ b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
@@ -73,7 +73,8 @@ public class SlingPaxOptions {
         return Arrays.asList(runModes.split(","));
     }
     
-    public static CompositeOption defaultLaunchpadOptions() {
+    /** @param launchpadVersion null means use the latest */
+    public static CompositeOption defaultLaunchpadOptions(String launchpadVersion) {
         final String paxLogLevel = System.getProperty("pax.exam.log.level", "INFO");
         
         final int slingStartLevel = DEFAULT_SLING_START_LEVEL;
@@ -88,7 +89,7 @@ public class SlingPaxOptions {
                 systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value(paxLogLevel),
                 SlingPaxOptions.felixRemoteShellBundles(),
                 SlingPaxOptions.slingBootstrapBundles(),
-                SlingPaxOptions.slingLaunchpadBundles(null),
+                SlingPaxOptions.slingLaunchpadBundles(launchpadVersion),
                 CoreOptions.frameworkStartLevel(slingStartLevel),
                 CoreOptions.frameworkProperty(PROP_TELNET_PORT).value(telnetPort),
                 CoreOptions.frameworkProperty(PROP_HTTP_PORT).value(httpPort)
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
index dadecf1..13c49cb 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -42,7 +42,7 @@ public class SlingRepositoryTest {
     
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        return SlingPaxOptions.defaultLaunchpadOptions().getOptions();
+        return SlingPaxOptions.defaultLaunchpadOptions("7-SNAPSHOT").getOptions();
     }
 
     @Test
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
index 65f2f11..cc7cfe2 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
@@ -45,7 +45,7 @@ public class SlingSetupTest {
     
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        return SlingPaxOptions.defaultLaunchpadOptions().getOptions();
+        return SlingPaxOptions.defaultLaunchpadOptions("7-SNAPSHOT").getOptions();
     }
 
     private void assertBundleActive(String symbolicName) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 06/15: Cannot logout if session is null...

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit ba53539b98cc2f6d136b12bc2029aee7288a0240
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Jan 6 15:42:59 2014 +0000

    Cannot logout if session is null...
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/sling-pax-util@1555868 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/paxexam/util/SlingRepositoryTest.java    | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
index 13c49cb..fc7de75 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -60,10 +60,7 @@ public class SlingRepositoryTest {
     @Test
     public void testLogin() throws RepositoryException {
         final Session s = repository.loginAdministrative(null);
-        try {
-            assertNotNull(s);
-        } finally {
-            s.logout();
-        }
+        assertNotNull(s);
+        s.logout();
     }
  }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 02/15: Sling pax utilities - SlingRepositoryTest demonstrates a simple launchpad-based test

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 1c367702a21cc693b58892651d4536f336eca488
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Nov 6 14:39:42 2013 +0000

    Sling pax utilities - SlingRepositoryTest demonstrates a simple launchpad-based test
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/sling-pax-util@1539351 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  24 +++
 .../apache/sling/paxexam/util/SlingPaxOptions.java |  70 +++++++-
 .../sling/paxexam/util/SlingRepositoryTest.java    |  62 +++++++
 .../{SlingBundlesTest.java => SlingSetupTest.java} | 179 ++++++---------------
 4 files changed, 205 insertions(+), 130 deletions(-)

diff --git a/pom.xml b/pom.xml
index a5c4baf..34d3673 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,6 +105,30 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.4.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.api</artifactId>
+            <version>2.1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.settings</artifactId>
+            <version>1.3.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
diff --git a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
index dbb8744..ddf833c 100644
--- a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
+++ b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
@@ -16,7 +16,9 @@
  */
 package org.apache.sling.paxexam.util;
 
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -25,6 +27,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.ServerSocket;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -33,14 +36,55 @@ import org.apache.sling.maven.projectsupport.BundleListUtils;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.options.CompositeOption;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/** Pax exam options utilities for Sling */
+/** Pax exam options and utilities to test Sling applications
+ *  The basic idea is to get a vanilla Sling launchpad instance
+ *  setup with a minimal amount of boilerplate code.
+ *  See {@link SlingSetupTest} for an example.
+ * */
 public class SlingPaxOptions {
     private static final Logger log = LoggerFactory.getLogger(SlingPaxOptions.class);
+    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";
+    
+    private static int getAvailablePort() {
+        int result = Integer.MIN_VALUE;
+        try {
+            final ServerSocket s = new ServerSocket(0);
+            result = s.getLocalPort();
+            s.close();
+        } catch(IOException ignore) {
+        }
+        return result;
+    }
+    
+    public static CompositeOption defaultLaunchpadOptions() {
+        final String paxLogLevel = System.getProperty("pax.exam.log.level", "INFO");
+        
+        final int slingStartLevel = DEFAULT_SLING_START_LEVEL;
+        final String telnetPort = System.getProperty(PROP_TELNET_PORT, String.valueOf(getAvailablePort()));
+        final String httpPort = System.getProperty(PROP_HTTP_PORT, String.valueOf(getAvailablePort()));
+        
+        log.info("{}={}", PROP_TELNET_PORT, telnetPort);
+        log.info("{}={}", PROP_HTTP_PORT, httpPort);
+                
+        return new DefaultCompositeOption(
+                junitBundles(),
+                systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value(paxLogLevel),
+                SlingPaxOptions.felixRemoteShellBundles(),
+                SlingPaxOptions.slingBootstrapBundles(),
+                SlingPaxOptions.slingLaunchpadBundles(null),
+                CoreOptions.frameworkStartLevel(slingStartLevel),
+                CoreOptions.frameworkProperty(PROP_TELNET_PORT).value(telnetPort),
+                CoreOptions.frameworkProperty(PROP_HTTP_PORT).value(httpPort)
+        );
+    }
     
     public static CompositeOption slingBundleList(String groupId, String artifactId, String version, String type, String classifier) {
         
@@ -67,7 +111,10 @@ public class SlingPaxOptions {
             final BundleList list = BundleListUtils.readBundleList(tmp);
             int counter = 0;
             for(StartLevel s : list.getStartLevels()) {
-                final int startLevel = s.getStartLevel();
+                
+                // Start level < 0 means bootstrap in our bundle lists
+                final int startLevel = s.getStartLevel() < 0 ? 1 : s.getStartLevel();
+                
                 for(Bundle b : s.getBundles()) {
                     counter++;
                     
@@ -77,6 +124,12 @@ 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;
+                    }
+                    
                     if(isFragment) {
                         result.add(mavenBundle(b.getGroupId(), b.getArtifactId(), b.getVersion()).noStart());
                     } else if(startLevel == 0){
@@ -113,6 +166,17 @@ public class SlingPaxOptions {
         return slingBundleList("org.apache.sling", "org.apache.sling.launchpad", version, "xml", "bundlelist");
     }
     
+    /** @param version can be null, to use default */ 
+    public static CompositeOption felixRemoteShellBundles() {
+        final String gogoVersion = "0.10.0";
+        return new DefaultCompositeOption(
+                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.runtime").version(gogoVersion),
+                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.shell").version(gogoVersion),
+                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.command").version(gogoVersion),
+                mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.shell.remote").version("1.1.2")
+        );
+    }
+    
     private static File dumpMvnUrlToTmpFile(String mvnUrl) throws IOException {
         final URL url = new URL(mvnUrl);
         final InputStream is = new BufferedInputStream(url.openStream());
@@ -135,4 +199,4 @@ public class SlingPaxOptions {
         
         return tmp;
     }
-}
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
new file mode 100644
index 0000000..0a21f29
--- /dev/null
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.paxexam.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.inject.Inject;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.jcr.api.SlingRepository;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+/** Verify that our tests have access to a functional Sling instance,
+ *  and demonstrate how a simple test is setup
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class SlingRepositoryTest {
+    @Inject
+    private SlingRepository repository;
+    
+    @org.ops4j.pax.exam.Configuration
+    public Option[] config() {
+        return SlingPaxOptions.defaultLaunchpadOptions().getOptions();
+    }
+
+    @Test
+    public void testNameDescriptor() {
+        assertEquals("Jackrabbit", repository.getDescriptor("jcr.repository.name"));
+    }
+    
+    @Test
+    public void testLogin() throws RepositoryException {
+        final Session s = repository.loginAdministrative(null);
+        try {
+            assertNotNull(s);
+        } finally {
+            s.logout();
+        }
+    }
+ }
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingBundlesTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
similarity index 51%
rename from src/test/java/org/apache/sling/paxexam/util/SlingBundlesTest.java
rename to src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
index 803dcdc..65f2f11 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingBundlesTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
@@ -19,94 +19,64 @@ package org.apache.sling.paxexam.util;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.inject.Inject;
 
-import org.apache.sling.launchpad.api.StartupListener;
-import org.apache.sling.launchpad.api.StartupMode;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
+/** Verify that we get a working Sling launchpad with what SlingPaxOptions provide */
 @RunWith(PaxExam.class)
-public class SlingBundlesTest {
-    
-    private final Logger log = LoggerFactory.getLogger(getClass());
+@ExamReactorStrategy(PerClass.class)
+public class SlingSetupTest {
     
     @Inject
     private BundleContext bundleContext;
     
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        final String paxLogLevel = System.getProperty("pax.exam.log.level", "INFO");
-        
-        return options(
-                junitBundles(),
-                systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value(paxLogLevel),
-                SlingPaxOptions.slingBootstrapBundles(),
-                SlingPaxOptions.slingLaunchpadBundles(null)
-        );
+        return SlingPaxOptions.defaultLaunchpadOptions().getOptions();
     }
 
+    private void assertBundleActive(String symbolicName) {
+        assertEquals("Expecting bundle to be active:" + symbolicName, Bundle.ACTIVE, getBundleState(symbolicName));
+    }
+    
     private boolean isFragment(Bundle b) {
         return b.getHeaders().get("Fragment-Host") != null;
     }
     
-    private void assertBundleActive(String symbolicName) {
-        Bundle b = null;
-        for(Bundle x : bundleContext.getBundles()) {
-            if(symbolicName.equals(x.getSymbolicName())) {
-                b = x;
-                break;
+    private Bundle getBundle(String symbolicName) {
+        for(Bundle b : bundleContext.getBundles()) {
+            if(symbolicName.equals(b.getSymbolicName())) {
+                return b;
             }
         }
-        assertNotNull("Expecting bundle " + symbolicName + " to be present", b);
-        if(!isFragment(b)) {
-            assertEquals("Expecting bundle " + symbolicName + " to be active", Bundle.ACTIVE, b.getState());
-        }
+        return null;
+    }
+    /** @return bundle state, UNINSTALLED if absent */
+    private int getBundleState(String symbolicName) {
+        return getBundleState(getBundle(symbolicName));
     }
     
-    @Before 
-    public void startAllBundles() {
-        final List<String> notStarted = new LinkedList<String>();
-        int lastNotStarted = Integer.MAX_VALUE;
-        
-        while(true) {
-            notStarted.clear();
-            for(Bundle b : bundleContext.getBundles()) {
-                if(!isFragment(b) && b.getState() != Bundle.ACTIVE) {
-                    notStarted.add(b.getSymbolicName());
-                    try {
-                        b.start();
-                    } catch(Exception e) {
-                        fail("Cannot start Bundle " + b.getSymbolicName() + ": " + e);
-                    } 
-                }
-            }
-            
-            if(notStarted.isEmpty()) {
-                break;
-            }
-            
-            if(!notStarted.isEmpty() && notStarted.size() >= lastNotStarted) {
-                log.error("No bundles started in the last cycle, inactive bundles={}", notStarted);
-                break;
-            }
-            lastNotStarted = notStarted.size();
+    /** @return bundle state, UNINSTALLED if absent, ACTIVE  */
+    private int getBundleState(Bundle b) {
+        if(b == null) {
+            return Bundle.UNINSTALLED; 
+        } else if(isFragment(b)) {
+            return Bundle.ACTIVE;
+        } else {
+            return b.getState();
         }
     }
     
@@ -143,12 +113,10 @@ public class SlingBundlesTest {
                 "org.apache.sling.extensions.threaddump",
                 "org.apache.sling.extensions.webconsolebranding",
                 "org.apache.sling.extensions.webconsolesecurityprovider",
-                "org.apache.sling.fragment.activation",
                 "org.apache.sling.fragment.transaction",
                 "org.apache.sling.fragment.ws",
                 "org.apache.sling.fragment.xml",
                 "org.apache.sling.fsresource",
-                "org.apache.sling.installer.api",
                 "org.apache.sling.installer.console",
                 "org.apache.sling.installer.core",
                 "org.apache.sling.installer.factory.configuration",
@@ -182,84 +150,41 @@ public class SlingBundlesTest {
                 "org.apache.sling.settings"
         };
         
+        final List<String> missing = new ArrayList<String>();
         for(String bundleName : bundles) {
-            assertBundleActive(bundleName);
+            final int state = getBundleState(bundleName); 
+            if(state != Bundle.ACTIVE) {
+                missing.add(bundleName + " (state=" + state + ")");
+            }
+        }
+        
+        if(!missing.isEmpty()) {
+            fail("Some required bundles are missing or inactive:" + missing);
         }
     }
     
     @Test
     public void testSlingServices() {
+        assertBundleActive("org.apache.sling.commons.mime");
+        assertBundleActive("org.apache.sling.engine");
         
-        class LocalStartupListener implements StartupListener {
-            
-            boolean testsHaveRun;
-            
-            public void inform(StartupMode m, boolean finished) {
-                log.info("inform(finished={})", finished);
-                if(finished) {
-                    runTests();
-                }
-            }
-
-            public void startupFinished(StartupMode m) {
-                log.info("Startup finished");
-                runTests();
-            }
-
-            public void startupProgress(float f) {
-                log.info("Startup progress {}", f);
-            }
-            
-            void runTests() {
-                if(!testsHaveRun) {
-                    testsHaveRun = true;
-                }
-                
-                try {
-                    assertBundleActive("org.apache.sling.commons.mime");
-                    assertBundleActive("org.apache.sling.engine");
-                    
-                    final String [] services = {
-                            "org.apache.sling.commons.mime.MimeTypeService",
-                            "org.apache.sling.engine.SlingRequestProcessor"
-                    };
-                    
-                    for(String svc : services) {
-                        final ServiceReference<?> ref = bundleContext.getServiceReference(svc);
-                        assertNotNull("Expecting " + svc + " to be available", ref);
-                        bundleContext.ungetService(ref);
-                    }
-                } finally {
-                    log.info("Done running tests");
-                    synchronized (this) {
-                        notify();
-                    }
-                }
-            }
+        final String [] services = {
+                "org.apache.sling.engine.SlingRequestProcessor",
+                "org.apache.sling.commons.mime.MimeTypeService",
+                "org.apache.sling.jcr.api.SlingRepository"
         };
         
-
-        final LocalStartupListener s = new LocalStartupListener();
-        s.runTests();
-        
-        /*
-        // TODO generalize this "wait for Sling startup" - assuming we really need it
-        final ServiceRegistration<?> reg = bundleContext.registerService(StartupListener.class.getName(), s, null);
-        final long timeout = 5000L;
-        try {
-            synchronized (s) {
-                log.info("Waiting for {} to be done running tests", s);
-                s.wait(timeout);
+        final List<String> missing = new ArrayList<String>();
+        for(String svc : services) {
+            final ServiceReference<?> ref = bundleContext.getServiceReference(svc);
+            if(ref == null) {
+                missing.add(svc);
+            } else {
+                bundleContext.ungetService(ref);
             }
-        } catch(InterruptedException ignored) {
-            fail("InterruptedException waiting tests to be executed");
-        } finally {
-            reg.unregister();
         }
-        
-        if(!s.testsHaveRun) {
-            fail("Timeout waiting for tests to run, after " + timeout + " msec");
+        if(!missing.isEmpty()) {
+            fail("Some required services are missing:" + missing);
         }
-        */
     }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 15/15: [maven-release-plugin] copy for tag org.apache.sling.paxexam.util-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 0cac1dac62ae8a05e5f0d11fdd4a91daa305105b
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 13:10:22 2014 +0000

    [maven-release-plugin]  copy for tag org.apache.sling.paxexam.util-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2@1560983 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 11/15: SLING-2788 - explain this better

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 038bd429236d7266eaf2b7e8395277b2bc9e61f1
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 11:10:39 2014 +0000

    SLING-2788 - explain this better
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560942 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                    |  5 +++++
 .../org/apache/sling/paxexam/util/SlingRepositoryTest.java | 14 ++++++++------
 .../java/org/apache/sling/paxexam/util/SlingSetupTest.java |  5 ++++-
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index a69e323..4f694fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,6 +27,11 @@
     <packaging>jar</packaging>
 
     <name>Apache Sling Pax Exam Utilities</name>
+    
+    <description>
+        Utilities that make it easier to test Sling code with Pax Exam.
+        See this module's tests for usage examples.
+    </description>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
index b436511..18bbd3e 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -34,11 +34,10 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 /** Verify that our tests have access to a functional Sling instance,
  *  and demonstrate how a simple test is setup.
  *  
- *  To create a test like this that runs against a full Sling launchpad 
- *  instance, one only needs the pax exam setup in the pom and a test 
- *  like this one that runs with @RunWith PaxExam, that provides a 
- *  Configuration method and can access services or the BundleContext
- *  using @Inject. 
+ *  Note how little boilerplate this example test has. You basically just 
+ *  define which version of the Sling launchpad bundle list you want to use, 
+ *  and you can then @Inject any OSGi services to be tested, along with the 
+ *  BundleContext.  
  */
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
@@ -46,9 +45,12 @@ public class SlingRepositoryTest {
     @Inject
     private SlingRepository repository;
     
+    /** Use a released launchpad for this example */
+    public static final String SLING_LAUNCHPAD_VERSION = "6";
+    
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        return SlingPaxOptions.defaultLaunchpadOptions("6").getOptions();
+        return SlingPaxOptions.defaultLaunchpadOptions(SLING_LAUNCHPAD_VERSION).getOptions();
     }
 
     @Test
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
index f11cd16..0738efd 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingSetupTest.java
@@ -40,12 +40,15 @@ import org.osgi.framework.ServiceReference;
 @ExamReactorStrategy(PerClass.class)
 public class SlingSetupTest {
     
+    /** Use a released launchpad for this example */
+    public static final String SLING_LAUNCHPAD_VERSION = "6";
+    
     @Inject
     private BundleContext bundleContext;
     
     @org.ops4j.pax.exam.Configuration
     public Option[] config() {
-        return SlingPaxOptions.defaultLaunchpadOptions("6").getOptions();
+        return SlingPaxOptions.defaultLaunchpadOptions(SLING_LAUNCHPAD_VERSION).getOptions();
     }
 
     private void assertBundleActive(String symbolicName) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 12/15: [maven-release-plugin] prepare release org.apache.sling.paxexam.util-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit ddedcb922039670068db6174c680e8b7dc2044a7
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 13:02:48 2014 +0000

    [maven-release-plugin] prepare release org.apache.sling.paxexam.util-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560978 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4f694fe..e582acd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,8 +9,7 @@
     License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
     OF ANY KIND, either express or implied. See the License for the specific 
     language governing permissions and limitations under the License. -->
-<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/maven-v4_0_0.xsd">
+<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/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
     
@@ -23,7 +22,7 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.paxexam.util</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.0.2</version>
     <packaging>jar</packaging>
 
     <name>Apache Sling Pax Exam Utilities</name>
@@ -162,4 +161,10 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2</developerConnection>
+    <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.paxexam.util-1.0.2</url>
+  </scm>
 </project>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 08/15: SLING-2788 - move sling-pax-util under testing

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 09971e2d4af1d0ebc54f68dc074d14a7c5f825c8
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 10:46:07 2014 +0000

    SLING-2788 - move sling-pax-util under testing
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560938 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 05/15: SLING-3147 - move sling-pax-util under contrib

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 2393110ed29344e97cb36e4b4e7b18d364f43742
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Nov 6 16:49:15 2013 +0000

    SLING-3147 - move sling-pax-util under contrib
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/sling-pax-util@1539394 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 13/15: SLING-2788 - add missing section

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit f04d875bfe53e4f6e1a3ba236d1f883e0e390062
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 13:08:47 2014 +0000

    SLING-2788 - add missing <scm> section
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560981 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index e582acd..ea8ffe0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.paxexam.util</artifactId>
-    <version>1.0.2</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>jar</packaging>
 
     <name>Apache Sling Pax Exam Utilities</name>
@@ -39,6 +39,12 @@
         <pax.exam.log.level>INFO</pax.exam.log.level>
     </properties>
 
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/testing/sling-pax-util</url>
+    </scm>
+
     <build>
         <plugins>
             <plugin>
@@ -162,9 +168,4 @@
         </dependency>
     </dependencies>
 
-  <scm>
-    <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2</connection>
-    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.paxexam.util-1.0.2</developerConnection>
-    <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.paxexam.util-1.0.2</url>
-  </scm>
 </project>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 01/15: Playing with pax exam bundle provisioning driven by Sling bundle lists - still quite rough

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit a2c690a58e1521a57088635a029f4373bcb8ad8a
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri May 24 15:35:33 2013 +0000

    Playing with pax exam bundle provisioning driven by Sling bundle lists - still quite rough
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/sling-pax-util@1486095 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 121 ++++++++++
 .../apache/sling/paxexam/util/SlingPaxOptions.java | 138 +++++++++++
 .../sling/paxexam/util/SlingBundlesTest.java       | 265 +++++++++++++++++++++
 3 files changed, 524 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..a5c4baf
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+    license agreements. See the NOTICE file distributed with this work for additional 
+    information regarding copyright ownership. The ASF licenses this file to 
+    you under the Apache License, Version 2.0 (the "License"); you may not use 
+    this file except in compliance with the License. You may obtain a copy of 
+    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+    by applicable law or agreed to in writing, software distributed under the 
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+    OF ANY KIND, either express or implied. See the License for the specific 
+    language governing permissions and limitations under the License. -->
+<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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>16</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.sling</groupId>
+    <artifactId>org.apache.sling.paxexam.util</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>Sling Pax Exam Utilities</name>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <exam.version>3.0.3</exam.version>
+        <url.version>1.5.2</url.version>
+        <pax.exam.log.level>INFO</pax.exam.log.level>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <systemProperties>
+                        <property>
+                            <name>pax.exam.log.level</name>
+                            <value>${pax.exam.log.level}</value>
+                        </property>
+                        <property>
+                            <name>java.protocol.handler.pkgs</name>
+                            <value>org.ops4j.pax.url</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <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>
+        </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>4.2.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>maven-launchpad-plugin</artifactId>
+            <version>2.2.1-SNAPSHOT</version>
+            <type>maven-plugin</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.launchpad.api</artifactId>
+            <version>1.1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
new file mode 100644
index 0000000..dbb8744
--- /dev/null
+++ b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.paxexam.util;
+
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sling.maven.projectsupport.BundleListUtils;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Pax exam options utilities for Sling */
+public class SlingPaxOptions {
+    private static final Logger log = LoggerFactory.getLogger(SlingPaxOptions.class);
+    
+    public static CompositeOption slingBundleList(String groupId, String artifactId, String version, String type, String classifier) {
+        
+        final DefaultCompositeOption result = new DefaultCompositeOption();
+        
+        final String paxUrl = new StringBuilder()
+        .append("mvn:")
+        .append(groupId)
+        .append("/")
+        .append(artifactId)
+        .append("/")
+        .append(version == null ? "" : version)
+        .append("/")
+        .append(type == null ? "" : type)
+        .append("/")
+        .append(classifier == null ? "" : classifier)
+        .toString();
+        
+        // TODO BundleList should take an InputStream - for now copy to a tmp file for parsing
+        log.info("Getting bundle list {}", paxUrl);
+        File tmp = null;
+        try {
+            tmp = dumpMvnUrlToTmpFile(paxUrl);
+            final BundleList list = BundleListUtils.readBundleList(tmp);
+            int counter = 0;
+            for(StartLevel s : list.getStartLevels()) {
+                final int startLevel = s.getStartLevel();
+                for(Bundle b : s.getBundles()) {
+                    counter++;
+                    
+                    // TODO need better fragment detection
+                    // (but pax exam should really detect that by itself?)
+                    final List<String> KNOWN_FRAGMENTS = new ArrayList<String>();
+                    KNOWN_FRAGMENTS.add("org.apache.sling.extensions.webconsolebranding");
+                    final boolean isFragment = b.getArtifactId().contains("fragment") || KNOWN_FRAGMENTS.contains(b.getArtifactId());
+                    
+                    if(isFragment) {
+                        result.add(mavenBundle(b.getGroupId(), b.getArtifactId(), b.getVersion()).noStart());
+                    } else if(startLevel == 0){
+                        result.add(mavenBundle(b.getGroupId(), b.getArtifactId(), b.getVersion()));
+                    } else {
+                        result.add(mavenBundle(b.getGroupId(), b.getArtifactId(), b.getVersion()).startLevel(startLevel));
+                    }
+                    
+                    log.info("Bundle added: {}/{}/{}", new Object [] { b.getGroupId(), b.getArtifactId(), b.getVersion()});
+                }
+            }
+            log.info("Got {} bundles from {}", counter, paxUrl);
+        } catch(Exception e) {
+            throw new RuntimeException("Error getting bundle list " + paxUrl, e);
+        } finally {
+            if(tmp != null) {
+                tmp.delete();
+            }
+        }
+        
+        return result;
+    }
+
+    public static CompositeOption slingBootstrapBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.http.jetty", "2.2.0"),
+                
+                // TODO: why is this needed?
+                mavenBundle("org.apache.sling", "org.apache.sling.launchpad.api", "1.1.0")
+        );
+    }
+    
+    public static CompositeOption slingLaunchpadBundles(String version) {
+        return slingBundleList("org.apache.sling", "org.apache.sling.launchpad", version, "xml", "bundlelist");
+    }
+    
+    private static File dumpMvnUrlToTmpFile(String mvnUrl) throws IOException {
+        final URL url = new URL(mvnUrl);
+        final InputStream is = new BufferedInputStream(url.openStream());
+        
+        final File tmp = File.createTempFile(SlingPaxOptions.class.getName(), "xml");
+        log.debug("Copying bundle list contents to {}", tmp.getAbsolutePath());
+        tmp.deleteOnExit();
+        final OutputStream os = new BufferedOutputStream(new FileOutputStream(tmp));
+        try {
+            final byte [] buffer = new byte[16384];
+            int len = 0;
+            while( (len = is.read(buffer, 0, buffer.length)) > 0) {
+                os.write(buffer, 0, len);
+            }
+            os.flush();
+        } finally {
+            os.close();
+            is.close();
+        }
+        
+        return tmp;
+    }
+}
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingBundlesTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingBundlesTest.java
new file mode 100644
index 0000000..803dcdc
--- /dev/null
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingBundlesTest.java
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.paxexam.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.sling.launchpad.api.StartupListener;
+import org.apache.sling.launchpad.api.StartupMode;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(PaxExam.class)
+public class SlingBundlesTest {
+    
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
+    @Inject
+    private BundleContext bundleContext;
+    
+    @org.ops4j.pax.exam.Configuration
+    public Option[] config() {
+        final String paxLogLevel = System.getProperty("pax.exam.log.level", "INFO");
+        
+        return options(
+                junitBundles(),
+                systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value(paxLogLevel),
+                SlingPaxOptions.slingBootstrapBundles(),
+                SlingPaxOptions.slingLaunchpadBundles(null)
+        );
+    }
+
+    private boolean isFragment(Bundle b) {
+        return b.getHeaders().get("Fragment-Host") != null;
+    }
+    
+    private void assertBundleActive(String symbolicName) {
+        Bundle b = null;
+        for(Bundle x : bundleContext.getBundles()) {
+            if(symbolicName.equals(x.getSymbolicName())) {
+                b = x;
+                break;
+            }
+        }
+        assertNotNull("Expecting bundle " + symbolicName + " to be present", b);
+        if(!isFragment(b)) {
+            assertEquals("Expecting bundle " + symbolicName + " to be active", Bundle.ACTIVE, b.getState());
+        }
+    }
+    
+    @Before 
+    public void startAllBundles() {
+        final List<String> notStarted = new LinkedList<String>();
+        int lastNotStarted = Integer.MAX_VALUE;
+        
+        while(true) {
+            notStarted.clear();
+            for(Bundle b : bundleContext.getBundles()) {
+                if(!isFragment(b) && b.getState() != Bundle.ACTIVE) {
+                    notStarted.add(b.getSymbolicName());
+                    try {
+                        b.start();
+                    } catch(Exception e) {
+                        fail("Cannot start Bundle " + b.getSymbolicName() + ": " + e);
+                    } 
+                }
+            }
+            
+            if(notStarted.isEmpty()) {
+                break;
+            }
+            
+            if(!notStarted.isEmpty() && notStarted.size() >= lastNotStarted) {
+                log.error("No bundles started in the last cycle, inactive bundles={}", notStarted);
+                break;
+            }
+            lastNotStarted = notStarted.size();
+        }
+    }
+    
+    @Test
+    public void testBundleContext() {
+        assertNotNull("Expecting BundleContext to be set", bundleContext);
+    }
+    
+    @Test
+    public void testSlingBundles() {
+        final String [] bundles = {
+                "org.apache.sling.adapter",
+                "org.apache.sling.api",
+                "org.apache.sling.auth.core",
+                "org.apache.sling.auth.form",
+                "org.apache.sling.auth.openid",
+                "org.apache.sling.auth.selector",
+                "org.apache.sling.bundleresource.impl",
+                "org.apache.sling.commons.classloader",
+                "org.apache.sling.commons.json",
+                "org.apache.sling.commons.log",
+                "org.apache.sling.commons.logservice",
+                "org.apache.sling.commons.mime",
+                "org.apache.sling.commons.osgi",
+                "org.apache.sling.commons.scheduler",
+                "org.apache.sling.commons.threads",
+                "org.apache.sling.discovery.api",
+                "org.apache.sling.discovery.impl",
+                "org.apache.sling.discovery.support",
+                "org.apache.sling.engine",
+                "org.apache.sling.event",
+                "org.apache.sling.extensions.explorer",
+                "org.apache.sling.extensions.groovy",
+                "org.apache.sling.extensions.threaddump",
+                "org.apache.sling.extensions.webconsolebranding",
+                "org.apache.sling.extensions.webconsolesecurityprovider",
+                "org.apache.sling.fragment.activation",
+                "org.apache.sling.fragment.transaction",
+                "org.apache.sling.fragment.ws",
+                "org.apache.sling.fragment.xml",
+                "org.apache.sling.fsresource",
+                "org.apache.sling.installer.api",
+                "org.apache.sling.installer.console",
+                "org.apache.sling.installer.core",
+                "org.apache.sling.installer.factory.configuration",
+                "org.apache.sling.installer.provider.file",
+                "org.apache.sling.installer.provider.jcr",
+                "org.apache.sling.jcr.jcr-wrapper",
+                "org.apache.sling.jcr.api",
+                "org.apache.sling.jcr.base",
+                "org.apache.sling.jcr.classloader",
+                "org.apache.sling.jcr.contentloader",
+                "org.apache.sling.jcr.davex",
+                "org.apache.sling.jcr.jackrabbit.accessmanager",
+                "org.apache.sling.jcr.jackrabbit.server",
+                "org.apache.sling.jcr.jackrabbit.usermanager",
+                "org.apache.sling.jcr.ocm",
+                "org.apache.sling.jcr.registration",
+                "org.apache.sling.jcr.resource",
+                "org.apache.sling.jcr.webconsole",
+                "org.apache.sling.jcr.webdav",
+                "org.apache.sling.launchpad.content",
+                "org.apache.sling.launchpad.installer",
+                "org.apache.sling.resourceresolver",
+                "org.apache.sling.scripting.api",
+                "org.apache.sling.scripting.core",
+                "org.apache.sling.scripting.javascript",
+                "org.apache.sling.scripting.jsp",
+                "org.apache.sling.scripting.jsp.taglib",
+                "org.apache.sling.servlets.get",
+                "org.apache.sling.servlets.post",
+                "org.apache.sling.servlets.resolver",
+                "org.apache.sling.settings"
+        };
+        
+        for(String bundleName : bundles) {
+            assertBundleActive(bundleName);
+        }
+    }
+    
+    @Test
+    public void testSlingServices() {
+        
+        class LocalStartupListener implements StartupListener {
+            
+            boolean testsHaveRun;
+            
+            public void inform(StartupMode m, boolean finished) {
+                log.info("inform(finished={})", finished);
+                if(finished) {
+                    runTests();
+                }
+            }
+
+            public void startupFinished(StartupMode m) {
+                log.info("Startup finished");
+                runTests();
+            }
+
+            public void startupProgress(float f) {
+                log.info("Startup progress {}", f);
+            }
+            
+            void runTests() {
+                if(!testsHaveRun) {
+                    testsHaveRun = true;
+                }
+                
+                try {
+                    assertBundleActive("org.apache.sling.commons.mime");
+                    assertBundleActive("org.apache.sling.engine");
+                    
+                    final String [] services = {
+                            "org.apache.sling.commons.mime.MimeTypeService",
+                            "org.apache.sling.engine.SlingRequestProcessor"
+                    };
+                    
+                    for(String svc : services) {
+                        final ServiceReference<?> ref = bundleContext.getServiceReference(svc);
+                        assertNotNull("Expecting " + svc + " to be available", ref);
+                        bundleContext.ungetService(ref);
+                    }
+                } finally {
+                    log.info("Done running tests");
+                    synchronized (this) {
+                        notify();
+                    }
+                }
+            }
+        };
+        
+
+        final LocalStartupListener s = new LocalStartupListener();
+        s.runTests();
+        
+        /*
+        // TODO generalize this "wait for Sling startup" - assuming we really need it
+        final ServiceRegistration<?> reg = bundleContext.registerService(StartupListener.class.getName(), s, null);
+        final long timeout = 5000L;
+        try {
+            synchronized (s) {
+                log.info("Waiting for {} to be done running tests", s);
+                s.wait(timeout);
+            }
+        } catch(InterruptedException ignored) {
+            fail("InterruptedException waiting tests to be executed");
+        } finally {
+            reg.unregister();
+        }
+        
+        if(!s.testsHaveRun) {
+            fail("Timeout waiting for tests to run, after " + timeout + " msec");
+        }
+        */
+    }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 09/15: SLING-2788 - move sling-pax-util under testing

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit 0f3977186270d59a01edbce984e2a1e8966d4945
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 24 10:49:12 2014 +0000

    SLING-2788 - move sling-pax-util under testing
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/sling-pax-util@1560940 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 34d3673..b4b08bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
     <version>1.0-SNAPSHOT</version>
     <packaging>jar</packaging>
 
-    <name>Sling Pax Exam Utilities</name>
+    <name>Apache Sling Pax Exam Utilities</name>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-paxexam-util] 03/15: Take sling.run.modes into account

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.paxexam.util-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-paxexam-util.git

commit f2653fbfa2b279c8451c7a9bfc66fe8def796834
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Nov 6 14:54:25 2013 +0000

    Take sling.run.modes into account
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/sling-pax-util@1539355 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/paxexam/util/SlingPaxOptions.java | 29 +++++++++++++++++++---
 .../sling/paxexam/util/SlingRepositoryTest.java    |  9 ++++++-
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
index ddf833c..acbf777 100644
--- a/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
+++ b/src/main/java/org/apache/sling/paxexam/util/SlingPaxOptions.java
@@ -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) {
diff --git a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
index 0a21f29..dadecf1 100644
--- a/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
+++ b/src/test/java/org/apache/sling/paxexam/util/SlingRepositoryTest.java
@@ -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

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.