You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2020/02/23 10:16:20 UTC

[sling-org-apache-sling-servlets-resolver] branch master updated (c14870e -> 23b4e02)

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

olli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git.


    from c14870e  Workaround for pax's RepositoryOptionImpl bug (and yes I should contribute a fix to that)
     new b69759c  SLING-8962 Use Sling API 2.22.0
     new 351e78f  SLING-9130 Update to Sling Bundle Parent 38
     new 23b4e02  SLING-9105 Update Pax Exam to 4.13.2

The 3 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.


Summary of changes:
 pom.xml                                            |  26 +++-
 .../resolver/it/ServletResolverTestSupport.java    | 131 +++++++--------------
 2 files changed, 64 insertions(+), 93 deletions(-)


[sling-org-apache-sling-servlets-resolver] 03/03: SLING-9105 Update Pax Exam to 4.13.2

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git

commit 23b4e02fd2b696a5df808c5fddfb5e2ef6cc2b59
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Feb 23 11:15:54 2020 +0100

    SLING-9105 Update Pax Exam to 4.13.2
    
    Update Pax Exam and clean up configurations
---
 pom.xml                                            |  20 +++-
 .../resolver/it/ServletResolverTestSupport.java    | 131 +++++++--------------
 2 files changed, 61 insertions(+), 90 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8886e72..fb0d41f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,7 @@
 
     <properties>
         <site.jira.version.id>12314292</site.jira.version.id>
-        <pax.exam.version>4.13.1</pax.exam.version>
+        <pax.exam.version>4.13.2</pax.exam.version>
         <!-- To debug the pax process, override this with -D -->
         <pax.vm.options>-Xmx512M</pax.vm.options>
     </properties>
@@ -124,6 +124,7 @@
             </plugin>
         </plugins>
     </build>
+
     <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
@@ -291,5 +292,22 @@
             <version>1.3.0</version>
             <scope>test</scope>
         </dependency>
+        <!-- compatible with API 2.22.0 -->
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.resourceresolver</artifactId>
+            <version>1.6.16</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- compatible with API 2.22.0, but breaks ScriptSelection2Test (see ServletResolverTestSupport)-->
+        <!--
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.scripting.core</artifactId>
+            <version>2.2.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        -->
     </dependencies>
+
 </project>
diff --git a/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.java b/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.java
index e0f5fe6..35e6c96 100644
--- a/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.java
+++ b/src/test/java/org/apache/sling/servlets/resolver/it/ServletResolverTestSupport.java
@@ -18,28 +18,8 @@
  */
 package org.apache.sling.servlets.resolver.it;
 
-import org.apache.sling.testing.paxexam.TestSupport;
-import org.junit.Before;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
-import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
-import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
-import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 
 import javax.inject.Inject;
@@ -50,23 +30,35 @@ import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.servlethelpers.MockSlingHttpServletRequest;
 import org.apache.sling.servlethelpers.MockSlingHttpServletResponse;
-import org.ops4j.pax.exam.options.CompositeOption;
-import static org.ops4j.pax.exam.CoreOptions.vmOption;
-import static org.ops4j.pax.exam.CoreOptions.keepCaches;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.when;
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.junit.Before;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
+import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
+import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+
 public class ServletResolverTestSupport extends TestSupport {
+
     @Inject
     private ResourceResolverFactory resourceResolverFactory;
 
     @Inject
     protected BundleContext bundleContext;
 
-    protected final int httpPort = findFreePort();
-
     private final static int STARTUP_WAIT_SECONDS = 30;
 
     public static final String P_PATHS = "sling.servlet.paths";
@@ -82,31 +74,16 @@ public class ServletResolverTestSupport extends TestSupport {
     @Configuration
     public Option[] configuration() {
         final String vmOpt = System.getProperty("pax.vm.options");
-        final String localRepo = System.getProperty("maven.repo.local", "");
-
-        // workaround for https support, and pax's RepositoryOptionImpl adds a +
-        // in front of each URL, cannot use several instances of that option
-        final String repositoriesURL =
-            "+"
-            + "https://repository.apache.org/content/groups/snapshots/@snapshots@id=apache-snapshots"
-            + ",https://repo1.maven.org/maven2@id=central"
-        ;
-
         assertNotNull("Expecting non-null VM options", vmOpt);
-        return remove(
-            options(
+        versionResolver.setVersionFromProject("org.apache.sling", "org.apache.sling.api");
+        versionResolver.setVersionFromProject("org.apache.sling", "org.apache.sling.resourceresolver");
+        // adding Scripting Core to POM breaks ScriptSelection2Test
+        versionResolver.setVersion("org.apache.sling", "org.apache.sling.scripting.core", "2.2.0-SNAPSHOT");
+        return options(
+            composite(
                 vmOption(vmOpt),
-                failOnUnresolvedBundles(),
-                keepCaches(),
-                systemProperty("org.ops4j.pax.url.mvn.repositories").value(repositoriesURL),
-                when(localRepo.length() > 0).useOptions(
-                    systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)
-                ),
                 baseConfiguration(),
-                slingQuickstartOakTar(workingDirectory(), httpPort),
-                mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.api").versionAsInProject(),
-                mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.resourceresolver").version("1.6.16"), // compatible with API 2.22.0
-                mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.scripting.core").version("2.1.1-SNAPSHOT"), // compatible with API 2.22.0 - TODO replace with release when available
+                slingQuickstart(),
                 mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.converter").version("1.0.12"), // new Sling API dependency
                 testBundle("bundle.filename"),
                 wrappedBundle(mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.servlet-helpers").versionAsInProject()),
@@ -114,15 +91,21 @@ public class ServletResolverTestSupport extends TestSupport {
                 newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
                     .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
                     .asOption()
-            ),
-            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.api").version(versionResolver),
-            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.resourceresolver").version(versionResolver),
-            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.scripting.core").version(versionResolver),
-            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.servlets.resolver").version(versionResolver) // remove bundle from slingQuickstartOakTar, added via testBundle in current version
+            ).remove(
+                mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.servlets.resolver").version(versionResolver) // remove bundle from slingQuickstartOakTar, added via testBundle in current version
+            )
         );
     }
 
-    /** Injecting the appropriate services to wait for would be more elegant but this is very reliable.. */
+    protected Option slingQuickstart() {
+        final int httpPort = findFreePort();
+        final String workingDirectory = workingDirectory();
+        return slingQuickstartOakTar(workingDirectory, httpPort);
+    }
+
+    /**
+     * Injecting the appropriate services to wait for would be more elegant but this is very reliable..
+     */
     @Before
     public void waitForSling() throws Exception {
         final int expectedStatus = 200;
@@ -130,10 +113,10 @@ public class ServletResolverTestSupport extends TestSupport {
         final String path = "/.json";
         final long endTime = System.currentTimeMillis() + STARTUP_WAIT_SECONDS * 1000;
 
-        while(System.currentTimeMillis() < endTime) {
+        while (System.currentTimeMillis() < endTime) {
             final int status = executeRequest(path, -1).getStatus();
             statuses.add(status);
-            if(status == expectedStatus) {
+            if (status == expectedStatus) {
                 return;
             }
             Thread.sleep(250);
@@ -170,7 +153,7 @@ public class ServletResolverTestSupport extends TestSupport {
         try {
             // void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse resource, ResourceResolver resourceResolver)
             final Method processMethod = processor.getClass().getMethod(
-                "processRequest", 
+                "processRequest",
                 HttpServletRequest.class, HttpServletResponse.class, ResourceResolver.class);
             assertNotNull("Expecting processRequest method", processMethod);
             processMethod.invoke(processor, request, response, resourceResolver);
@@ -178,7 +161,7 @@ public class ServletResolverTestSupport extends TestSupport {
             bundleContext.ungetService(ref);
         }
 
-        if(expectedStatus > 0) {
+        if (expectedStatus > 0) {
             assertEquals("Expected status " + expectedStatus + " for " + method
                 + " at " + path, expectedStatus, response.getStatus());
         }
@@ -204,34 +187,4 @@ public class ServletResolverTestSupport extends TestSupport {
         assertTrue("Expecting output to contain " + expected + ", got " + output, output.contains(expected));
     }
 
-    // move below helpers for deep removal to Pax Exam
-
-    private static List<Option> expand(final Option[] options) {
-        final List<Option> expanded = new ArrayList<>();
-        if (options != null) {
-            for (final Option option : options) {
-                if (option != null) {
-                    if (option instanceof CompositeOption) {
-                        expanded.addAll(Arrays.asList(((CompositeOption) option).getOptions()));
-                    } else {
-                        expanded.add(option);
-                    }
-                }
-            }
-        }
-        return expanded;
-    }
-
-    private static Option[] remove(final Option[] options, final Option... removables) {
-        final List<Option> expanded = expand(options);
-        for (final Option removable : removables) {
-            if (removable instanceof CompositeOption) {
-                expanded.removeAll(Arrays.asList(((CompositeOption) removable).getOptions()));
-            } else {
-                expanded.removeAll(Collections.singleton(removable));
-            }
-        }
-        return expanded.toArray(new Option[0]);
-    }
-
 }


[sling-org-apache-sling-servlets-resolver] 02/03: SLING-9130 Update to Sling Bundle Parent 38

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git

commit 351e78f2afefb4aaf58a830b278e358f8edbf206
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Feb 23 11:05:36 2020 +0100

    SLING-9130 Update to Sling Bundle Parent 38
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6efa02f..8886e72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
-        <version>35</version>
+        <version>38</version>
         <relativePath />
     </parent>
 


[sling-org-apache-sling-servlets-resolver] 01/03: SLING-8962 Use Sling API 2.22.0

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git

commit b69759cbd7423224d4a18a47749d58c9b51bb26e
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Feb 23 11:03:46 2020 +0100

    SLING-8962 Use Sling API 2.22.0
    
    Use release and increase minor version
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1d33cb9..6efa02f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.servlets.resolver</artifactId>
-    <version>2.5.9-SNAPSHOT</version>
+    <version>2.6.0-SNAPSHOT</version>
 
     <name>Apache Sling Servlets Resolver</name>
     <description>
@@ -150,7 +150,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.22.1-SNAPSHOT</version>
+            <version>2.22.0</version>
             <scope>provided</scope>
         </dependency>
         <!-- for ServiceUserMapped (SLING-4312) -->