test/java/nio/file/Files/SBC.java

Print this page
rev 8975 : 8028537: PPC64: Updated the JDK regression tests to run on AIX
Reviewed-by: alanb
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, volker.simonis@gmail.com


 218             // clean-up
 219             TestUtil.deleteUnchecked(file);
 220         }
 221 
 222     }
 223 
 224     // test NOFOLLOW_LINKS option
 225     static void noFollowLinksTests(Path dir) throws Exception {
 226         if (!supportsLinks)
 227             return;
 228         Path file = Files.createFile(dir.resolve("foo"));
 229         try {
 230             // ln -s foo link
 231             Path link = dir.resolve("link");
 232             Files.createSymbolicLink(link, file);
 233 
 234             // open with NOFOLLOW_LINKS option
 235             try {
 236                 Files.newByteChannel(link, READ, LinkOption.NOFOLLOW_LINKS);
 237                 throw new RuntimeException();
 238             } catch (IOException x) {
 239             } finally {
 240                 TestUtil.deleteUnchecked(link);
 241             }
 242 
 243         } finally {
 244             // clean-up
 245             TestUtil.deleteUnchecked(file);
 246         }
 247     }
 248 
 249     // test size/truncate/position methods
 250     static void sizeTruncatePositionTests(Path dir) throws Exception {
 251         Path file = dir.resolve("foo");
 252         try {
 253             try (SeekableByteChannel sbc = Files.newByteChannel(file, CREATE_NEW, READ, WRITE)) {
 254                 if (sbc.size() != 0L)
 255                     throw new RuntimeException("Unexpected size");
 256 
 257                 // check size
 258                 write(sbc, "hello");




 218             // clean-up
 219             TestUtil.deleteUnchecked(file);
 220         }
 221 
 222     }
 223 
 224     // test NOFOLLOW_LINKS option
 225     static void noFollowLinksTests(Path dir) throws Exception {
 226         if (!supportsLinks)
 227             return;
 228         Path file = Files.createFile(dir.resolve("foo"));
 229         try {
 230             // ln -s foo link
 231             Path link = dir.resolve("link");
 232             Files.createSymbolicLink(link, file);
 233 
 234             // open with NOFOLLOW_LINKS option
 235             try {
 236                 Files.newByteChannel(link, READ, LinkOption.NOFOLLOW_LINKS);
 237                 throw new RuntimeException();
 238             } catch (IOException | UnsupportedOperationException x) {
 239             } finally {
 240                 TestUtil.deleteUnchecked(link);
 241             }
 242 
 243         } finally {
 244             // clean-up
 245             TestUtil.deleteUnchecked(file);
 246         }
 247     }
 248 
 249     // test size/truncate/position methods
 250     static void sizeTruncatePositionTests(Path dir) throws Exception {
 251         Path file = dir.resolve("foo");
 252         try {
 253             try (SeekableByteChannel sbc = Files.newByteChannel(file, CREATE_NEW, READ, WRITE)) {
 254                 if (sbc.size() != 0L)
 255                     throw new RuntimeException("Unexpected size");
 256 
 257                 // check size
 258                 write(sbc, "hello");