How to unit test below piece of code, without getting a "Resourceresolver already closed" exception.
I am using AemContext.resourceResolver() to get handle onto resource resolver and try with resource block closing resource resolver after unit of work complete.
How anyone is testing below piece of code
try (ResourceResolver resolver = factory.getServiceResourceResolver(authInfo)) {
Resource resource = resolver.getResource("/content/sourcedcode/jcr:content");
if (Objects.nonNull(resource)) {
String prop = resource.getValueMao().get("key", String.class);
}
} catch (Exception e) {
e.printStackTrace();
}