diff --git a/src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java b/src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java index 2bfe9f2f..1308c044 100644 --- a/src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java +++ b/src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java @@ -27,9 +27,8 @@ import java.util.Random; import org.janelia.saalfeldlab.n5.N5Reader.Version; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; /** @@ -47,16 +46,14 @@ public abstract class AbstractN5Test { static protected final long[] dimensions = new long[]{100, 200, 300}; static protected final int[] blockSize = new int[]{44, 33, 22}; - static protected byte[] byteBlock; - static protected short[] shortBlock; - static protected int[] intBlock; - static protected long[] longBlock; - static protected float[] floatBlock; - static protected double[] doubleBlock; + protected static byte[] byteBlock; + protected static short[] shortBlock; + protected static int[] intBlock; + protected static long[] longBlock; + protected static float[] floatBlock; + protected static double[] doubleBlock; - static protected N5Writer n5; - - protected abstract N5Writer createN5Writer() throws IOException; + protected N5Writer n5; protected Compression[] getCompressions() { @@ -73,13 +70,8 @@ protected Compression[] getCompressions() { /** * @throws IOException */ - @Before - public void setUpOnce() throws IOException { - - if (n5 != null) - return; - - n5 = createN5Writer(); + @BeforeClass + public static void setUpOnce() throws IOException { final Random rnd = new Random(); byteBlock = new byte[blockSize[0] * blockSize[1] * blockSize[2]]; @@ -98,18 +90,6 @@ public void setUpOnce() throws IOException { } } - /** - * @throws IOException - */ - @AfterClass - public static void rampDownAfterClass() throws IOException { - - if (n5 != null) { - Assert.assertTrue(n5.remove()); - n5 = null; - } - } - @Test public void testCreateGroup() { diff --git a/src/test/java/org/janelia/saalfeldlab/n5/N5FSTest.java b/src/test/java/org/janelia/saalfeldlab/n5/N5FSTest.java index 8fa240c3..07dbf017 100644 --- a/src/test/java/org/janelia/saalfeldlab/n5/N5FSTest.java +++ b/src/test/java/org/janelia/saalfeldlab/n5/N5FSTest.java @@ -18,6 +18,10 @@ import java.io.IOException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; + /** * Initiates testing of the filesystem-based N5 implementation. * @@ -26,14 +30,12 @@ */ public class N5FSTest extends AbstractN5Test { - static private String testDirPath = System.getProperty("user.home") + "/tmp/n5-test"; - - /** - * @throws IOException - */ - @Override - protected N5Writer createN5Writer() throws IOException { + @Rule + public TemporaryFolder temp = new TemporaryFolder(); - return new N5FSWriter(testDirPath); + @Before + public void setUp() throws IOException { + n5 = new N5FSWriter(temp.newFolder("n5-test").getAbsolutePath()); } + }