Try to fix NestedFileSystemProviderTests on Windows
See gh-7161
This commit is contained in:
@@ -30,9 +30,12 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.nio.file.attribute.BasicFileAttributeView;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
@@ -69,6 +72,11 @@ class NestedFileSystemProviderTests {
|
||||
this.uriPrefix = "nested:" + this.file.toURI().getPath() + "/!";
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
this.provider.cleanUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSchemeReturnsScheme() {
|
||||
assertThat(this.provider.getScheme()).isEqualTo("nested");
|
||||
@@ -259,6 +267,8 @@ class NestedFileSystemProviderTests {
|
||||
|
||||
private Path mockJarPath;
|
||||
|
||||
private List<Path> paths = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected Path getJarPath(Path path) {
|
||||
return (this.mockJarPath != null) ? this.mockJarPath : super.getJarPath(path);
|
||||
@@ -268,6 +278,24 @@ class NestedFileSystemProviderTests {
|
||||
this.mockJarPath = mockJarPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath(URI uri) {
|
||||
Path path = super.getPath(uri);
|
||||
this.paths.add(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
private void cleanUp() {
|
||||
this.paths.forEach((path) -> {
|
||||
try {
|
||||
Path.of(path.toUri()).getFileSystem().close();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Ignore
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user