|
1 | 1 | package dev.zarr.zarrjava; |
2 | 2 |
|
| 3 | +import com.fasterxml.jackson.databind.JsonNode; |
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; |
3 | 5 | import dev.zarr.zarrjava.v3.codec.Codec; |
4 | 6 | import dev.zarr.zarrjava.v3.codec.core.BloscCodec; |
5 | 7 | import dev.zarr.zarrjava.v3.codec.core.ShardingIndexedCodec; |
|
30 | 32 | import java.util.HashMap; |
31 | 33 | import java.util.Map; |
32 | 34 | import java.util.function.Function; |
| 35 | +import java.util.stream.Collectors; |
33 | 36 | import java.util.stream.Stream; |
34 | 37 |
|
35 | 38 | import static dev.zarr.zarrjava.core.ArrayMetadata.parseFillValue; |
@@ -549,6 +552,23 @@ public void testCreateArray() throws ZarrException, IOException { |
549 | 552 | Assertions.assertTrue(Files.exists(Paths.get(storeHandleString).resolve("zarr.json"))); |
550 | 553 | } |
551 | 554 |
|
| 555 | + @Test |
| 556 | + public void testZarrJsonFormat() throws ZarrException, IOException { |
| 557 | + // regression test: ensure that 'name' keyword of named configurations (e.g. codecs) are only written once. |
| 558 | + StoreHandle storeHandle = new FilesystemStore(TESTOUTPUT).resolve("testZarrJsonFormatV3"); |
| 559 | + Array.create(storeHandle, Array.metadataBuilder() |
| 560 | + .withShape(10, 10) |
| 561 | + .withDataType(DataType.UINT8) |
| 562 | + .withChunkShape(5, 5) |
| 563 | + .build()); |
| 564 | + |
| 565 | + try (BufferedReader reader = Files.newBufferedReader(storeHandle.resolve("zarr.json").toPath())) { |
| 566 | + String jsonInString = reader.lines().collect(Collectors.joining(System.lineSeparator())); |
| 567 | + JsonNode JSON = new ObjectMapper().readTree(jsonInString); |
| 568 | + Assertions.assertEquals(JSON.toPrettyString(), jsonInString); |
| 569 | + } |
| 570 | + } |
| 571 | + |
552 | 572 | @Test |
553 | 573 | public void testCreateGroup() throws ZarrException, IOException { |
554 | 574 | StoreHandle storeHandle = new FilesystemStore(TESTOUTPUT).resolve("testCreateGroupV3"); |
@@ -585,5 +605,12 @@ public void testCodecWithoutConfiguration() throws ZarrException, IOException { |
585 | 605 | Assertions.assertInstanceOf(BytesCodec.class, bytesCodec); |
586 | 606 | Assertions.assertNull(((BytesCodec) bytesCodec).configuration); |
587 | 607 | // further todo: remove redundant "name" attribute from codec metadata serialization |
| 608 | + } |
| 609 | + |
| 610 | + @Test |
| 611 | + public void testParseZarrJson(){ |
| 612 | + |
| 613 | + |
| 614 | + |
588 | 615 | } |
589 | 616 | } |
0 commit comments