Skip to content

Commit

Permalink
test: use URI for containerDir
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Apr 29, 2024
1 parent c3d91d4 commit 0c2f09b
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/test/java/org/janelia/saalfeldlab/n5/ij/MacroTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

public class MacroTests {

private File containerDir;
private URI containerDir;

private URI n5rootF;

Expand All @@ -42,7 +42,9 @@ public class MacroTests {
public void before() {
System.setProperty("java.awt.headless", "true");

containerDir = new File(tempN5PathName());
try {
containerDir = new File(tempN5PathName()).getCanonicalFile().toURI();
} catch (IOException e) {}

n5rootF = Paths.get("src", "test", "resources", "test.n5").toUri();
dataset = "dataset";
Expand All @@ -51,19 +53,16 @@ public void before() {
final String format = N5ScalePyramidExporter.N5_FORMAT;

final N5ScalePyramidExporter writer = new N5ScalePyramidExporter();
writer.setOptions( imp, containerDir.getAbsolutePath(), dataset, format, "16,16,16", false,
writer.setOptions( imp, containerDir.toString(), dataset, format, "16,16,16", false,
N5ScalePyramidExporter.NONE, N5ScalePyramidExporter.DOWN_SAMPLE, N5ScalePyramidExporter.RAW_COMPRESSION);
writer.run(); // run() closes the n5 writer
}

@After
public void after() {

N5Writer n5;
try {
n5 = new N5Factory().openWriter(containerDir.getCanonicalPath());
n5.remove();
} catch (IOException e) {}
N5Writer n5 = new N5Factory().openWriter(containerDir.toString());
n5.remove();
}

private static String tempN5PathName() {
Expand All @@ -85,7 +84,6 @@ protected String tempN5Location() throws URISyntaxException {

@Test
public void testMacroContentPath() throws IOException {
System.out.println("testMacroContent Path style");
testMacroContentHelper("url=%s/%s");
}

Expand All @@ -99,20 +97,16 @@ public void testMacroContentUri() throws IOException {

public void testMacroContentHelper( String urlFormat ) throws IOException {

System.out.println(urlFormat);
System.out.println(containerDir.getCanonicalPath());

// URL
final N5Importer plugin = (N5Importer)IJ.runPlugIn("org.janelia.saalfeldlab.n5.ij.N5Importer",
String.format( urlFormat + " hide", containerDir.getCanonicalPath(), dataset ));
String.format( urlFormat + " hide", containerDir.toString(), dataset ));

final List<ImagePlus> res = plugin.getResult();
final ImagePlus imgImported = res.get(0);
assertTrue( "equal content", TestExportImports.equal(imp, imgImported));

final N5Importer pluginCrop = (N5Importer)IJ.runPlugIn("org.janelia.saalfeldlab.n5.ij.N5Importer",
String.format( urlFormat + " hide min=0,1,2 max=5,5,5",
containerDir.getAbsolutePath(), "dataset" ));
containerDir.toString(), "dataset" ));
final List<ImagePlus> resCrop = pluginCrop.getResult();
final ImagePlus imgImportedCrop = resCrop.get(0);

Expand Down

0 comments on commit 0c2f09b

Please sign in to comment.