@Test
void getPermanentDirectoryWhenNotSet() throws Exception
{

    ServletContext servletContext = mock(ServletContext.class);
    when(servletContext.getAttribute("javax.servlet.context.tempdir")).thenReturn(this.servletTmpDir);
    this.environment.setServletContext(servletContext);
    Logger logger = mock(Logger.class);
    ReflectionUtils.setFieldValue(this.environment, "logger", logger);
    assertEquals(this.servletTmpDir.getCanonicalFile(),
        this.environment.getPermanentDirectory().getCanonicalFile());
    // Also verify that we log a warning!
    verify(logger).warn("No permanent directory configured, fallbacking to temporary directory. You should set "
        + "the \"environment.permanentDirectory\" configuration property in the xwiki.properties file.");
    verify(logger).info("Using permanent directory [{}]", this.servletTmpDir.getCanonicalFile());
}