2727import java .util .Random ;
2828
2929import org .janelia .saalfeldlab .n5 .N5Reader .Version ;
30- import org .junit .AfterClass ;
3130import org .junit .Assert ;
32- import org .junit .Before ;
31+ import org .junit .BeforeClass ;
32+ import org .junit .Rule ;
3333import org .junit .Test ;
34+ import org .junit .rules .TemporaryFolder ;
3435
3536/**
3637 * Abstract base class for testing N5 functionality.
4142 */
4243public abstract class AbstractN5Test {
4344
45+ @ Rule
46+ public TemporaryFolder temp = new TemporaryFolder ();
47+
4448 static protected final String groupName = "/test/group" ;
4549 static protected final String [] subGroupNames = new String []{"a" , "b" , "c" };
4650 static protected final String datasetName = "/test/group/dataset" ;
@@ -54,9 +58,7 @@ public abstract class AbstractN5Test {
5458 static protected float [] floatBlock ;
5559 static protected double [] doubleBlock ;
5660
57- static protected N5Writer n5 ;
58-
59- protected abstract N5Writer createN5Writer () throws IOException ;
61+ protected N5Writer n5 ;
6062
6163 protected Compression [] getCompressions () {
6264
@@ -73,13 +75,8 @@ protected Compression[] getCompressions() {
7375 /**
7476 * @throws IOException
7577 */
76- @ Before
77- public void setUpOnce () throws IOException {
78-
79- if (n5 != null )
80- return ;
81-
82- n5 = createN5Writer ();
78+ @ BeforeClass
79+ public static void setUpOnce () throws IOException {
8380
8481 final Random rnd = new Random ();
8582 byteBlock = new byte [blockSize [0 ] * blockSize [1 ] * blockSize [2 ]];
@@ -98,18 +95,6 @@ public void setUpOnce() throws IOException {
9895 }
9996 }
10097
101- /**
102- * @throws IOException
103- */
104- @ AfterClass
105- public static void rampDownAfterClass () throws IOException {
106-
107- if (n5 != null ) {
108- Assert .assertTrue (n5 .remove ());
109- n5 = null ;
110- }
111- }
112-
11398 @ Test
11499 public void testCreateGroup () {
115100
0 commit comments