ApplicationDirectoriesImpl extends ComponentSupport implements ApplicationDirectories { @Override public File getWorkDirectory() { return workDir; } @Inject  ApplicationDirectoriesImpl(@Named("${karaf.base}") final File installDir,
                                    @Named("${karaf.data}") final File workDir); @Override File getInstallDirectory(); @Override File getConfigDirectory(final String subsystem); @Override File getTemporaryDirectory(); @Override File getWorkDirectory(); @Override File getWorkDirectory(final String path, final boolean create); @Override File getWorkDirectory(final String path);  }
@Test public void ensureWorkDir_exists() throws Exception { File dir = underTest.getWorkDirectory(); assertThat(dir, notNullValue()); assertThat(dir, is(workDir)); assertThat(dir, FileMatchers.exists()); }
@Test public void ensureWorkDir_childExists() throws Exception { File dir = underTest.getWorkDirectory("child"); assertThat(dir, notNullValue()); assertThat(dir, FileMatchers.exists()); }
@Test public void ensureWorkDir_childWithCreateExists() throws Exception { File dir = underTest.getWorkDirectory("child", true); assertThat(dir, notNullValue()); assertThat(dir, FileMatchers.exists()); }
@Test public void ensureWorkDir_childNoCreateNotExists() throws Exception { File dir = underTest.getWorkDirectory("child", false); assertThat(dir, notNullValue()); assertThat(dir, not(FileMatchers.exists())); }
@Test public void ensureWorkDir_referencesSonatypeWorkFolderUnlessAbsolute() throws Exception { File tempDir = util.createTempDir("temp"); File relative = underTest.getWorkDirectory("."); File absolute = underTest.getWorkDirectory(tempDir.getAbsolutePath()); assertThat(relative.getCanonicalFile(), equalTo(workDir.getCanonicalFile())); assertThat(absolute.getCanonicalFile(), equalTo(tempDir.getCanonicalFile())); }