doc / ch.tutteli.atrium.api.fluent.en_GB / notToBeExecutable

notToBeExecutable

fun <T : Path> Expect<T>.notToBeExecutable(): Expect<T> (source)

Expects that the subject of this expectation (a Path) is not executable; meaning that there is a file system entry at the location the Path points to and that the current thread does not have the permission to execute it.

The semantics of “permission to execute it” may differ when checking access to a directory. For example, on UNIX systems, it means that the Java virtual machine has permission to search the directory in order to access file or subdirectories.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

assertIf(ifPosixSupported) {
    val readyOnlyPermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--r--r--"))
    val readyWriteExecutePermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--"))

    val readOnlyDir = tempDir.newDirectory("read_only_dir", readyOnlyPermissions)
    val readOnlyFile = tempDir.newFile("read_only_file", readyOnlyPermissions)
    val readWriteExecuteDir = tempDir.newDirectory("read_write_execute_dir", readyWriteExecutePermissions)
    val readWriteExecuteFile = tempDir.newFile("read_write_execute_file", readyWriteExecutePermissions)

    expect(readOnlyDir).notToBeExecutable()
    expect(readOnlyFile).notToBeExecutable()

    fails {
        expect(readWriteExecuteDir).notToBeExecutable()
    }
    fails {
        expect(readWriteExecuteFile).notToBeExecutable()
    }
}

fails {
    expect(Paths.get("non_existing_dir")).notToBeExecutable()
}

Return
an Expect for the subject of this expectation.

Since
0.17.0