AssetsController { public Result serveWebJars() { Object renderable = new Renderable() { @Override public void render(Context context, Result result) { String fileName = getFileNameFromPathOrReturnRequestPath(context); URL url = getStaticFileFromMetaInfResourcesDir(fileName); streamOutUrlEntity(url, context, result); } }; return Results.ok().render(renderable); } @Inject  AssetsController(AssetsControllerHelper assetsControllerHelper,
                            HttpCacheToolkit httpCacheToolkit,
                            MimeTypes mimeTypes,
                            NinjaProperties ninjaProperties); Result serveStatic(); Result serveWebJars(); final static String ASSETS_DIR; final static String FILENAME_PATH_PARAM; }
@Test public void testServeWebJars() throws Exception { AssetsControllerHelper assetsControllerHelper = Mockito.mock(AssetsControllerHelper.class, Mockito.CALLS_REAL_METHODS); assetsController = new AssetsController( assetsControllerHelper, httpCacheToolkit, mimeTypes, ninjaProperties); Result result = Results.ok(); when(contextRenderable.getRequestPath()).thenReturn( "/webjar_asset.txt"); when(contextRenderable.finalizeHeadersWithoutFlashAndSessionCookie(Mockito.eq(result))).thenReturn( responseStreams); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); when(responseStreams.getOutputStream()).thenReturn( byteArrayOutputStream); Result result2 = assetsController.serveWebJars(); Renderable renderable = (Renderable) result2.getRenderable(); renderable.render(contextRenderable, result); verify(contextRenderable).finalizeHeadersWithoutFlashAndSessionCookie(resultCaptor.capture()); assertEquals(Result.SC_200_OK, resultCaptor.getValue().getStatusCode()); assertEquals("webjar_asset", byteArrayOutputStream.toString()); verify(assetsControllerHelper).normalizePathWithoutLeadingSlash("/webjar_asset.txt", true); }