Search in sources :

Example 6 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project spring-boot by spring-projects.

the class FilePermissionsTests method umaskForPathOnWindowsFails.

@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");
}
Also used : Path(java.nio.file.Path) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 7 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project gocd by gocd.

the class ArtifactsServiceTest method shouldProvideArtifactRootForAJobOnWindows.

@Test
@EnabledOnOs(OS.WINDOWS)
void shouldProvideArtifactRootForAJobOnWindows() throws Exception {
    assumeArtifactsRoot(fakeRoot);
    ArtifactsService artifactsService = new ArtifactsService(resolverService, stageService, artifactsDirHolder, zipUtil);
    artifactsService.initialize();
    JobIdentifier oldId = new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null);
    when(resolverService.actualJobIdentifier(oldId)).thenReturn(new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null));
    String artifactRoot = artifactsService.findArtifactRoot(oldId);
    assertThat(artifactRoot).isEqualTo("pipelines\\cruise\\1\\dev\\2\\linux-firefox");
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 8 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project gocd by gocd.

the class ZipUtilTest method shouldZipFileWhoseNameHasSpecialCharactersOnLinux.

@Test
@EnabledOnOs(OS.LINUX)
void shouldZipFileWhoseNameHasSpecialCharactersOnLinux() throws IOException {
    File specialFile = new File(srcDir, "$`#?@!()?-_{}^'~.+=[];,a.txt");
    FileUtils.writeStringToFile(specialFile, "specialFile", UTF_8);
    zipFile = zipUtil.zip(srcDir, createFileInTempDir(), Deflater.NO_COMPRESSION);
    zipUtil.unzip(zipFile, destDir);
    File baseDir = new File(destDir, srcDir.getName());
    File actualSpecialFile = new File(baseDir, specialFile.getName());
    assertThat(actualSpecialFile.isFile()).isTrue();
    assertThat(fileContent(actualSpecialFile)).isEqualTo(fileContent(specialFile));
}
Also used : File(java.io.File) ZipFile(java.util.zip.ZipFile) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 9 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project gocd by gocd.

the class CommandLineTest method shouldLogPasswordsOnOutputAsStarsUnderWindows.

@Test
@EnabledOnOs(OS.WINDOWS)
void shouldLogPasswordsOnOutputAsStarsUnderWindows() {
    CommandLine line = CommandLine.createCommandLine("cmd").withEncoding("utf-8").withArg("/c").withArg("echo").withArg("My Password is:").withArg(new PasswordArgument("secret"));
    InMemoryStreamConsumer output = new InMemoryStreamConsumer();
    InMemoryStreamConsumer displayOutputStreamConsumer = InMemoryStreamConsumer.inMemoryConsumer();
    ProcessWrapper processWrapper = line.execute(output, new EnvironmentVariableContext(), null);
    processWrapper.waitForExit();
    assertThat(output.getAllOutput(), containsString("secret"));
    assertThat(displayOutputStreamConsumer.getAllOutput(), not(containsString("secret")));
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 10 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project gocd by gocd.

the class CommandBuilderTest method commandWithArgs_shouldAddCmdBeforeAWindowsCommand.

@Test
@EnabledOnOs(OS.WINDOWS)
void commandWithArgs_shouldAddCmdBeforeAWindowsCommand() {
    CommandBuilder commandBuilder = new CommandBuilder("echo", "some thing", tempWorkDir, null, null, "some desc");
    CommandLine commandLine = commandBuilder.buildCommandLine();
    assertThat(commandLine.toStringForDisplay()).isEqualTo("cmd /c echo some thing");
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)36 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)36 File (java.io.File)14 Path (java.nio.file.Path)7 URI (java.net.URI)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 EnabledForRepository (org.opengrok.indexer.condition.EnabledForRepository)5 TestRepository (org.opengrok.indexer.util.TestRepository)5 URL (java.net.URL)3 URLClassLoader (java.net.URLClassLoader)3 Date (java.util.Date)3 LinkedList (java.util.LinkedList)3 StringBinding (javafx.beans.binding.StringBinding)3 DisplayName (org.junit.jupiter.api.DisplayName)3 EnabledIf (org.junit.jupiter.api.condition.EnabledIf)3 CommandLine (com.thoughtworks.go.util.command.CommandLine)2 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)2 HashSet (java.util.HashSet)2 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)2 NantTask (com.thoughtworks.go.config.NantTask)1