You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (Jira)" <ji...@apache.org> on 2024/08/19 08:54:00 UTC
[jira] [Resolved] (SLING-10062) Provide a way to allow mocking of findResources or query manager for resource resolvers / sessions obtained inside production code
[ https://issues.apache.org/jira/browse/SLING-10062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Seifert resolved SLING-10062.
------------------------------------
Resolution: Duplicate
should be fixed with SLING-12001
> Provide a way to allow mocking of findResources or query manager for resource resolvers / sessions obtained inside production code
> ----------------------------------------------------------------------------------------------------------------------------------
>
> Key: SLING-10062
> URL: https://issues.apache.org/jira/browse/SLING-10062
> Project: Sling
> Issue Type: Improvement
> Components: Testing
> Reporter: Roy Teeuwen
> Priority: Major
>
> At this moment it is not possible to do a mock for query results of resource resolvers / sessions that are obtained inside the code instead of passed as method parameter from the SlingContext / JcrContext.
> Example:
> {code:java}
> @Component
> public class MyClass {
> @Reference
> private ResourceResolverFactory resourceResolverFactory;
> public void methodToTest() {
> try(ResourceResolver resourceResolver: resourceResolverFactory.getServiceResourceResolver(AUTH_INFO)) {
> // something to test
> }
> }
> }{code}
> Currently I solve this by just making a second method that gets the resource resolver as parameter and making it public so that it can be tested, but that breaks my private / public stuff
--
This message was sent by Atlassian Jira
(v8.20.10#820010)