Skip to content

Commit 030f701

Browse files
committed
test: clarify ambigious zarr test differences for N5FactoryWithCache
1 parent 239d82c commit 030f701

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/test/java/org/janelia/saalfeldlab/n5/universe/N5FactoryWithCacheTests.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,23 @@ public void testAmbiguousZarrFormat() throws IOException {
8282
assertEquals(ZarrKeyValueWriter.class, factory.openWriter(StorageFormat.ZARR, bothZarrs).getClass());
8383

8484
N5Writer bothZarr3 = factory.openWriter(StorageFormat.ZARR3, bothZarrs);
85+
8586
/* the base factory re-resolves and returns zarr3 here; the cache instead returns the zarr2 reader cached
8687
* above, since it is still format-compatible with the ambiguous ZARR request */
87-
assertEquals(ZarrKeyValueReader.class, factory.openReader(StorageFormat.ZARR, bothZarrs).getClass());
88+
N5Reader cachedZarr2Reader = factory.openReader(StorageFormat.ZARR, bothZarrs);
89+
assertEquals(ZarrKeyValueReader.class, cachedZarr2Reader.getClass());
90+
8891
/* the writer cache, on the other hand, was replaced by the zarr3 writer just opened, so ambiguous returns it */
8992
assertEquals(ZarrV3KeyValueWriter.class, factory.openWriter(StorageFormat.ZARR, bothZarrs).getClass());
9093

91-
assertEquals(ZarrKeyValueReader.class, factory.openReader(StorageFormat.ZARR2, bothZarrs).getClass());
94+
/* explicitly open a zarr3 reader, which should replace the reader cache entry */
95+
assertEquals(ZarrV3KeyValueReader.class, factory.openReader(StorageFormat.ZARR3, bothZarrs).getClass());
96+
97+
N5Reader newZarr2Reader = factory.openReader(StorageFormat.ZARR2, bothZarrs);
98+
assertEquals(ZarrKeyValueReader.class, newZarr2Reader.getClass());
99+
100+
assertNotSame("returned zarr2 reader should be a new one, since the cache was updated by the previous explicit zarr3 open reader", cachedZarr2Reader, newZarr2Reader);
101+
assertSame("returned zarr2 reader should NOW be the same", newZarr2Reader, factory.openReader(StorageFormat.ZARR2, bothZarrs));
92102
assertEquals(ZarrKeyValueWriter.class, factory.openWriter(StorageFormat.ZARR2, bothZarrs).getClass());
93103
}
94104

0 commit comments

Comments
 (0)