Create LOCK file and other IO stuff that Db helper needs.. Cleanup after test
package net.consensys.tessera.migration.data;
import net.consensys.orion.config.Config;
-import org.junit.Ignore;
+import org.junit.After;
import org.junit.Test;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@Ignore
public class InboundDbHelperTest {
+ @After
+ public void afterTest() throws Exception {
+ Path storageDir = Paths.get("build","junitdb");
+ if(Files.notExists(storageDir)) {
+ return;
+ }
+
+ Files.list(storageDir)
+ .forEach(p -> {
+ try {
+ System.out.println(p);
+ Files.deleteIfExists(p);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
+
+ Files.deleteIfExists(storageDir);
+ }
+
@Test
- public void leveldb() {
+ public void leveldb() throws IOException {
+
+ Path storageDir = Paths.get("build","junitdb");
+ Files.createDirectories(storageDir);
+ Files.createFile(storageDir.resolve("LOCK"));
+
Config leveldbConfig = mock(Config.class);
when(leveldbConfig.storage()).thenReturn("leveldb:junitdb");
when(leveldbConfig.workDir()).thenReturn(Paths.get("build"));
