@@ -83,35 +83,48 @@ public void toRealPath() throws Exception {
8383 windowsMountPoint (VFS_WIN_MOUNT_POINT ).//
8484 extractFilter (p -> p .getFileName ().toString ().equals ("file1" )).//
8585 resourceLoadingClass (VirtualFileSystemTest .class ).build ();
86- // check regular resource file
86+ // check regular resource dir
8787 assertEquals ("dir1" , vfs .toRealPath (Path .of ("dir1" )).toString ());
8888 assertEquals (VFS_MOUNT_POINT + File .separator + "dir1" , vfs .toRealPath (Path .of (VFS_MOUNT_POINT + File .separator + "dir1" )).toString ());
89+ // check regular resource file
90+ assertEquals ("SomeFile" , vfs .toRealPath (Path .of ("SomeFile" )).toString ());
91+ assertEquals (VFS_MOUNT_POINT + File .separator + "SomeFile" , vfs .toRealPath (Path .of (VFS_MOUNT_POINT + File .separator + "SomeFile" )).toString ());
8992 // check to be extracted file
90- checkExtractedFile (vfs .toRealPath (Path .of ("file1" )));
91- checkExtractedFile (vfs .toRealPath (Path .of (VFS_MOUNT_POINT + File .separator + "file1" )));
93+ checkExtractedFile (vfs .toRealPath (Path .of ("file1" )), new String []{ "text1" , "text2" } );
94+ checkExtractedFile (vfs .toRealPath (Path .of (VFS_MOUNT_POINT + File .separator + "file1" )), new String []{ "text1" , "text2" } );
9295 }
9396
9497 @ Test
9598 public void toAbsolutePath () throws Exception {
9699 VirtualFileSystem vfs = VirtualFileSystem .newBuilder ().//
97100 unixMountPoint (VFS_MOUNT_POINT ).//
98101 windowsMountPoint (VFS_WIN_MOUNT_POINT ).//
99- extractFilter (p -> p .getFileName ().toString ().equals ("file1" )).//
102+ extractFilter (p -> p .getFileName ().toString ().equals ("file1" ) || p . getFileName (). toString (). equals ( "file2" ) ).//
100103 resourceLoadingClass (VirtualFileSystemTest .class ).build ();
101- // check regular resource file
104+ // check regular resource dir
102105 assertEquals (VFS_MOUNT_POINT + File .separator + "dir1" , vfs .toAbsolutePath (Path .of ("dir1" )).toString ());
103106 assertEquals (VFS_MOUNT_POINT + File .separator + "dir1" , vfs .toAbsolutePath (Path .of (VFS_MOUNT_POINT + File .separator + "dir1" )).toString ());
107+ // check regular resource file
108+ assertEquals (VFS_MOUNT_POINT + File .separator + "SomeFile" , vfs .toAbsolutePath (Path .of ("SomeFile" )).toString ());
109+ assertEquals (VFS_MOUNT_POINT + File .separator + "SomeFile" , vfs .toAbsolutePath (Path .of (VFS_MOUNT_POINT + File .separator + "SomeFile" )).toString ());
104110 // check to be extracted file
105- checkExtractedFile (vfs .toAbsolutePath (Path .of ("file1" )));
106- checkExtractedFile (vfs .toAbsolutePath (Path .of (VFS_MOUNT_POINT + File .separator + "file1" )));
111+ checkExtractedFile (vfs .toAbsolutePath (Path .of ("file1" )), new String []{"text1" , "text2" });
112+ checkExtractedFile (vfs .toAbsolutePath (Path .of (VFS_MOUNT_POINT + File .separator + "file1" )), new String []{"text1" , "text2" });
113+ checkExtractedFile (vfs .toAbsolutePath (Path .of ("dir1/file2" )), null );
114+ checkExtractedFile (vfs .toAbsolutePath (Path .of (VFS_MOUNT_POINT + File .separator + "dir1/file2" )), null );
107115 }
108116
109- private static void checkExtractedFile (Path extractedFile ) throws IOException {
117+ private static void checkExtractedFile (Path extractedFile , String [] expectedContens ) throws IOException {
110118 assertTrue (Files .exists (extractedFile ));
111119 List <String > lines = Files .readAllLines (extractedFile );
112- assertEquals (2 , lines .size ());
113- assertTrue (lines .contains ("text1" ));
114- assertTrue (lines .contains ("text2" ));
120+ if (expectedContens != null ) {
121+ assertEquals ("expected " + expectedContens .length + " lines in extracted file '" + extractedFile + "'" , expectedContens .length , lines .size ());
122+ for (String line : expectedContens ) {
123+ assertTrue ("expected line '" + line + "' in file '" + extractedFile + "' with contents:\n " + expectedContens , lines .contains (line ));
124+ }
125+ } else {
126+ assertEquals ("extracted file '" + extractedFile + "' expected to be empty, but had " + lines .size () + " lines" , 0 , lines .size ());
127+ }
115128 }
116129
117130 @ Test
0 commit comments