Skip to content

Commit c8ae169

Browse files
abhn-gitPaul Hohensee
authored andcommitted
8359449: [TEST] open/test/jdk/java/io/File/SymLinks.java Refactor extract method for Windows specific test
Backport-of: 49a82d880636a632f4a3471b14b1b1b29ce1d5e6
1 parent f9d3489 commit c8ae169

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

test/jdk/java/io/File/SymLinks.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -281,22 +281,7 @@ static void go() throws IOException {
281281
assertTrue(link2dir.isDirectory());
282282
assertTrue(link2link2dir.isDirectory());
283283

284-
// on Windows we test with the DOS hidden attribute set
285-
if (System.getProperty("os.name").startsWith("Windows")) {
286-
DosFileAttributeView view = Files
287-
.getFileAttributeView(file.toPath(), DosFileAttributeView.class);
288-
view.setHidden(true);
289-
try {
290-
assertTrue(file.isHidden());
291-
assertTrue(link2file.isHidden());
292-
assertTrue(link2link2file.isHidden());
293-
} finally {
294-
view.setHidden(false);
295-
}
296-
assertFalse(file.isHidden());
297-
assertFalse(link2file.isHidden());
298-
assertFalse(link2link2file.isHidden());
299-
}
284+
testDOSHiddenAttributes();
300285

301286
header("length");
302287

@@ -362,6 +347,26 @@ static void go() throws IOException {
362347
}
363348
}
364349

350+
static void testDOSHiddenAttributes() throws IOException {
351+
// on Windows we test with the DOS hidden attribute set
352+
if (System.getProperty("os.name").startsWith("Windows")) {
353+
header("testDOSHiddenAttributes");
354+
DosFileAttributeView view = Files
355+
.getFileAttributeView(file.toPath(), DosFileAttributeView.class);
356+
view.setHidden(true);
357+
try {
358+
assertTrue(file.isHidden());
359+
assertTrue(link2file.isHidden());
360+
assertTrue(link2link2file.isHidden());
361+
} finally {
362+
view.setHidden(false);
363+
}
364+
assertFalse(file.isHidden());
365+
assertFalse(link2file.isHidden());
366+
assertFalse(link2link2file.isHidden());
367+
}
368+
}
369+
365370
public static void main(String[] args) throws IOException {
366371
if (supportsSymLinks(top)) {
367372
try {

0 commit comments

Comments
 (0)