This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-12894
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
The following commit(s) were added to refs/heads/SLING-12894 by this push:
new a568dc62 SLING-12894: alias refactoring - support observation events
while bg init not finished
a568dc62 is described below
commit a568dc62535ed55457e83c0de69091f0c9cd15e1
Author: Julian Reschke <[email protected]>
AuthorDate: Fri Aug 22 14:32:40 2025 +0100
SLING-12894: alias refactoring - support observation events while bg init
not finished
---
.../impl/mapping/AliasMapEntriesTest.java | 26 +++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
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 36a77aaa..db2bd0a3 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
@@ -1269,7 +1269,12 @@ public class AliasMapEntriesTest extends
AbstractMappingMapEntriesTest {
assertFalse(ah.isReady());
// bg init will wait until we give green light
+ // Resource leaf2 = createMockedResource(top, "leaf2");
+ //
when(leaf2.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS,
"alias2"));
+
+ removeResource(leaf);
mapEntries.onChange(List.of(new
ResourceChange(ResourceChange.ChangeType.REMOVED, leaf.getPath(), false)));
+ // mapEntries.onChange(List.of(new
ResourceChange(ResourceChange.ChangeType.ADDED, leaf2.getPath(), false)));
greenLight.set(true);
waitForBgInit();
@@ -1358,7 +1363,6 @@ public class AliasMapEntriesTest extends
AbstractMappingMapEntriesTest {
}
private void attachChildResource(Resource parent, Resource child) {
-
List<Resource> newChildren = new ArrayList<>();
parent.getChildren().forEach(newChildren::add);
newChildren.add(child);
@@ -1368,4 +1372,24 @@ public class AliasMapEntriesTest extends
AbstractMappingMapEntriesTest {
when(child.getParent()).thenReturn(parent);
}
+
+ private void detachChildResource(Resource parent, Resource child) {
+ List<Resource> oldChildren = new ArrayList<>();
+ parent.getChildren().forEach(oldChildren::add);
+ oldChildren.remove(child);
+
+ when(parent.getChildren()).thenReturn(oldChildren);
+ when(parent.getChild(child.getName())).thenReturn(null);
+
+ when(child.getParent()).thenReturn(null);
+ }
+
+ private void removeResource(Resource resource) {
+ Resource parent = resource.getParent();
+ if (parent != null) {
+ detachChildResource(parent, resource);
+ }
+ when(resource.getParent()).thenReturn(null);
+
when(resourceResolver.getResource(resource.getPath())).thenReturn(null);
+ }
}