From 6998def8dfe96dee24de1baa6db3de769f8aaa2f Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 23 Aug 2017 17:25:12 +0300 Subject: [PATCH] Move testfolder cleaning to TestInit --- .../plan/database/DatabaseTest.java | 3 -- Plan/test/test/java/utils/DBTestSuite.java | 48 ------------------- Plan/test/test/java/utils/TestInit.java | 14 ++++++ 3 files changed, 14 insertions(+), 51 deletions(-) delete mode 100644 Plan/test/test/java/utils/DBTestSuite.java diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java index 9efafb711..7c852689b 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -64,7 +64,6 @@ public class DatabaseTest { db = new SQLiteDB(plan, "debug" + MiscUtils.getTime()); File f = new File(plan.getDataFolder(), "Errors.txt"); rows = FileUtil.lines(f).size(); - db.init(); } @@ -230,10 +229,8 @@ public class DatabaseTest { expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded)); expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded)); - List tpsDataOld = tpsTable.getTPSData(); tpsTable.saveTPSData(expected); - expected.addAll(0, tpsDataOld); assertEquals(expected, tpsTable.getTPSData()); } } diff --git a/Plan/test/test/java/utils/DBTestSuite.java b/Plan/test/test/java/utils/DBTestSuite.java deleted file mode 100644 index a8fc5e31e..000000000 --- a/Plan/test/test/java/utils/DBTestSuite.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licence is provided in the jar as license.yml also here: - * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml - */ -package test.java.utils; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import test.java.main.java.com.djrapitops.plan.database.DatabaseCommitTest; -import test.java.main.java.com.djrapitops.plan.database.DatabaseTest; - -import java.io.File; -import java.io.IOException; - -/** - * @author Fuzzlemann - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({DatabaseCommitTest.class, DatabaseTest.class}) -public class DBTestSuite { - @BeforeClass - public static void setUp() throws IOException { - clean(true); - } - - @AfterClass - public static void tearDown() throws IOException { - clean(false); - } - - private static void clean(boolean dbOnly) throws IOException { - File testFolder = TestInit.getTestFolder(); - - if (!testFolder.exists() || !testFolder.isDirectory()) { - return; - } - - for (File f : testFolder.listFiles()) { - if (dbOnly && !f.getName().contains(".db")) { - continue; - } - - f.delete(); - } - } -} diff --git a/Plan/test/test/java/utils/TestInit.java b/Plan/test/test/java/utils/TestInit.java index 343c9800e..20e74e599 100644 --- a/Plan/test/test/java/utils/TestInit.java +++ b/Plan/test/test/java/utils/TestInit.java @@ -67,6 +67,8 @@ public class TestInit { } private void setUp() throws Exception { + clean(); + planMock = PowerMockito.mock(Plan.class); StaticHolder.setInstance(Plan.class, planMock); StaticHolder.setInstance(planMock.getClass(), planMock); @@ -193,4 +195,16 @@ public class TestInit { public Plan getPlanMock() { return planMock; } + + public static void clean() throws IOException { + File testFolder = getTestFolder(); + + if (!testFolder.exists() || !testFolder.isDirectory()) { + return; + } + + for (File f : testFolder.listFiles()) { + f.delete(); + } + } }