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:04 UTC

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

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