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 2025/05/23 10:02:02 UTC

(sling-org-apache-sling-resourceresolver) branch SLING-12799 created (now 988beee2)

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

reschke pushed a change to branch SLING-12799
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


      at 988beee2 SLING-12799: alias refactoring - check behavior when aliases both on node and jcr:content child node

This branch includes the following new commits:

     new 988beee2 SLING-12799: alias refactoring - check behavior when aliases both on node and jcr:content child node

The 1 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) 01/01: SLING-12799: alias refactoring - check behavior when aliases both on node and jcr:content child node

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

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

commit 988beee2abaaa2e46f597e132a0df1a62ea96f19
Author: Julian Reschke <re...@apache.org>
AuthorDate: Fri May 23 11:01:44 2025 +0100

    SLING-12799: alias refactoring - check behavior when aliases both on node and jcr:content child node
---
 .../impl/mapping/AliasMapEntriesTest.java          | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java
index 9157dee0..10aa16d1 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/AliasMapEntriesTest.java
@@ -324,6 +324,49 @@ public class AliasMapEntriesTest extends AbstractMappingMapEntriesTest {
         assertEquals(1, detectedConflictingAliases.get());
     }
 
+    // checks that alias lists for "x" and "x/jcr:content" are merged
+    @Test
+    public void test_alias_on_parent_and_on_content_child() {
+        Resource parent = mock(Resource.class);
+        when(parent.getPath()).thenReturn("/parent");
+        when(parent.getName()).thenReturn("parent");
+
+        final Resource node = mock(Resource.class);
+        when(node.getParent()).thenReturn(parent);
+        when(node.getPath()).thenReturn("/parent/node");
+        when(node.getName()).thenReturn("node");
+        when(node.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "alias"));
+
+        final Resource content = mock(Resource.class);
+        when(content.getParent()).thenReturn(node);
+        when(content.getPath()).thenReturn("/parent/node/jcr:content");
+        when(content.getName()).thenReturn("jcr:content");
+        when(content.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, "contentalias"));
+
+        when(resourceResolver.findResources(anyString(), eq("JCR-SQL2")))
+                .thenAnswer((Answer<Iterator<Resource>>) invocation -> {
+                    if (invocation.getArguments()[0].toString().contains(ResourceResolverImpl.PROP_ALIAS)) {
+                        return List.of(node, content).iterator();
+                    } else {
+                        return Collections.emptyIterator();
+                    }
+                });
+
+        mapEntries.ah.initializeAliases();
+
+        // "/parent" has aliases both from "/parent/node" and "parent/node/jcr:content"
+        Map<String, Collection<String>> aliasMap = mapEntries.getAliasMap("/parent");
+        assertNotNull(aliasMap);
+        assertTrue(aliasMap.containsKey("node"));
+        assertEquals(2, aliasMap.get("node").size());
+        assertTrue("alias", aliasMap.get("node").containsAll(List.of("alias", "contentalias")));
+
+        // "/parent/node" has no aliases
+        Map<String, Collection<String>> nodeAliasMap = mapEntries.getAliasMap("/parent/node");
+        assertNotNull(nodeAliasMap);
+        assertEquals(0, nodeAliasMap.size());
+    }
+
     @Test
     public void test_getActualContentPath() throws Exception {