JUnit 5 throws java.lang.NullPointerException: Cannot invoke "org.apache.sling.api.resource.Resource.getPath()" because "parent" is null
Hi,
I have a servlet uses SlingServletPaths and Get Method. Servlet receives more than one request parameter then perform operations.
I have below ServletTest to test my ExampleServlet. Below Error is thrown when I ran mvn clean install command
java.lang.NullPointerException: Cannot invoke "org.apache.sling.api.resource.Resource.getPath()" because "parent" is null
@ExtendWith(AemContextExtension.class)
public class ExampleServletTest {
ExampleServlet example = new ExampleServlet();
@2785667
void testDoGet(AemContext context)throws ServletException,IOException {
MockSlingHttpServletRequest request = context.request();
MockSlingHttpServletResponse response = context.response();
request.setQueryString("param1=test1");
request.setQueryString("param2=test2");
request.setQueryString("param3=test3");
example.doGet(request, response);
}
}
Any pointer or help would be appreciated?