3333import java .util .stream .Stream ;
3434
3535import dev .zarr .zarrjava .v3 .codec .CodecBuilder ;
36- import org .junit .Ignore ;
37- import org .junit .Test ;
38- import org .junit .jupiter .api .Assertions ;
39- import org .junit .jupiter .api .BeforeAll ;
36+
37+ import org .junit .jupiter .api .*;
4038import org .junit .jupiter .params .ParameterizedTest ;
4139import org .junit .jupiter .params .provider .ValueSource ;
4240
@@ -66,8 +64,8 @@ public static void clearTestoutputFolder() throws IOException {
6664 //@BeforeAll
6765 //TODO: might be needed for Windows
6866 public static void installZarritaInCondaEnv () throws IOException {
69- // Process process = Runtime.getRuntime().exec("conda run -n " + CONDA_ENVIRONMENT + " pip install zarrita");
70- Process process = Runtime .getRuntime ().exec (new String []{"/bin/bash" , "-c" , "conda run -n " + CONDA_ENVIRONMENT + " pip install zarrita" });
67+ Process process = Runtime .getRuntime ().exec ("conda run -n " + CONDA_ENVIRONMENT + " pip install zarrita" );
68+ // Process process = Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "conda run -n " + CONDA_ENVIRONMENT + " pip install zarrita"});
7169
7270 BufferedReader stdError = new BufferedReader (new InputStreamReader (process .getErrorStream ()));
7371 String s ;
@@ -128,7 +126,7 @@ public void testReadFromZarrita(String codec) throws IOException, ZarrException,
128126 int exitCode = process .waitFor ();
129127 assert exitCode == 0 ;
130128
131- Array array = Array .open (new FilesystemStore (TESTOUTPUT ).resolve ("zarrita_write " , codec ));
129+ Array array = Array .open (new FilesystemStore (TESTOUTPUT ).resolve ("read_from_zarrita " , codec ));
132130 ucar .ma2 .Array result = array .read ();
133131
134132 //for expected values see zarrita_write.py
@@ -143,21 +141,20 @@ public void testReadFromZarrita(String codec) throws IOException, ZarrException,
143141 Assertions .assertArrayEquals (expectedData , (int []) result .get1DJavaArray (ucar .ma2 .DataType .INT ));
144142 }
145143
146- //ParameterizedTest instead of Test is a workaround to trigger @BeforeAll
147- //TODO: dont misuse ParameterizedTest
148144 @ ParameterizedTest
149- @ ValueSource (strings = "dummy" )
150- public void testWriteToZarrita (String dummy ) throws IOException , ZarrException , InterruptedException {
151- StoreHandle storeHandle = new FilesystemStore (TESTOUTPUT ).resolve ("array" );
145+ @ ValueSource (strings = { "blosc" , "gzip" , "zstd" , "bytes" , "transpose" , "sharding" , "crc32c" } )
146+ public void testWriteToZarrita (String codec ) throws IOException , ZarrException , InterruptedException {
147+ StoreHandle storeHandle = new FilesystemStore (TESTOUTPUT ).resolve ("write_to_zarrita" , codec );
152148
149+ //TODO: have correct codecs
153150 Array array = Array .create (
154151 storeHandle ,
155152 Array .metadataBuilder ()
156153 .withShape (16 , 16 )
157154 .withDataType (DataType .UINT32 )
158- .withChunkShape (4 , 4 )
155+ .withChunkShape (8 , 8 )
159156 .withFillValue (0 )
160- .withCodecs (c -> c .withSharding (new int []{4 , 4 }, CodecBuilder :: withBlosc ))
157+ .withCodecs (c -> c .withSharding (new int []{4 , 4 }, c1 -> c1 . withBytes ( "LITTLE" ) ))
161158 .build ());
162159
163160 ucar .ma2 .Array testData = ucar .ma2 .Array .factory (ucar .ma2 .DataType .UINT , new int []{16 , 16 });
@@ -167,7 +164,7 @@ public void testWriteToZarrita(String dummy) throws IOException, ZarrException,
167164
168165 String command = "zarrita/bin/python" ;
169166
170- ProcessBuilder pb = new ProcessBuilder (command , ZARRITA_READ_PATH .toString (), TESTOUTPUT .toString ());
167+ ProcessBuilder pb = new ProcessBuilder (command , ZARRITA_READ_PATH .toString (), codec , TESTOUTPUT .toString ());
171168 Process process = pb .start ();
172169
173170 BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
0 commit comments