### Question:
JspHandler { public void setupWebAppContext(WebAppContext servletContextHandler) throws IOException, URISyntaxException { Objects.requireNonNull(servletContextHandler, "servletContextHandler is null"); File scratchDir = getScratchDir(); servletContextHandler.setAttribute("javax.servlet.context.tempdir", scratchDir); servletContextHandler.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$"); URI baseUri = webRootResourceLocator.getWebRootResourceUri(); servletContextHandler.setResourceBase(baseUri.toASCIIString()); servletContextHandler.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers()); servletContextHandler.addBean(new ServletContainerInitializersStarter(servletContextHandler), true); servletContextHandler.setClassLoader(getUrlClassLoader()); servletContextHandler.addServlet(jspServletHolder(), "*.jsp"); servletContextHandler.addServlet(jspFileMappedServletHolder(), "/oozie/"); servletContextHandler.addServlet(defaultServletHolder(baseUri), "/"); } JspHandler(final File scratchDir, final WebRootResourceLocator webRootResourceLocator); void setupWebAppContext(WebAppContext servletContextHandler);  }### Answer:
@Test public void scratchDir_Is_Created_When_Setup_Called_And_ScratchDir_Did_Not_Exist() throws IOException, URISyntaxException { when(mockScratchDir.exists()).thenReturn(false); when(mockScratchDir.mkdirs()).thenReturn(true); jspHandler.setupWebAppContext(mockWebAppContext); verify(mockScratchDir).mkdirs(); }
@Test public void scratchDir_Cannot_Be_Created_When_Setup_Called_And_ScratchDir_Did_Not_Exist() throws IOException, URISyntaxException { when(mockScratchDir.exists()).thenReturn(false); when(mockScratchDir.mkdirs()).thenReturn(false); expectedException.expect(IOException.class); jspHandler.setupWebAppContext(mockWebAppContext); verify(mockScratchDir).mkdirs(); }
@Test public void scratchDir_Is_Reused_When_Setup_Called_And_ScratchDir_Existed() throws IOException, URISyntaxException { when(mockScratchDir.exists()).thenReturn(true); jspHandler.setupWebAppContext(mockWebAppContext); verify(mockScratchDir, times(0)).mkdirs(); }