Use temporary folder in FrontierTest
@@ -3,9 +3,8 @@ package focusedCrawler.link.frontier;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
-import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
@@ -14,23 +13,24 @@ import java.nio.file.Paths;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import focusedCrawler.util.persistence.PersistentHashtable.DB;
public class FrontierTest {
- final Path testPath = Paths.get("frontier_temp/");
+ @Rule
+ public TemporaryFolder tempFolder = new TemporaryFolder();
+
+ public Path testPath;
+
private Frontier frontier;
@Before
public void setUp() throws IOException {
-
- File file = testPath.toFile();
- if(file.exists()) {
- FileUtils.deleteDirectory(file);
- }
-
+ testPath = Paths.get(tempFolder.newFolder().toString());
frontier = new Frontier(testPath.toString(), 1000, DB.ROCKSDB);
}
