JAVA-2599: Update OS specific unit tests
This commit is contained in:
parent
89f0f75667
commit
4f14873967
|
@ -9,4 +9,5 @@ This module contains articles about core Java input and output (IO)
|
|||
- [Check If a File or Directory Exists in Java](https://www.baeldung.com/java-file-directory-exists)
|
||||
- [Copy a Directory in Java](https://www.baeldung.com/java-copy-directory)
|
||||
- [Java Files Open Options](https://www.baeldung.com/java-file-options)
|
||||
- [Creating Temporary Directories in Java](https://www.baeldung.com/java-temp-directories)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-io-2)
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.junit.Test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -20,8 +21,8 @@ public class DirectoryEmptinessUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenPath_whenNotDirectory_thenReturnsFalse() throws IOException {
|
||||
Path aFile = Paths.get(getClass().getResource("/notDir.txt").getPath());
|
||||
public void givenPath_whenNotDirectory_thenReturnsFalse() throws IOException, URISyntaxException {
|
||||
Path aFile = Paths.get(getClass().getResource("/notDir.txt").toURI());
|
||||
assertThat(isEmpty(aFile)).isFalse();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -66,6 +67,11 @@ public class TemporaryDirectoriesUnitTest {
|
|||
|
||||
@Test
|
||||
public void givenTempDirWithPrefixWithFileAttrs_whenCreatePlainJava_thenAttributesAreSet() throws IOException {
|
||||
boolean isPosix = FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
|
||||
|
||||
if(!isPosix){
|
||||
System.out.println("You must be under a Posix Compliant Filesystem to run this test.");
|
||||
} else {
|
||||
final FileAttribute<Set<PosixFilePermission>> attrs = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--------"));
|
||||
|
||||
final Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix", attrs);
|
||||
|
@ -73,3 +79,4 @@ public class TemporaryDirectoriesUnitTest {
|
|||
assertThat(tmpdir.toFile().canWrite()).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue