@@ -270,7 +270,8 @@ void testListFiles(String path, boolean shouldWork, List<String> expectedFiles)
270
270
271
271
private static Stream <Arguments > testListFilesSource () {
272
272
return Stream .of (
273
- Arguments .of (TEST_PATH , true , List .of ("existingDir/" , "existingFile.x" , "existingFile2" , "existingFile3" , "existingFile4" )),
273
+ Arguments .of (TEST_PATH , true ,
274
+ List .of ("existingDir/" , "dir1/" , "existingFile.x" , "existingFile2" , "existingFile3" , "existingFile4" )),
274
275
Arguments .of (TEST_PATH + "existingDir/" , true , List .of ("subDir/" )),
275
276
Arguments .of (TEST_PATH + "existingDir/subDir/" , true , List .of ("existingFile.txt" )), Arguments .of (null , false , null ),
276
277
Arguments .of (TEST_PATH + "unexistingDirectory" , false , null ));
@@ -295,6 +296,34 @@ private static Stream<Arguments> testZipSource() {
295
296
Arguments .of ("existingDir" , false , null , null ), Arguments .of (null , false , null , null ));
296
297
}
297
298
299
+ @ ParameterizedTest
300
+ @ MethodSource ("testZipWithExclusionSource" )
301
+ void testZipWithExclusion (String path , boolean shouldWork , String destination , String realDestination , List <String > exclusion ,
302
+ List <String > subItems ) {
303
+ assertEquals (shouldWork , FLUFiles .zip (path , destination , exclusion ));
304
+ if (shouldWork ) {
305
+ // unzip
306
+ assertEquals (shouldWork , FLUFiles .unzip (destination , TEST_PATH_TEMPORARY + "TMP/" , "" ));
307
+ // check if the files are here
308
+ for (String s : subItems ) {
309
+ assertTrue (new File (TEST_PATH_TEMPORARY + "TMP/dir1/" + s ).exists ());
310
+ assertTrue (FLUFiles .delete (TEST_PATH_TEMPORARY + "TMP/dir1/" + s ));
311
+
312
+ }
313
+ assertTrue (FLUFiles .delete (realDestination ));
314
+ }
315
+ }
316
+
317
+ private static Stream <Arguments > testZipWithExclusionSource () {
318
+ return Stream .of (
319
+ Arguments .of (TEST_PATH + "existingDir/" , true , TEST_PATH_TEMPORARY + "existingDir.zip" ,
320
+ TEST_PATH_TEMPORARY + "existingDir.zip" , List .of (), List .of ()),
321
+ Arguments .of (TEST_PATH + "dir1/" , true , TEST_PATH_TEMPORARY + "dir1.zip" , TEST_PATH_TEMPORARY + "dir1.zip" ,
322
+ List .of ("nonExistingFile.txt" ), List .of ("dir2/" , "dir3/" , "file4.md" )),
323
+ Arguments .of (TEST_PATH + "dir1/" , true , TEST_PATH_TEMPORARY + "dir1.zip" , TEST_PATH_TEMPORARY + "dir1.zip" ,
324
+ List .of ("dir2/" ), List .of ("dir3/" , "file4.md" )));
325
+ }
326
+
298
327
@ ParameterizedTest
299
328
@ MethodSource ("testUnzipSource" )
300
329
void testUnzip (String pathToBeZip , boolean shouldWork , String zipedFile , String pathToDownloadIntoZip , String fileToCheck ) {
@@ -389,6 +418,11 @@ public static void main(String[] args) {
389
418
390
419
clean ();
391
420
// FLUFiles.zip("../teavm/", "teavm.zip");
392
- FLUFiles .unzip ("teavm.zip" , TEST_PATH_TEMPORARY , "teavm/jso/*" );
421
+ // FLUFiles.unzip("teavm.zip", TEST_PATH_TEMPORARY, "teavm/jso/*");
422
+ // FLUFiles.zip("C:\\Users\\Hydrolien\\git\\paper.1.21\\", "C:\\Users\\Hydrolien\\git\\paper.1.21\\saves\\1.zip",
423
+ // List.of("saves/", "cache/"));
424
+ // FLUFiles.zip("C:/Users/Hydrolien/git/paper.1.21/", "C:/Users/Hydrolien/git/paper.1.21/save/1.zip");
425
+ FLUFiles .zip ("C:/Users/Hydrolien/git/paper.1.21/" , "C:/Users/Hydrolien/git/paper.1.21/saves/" + FLUTime .currentTime () + ".zip" ,
426
+ List .of ("saves/" , "cache/" ));
393
427
}
394
428
}
0 commit comments