protected final File getValidSessionStoreDir(boolean mkdirs) { File dir = getSessionStoreDir(); if (dir == null) { return new ApplicationTemp().getDir("servlet-sessions"); } if (!dir.isAbsolute()) { dir = new File(new ApplicationHome().getDir(), dir.getPath()); } if (!dir.exists() && mkdirs) { dir.mkdirs(); } Assert.state(!mkdirs || dir.exists(), "Session dir " + dir + " does not exist"); Assert.state(!dir.isFile(), "Session dir " + dir + " points to a file"); return dir; }
@Test public void getValidSessionStoreWhenSessionStoreNotSet() throws Exception { AbstractEmbeddedServletContainerFactory factory = getFactory(); File dir = factory.getValidSessionStoreDir(false); assertThat(dir.getName()).isEqualTo("servlet-sessions"); assertThat(dir.getParentFile()).isEqualTo(new ApplicationTemp().getDir()); }
@Test public void getValidSessionStoreWhenSessionStoreNotSet() throws Exception { AbstractEmbeddedServletContainerFactory factory = getFactory(); File dir = factory.getValidSessionStoreDir(false); assertThat(dir.getName(), equalTo("servlet-sessions")); assertThat(dir.getParentFile(), equalTo(new ApplicationTemp().getDir())); }