@@ -49,66 +49,58 @@ static void checkNewFileSystemFromPath() {
4949 @ EntitlementTest (expectedAccess = PLUGINS )
5050 static void checkNewInputStream () throws IOException {
5151 var fs = FileSystems .getDefault ().provider ();
52- var file = EntitledActions .createTempFile ();
53- try (var is = fs .newInputStream (file )) {}
52+ try (var is = fs .newInputStream (FileCheckActions .readFile ())) {}
5453 }
5554
5655 @ EntitlementTest (expectedAccess = PLUGINS )
5756 static void checkNewOutputStream () throws IOException {
5857 var fs = FileSystems .getDefault ().provider ();
59- var file = EntitledActions .createTempFile ();
60- try (var os = fs .newOutputStream (file )) {}
58+ try (var os = fs .newOutputStream (FileCheckActions .readWriteFile ())) {}
6159 }
6260
6361 @ EntitlementTest (expectedAccess = PLUGINS )
6462 static void checkNewFileChannelRead () throws IOException {
6563 var fs = FileSystems .getDefault ().provider ();
66- var file = EntitledActions .createTempFile ();
67- try (var fc = fs .newFileChannel (file , Set .of (StandardOpenOption .READ ))) {}
64+ try (var fc = fs .newFileChannel (FileCheckActions .readFile (), Set .of (StandardOpenOption .READ ))) {}
6865 }
6966
7067 @ EntitlementTest (expectedAccess = PLUGINS )
7168 static void checkNewFileChannelWrite () throws IOException {
7269 var fs = FileSystems .getDefault ().provider ();
73- var file = EntitledActions .createTempFile ();
74- try (var fc = fs .newFileChannel (file , Set .of (StandardOpenOption .WRITE ))) {}
70+ try (var fc = fs .newFileChannel (FileCheckActions .readWriteFile (), Set .of (StandardOpenOption .WRITE ))) {}
7571 }
7672
7773 @ EntitlementTest (expectedAccess = PLUGINS )
7874 static void checkNewAsynchronousFileChannel () throws IOException {
7975 var fs = FileSystems .getDefault ().provider ();
80- var file = EntitledActions .createTempFile ();
81- try (var fc = fs .newAsynchronousFileChannel (file , Set .of (StandardOpenOption .WRITE ), EsExecutors .DIRECT_EXECUTOR_SERVICE )) {}
76+ try (var fc = fs .newAsynchronousFileChannel (FileCheckActions .readWriteFile (), Set .of (StandardOpenOption .WRITE ), EsExecutors .DIRECT_EXECUTOR_SERVICE )) {}
8277 }
8378
8479 @ EntitlementTest (expectedAccess = PLUGINS )
8580 static void checkNewByteChannel () throws IOException {
8681 var fs = FileSystems .getDefault ().provider ();
87- var file = EntitledActions .createTempFile ();
88- try (var bc = fs .newByteChannel (file , Set .of (StandardOpenOption .WRITE ))) {}
82+ try (var bc = fs .newByteChannel (FileCheckActions .readWriteFile (), Set .of (StandardOpenOption .WRITE ))) {}
8983 }
9084
9185 @ EntitlementTest (expectedAccess = PLUGINS )
9286 static void checkNewDirectoryStream () throws IOException {
9387 var fs = FileSystems .getDefault ().provider ();
94- var directory = EntitledActions .createTempDirectory ();
95- try (var bc = fs .newDirectoryStream (directory , entry -> false )) {}
88+ try (var bc = fs .newDirectoryStream (FileCheckActions .readDir (), entry -> false )) {}
9689 }
9790
9891 @ EntitlementTest (expectedAccess = PLUGINS )
9992 static void checkCreateDirectory () throws IOException {
10093 var fs = FileSystems .getDefault ().provider ();
101- var directory = EntitledActions .createTempDirectory ();
94+ var directory = EntitledActions .createTempDirectoryForWrite ();
10295 fs .createDirectory (directory .resolve ("subdir" ));
10396 }
10497
10598 @ EntitlementTest (expectedAccess = PLUGINS )
10699 static void checkCreateSymbolicLink () throws IOException {
107100 var fs = FileSystems .getDefault ().provider ();
108- var directory = EntitledActions .createTempDirectory ();
109- var file = EntitledActions .createTempFile ();
101+ var directory = EntitledActions .createTempDirectoryForWrite ();
110102 try {
111- fs .createSymbolicLink (directory .resolve ("link" ), file );
103+ fs .createSymbolicLink (directory .resolve ("link" ), FileCheckActions . readFile () );
112104 } catch (UnsupportedOperationException e ) {
113105 // OK not to implement symbolic link in the filesystem
114106 }
@@ -117,111 +109,103 @@ static void checkCreateSymbolicLink() throws IOException {
117109 @ EntitlementTest (expectedAccess = PLUGINS )
118110 static void checkCreateLink () throws IOException {
119111 var fs = FileSystems .getDefault ().provider ();
120- var directory = EntitledActions .createTempDirectory ();
121- var file = EntitledActions .createTempFile ();
112+ var directory = EntitledActions .createTempDirectoryForWrite ();
122113 try {
123- fs .createLink (directory .resolve ("link" ), file );
114+ fs .createLink (directory .resolve ("link" ), FileCheckActions . readFile () );
124115 } catch (UnsupportedOperationException e ) {
125116 // OK not to implement symbolic link in the filesystem
126117 }
127-
128118 }
129119
130120 @ EntitlementTest (expectedAccess = PLUGINS )
131121 static void checkDelete () throws IOException {
132122 var fs = FileSystems .getDefault ().provider ();
133- var file = EntitledActions .createTempFile ();
123+ var file = EntitledActions .createTempFileForWrite ();
134124 fs .delete (file );
135125 }
136126
137127 @ EntitlementTest (expectedAccess = PLUGINS )
138128 static void checkDeleteIfExists () throws IOException {
139129 var fs = FileSystems .getDefault ().provider ();
140- fs .deleteIfExists (Path .of ("/dummy/path" ));
130+ var file = EntitledActions .createTempFileForWrite ();
131+ fs .deleteIfExists (file );
141132 }
142133
143134 @ EntitlementTest (expectedAccess = PLUGINS )
144- static void checkReadSymbolicLink () {
145- // TODO
135+ static void checkReadSymbolicLink () throws IOException {
136+ var fs = FileSystems .getDefault ().provider ();
137+ var link = EntitledActions .createTempSymbolicLink ();
138+ fs .readSymbolicLink (link );
146139 }
147140
148141 @ EntitlementTest (expectedAccess = PLUGINS )
149142 static void checkCopy () throws IOException {
150143 var fs = FileSystems .getDefault ().provider ();
151- var directory = EntitledActions .createTempDirectory ();
152- var file = EntitledActions .createTempFile ();
153- fs .copy (file , directory .resolve ("copied" ));
144+ var directory = EntitledActions .createTempDirectoryForWrite ();
145+ fs .copy (FileCheckActions .readFile (), directory .resolve ("copied" ));
154146 }
155147
156148 @ EntitlementTest (expectedAccess = PLUGINS )
157149 static void checkMove () throws IOException {
158150 var fs = FileSystems .getDefault ().provider ();
159- var directory = EntitledActions .createTempDirectory ();
160- var file = EntitledActions .createTempFile ();
151+ var directory = EntitledActions .createTempDirectoryForWrite ();
152+ var file = EntitledActions .createTempFileForWrite ();
161153 fs .move (file , directory .resolve ("moved" ));
162154 }
163155
164156 @ EntitlementTest (expectedAccess = PLUGINS )
165157 static void checkIsSameFile () throws IOException {
166158 var fs = FileSystems .getDefault ().provider ();
167- var file1 = EntitledActions .createTempFile ();
168- var file2 = EntitledActions .createTempFile ();
169- fs .isSameFile (file1 , file2 );
159+ fs .isSameFile (FileCheckActions .readWriteFile (), FileCheckActions .readFile ());
170160 }
171161
172162 @ EntitlementTest (expectedAccess = PLUGINS )
173163 static void checkIsHidden () throws IOException {
174164 var fs = FileSystems .getDefault ().provider ();
175- var file = EntitledActions .createTempFile ();
176- fs .isHidden (file );
165+ fs .isHidden (FileCheckActions .readFile ());
177166 }
178167
179168 @ EntitlementTest (expectedAccess = PLUGINS )
180169 static void checkGetFileStore () throws IOException {
181170 var fs = FileSystems .getDefault ().provider ();
182- var file = EntitledActions .createTempFile ();
171+ var file = EntitledActions .createTempFileForRead ();
183172 var store = fs .getFileStore (file );
184173 }
185174
186175 @ EntitlementTest (expectedAccess = PLUGINS )
187176 static void checkCheckAccess () throws IOException {
188177 var fs = FileSystems .getDefault ().provider ();
189- var file = EntitledActions .createTempFile ();
190- fs .checkAccess (file );
178+ fs .checkAccess (FileCheckActions .readFile ());
191179 }
192180
193181 @ EntitlementTest (expectedAccess = ALWAYS_DENIED )
194- static void checkGetFileAttributeView () throws IOException {
182+ static void checkGetFileAttributeView () {
195183 var fs = FileSystems .getDefault ().provider ();
196- var file = EntitledActions .createTempFile ();
197- fs .getFileAttributeView (file , FileOwnerAttributeView .class );
184+ fs .getFileAttributeView (FileCheckActions .readFile (), FileOwnerAttributeView .class );
198185 }
199186
200187 @ EntitlementTest (expectedAccess = PLUGINS )
201188 static void checkReadAttributesWithClass () throws IOException {
202189 var fs = FileSystems .getDefault ().provider ();
203- var file = EntitledActions .createTempFile ();
204- fs .readAttributes (file , BasicFileAttributes .class );
190+ fs .readAttributes (FileCheckActions .readFile (), BasicFileAttributes .class );
205191 }
206192
207193 @ EntitlementTest (expectedAccess = PLUGINS )
208194 static void checkReadAttributesWithString () throws IOException {
209195 var fs = FileSystems .getDefault ().provider ();
210- var file = EntitledActions .createTempFile ();
211- fs .readAttributes (file , "*" );
196+ fs .readAttributes (FileCheckActions .readFile (), "*" );
212197 }
213198
214199 @ EntitlementTest (expectedAccess = PLUGINS )
215200 static void checkReadAttributesIfExists () throws IOException {
216201 var fs = FileSystems .getDefault ().provider ();
217- var file = EntitledActions .createTempFile ();
218- fs .readAttributesIfExists (file , BasicFileAttributes .class );
202+ fs .readAttributesIfExists (FileCheckActions .readFile (), BasicFileAttributes .class );
219203 }
220204
221205 @ EntitlementTest (expectedAccess = PLUGINS )
222206 static void checkSetAttribute () throws IOException {
223207 var fs = FileSystems .getDefault ().provider ();
224- var file = EntitledActions .createTempFile ();
208+ var file = EntitledActions .createTempFileForWrite ();
225209 try {
226210 fs .setAttribute (file , "dos:hidden" , true );
227211 } catch (UnsupportedOperationException | IllegalArgumentException e ) {
@@ -232,7 +216,7 @@ static void checkSetAttribute() throws IOException {
232216 @ EntitlementTest (expectedAccess = PLUGINS )
233217 static void checkExists () {
234218 var fs = FileSystems .getDefault ().provider ();
235- fs .exists (Path . of ( "/dummy/path" ));
219+ fs .exists (FileCheckActions . readFile ( ));
236220 }
237221
238222 private NioFileSystemActions () {}
0 commit comments