This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch SLING-12648
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
The following commit(s) were added to refs/heads/SLING-12648 by this push:
new e8609e3 SLING-12653: add test coverage for query exception disabling
optimized alias handling (#141)
e8609e3 is described below
commit e8609e3a2283bc336a7501bb138de52189cf3927
Author: Julian Reschke <[email protected]>
AuthorDate: Tue Feb 11 15:45:20 2025 +0100
SLING-12653: add test coverage for query exception disabling optimized
alias handling (#141)
---
.../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