@Test
void getTemporaryDirectoryWhenNotSet() throws Exception
{

    ServletContext servletContext = mock(ServletContext.class);
    when(servletContext.getAttribute("javax.servlet.context.tempdir")).thenReturn(this.servletTmpDir);
    this.environment.setServletContext(servletContext);
    File tmpDir = this.environment.getTemporaryDirectory();
    // Make sure it is the "xwiki-temp" dir which is under the main temp dir.
    assertEquals(this.servletTmpDir.listFiles()[0].getCanonicalFile(), tmpDir.getCanonicalFile());
}