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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3f81fed  SLING-11755: resource resolver: add test coverage for URL 
patterns in vanity paths (#90)
3f81fed is described below

commit 3f81fed721c944587d39830fc529fd5a8d829603
Author: Julian Reschke <[email protected]>
AuthorDate: Tue Jan 17 15:27:02 2023 +0100

    SLING-11755: resource resolver: add test coverage for URL patterns in 
vanity paths (#90)
---
 .../impl/mapping/ResourceMapperImplTest.java          | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
 
b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
index 33c3803..88f610e 100644
--- 
a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
+++ 
b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
@@ -114,7 +114,8 @@ public class ResourceMapperImplTest {
         resourceProvider.putResource("/parent/child", PROP_ALIAS, 
"alias-child"); // child has alias
         resourceProvider.putResource("/parent/child-multiple", PROP_ALIAS, 
"alias-child-1", "alias-child-2"); // child has multiple alias
         resourceProvider.putResource("/vain", "sling:vanityPath", "/vanity-a", 
"/vanity-b"); // vanity path
-
+        // vanity path with URL shaped target, see SLING-11749
+        resourceProvider.putResource("/vain-url", "sling:vanityPath", /* 
"https://example.com";, TODO: NPE*/ "https://example/";, "https://example/foo";); 
         // build /etc/map structure
         resourceProvider.putResource("/etc");
         resourceProvider.putResource("/etc/map");
@@ -329,6 +330,22 @@ public class ResourceMapperImplTest {
             .verify(resolver, req);
     }
 
+    /**
+     * Validates that vanity paths are returned as mappings, URL shaped 
variants (see see SLING-11749)
+     *
+     * <p>As vanity paths are alternate paths rather than variations so they 
will not be returned
+     * from the singleMapping() methods.</p>
+     */
+    @Test
+    public void mapResourceWithVanityPathsURLTarget() {
+        ExpectedMappings.existingResource("/vain-url")
+            .singleMapping("/vain-url")
+            .singleMappingWithRequest("/app/vain-url")
+            .allMappings("/vain-url", "/foo", "/")
+            .allMappingsWithRequest("/app/vain-url", "/app/foo", "/app/")
+            .verify(resolver, req);
+    }
+
     /**
      * Validates that the mapping for a non-existing resource that is the 
target of an alias
      * is the alias itself

Reply via email to