-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadLevelDBTest.java
37 lines (29 loc) · 1.02 KB
/
ReadLevelDBTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.zimmerbell.repaper;
import static org.fusesource.leveldbjni.JniDBFactory.factory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import org.apache.commons.io.FileUtils;
import org.iq80.leveldb.DB;
import org.iq80.leveldb.Options;
import org.testng.annotations.Test;
import com.zimmerbell.repaper.sources.MomentumSource;
@Test
public class ReadLevelDBTest {
private final static String LEVELDB_DIR = MomentumSource.CHROME_PROFILES + File.separator + "Default" + MomentumSource.CHROME_LEVELDB_PATH;
public void testOpenLevelDB() throws IOException {
File tempDir = Files.createTempDirectory("leveldb").toFile();
try {
FileUtils.copyDirectory(new File(LEVELDB_DIR), tempDir);
for (File file : tempDir.listFiles()) {
if (file.getName().endsWith(".ldb")) {
file.renameTo(new File(file.getParentFile(), file.getName().replaceAll("ldb$", "sst")));
}
}
try (DB db = factory.open(tempDir, new Options())) {
}
} finally {
FileUtils.deleteDirectory(tempDir);
}
}
}