Thank you @Ritesh_Mittal for your reply, as per my understanding requestProcessor.processRequest(req, resp, resourceResolver); statment will assign the generated response to baos object isn't it. getJSONFromPSPPPage method code is running perfectly fine but somehow not for Junit. Can you please elab...