Commit fba5ffc6 authored by Scott Frederick's avatar Scott Frederick

Fix FilePermissionsTests on Windows

See gh-26658
parent 8df6392c
......@@ -27,11 +27,15 @@ import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIOException;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Tests for {@link FilePermissions}.
......@@ -44,6 +48,7 @@ class FilePermissionsTests {
Path tempDir;
@Test
@DisabledOnOs(OS.WINDOWS)
void umaskForPath() throws IOException {
FileAttribute<Set<PosixFilePermission>> fileAttribute = PosixFilePermissions
.asFileAttribute(PosixFilePermissions.fromString("rw-r-----"));
......@@ -52,11 +57,20 @@ class FilePermissionsTests {
}
@Test
@DisabledOnOs(OS.WINDOWS)
void umaskForPathWithNonExistentFile() throws IOException {
assertThatIOException()
.isThrownBy(() -> FilePermissions.umaskForPath(Paths.get(this.tempDir.toString(), "does-not-exist")));
}
@Test
@EnabledOnOs(OS.WINDOWS)
void umaskForPathOnWindowsFails() throws IOException {
Path tempFile = Files.createTempFile("umask", null);
assertThatIllegalStateException().isThrownBy(() -> FilePermissions.umaskForPath(tempFile))
.withMessageContaining("Unsupported file type for retrieving Posix attributes");
}
@Test
void umaskForPathWithNullPath() throws IOException {
assertThatIllegalArgumentException().isThrownBy(() -> FilePermissions.umaskForPath(null));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment