Expand my Community achievements bar.

Who Me Too'd this topic

Avatar

Level 1

Hello,

I'm new to AEM and AEM Mocks, and trying to implement unit testing in a small AEM 6.5 project. However I'm having issues with the AemContext.

I have 3 test cases to test an OSGi service, the service itself is basically a POJO that takes a page (com.day.cq.wcm.api.Page) as a parameter.

My problem is that only the first test case that executes can retrieve pages from the mock context. The other two test cases, even when using the exact same method of grabbing pages, result in a NullPointerException on the line that gets the page from the context.

I've also tried using context.currentResource("/content/en/eventPage1").adaptTo(Page.class); and again this works only in the first test method.

Here is my test file:

And my test JSON:

Who Me Too'd this topic