Skip to content

Commit 0ca87ba

Browse files
committed
test: delete database folder afterClass .
1 parent 7f79c3c commit 0ca87ba

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/test/java/org/tron/program/AccountVoteWitnessTest.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import com.google.common.collect.Lists;
44
import com.google.protobuf.ByteString;
5+
import java.io.File;
56
import java.util.List;
7+
import org.junit.AfterClass;
68
import org.junit.BeforeClass;
79
import org.junit.Test;
810
import org.slf4j.Logger;
@@ -19,15 +21,36 @@ public class AccountVoteWitnessTest {
1921

2022
private static final Logger logger = LoggerFactory.getLogger("Test");
2123
private static Manager dbManager = new Manager();
24+
private static String dbPath = "output_witness";
2225

2326
@BeforeClass
24-
public static void initConf() {
27+
public static void init() {
2528
//Args.setParam(new String[]{}, Configuration.getByPath(Constant.TEST_CONF));
26-
Args.setParam(new String[]{"-d", "output_witness"},
29+
Args.setParam(new String[]{"-d", dbPath},
2730
Configuration.getByPath(Constant.TEST_CONF));
31+
2832
dbManager.init();
2933
}
3034

35+
@AfterClass
36+
public static void removeDb() {
37+
File dbFolder = new File(dbPath);
38+
deleteFolder(dbFolder);
39+
}
40+
41+
private static void deleteFolder(File index) {
42+
if (!index.isDirectory() || index.listFiles().length <= 0) {
43+
index.delete();
44+
return;
45+
}
46+
for (File file : index.listFiles()) {
47+
if (null != file) {
48+
deleteFolder(file);
49+
}
50+
}
51+
index.delete();
52+
}
53+
3154
@Test
3255
public void testAccountVoteWitness() {
3356
final List<AccountCapsule> accountCapsuleList = this.getAccountList();

0 commit comments

Comments
 (0)