You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by re...@apache.org on 2026/08/18 10:49:00 UTC
(sling-org-apache-sling-resourceresolver) branch SLING-13301-1.x created (now a2e91b8c)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch SLING-13301-1.x
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
at a2e91b8c SLING-13301: test syntax variants (#229)
This branch includes the following new commits:
new ee921d8c SLING-13301: test syntax variants (#228)
new a2e91b8c SLING-13301: test syntax variants (#229)
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.
(sling-org-apache-sling-resourceresolver) 02/02: SLING-13301: test syntax variants (#229)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-13301-1.x
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit a2e91b8c2e4de183dbce1fee95ed2e72b2e071db
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Wed Aug 12 15:19:54 2026 +0200
SLING-13301: test syntax variants (#229)
* SLING-13301: test syntax variants
* Update src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
Co-authored-by: Jörg Hoh <jo...@users.noreply.github.com>
* SLING-13301: test syntax variants
---------
Co-authored-by: Jörg Hoh <jo...@users.noreply.github.com>
---
.../impl/mapping/VanityPathMapEntriesTest.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
index ff683aed..87298f52 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
@@ -271,21 +271,21 @@ public class VanityPathMapEntriesTest extends AbstractMappingMapEntriesTest {
@Test
public void test_syntax_variants() {
// absolute path
- internal_test_syntax_variants("/x", "/x");
+ assertPathResolvesTo("/x", "/x");
// relative path
- internal_test_syntax_variants("x", "/x");
+ assertPathResolvesTo("x", "/x");
// multi-segment absolute path
- internal_test_syntax_variants("/x/y", "/x/y");
+ assertPathResolvesTo("/x/y", "/x/y");
// multi-segment relative path
- internal_test_syntax_variants("x/y", "/x/y");
+ assertPathResolvesTo("x/y", "/x/y");
// multi-segment absolute path starting with "//"
- internal_test_syntax_variants("//x//y", "//x//y");
+ assertPathResolvesTo("//x//y", "//x//y");
// multi-segment absolute path starting with "/.."
- internal_test_syntax_variants("/../x", "/../x");
+ assertPathResolvesTo("/../x", "/../x");
// blank path
- internal_test_syntax_variants(" ", null);
+ assertPathResolvesTo(" ", null);
// empty path
- internal_test_syntax_variants("", null);
+ assertPathResolvesTo("", null);
}
private void assertPathResolvesTo(String vanityPath, String expectedPath) {
@@ -299,12 +299,12 @@ public class VanityPathMapEntriesTest extends AbstractMappingMapEntriesTest {
Map<String, List<String>> vanityMap = mapEntries.getVanityPathMappings();
assertNotNull("vm should not be null", vanityMap);
- if (expectation == null) {
+ if (expectedPath == null) {
assertEquals("size of vm should be 0", 0, vanityMap.size());
} else {
assertEquals("size of vm should be 1", 1, vanityMap.size());
assertNotNull("vp should be present in vm, got " + vanityMap, vanityMap.get(path));
- assertEquals(expectation, vanityMap.get(path).get(0));
+ assertEquals(expectedPath, vanityMap.get(path).get(0));
}
}
(sling-org-apache-sling-resourceresolver) 01/02: SLING-13301: test syntax variants (#228)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-13301-1.x
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit ee921d8c1c3e521b08c8067841a0554331912853
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Wed Aug 12 13:22:47 2026 +0200
SLING-13301: test syntax variants (#228)
---
.../impl/mapping/VanityPathMapEntriesTest.java | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
index 05706e03..ff683aed 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
@@ -267,6 +267,66 @@ public class VanityPathMapEntriesTest extends AbstractMappingMapEntriesTest {
assertNotNull(vanityMap.get("/" + containerName + "/" + oneMore));
}
+ // see https://issues.apache.org/jira/browse/SLING-13301
+ @Test
+ public void test_syntax_variants() {
+ // absolute path
+ internal_test_syntax_variants("/x", "/x");
+ // relative path
+ internal_test_syntax_variants("x", "/x");
+ // multi-segment absolute path
+ internal_test_syntax_variants("/x/y", "/x/y");
+ // multi-segment relative path
+ internal_test_syntax_variants("x/y", "/x/y");
+ // multi-segment absolute path starting with "//"
+ internal_test_syntax_variants("//x//y", "//x//y");
+ // multi-segment absolute path starting with "/.."
+ internal_test_syntax_variants("/../x", "/../x");
+ // blank path
+ internal_test_syntax_variants(" ", null);
+ // empty path
+ internal_test_syntax_variants("", null);
+ }
+
+ private void assertPathResolvesTo(String vanityPath, String expectedPath) {
+
+ String path = "/foo/bar";
+
+ prepareMapEntriesForSingleVanityPath(path, vanityPath);
+
+ initializeVanityPaths();
+
+ Map<String, List<String>> vanityMap = mapEntries.getVanityPathMappings();
+
+ assertNotNull("vm should not be null", vanityMap);
+ if (expectation == null) {
+ assertEquals("size of vm should be 0", 0, vanityMap.size());
+ } else {
+ assertEquals("size of vm should be 1", 1, vanityMap.size());
+ assertNotNull("vp should be present in vm, got " + vanityMap, vanityMap.get(path));
+ assertEquals(expectation, vanityMap.get(path).get(0));
+ }
+ }
+
+ private void prepareMapEntriesForSingleVanityPath(String node, String vanityPath) {
+
+ Resource parent = createMockedResource(ResourceUtil.getParent(node));
+
+ Resource vanity = createMockedResource(node);
+ when(vanity.getParent()).thenReturn(parent);
+ when(vanity.getValueMap()).thenReturn(buildValueMap(VanityPathHandler.PROP_VANITY_PATH, vanityPath));
+
+ when(resourceResolver.findResources(anyString(), eq("JCR-SQL2")))
+ .thenAnswer((Answer<Iterator<Resource>>) invocation -> {
+ String query = invocation.getArguments()[0].toString();
+ if (matchesPagedQuery(query)) {
+ return List.of(vanity).iterator();
+ } else {
+ return Collections.emptyIterator();
+ }
+ });
+ }
+
// see SLING-12620
@Test
public void test_simple_vanity_path_support_with_null_parent() {