1515import java .nio .file .NoSuchFileException ;
1616import java .nio .file .Path ;
1717import java .nio .file .Paths ;
18+ import java .util .Arrays ;
1819
1920public class ZarrV2Test extends ZarrTest {
2021 @ ParameterizedTest
@@ -281,7 +282,7 @@ public void testAttributes() throws IOException, ZarrException {
281282
282283 @ Test
283284 public void testSetAndUpdateAttributes () throws IOException , ZarrException {
284- StoreHandle storeHandle = new FilesystemStore (TESTOUTPUT ).resolve ("testSetAttributesV3 " );
285+ StoreHandle storeHandle = new FilesystemStore (TESTOUTPUT ).resolve ("testSetAttributesV2 " );
285286
286287 ArrayMetadata arrayMetadata = Array .metadataBuilder ()
287288 .withShape (10 , 10 )
@@ -308,4 +309,32 @@ public void testSetAndUpdateAttributes() throws IOException, ZarrException {
308309
309310 assertContainsTestAttributes (array .metadata ().attributes ());
310311 }
312+
313+ @ Test
314+ public void testResizeArray () throws IOException , ZarrException {
315+ int [] testData = new int [10 * 10 ];
316+ Arrays .setAll (testData , p -> p );
317+
318+ StoreHandle storeHandle = new FilesystemStore (TESTOUTPUT ).resolve ("testResizeArrayV2" );
319+ ArrayMetadata arrayMetadata = Array .metadataBuilder ()
320+ .withShape (10 , 10 )
321+ .withDataType (DataType .UINT32 )
322+ .withChunks (5 , 5 )
323+ .withFillValue (1 )
324+ .build ();
325+ ucar .ma2 .DataType ma2DataType = arrayMetadata .dataType .getMA2DataType ();
326+ Array array = Array .create (storeHandle , arrayMetadata );
327+ array .write (new long []{0 , 0 }, ucar .ma2 .Array .factory (ma2DataType , new int []{10 , 10 }, testData ));
328+
329+ array = array .resize (new long []{20 , 15 });
330+ Assertions .assertArrayEquals (new int []{20 , 15 }, array .read ().getShape ());
331+
332+ ucar .ma2 .Array data = array .read (new long []{0 , 0 }, new int []{10 , 10 });
333+ Assertions .assertArrayEquals (testData , (int []) data .get1DJavaArray (ma2DataType ));
334+
335+ data = array .read (new long []{10 , 10 }, new int []{5 , 5 });
336+ int [] expectedData = new int [5 * 5 ];
337+ Arrays .fill (expectedData , 1 );
338+ Assertions .assertArrayEquals (expectedData , (int []) data .get1DJavaArray (ma2DataType ));
339+ }
311340}
0 commit comments