I set up a small project to test the AemMocks dependencies (because the "big" project kept failing) and I'm stuck with an NPE:
java.lang.NullPointerException
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolver(SlingContextImpl.java:189)
The project is at https://github.com/dplaton/test-aem-mocks - it has just a test class which creates a resource in the "setUp" method.
You're right, it's that kind of error that makes you go crazy when in fact the cause is trivial - adding the @Rule annotation fixed the NPE, but leads to another error:
- when using JCR_MOCK I get a java.lang.RuntimeException: Unable to initialize JCR_MOCK resource resolver factory: Unable to get ResourceResolverFactory.
- when using JCR_OAK I get "java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository", caused by Caused by: java.lang.IllegalAccessError: tried to access class org.apache.jackrabbit.oak.plugins.version.VersionEditorProvider from class org.apache.jackrabbit.oak.jcr.Jcr
I updated my project to use public dependencies.
Thank you and have a nice day,
Dan
Well, I finally got it working, using the aem-mocks 2.0.1-SNAPSHOT.
I was using org.apache.sling.commons.testing library in order to use RepositoryUtil#registerNodeTypes(). Do I have an alternative for registering node-types other that o.a.s.c.testing?
Thank you and have a nice day,
Dan