Created
June 30, 2014 14:49
-
-
Save KMax/64bbc5b2fd521f62091b to your computer and use it in GitHub Desktop.
CQELS: Stop and close everything
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.deri.cqels; | |
import com.hp.hpl.jena.tdb.StoreConnection; | |
import java.io.File; | |
import java.io.IOException; | |
import java.nio.file.FileVisitResult; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.SimpleFileVisitor; | |
import java.nio.file.attribute.BasicFileAttributes; | |
import org.deri.cqels.engine.ExecContext; | |
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class ResetTest { | |
private static final String CQELS_HOME = "cqels_home"; | |
@Test | |
public void test() { | |
final File HOME = new File(CQELS_HOME); | |
if(!HOME.exists()) { | |
HOME.mkdir(); | |
} | |
final ExecContext context = new ExecContext(CQELS_HOME, true); | |
context.env().close(); | |
context.getDataset().close(); | |
context.getARQExCtx().getDataset().close(); | |
context.dictionary().close(); | |
try { | |
Files.walkFileTree(new File(CQELS_HOME).toPath(), new SimpleFileVisitor<Path>() { | |
@Override | |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { | |
Files.delete(file); | |
return FileVisitResult.CONTINUE; | |
} | |
@Override | |
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { | |
Files.delete(dir); | |
return FileVisitResult.CONTINUE; | |
} | |
}); | |
} catch (IOException ex) { | |
fail(ex.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment