Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
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.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

/**
* Abstract base class for testing N5 functionality.
Expand All @@ -41,6 +42,9 @@
*/
public abstract class AbstractN5Test {

@Rule
public TemporaryFolder temp = new TemporaryFolder();

static protected final String groupName = "/test/group";
static protected final String[] subGroupNames = new String[]{"a", "b", "c"};
static protected final String datasetName = "/test/group/dataset";
Expand All @@ -54,9 +58,7 @@ public abstract class AbstractN5Test {
static protected float[] floatBlock;
static protected double[] doubleBlock;

static protected N5Writer n5;

protected abstract N5Writer createN5Writer() throws IOException;
protected N5Writer n5;

protected Compression[] getCompressions() {

Expand All @@ -73,13 +75,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]];
Expand All @@ -98,18 +95,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() {

Expand Down
15 changes: 6 additions & 9 deletions src/test/java/org/janelia/saalfeldlab/n5/N5FSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.io.IOException;

import org.junit.Before;

/**
* Initiates testing of the filesystem-based N5 implementation.
*
Expand All @@ -26,14 +28,9 @@
*/
public class N5FSTest extends AbstractN5Test {

static private String testDirPath = System.getProperty("user.home") + "/tmp/n5-test";

/**
* @throws IOException
*/
@Override
protected N5Writer createN5Writer() throws IOException {

return new N5FSWriter(testDirPath);
@Before
public void setUp() throws IOException {
n5 = new N5FSWriter(temp.newFolder("n5-test").getAbsolutePath());
}

}