ClassLoaders { static void createDirectoryOrCleanPreviousContentsWithPrefix(File dir, String prefix) throws IOException { deleteIfRegularFile(dir); if (dir.exists()) { deleteFilesWithPrefix(dir, prefix); } else { createDirectory(dir); } } private  ClassLoaders();   }
@Test public void shouldDeleteRegularFile() throws IOException { File file = File.createTempFile("glowroot-unit-test-", ""); ClassLoaders.createDirectoryOrCleanPreviousContentsWithPrefix(file, "abc"); assertThat(file.isDirectory()).isTrue(); }
@Test public void shouldCreateDirectory() throws IOException { File file = File.createTempFile("glowroot-unit-test-", ""); file.delete(); ClassLoaders.createDirectoryOrCleanPreviousContentsWithPrefix(file, "abc"); assertThat(file.isDirectory()).isTrue(); }