You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2020/01/28 12:40:03 UTC

[sling-org-apache-sling-servlets-resolver] branch master updated (58689df -> 17ebdad)

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

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


    from 58689df  Pax exam bug workaround
     new b09faa4  SLING-8936 - use constants
     new 17ebdad  SLING-8936 - clearer syntax

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:
 .../resolver/it/ServletResolverTestSupport.java    | 19 +++++++--
 .../servlets/resolver/it/ServletSelectionIT.java   | 48 +++++++++++-----------
 2 files changed, 40 insertions(+), 27 deletions(-)


[sling-org-apache-sling-servlets-resolver] 02/02: SLING-8936 - clearer syntax

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

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

commit 17ebdade79d9673d5656bfcfb361f5ed4615dd26
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jan 28 13:39:50 2020 +0100

    SLING-8936 - clearer syntax
---
 .../sling/servlets/resolver/it/ServletResolverTestSupport.java | 10 +++++++---
 .../apache/sling/servlets/resolver/it/ServletSelectionIT.java  |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)

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 25f9b5c..bca6901 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
@@ -166,9 +166,13 @@ public class ServletResolverTestSupport extends TestSupport {
     }
 
     protected void assertTestServlet(final String method, final String path, final String servletName) throws Exception {
-        final String output = executeRequest(method, path, 200).getOutputAsString();
-        final String expected = TestServlet.SERVED_BY_PREFIX + servletName;
-        assertTrue("Expecting output to contain " + expected + ", got " + output, output.contains(expected));
+        if(servletName == null) {
+            executeRequest(method, path, 404);
+        } else {
+            final String output = executeRequest(method, path, 200).getOutputAsString();
+            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
diff --git a/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java b/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java
index 201f5b4..3b7d730 100644
--- a/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java
+++ b/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java
@@ -95,7 +95,7 @@ public class ServletSelectionIT extends ServletResolverTestSupport {
 
     @Test
     public void testFooPathServletWithPathSuffix() throws Exception {
-        executeRequest("/foo/path/suffix", 404);
+        assertTestServlet("/foo/path/suffix", null);
         assertTestServlet("/foo.someExtensions/path/suffix", "FooPathServlet");
         assertTestServlet("/foo.someSelector.someExtension/path/suffix", "FooPathServlet");
     }
@@ -112,7 +112,7 @@ public class ServletSelectionIT extends ServletResolverTestSupport {
 
     @Test
     public void testNoServletForExtension() throws Exception {
-        executeRequest("/.yapas", 404);
+        assertTestServlet("/.yapas", null);
     }
 
     @Test


[sling-org-apache-sling-servlets-resolver] 01/02: SLING-8936 - use constants

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

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

commit b09faa453ab6863d8bfe0d2723861a6f28cc7a78
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jan 28 13:36:21 2020 +0100

    SLING-8936 - use constants
---
 .../resolver/it/ServletResolverTestSupport.java    |  9 +++++
 .../servlets/resolver/it/ServletSelectionIT.java   | 44 +++++++++++-----------
 2 files changed, 31 insertions(+), 22 deletions(-)

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 4634785..25f9b5c 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
@@ -65,6 +65,15 @@ public class ServletResolverTestSupport extends TestSupport {
 
     private final static int STARTUP_WAIT_SECONDS = 30;
 
+    public static final String P_PATHS = "sling.servlet.paths";
+    public static final String P_RESOURCE_TYPES = "sling.servlet.resourceTypes";
+    public static final String P_METHODS = "sling.servlet.methods";
+    public static final String P_EXTENSIONS = "sling.servlet.extensions";
+    public static final String P_SELECTORS = "sling.servlet.selectors";
+    public static final String RT_DEFAULT = "sling/servlet/default";
+    public static final String M_GET = "GET";
+    public static final String M_POST = "POST";
+
     @Configuration
     public Option[] configuration() {
         return remove(
diff --git a/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java b/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java
index 831e9f3..201f5b4 100644
--- a/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java
+++ b/src/test/java/org/apache/sling/servlets/resolver/it/ServletSelectionIT.java
@@ -36,34 +36,34 @@ public class ServletSelectionIT extends ServletResolverTestSupport {
     public void setupTestServlets() throws Exception {
 
         new TestServlet("FooPathServlet")
-        .with("sling.servlet.paths", "/foo")
+        .with(P_PATHS, "/foo")
         .register(bundleContext);
 
         new TestServlet("AllExceptPathsIgnored")
-        .with("sling.servlet.paths", "/allprops")
-        .with("sling.servlet.resourceTypes", "allresource")
-        .with("sling.servlet.methods", "allmethod")
-        .with("sling.servlet.extensions", "allext")
-        .with("sling.servlet.selectors", "allsel")
+        .with(P_PATHS, "/allprops")
+        .with(P_RESOURCE_TYPES, "allresource")
+        .with(P_METHODS, "allmethod")
+        .with(P_EXTENSIONS, "allext")
+        .with(P_SELECTORS, "allsel")
         .register(bundleContext);
 
         new TestServlet("ExtServlet")
-        .with("sling.servlet.resourceTypes", "sling/servlet/default")
-        .with("sling.servlet.methods", "GET")
-        .with("sling.servlet.extensions", "testext")
+        .with(P_RESOURCE_TYPES, RT_DEFAULT)
+        .with(P_METHODS, M_GET)
+        .with(P_EXTENSIONS, "testext")
         .register(bundleContext);
 
         new TestServlet("ExtPostServlet")
-        .with("sling.servlet.resourceTypes", "sling/servlet/default")
-        .with("sling.servlet.methods", "POST")
-        .with("sling.servlet.extensions", "testext")
+        .with(P_RESOURCE_TYPES, RT_DEFAULT)
+        .with(P_METHODS, M_POST)
+        .with(P_EXTENSIONS, "testext")
         .register(bundleContext);
 
         new TestServlet("ExtSelServlet")
-        .with("sling.servlet.resourceTypes", "sling/servlet/default")
-        .with("sling.servlet.methods", "GET")
-        .with("sling.servlet.extensions", "testext")
-        .with("sling.servlet.selectors", "testsel")
+        .with(P_RESOURCE_TYPES, RT_DEFAULT)
+        .with(P_METHODS, M_GET)
+        .with(P_EXTENSIONS, "testext")
+        .with(P_SELECTORS, "testsel")
         .register(bundleContext);
     }
 
@@ -117,7 +117,7 @@ public class ServletSelectionIT extends ServletResolverTestSupport {
 
     @Test
     public void testExtPostServlet() throws Exception {
-        assertTestServlet("POST", "/.testext", "ExtPostServlet");
+        assertTestServlet(M_POST, "/.testext", "ExtPostServlet");
     }
 
     @Test
@@ -125,11 +125,11 @@ public class ServletSelectionIT extends ServletResolverTestSupport {
         assertTestServlet("/allprops", "AllExceptPathsIgnored");
         assertTestServlet("/allprops.zero", "AllExceptPathsIgnored");
         assertTestServlet("/allprops.one.two", "AllExceptPathsIgnored");
-        assertTestServlet("POST", "/allprops", "AllExceptPathsIgnored");
-        assertTestServlet("POST", "/allprops.ext", "AllExceptPathsIgnored");
-        assertTestServlet("POST", "/allprops.three.four", "AllExceptPathsIgnored");
+        assertTestServlet(M_POST, "/allprops", "AllExceptPathsIgnored");
+        assertTestServlet(M_POST, "/allprops.ext", "AllExceptPathsIgnored");
+        assertTestServlet(M_POST, "/allprops.three.four", "AllExceptPathsIgnored");
         assertTestServlet("/allprops.five.six/suffix", "AllExceptPathsIgnored");
-        assertTestServlet("POST", "/allprops.seven.eight/suffix", "AllExceptPathsIgnored");
-        assertTestServlet("POST", "/allprops.nine/suffix", "AllExceptPathsIgnored");
+        assertTestServlet(M_POST, "/allprops.seven.eight/suffix", "AllExceptPathsIgnored");
+        assertTestServlet(M_POST, "/allprops.nine/suffix", "AllExceptPathsIgnored");
     }
 }
\ No newline at end of file