8280965: Tests com/sun/net/httpserver/simpleserver fail with FileSystemException on Windows 11

Reviewed-by: dfuchs
This commit is contained in:
Julia Boes 2022-02-07 09:28:05 +00:00
parent 95fd9d20f3
commit f3e8242683
2 changed files with 28 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -74,6 +74,7 @@ import jdk.test.lib.net.URIBuilder;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.SkipException;
import static java.net.http.HttpClient.Builder.NO_PROXY;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.StandardOpenOption.CREATE;
@ -395,7 +396,7 @@ public class CustomFileSystemTest {
var root = createDirectoryInCustomFs("testSymlinkGET");
var symlink = root.resolve("symlink");
var target = Files.writeString(root.resolve("target.txt"), "some text", CREATE);
Files.createSymbolicLink(symlink, target);
createSymLink(symlink, target);
var server = SimpleFileServer.createFileServer(LOOPBACK_ADDR, root, OutputLevel.VERBOSE);
server.start();
@ -422,7 +423,7 @@ public class CustomFileSystemTest {
var symlink = root.resolve("symlink");
var target = Files.createDirectory(root.resolve("target"));
Files.writeString(target.resolve("aFile.txt"), "some text", CREATE);
Files.createSymbolicLink(symlink, target);
createSymLink(symlink, target);
var server = SimpleFileServer.createFileServer(LOOPBACK_ADDR, root, OutputLevel.VERBOSE);
server.start();
@ -438,6 +439,16 @@ public class CustomFileSystemTest {
}
}
private void createSymLink(Path symlink, Path target) {
try {
Files.createSymbolicLink(symlink, target);
} catch (UnsupportedOperationException uoe) {
throw new SkipException("sym link creation not supported", uoe);
} catch (IOException ioe) {
throw new SkipException("probably insufficient privileges to create sym links (Windows)", ioe);
}
}
@Test
public void testHiddenFileGET() throws Exception {
var root = createDirectoryInCustomFs("testHiddenFileGET");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -56,6 +56,7 @@ import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.SkipException;
import static java.net.http.HttpClient.Builder.NO_PROXY;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.StandardOpenOption.CREATE;
@ -387,7 +388,7 @@ public class SimpleFileServerTest {
var root = Files.createDirectory(TEST_DIR.resolve("testSymlinkGET"));
var symlink = root.resolve("symlink");
var target = Files.writeString(root.resolve("target.txt"), "some text", CREATE);
Files.createSymbolicLink(symlink, target);
createSymLink(symlink, target);
var server = SimpleFileServer.createFileServer(LOOPBACK_ADDR, root, OutputLevel.VERBOSE);
server.start();
@ -414,7 +415,7 @@ public class SimpleFileServerTest {
var symlink = root.resolve("symlink");
var target = Files.createDirectory(root.resolve("target"));
Files.writeString(target.resolve("aFile.txt"), "some text", CREATE);
Files.createSymbolicLink(symlink, target);
createSymLink(symlink, target);
var server = SimpleFileServer.createFileServer(LOOPBACK_ADDR, root, OutputLevel.VERBOSE);
server.start();
@ -430,6 +431,16 @@ public class SimpleFileServerTest {
}
}
private void createSymLink(Path symlink, Path target) {
try {
Files.createSymbolicLink(symlink, target);
} catch (UnsupportedOperationException uoe) {
throw new SkipException("sym link creation not supported", uoe);
} catch (IOException ioe) {
throw new SkipException("probably insufficient privileges to create sym links (Windows)", ioe);
}
}
@Test
public void testHiddenFileGET() throws Exception {
var root = Files.createDirectory(TEST_DIR.resolve("testHiddenFileGET"));