@VisibleForTesting
  StandardContext addStaticDir(Tomcat tomcat, String contextPath, File dir) {
    try {
      fs.createOrCleanupDir(dir);
    } catch (IOException e) {
      throw new IllegalStateException(format("Fail to create or clean-up directory %s", dir.getAbsolutePath()), e);
    }

    return addContext(tomcat, contextPath, dir);
  }
@Test
  public void fail_if_static_directory_can_not_be_initialized() throws Exception {
    File dir = temp.newFolder();

    TomcatContexts.Fs fs = mock(TomcatContexts.Fs.class);
    doThrow(new IOException()).when(fs).createOrCleanupDir(any(File.class));

    assertThatThrownBy(() -> new TomcatContexts(fs).addStaticDir(tomcat, "/deploy", dir))
      .isInstanceOf(IllegalStateException.class)
      .hasMessageContaining("Fail to create or clean-up directory " + dir.getAbsolutePath());
  }