[
https://issues.apache.org/jira/browse/SLING-11252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17517437#comment-17517437
]
Henry Kuijpers commented on SLING-11252:
----------------------------------------
This indeed allows us to access the MockResourceResolver without reflection, so
that's already an improvement.
I however think that it might be better to add the methods on
RRMockResourceResolverWrapper as well? Or provide another mechanism to be able
to override these mock querys.
Maybe by just implementing a mock OSGi service? Or even a mock
QueryLanguageProvider?
> 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
>
> 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.1#820001)