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/01/11 07:22:50 UTC

[sling-org-apache-sling-servlets-resolver] branch issue/SLING-8936 updated (c5d590a -> 719d3f8)

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

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


    from c5d590a  SLING-8936 - add more servlet selection tests
     new 9cb1a69  SLING-8936 Improve test coverage for path-mounted servlets
     new 719d3f8  SLING-8936 Improve test coverage for path-mounted servlets

The 2 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                                            |  4 +-
 .../resolver/it/ServletResolverTestSupport.java    | 66 ++++++++++++++++++----
 2 files changed, 58 insertions(+), 12 deletions(-)


[sling-org-apache-sling-servlets-resolver] 01/02: SLING-8936 Improve test coverage for path-mounted servlets

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

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

commit 9cb1a69b8035c69618abf7e1758370d35edd19a9
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sat Jan 11 08:09:11 2020 +0100

    SLING-8936 Improve test coverage for path-mounted servlets
    
    * Use Sling API 2.22.0
    * Use Resource Resolver compatible with API 2.22.0
    * Use Scripting Core compatible with API 2.22.0
    * Remove duplicated bundle
---
 pom.xml                                            |  2 +-
 .../resolver/it/ServletResolverTestSupport.java    | 66 ++++++++++++++++++----
 2 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/pom.xml b/pom.xml
index 675d330..a447c47 100644
--- a/pom.xml
+++ b/pom.xml
@@ -144,7 +144,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.20.0</version>
+            <version>2.22.0</version>
             <scope>provided</scope>
         </dependency>
         <!-- for ServiceUserMapped (SLING-4312) -->
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 84e29d6..cdb050b 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
@@ -25,9 +25,11 @@ 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;
@@ -36,6 +38,8 @@ 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;
@@ -46,6 +50,7 @@ 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 org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
@@ -62,16 +67,26 @@ public class ServletResolverTestSupport extends TestSupport {
 
     @Configuration
     public Option[] configuration() {
-        return new Option[]{
-            baseConfiguration(),
-            slingQuickstartOakTar(workingDirectory(), httpPort),
-            testBundle("bundle.filename"),
-            wrappedBundle(mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.servlet-helpers").versionAsInProject()),
-            junitBundles(),
-            newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
-                .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
-                .asOption(),
-        };
+        return remove(
+            options(
+                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
+                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()),
+                junitBundles(),
+                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
+        );
     }
 
     @Before
@@ -133,4 +148,35 @@ public class ServletResolverTestSupport extends TestSupport {
         final String expected = TestServlet.SERVED_BY_PREFIX + servletName;
         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/02: SLING-8936 Improve test coverage for path-mounted servlets

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

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

commit 719d3f891e46787926803bace96ccce40361453b
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sat Jan 11 08:09:50 2020 +0100

    SLING-8936 Improve test coverage for path-mounted servlets
    
    * Use Testing PaxExam 3.1.0
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a447c47..c91c48f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -270,7 +270,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.paxexam</artifactId>
-            <version>3.0.0</version>
+            <version>3.1.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>