mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8376419: (fs) Minor improvement of java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java
This commit is contained in:
parent
12570be64a
commit
f843deb31a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@
|
||||
* @library ../.. /test/lib
|
||||
* @key randomness
|
||||
* @build jdk.test.lib.Platform
|
||||
* @build jdk.test.lib.RandomFactory
|
||||
* @run main Basic
|
||||
*/
|
||||
|
||||
@ -38,17 +39,20 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import static java.nio.file.LinkOption.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.file.attribute.UserDefinedFileAttributeView;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.RandomFactory;
|
||||
|
||||
import jtreg.SkippedException;
|
||||
|
||||
public class Basic {
|
||||
|
||||
// Must be indeterministic
|
||||
private static final Random rand = new Random();
|
||||
private static final Random rand = RandomFactory.getRandom();
|
||||
|
||||
private static final String ATTR_NAME = "mime_type";
|
||||
private static final String ATTR_VALUE = "text/plain";
|
||||
@ -281,10 +285,8 @@ public class Basic {
|
||||
// create temporary directory to run tests
|
||||
Path dir = TestUtil.createTemporaryDirectory();
|
||||
try {
|
||||
if (!Files.getFileStore(dir).supportsFileAttributeView("user")) {
|
||||
System.out.println("UserDefinedFileAttributeView not supported - skip test");
|
||||
return;
|
||||
}
|
||||
if (!Files.getFileStore(dir).supportsFileAttributeView("user"))
|
||||
throw new SkippedException("UserDefinedFileAttributeView not supported");
|
||||
|
||||
// test access to user defined attributes of regular file
|
||||
Path file = dir.resolve("foo.html");
|
||||
@ -310,7 +312,7 @@ public class Basic {
|
||||
Path link = dir.resolve("link");
|
||||
Files.createSymbolicLink(link, target);
|
||||
try {
|
||||
test(link, NOFOLLOW_LINKS);
|
||||
test(link, LinkOption.NOFOLLOW_LINKS);
|
||||
} catch (IOException x) {
|
||||
// access to attributes of sym link may not be supported
|
||||
} finally {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user