You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Roy Teeuwen (Jira)" <ji...@apache.org> on 2021/01/13 14:52:00 UTC
[jira] [Created] (SLING-10062) Provide a way to allow mocking of
findResources or query manager for resource resolvers / sessions obtained
inside production code
Roy Teeuwen created SLING-10062:
-----------------------------------
Summary: 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
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.3.4#803005)