@@ -83,35 +83,48 @@ public void toRealPath() throws Exception {
83
83
windowsMountPoint (VFS_WIN_MOUNT_POINT ).//
84
84
extractFilter (p -> p .getFileName ().toString ().equals ("file1" )).//
85
85
resourceLoadingClass (VirtualFileSystemTest .class ).build ();
86
- // check regular resource file
86
+ // check regular resource dir
87
87
assertEquals ("dir1" , vfs .toRealPath (Path .of ("dir1" )).toString ());
88
88
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 ());
89
92
// 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" } );
92
95
}
93
96
94
97
@ Test
95
98
public void toAbsolutePath () throws Exception {
96
99
VirtualFileSystem vfs = VirtualFileSystem .newBuilder ().//
97
100
unixMountPoint (VFS_MOUNT_POINT ).//
98
101
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" ) ).//
100
103
resourceLoadingClass (VirtualFileSystemTest .class ).build ();
101
- // check regular resource file
104
+ // check regular resource dir
102
105
assertEquals (VFS_MOUNT_POINT + File .separator + "dir1" , vfs .toAbsolutePath (Path .of ("dir1" )).toString ());
103
106
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 ());
104
110
// 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 );
107
115
}
108
116
109
- private static void checkExtractedFile (Path extractedFile ) throws IOException {
117
+ private static void checkExtractedFile (Path extractedFile , String [] expectedContens ) throws IOException {
110
118
assertTrue (Files .exists (extractedFile ));
111
119
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
+ }
115
128
}
116
129
117
130
@ Test
0 commit comments