[ 
https://issues.apache.org/jira/browse/SLING-11252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17567170#comment-17567170
 ] 

Stefan Seifert commented on SLING-11252:
----------------------------------------

we also need a better solution in context of SLING-11455 - as soon as we switch 
to MockResourceProvider in sling-mock, even the workaround shown in the 
description will no longer work.

> RRMockResourceResolverWrapper supports no way of mocking searches
> -----------------------------------------------------------------
>
>                 Key: SLING-11252
>                 URL: https://issues.apache.org/jira/browse/SLING-11252
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing Sling Mock 3.2.2
>            Reporter: Henry Kuijpers
>            Assignee: Stefan Seifert
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Previously, it was possible to call 
> ((MockResourceResolver)context.resourceResolver()).addFindResourceHandler(...)
> Currently, we have to add a "find resource handler" this way:
> {code:java}
>         final Field wrappedField = 
> ResourceResolverWrapper.class.getDeclaredField("wrapped");
>         wrappedField.setAccessible(true);
>         ((MockResourceResolver) 
> wrappedField.get(context.resourceResolver())).addFindResourceHandler((s, s1) 
> -> {
>             assertEquals("my-language", s);
>             assertEquals("search term", s1);
>             return contentResource.listChildren();
>         });
> {code}
> This wrapping seems to have been added in: 
> https://github.com/apache/sling-org-apache-sling-testing-sling-mock/commit/a6d01ff058d422ff544c2a137b42291bd550f603
> We could add logic that consults the ResourceProviders to see if they can 
> execute the custom search that we'd like to do, or, we could add the methods 
> also on RRMockResourceResolverWrapper.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to