Search in sources :

Example 86 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project jspwiki by apache.

the class FileUtilTest method testReadContentsFromPipeOnLinux.

/**
 * ISO Latin 1 from a pipe.
 */
@Test
@DisabledOnOs(OS.WINDOWS)
public void testReadContentsFromPipeOnLinux() throws Exception {
    String src = "abc\n123456\n\nfoobar.\n";
    // Make a very long string.
    for (int i = 0; i < 10; i++) {
        src += src;
    }
    src += "\u00e4\u00e5\u00a6";
    final File f = FileUtil.newTmpFile(src, StandardCharsets.ISO_8859_1);
    final String[] envp = {};
    final Process process = Runtime.getRuntime().exec("cat " + f.getAbsolutePath(), envp, f.getParentFile());
    final String result = FileUtil.readContents(process.getInputStream(), StandardCharsets.UTF_8.name());
    f.delete();
    Assertions.assertEquals(src, result);
}
Also used : File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 87 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project robozonky by RoboZonky.

the class FileUtilTest method permissions.

@DisabledOnOs(OS.WINDOWS)
@Test
void permissions() throws IOException {
    File file = createTempFile();
    Path path = file.toPath();
    boolean result = FileUtil.configurePermissions(file, true);
    assertSoftly(softly -> {
        softly.assertThat(path.toFile()).canRead().canWrite();
        softly.assertThat(path.toFile().canExecute()).isTrue();
        softly.assertThat(result).isTrue();
    });
    boolean result2 = FileUtil.configurePermissions(file, false);
    assertSoftly(softly -> {
        softly.assertThat(path.toFile()).canRead().canWrite();
        softly.assertThat(path.toFile().canExecute()).isFalse();
        softly.assertThat(result2).isTrue();
    });
}
Also used : Path(java.nio.file.Path) File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)87 Test (org.junit.jupiter.api.Test)80 Path (java.nio.file.Path)39 File (java.io.File)26 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 PathsBaseTest (org.assertj.core.internal.PathsBaseTest)12 AssertionsUtil.expectAssertionError (org.assertj.core.util.AssertionsUtil.expectAssertionError)11 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)6 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)6 PageSwapperTest (org.neo4j.io.pagecache.PageSwapperTest)6 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)5 DelegatingStoreChannel (org.neo4j.io.fs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5 DisabledForRoot (org.neo4j.test.extension.DisabledForRoot)5 Closeable (java.io.Closeable)4 URI (java.net.URI)4 FileUtils.writeByteArrayToFile (org.apache.commons.io.FileUtils.writeByteArrayToFile)4 ShouldBeFile.shouldBeFile (org.assertj.core.error.ShouldBeFile.shouldBeFile)4 FilesBaseTest (org.assertj.core.internal.FilesBaseTest)4 Files.newFile (org.assertj.core.util.Files.newFile)4