### Question:
AssetRenditionServlet extends SlingSafeMethodsServlet { public final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, ServletException { try { final AssetRenditionParameters parameters = new AssetRenditionParameters(request); if (acceptsAssetRenditionParameters(parameters)) { for (final AssetRenditionDispatcher assetRenditionDispatcher : assetRenditionDispatchers.getAssetRenditionDispatchers()) { if (acceptedByAssetRenditionDispatcher(assetRenditionDispatcher, parameters)) { setResponseHeaders(response, parameters); assetRenditionDispatcher.dispatch(request, response); return; } } response.sendError(HttpServletResponse.SC_NOT_FOUND, "Unable to resolve an AssetRenditionDispatcher that can dispatch to a rendition."); } else { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unsupported suffix parameters detected."); } } catch (IllegalArgumentException e) { log.warn("Invalid request URL format for AssetRenditionServlet.", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR , "Invalid request URL format for AssetRenditionServlet."); } }  final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response); static final String SERVLET_EXTENSION; }### Answer:
@Test public void doGet() throws IOException, ServletException { final AssetRenditionDispatcher assetRenditionDispatcher = Mockito.spy(new StaticRenditionDispatcherImpl()); final byte[] expectedOutputStream = IOUtils.toByteArray(this.getClass().getResourceAsStream("AssetRenditionServletTest__cq5dam.web.1280.1280.png")); doAnswer(invocation -> { Object[] args = invocation.getArguments(); ((MockSlingHttpServletResponse) args[1]).getOutputStream().write(expectedOutputStream); return null; }).when(requestDispatcher).include(any(SlingHttpServletRequest.class), any(SlingHttpServletResponse.class)); ctx.registerInjectActivateService( new StaticRenditionDispatcherImpl(), ImmutableMap.<String, Object>builder(). put("rendition.mappings", new String[]{ "testing1=value doesnt matter"}). build()); ctx.registerInjectActivateService( assetRenditionDispatcher, ImmutableMap.<String, Object>builder(). put("rendition.mappings", new String[]{ "original=original", "testing2=^cq5dam\\.web\\..*"}). build()); ctx.registerInjectActivateService(new AssetRenditionServlet()); ctx.request().setMethod("GET"); ctx.requestPathInfo().setResourcePath("/content/dam/test.png"); ctx.requestPathInfo().setExtension("renditions"); ctx.requestPathInfo().setSuffix("testing2/asset.rendition"); ctx.getService(Servlet.class).service(ctx.request(), ctx.response()); Mockito.verify(assetRenditionDispatcher, Mockito.times(1)).dispatch(ctx.request(), ctx.response()); }