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/02/11 12:16:35 UTC
(sling-org-apache-sling-resourceresolver) branch SLING-12653 created (now 429f563)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a change to branch SLING-12653
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
at 429f563 SLING-12653: add test coverage for query exception disabling optimized alias handling
This branch includes the following new commits:
new 429f563 SLING-12653: add test coverage for query exception disabling optimized alias handling
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-12653: add test coverage for query exception disabling optimized alias handling
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-12653
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 429f56388b615f8909a9ea9739d1ab3db8b384aa
Author: Julian Reschke <re...@apache.org>
AuthorDate: Tue Feb 11 13:16:12 2025 +0100
SLING-12653: add test coverage for query exception disabling optimized alias handling
---
.../impl/mapping/MapEntriesTest.java | 33 ++++++++++++++++------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
index ffc5c27..58dd5c9 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
@@ -162,6 +162,12 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
assertEquals(List.of("foo", "bar"), aliasMap.get("child"));
}
+ @Test
+ public void internal_test_simple_alias_support_throwing_unsupported_operation_exception_exception() {
+ prepareMapEntriesForAlias(false, false, UnsupportedOperationException.class, "foo", "bar");
+ assertFalse(mapEntries.initializeAliases());
+ }
+
@Test
public void test_simple_multi_alias_support() {
internal_test_simple_multi_alias_support(false);
@@ -206,7 +212,12 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
assertEquals(invalidAliases.size(), detectedInvalidAliases.get());
}
- private void prepareMapEntriesForAlias(boolean onJcrContent, boolean withNullParent, String... alias) {
+ private void prepareMapEntriesForAlias(boolean onJcrContent, boolean withNullParent, String... aliases) {
+ prepareMapEntriesForAlias(onJcrContent, withNullParent, null, aliases);
+ }
+
+ private void prepareMapEntriesForAlias(boolean onJcrContent, boolean withNullParent, Class<? extends Exception> queryThrowsWith,
+ String... aliases) {
Resource parent = mock(Resource.class);
when(parent.getPath()).thenReturn("/parent");
@@ -222,15 +233,19 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
when(content.getPath()).thenReturn("/parent/child/jcr:content");
when(content.getName()).thenReturn("jcr:content");
- when(aliasResource.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, alias));
+ when(aliasResource.getValueMap()).thenReturn(buildValueMap(ResourceResolverImpl.PROP_ALIAS, aliases));
- when(resourceResolver.findResources(anyString(), eq("JCR-SQL2"))).thenAnswer((Answer<Iterator<Resource>>) invocation -> {
- if (invocation.getArguments()[0].toString().contains(ResourceResolverImpl.PROP_ALIAS)) {
- return List.of(aliasResource).iterator();
- } else {
- return Collections.emptyIterator();
- }
- });
+ if (queryThrowsWith == null) {
+ when(resourceResolver.findResources(anyString(), eq("JCR-SQL2"))).thenAnswer((Answer<Iterator<Resource>>) invocation -> {
+ if (invocation.getArguments()[0].toString().contains(ResourceResolverImpl.PROP_ALIAS)) {
+ return List.of(aliasResource).iterator();
+ } else {
+ return Collections.emptyIterator();
+ }
+ });
+ } else {
+ when(resourceResolver.findResources(anyString(), eq("JCR-SQL2"))).thenThrow(queryThrowsWith);
+ }
}
@Test