org.junit.jupiter.api.condition.OS Java Examples
The following examples show how to use
org.junit.jupiter.api.condition.OS.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 6 votes |
@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"))); }
Example #2
Source File: LocalDeployerPropertiesTests.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs(OS.LINUX) public void defaultNoPropertiesSet() { this.contextRunner .withUserConfiguration(Config1.class) .run((context) -> { LocalDeployerProperties properties = context.getBean(LocalDeployerProperties.class); assertThat(properties.getDebugPort()).isNull(); assertThat(properties.getDebugSuspend()).isNull(); assertThat(properties.isDeleteFilesOnExit()).isTrue(); assertThat(properties.getEnvVarsToInherit()).containsExactly("TMP", "LANG", "LANGUAGE", "LC_.*", "PATH", "SPRING_APPLICATION_JSON"); assertThat(properties.isInheritLogging()).isFalse(); assertThat(properties.getJavaCmd()).contains("java"); assertThat(properties.getJavaOpts()).isNull(); assertThat(properties.getMaximumConcurrentTasks()).isEqualTo(20); assertThat(properties.getPortRange()).isNotNull(); assertThat(properties.getPortRange().getLow()).isEqualTo(20000); assertThat(properties.getPortRange().getHigh()).isEqualTo(61000); assertThat(properties.getShutdownTimeout()).isEqualTo(30); assertThat(properties.isUseSpringApplicationJson()).isTrue(); assertThat(properties.getDocker().getNetwork()).isEqualTo("bridge"); }); }
Example #3
Source File: LocalDeployerPropertiesTests.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs(OS.WINDOWS) public void testOnWindows() { this.contextRunner .withInitializer(context -> { Map<String, Object> map = new HashMap<>(); map.put("spring.cloud.deployer.local.working-directories-root", "file:/C:/tmp"); context.getEnvironment().getPropertySources().addLast(new SystemEnvironmentPropertySource( StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, map)); }) .withUserConfiguration(Config1.class) .run((context) -> { LocalDeployerProperties properties = context.getBean(LocalDeployerProperties.class); assertThat(properties.getWorkingDirectoriesRoot()).isNotNull(); assertThat(properties.getWorkingDirectoriesRoot().toString()).isEqualTo("C:\\tmp"); }); }
Example #4
Source File: LocalDeployerPropertiesTests.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs(OS.LINUX) public void testOnLinux() { this.contextRunner .withInitializer(context -> { Map<String, Object> map = new HashMap<>(); map.put("spring.cloud.deployer.local.working-directories-root", "/tmp"); context.getEnvironment().getPropertySources().addLast(new SystemEnvironmentPropertySource( StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, map)); }) .withUserConfiguration(Config1.class) .run((context) -> { LocalDeployerProperties properties = context.getBean(LocalDeployerProperties.class); assertThat(properties.getWorkingDirectoriesRoot()).isNotNull(); assertThat(properties.getWorkingDirectoriesRoot().toString()).isEqualTo("/tmp"); }); }
Example #5
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfACommandSnippetXMLIsUnReadableAndRemoveItOnceItsReadable() throws IOException { File dirWithUnreadableFile = temporaryFolder.newFolder("dirWithUnreadableFile"); File unreadableFile = new File(dirWithUnreadableFile, "unreadable.xml"); FileUtils.copyFile(xmlFile, unreadableFile); unreadableFile.setReadable(false); walker.getAllCommandSnippets(dirWithUnreadableFile.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command snippet XML file located in Go Server Directory at " + unreadableFile.getPath() + ". Go does not have sufficient permissions to access it.")); unreadableFile.setReadable(true); walker.getAllCommandSnippets(dirWithUnreadableFile.getPath()); verify(serverHealthService, times(2)).update(serverHealthMessageWhichSaysItsOk()); verifyNoMoreInteractions(serverHealthService); }
Example #6
Source File: BuilderTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldReportErrorWhenCancelCommandDoesNotExist() { StubBuilder stubBuilder = new StubBuilder(); CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, ""); CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, ""); builder.cancel(goPublisher, new EnvironmentVariableContext(), null, null, "utf-8"); assertThat(goPublisher.getMessage()).contains("Error happened while attempting to execute 'echo2 cancel task'"); }
Example #7
Source File: CarBundlerTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void bundle(@TempDir final File temporaryFolder) throws Exception { final CarBundler.Configuration configuration = prepareBundle(temporaryFolder); // try to execute the main now in a fake studio final File fakeStudio = temporaryFolder; final File fakeConfig = new File(fakeStudio, "configuration/config.ini"); fakeConfig.getParentFile().mkdirs(); try (final Writer writer = new FileWriter(fakeConfig)) { // no-op, just create the file } final File fakeM2 = new File(fakeStudio, "configuration/.m2/repository/"); fakeM2.mkdirs(); assertEquals(0, new ProcessBuilder( new File(System.getProperty("java.home"), "/bin/java" + (OS.WINDOWS.isCurrentOs() ? ".exe" : "")).getAbsolutePath(), "-jar", configuration.getOutput().getAbsolutePath(), "studio-deploy", fakeStudio.getAbsolutePath()).inheritIO().start().waitFor()); // asserts the jar was installed and the component registered assertTrue(new File(fakeM2, "foo/bar/dummy/1.2/dummy-1.2.jar").exists()); assertEquals("component.java.coordinates = foo.bar:dummy:1.2", Files.readAllLines(fakeConfig.toPath()).stream().collect(joining("\n")).trim()); }
Example #8
Source File: CarBundlerTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void bundleWithExistingSameComponentOtherVersionAndOtherComponents(@TempDir final File temporaryFolder) throws Exception { final CarBundler.Configuration configuration = prepareBundle(temporaryFolder); // try to execute the main now in a fake studio final File fakeStudio = temporaryFolder; final File fakeConfig = new File(fakeStudio, "configuration/config.ini"); fakeConfig.getParentFile().mkdirs(); try (final Writer writer = new FileWriter(fakeConfig)) { writer.write("component.java.coordinates = a:b:1,foo.bar:dummy:1.1,d:e:3"); } final File fakeM2 = new File(fakeStudio, "configuration/.m2/repository/"); fakeM2.mkdirs(); assertEquals(0, new ProcessBuilder( new File(System.getProperty("java.home"), "/bin/java" + (OS.WINDOWS.isCurrentOs() ? ".exe" : "")).getAbsolutePath(), "-jar", configuration.getOutput().getAbsolutePath(), "studio-deploy", fakeStudio.getAbsolutePath()).inheritIO().start().waitFor()); assertEquals("component.java.coordinates = foo.bar:dummy:1.2,a:b:1,d:e:3", String.join("\n", Files.readAllLines(fakeConfig.toPath())).trim()); }
Example #9
Source File: CarBundlerTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void bundleWithExistingSameComponentOtherVersion(@TempDir final File temporaryFolder) throws Exception { final CarBundler.Configuration configuration = prepareBundle(temporaryFolder); // try to execute the main now in a fake studio final File fakeStudio = temporaryFolder; final File fakeConfig = new File(fakeStudio, "configuration/config.ini"); fakeConfig.getParentFile().mkdirs(); try (final Writer writer = new FileWriter(fakeConfig)) { writer.write("component.java.coordinates = foo.bar:dummy:1.1"); } final File fakeM2 = new File(fakeStudio, "configuration/.m2/repository/"); fakeM2.mkdirs(); assertEquals(0, new ProcessBuilder( new File(System.getProperty("java.home"), "/bin/java" + (OS.WINDOWS.isCurrentOs() ? ".exe" : "")).getAbsolutePath(), "-jar", configuration.getOutput().getAbsolutePath(), "studio-deploy", fakeStudio.getAbsolutePath()).inheritIO().start().waitFor()); assertEquals("component.java.coordinates = foo.bar:dummy:1.2", String.join("\n", Files.readAllLines(fakeConfig.toPath())).trim()); }
Example #10
Source File: CarBundlerTest.java From component-runtime with Apache License 2.0 | 6 votes |
@Test void bundleWithExistingOtherComponent(@TempDir final File temporaryFolder) throws Exception { final CarBundler.Configuration configuration = prepareBundle(temporaryFolder); // try to execute the main now in a fake studio final File fakeStudio = temporaryFolder; final File fakeConfig = new File(fakeStudio, "configuration/config.ini"); fakeConfig.getParentFile().mkdirs(); try (final Writer writer = new FileWriter(fakeConfig)) { writer.write("component.java.coordinates = a.bar:dummy:1.3,a.bar:h:2.2"); } final File fakeM2 = new File(fakeStudio, "configuration/.m2/repository/"); fakeM2.mkdirs(); assertEquals(0, new ProcessBuilder( new File(System.getProperty("java.home"), "/bin/java" + (OS.WINDOWS.isCurrentOs() ? ".exe" : "")).getAbsolutePath(), "-jar", configuration.getOutput().getAbsolutePath(), "studio-deploy", fakeStudio.getAbsolutePath()).inheritIO().start().waitFor()); assertEquals("component.java.coordinates = foo.bar:dummy:1.2,a.bar:dummy:1.3,a.bar:h:2.2", String.join("\n", Files.readAllLines(fakeConfig.toPath())).trim()); }
Example #11
Source File: ConfigurationTest.java From benchmarks with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs({ OS.LINUX, OS.MAC }) void throwsIllegalArgumentExceptionIfOutputDirectoryIsNotWriteable(final @TempDir Path tempDir) throws IOException { final Path outputDirectory = Files.createDirectory(tempDir.resolve("read-only"), PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ))); final Builder builder = new Builder() .numberOfMessages(4) .messageTransceiverClass(InMemoryMessageTransceiver.class) .outputDirectory(outputDirectory); final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, builder::build); assertEquals("output directory is not writeable: " + outputDirectory, ex.getMessage()); }
Example #12
Source File: ConfigurationTest.java From benchmarks with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs({ OS.LINUX, OS.MAC }) void throwsIllegalArgumentExceptionIfOutputDirectoryCannotBeCreated(final @TempDir Path tempDir) throws IOException { final Path rootDirectory = Files.createDirectory(tempDir.resolve("read-only"), PosixFilePermissions.asFileAttribute(EnumSet.of(PosixFilePermission.OWNER_READ))); final Path outputDirectory = rootDirectory.resolve("actual-dir"); final Builder builder = new Builder() .numberOfMessages(4) .messageTransceiverClass(InMemoryMessageTransceiver.class) .outputDirectory(outputDirectory); final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, builder::build); assertEquals("failed to create output directory: " + outputDirectory, ex.getMessage()); }
Example #13
Source File: GitMaterialTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs({OS.WINDOWS}) void shouldThrowExceptionWhenWorkingDirectoryIsNotGitRepoAndItsUnableToDeleteIt() throws IOException { File fileToBeLocked = new File(workingDir, "file"); RandomAccessFile lockedFile = new RandomAccessFile(fileToBeLocked, "rw"); FileLock lock = lockedFile.getChannel().lock(); try { git.latestModification(workingDir, new TestSubprocessExecutionContext()); fail("Should have failed to check modifications since the file is locked and cannot be removed."); } catch (Exception e) { assertThat("Failed to delete directory: " + workingDir.getAbsolutePath().trim()).isEqualTo(e.getMessage().trim()); assertThat(fileToBeLocked.exists()).isTrue(); } finally { lock.release(); } }
Example #14
Source File: ScriptRunnerTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @EnabledOnOs(OS.WINDOWS) void shouldMaskOutOccuranceOfSecureEnvironmentVariablesValuesInTheScriptOutput() throws CheckedCommandLineException { EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext(); environmentVariableContext.setProperty("secret", "the_secret_password", true); CommandLine command = CommandLine.createCommandLine("cmd") .withArg("/c") .withArg("echo") .withArg("the_secret_password") .withEncoding("utf-8"); InMemoryConsumer output = new InMemoryConsumer(); ExecScript script = new ExecScript("ERROR_STRING"); command.runScript(script, output, environmentVariableContext, null); assertThat(script.getExitCode()).isEqualTo(0); assertThat(output.contains("the_secret_password")).as(output.toString()).isFalse(); }
Example #15
Source File: ResolverConfigTest.java From dnsjava with BSD 2-Clause "Simplified" License | 6 votes |
@Test @EnabledOnOs(OS.WINDOWS) void windowsServersContainedInJndi() throws InitializationException { JndiContextResolverConfigProvider jndi = new JndiContextResolverConfigProvider(); jndi.initialize(); WindowsResolverConfigProvider win = new WindowsResolverConfigProvider(); win.initialize(); // the servers returned via Windows API must be in the JNDI list, but not necessarily the other // way round. Unless there IPv6 servers which are not in the registry and Java <= 15 does not // find. for (InetSocketAddress winServer : win.servers()) { assertTrue( jndi.servers().contains(winServer), winServer + " not found in JNDI, " + win.servers() + "; " + jndi.servers()); } }
Example #16
Source File: SvnCommandTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldRecogniseSvnAsTheSameIfURLContainsChineseCharacters() throws Exception { File working = temporaryFolder.newFolder("shouldRecogniseSvnAsTheSameIfURLContainsSpaces"); SvnTestRepo repo = new SvnTestRepo(temporaryFolder, "a directory with 司徒空在此"); SvnMaterial material = repo.material(); assertThat(material.getUrl()).contains("%20"); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); material.freshCheckout(output, new SubversionRevision("3"), working); assertThat(output.getAllOutput()).contains("Checked out revision 3"); InMemoryStreamConsumer output2 = new InMemoryStreamConsumer(); updateMaterial(material, new SubversionRevision("4"), working, output2); assertThat(output2.getAllOutput()).contains("Updated to revision 4"); }
Example #17
Source File: MaterialsTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldFailIfMultipleMaterialsHaveSameFolderNameSet_CaseInSensitive() { HgMaterialConfig materialOne = hg("http://url1", null); materialOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder")); HgMaterialConfig materialTwo = hg("http://url2", null); materialTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "foLder")); CruiseConfig config = GoConfigMother.configWithPipelines("one"); PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one")); pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne, materialTwo)); MaterialConfigs materials = pipelineOne.materialConfigs(); materials.validate(ConfigSaveValidationContext.forChain(config)); assertThat(materials.get(0).errors().isEmpty()).isFalse(); assertThat(materials.get(1).errors().isEmpty()).isFalse(); assertThat(materials.get(0).errors().on(ScmMaterialConfig.FOLDER)).isEqualTo("The destination directory must be unique across materials."); assertThat(materials.get(1).errors().on(ScmMaterialConfig.FOLDER)).isEqualTo("The destination directory must be unique across materials."); }
Example #18
Source File: SvnCommandTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldRecogniseSvnAsTheSameIfURLContainsSpaces() throws Exception { File working = temporaryFolder.newFolder("shouldRecogniseSvnAsTheSameIfURLContainsSpaces"); SvnTestRepo repo = new SvnTestRepo(temporaryFolder, "a directory with spaces"); SvnMaterial material = repo.material(); assertThat(material.getUrl()).contains("%20"); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); material.freshCheckout(output, new SubversionRevision("3"), working); assertThat(output.getAllOutput()).contains("Checked out revision 3"); InMemoryStreamConsumer output2 = new InMemoryStreamConsumer(); material.updateTo(output2, working, new RevisionContext(new SubversionRevision("4")), new TestSubprocessExecutionContext()); assertThat(output2.getAllOutput()).contains("Updated to revision 4"); }
Example #19
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldLogPasswordsOnEnvironemntAsStarsUnderLinux() { CommandLine line = CommandLine.createCommandLine("echo") .withArg("My Password is:") .withArg("secret") .withArg(new PasswordArgument("secret")) .withEncoding("utf-8"); EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext(); environmentVariableContext.setProperty("ENV_PASSWORD", "secret", false); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); InMemoryStreamConsumer forDisplay = InMemoryStreamConsumer.inMemoryConsumer(); ProcessWrapper processWrapper = line.execute(output, environmentVariableContext, null); processWrapper.waitForExit(); assertThat(forDisplay.getAllOutput(), not(containsString("secret"))); assertThat(output.getAllOutput(), containsString("secret")); }
Example #20
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldNotLogPasswordsOnExceptionThrown() throws IOException { File dir = temporaryFolder.newFolder(); File file = new File(dir, "test.sh"); FileOutputStream out = new FileOutputStream(file); out.write("echo $1 && exit 10".getBytes()); out.close(); CommandLine line = CommandLine.createCommandLine("/bin/sh").withArg(file.getAbsolutePath()).withArg(new PasswordArgument("secret")).withEncoding("utf-8"); try { line.runOrBomb(null); } catch (CommandLineException e) { assertThat(e.getMessage(), not(containsString("secret"))); } }
Example #21
Source File: ZipUtilTest.java From gocd with Apache License 2.0 | 5 votes |
@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, temporaryFolder.newFile(), 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)); }
Example #22
Source File: HgMaterialTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldNotRefreshWorkingFolderWhenFileProtocolIsUsedOnLinux() throws Exception { final UrlArgument repoUrl = hgTestRepo.url(); new HgCommand(null, workingFolder, "default", repoUrl.originalArgument(), null).clone(inMemoryConsumer(), repoUrl); File testFile = createNewFileInWorkingFolder(); hgMaterial = MaterialsMother.hgMaterial("file://" + hgTestRepo.projectRepositoryUrl()); updateMaterial(hgMaterial, new StringRevision("0")); String workingUrl = new HgCommand(null, workingFolder, "default", repoUrl.originalArgument(), null).workingRepositoryUrl().outputAsString(); assertThat(workingUrl).isEqualTo(hgTestRepo.projectRepositoryUrl()); assertThat(testFile.exists()).isTrue(); }
Example #23
Source File: BuildWorkTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @EnabledOnOs(OS.WINDOWS) void shouldReportErrorWhenComandIsNotExistOnWindows() throws Exception { buildWork = (BuildWork) getWork(CMD_NOT_EXIST, PIPELINE_NAME); buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry)); assertConsoleOut(artifactManipulator.consoleOut()).printedAppsMissingInfoOnWindows(SOMETHING_NOT_EXIST); assertThat(buildRepository.results).contains(Failed); }
Example #24
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfTheCommandRepositoryDirectoryIsActuallyAFile() throws IOException { walker.getAllCommandSnippets(xmlFile.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command repository located in Go Server Directory at " + xmlFile.getPath() + ". The directory does not exist or Go does not have sufficient permissions to access it.")); }
Example #25
Source File: CommandBuilderTest.java From gocd with Apache License 2.0 | 5 votes |
@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"); }
Example #26
Source File: ArtifactsServiceTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldProvideArtifactRootForAJobOnLinux() 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", 2, "2.2", "functional", "3", "mac-safari")); String artifactRoot = artifactsService.findArtifactRoot(oldId); assertThat(artifactRoot).isEqualTo("pipelines/cruise/2/functional/3/mac-safari"); }
Example #27
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldBeAbleToSpecifyEncoding() { String chrisWasHere = "?????"; CommandLine line = CommandLine.createCommandLine("echo") .withArg(chrisWasHere) .withEncoding("UTF-8"); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); ProcessWrapper processWrapper = line.execute(output, new EnvironmentVariableContext(), null); processWrapper.waitForExit(); assertThat(output.getAllOutput(), containsString(chrisWasHere)); }
Example #28
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldBeAbleToRunCommandsInSubdirectories() throws IOException { File shellScript = createScript("hello-world.sh", "echo ${PWD}"); assertThat(shellScript.setExecutable(true), is(true)); CommandLine line = CommandLine.createCommandLine("./hello-world.sh").withWorkingDir(subFolder).withEncoding("utf-8"); InMemoryStreamConsumer out = new InMemoryStreamConsumer(); line.execute(out, new EnvironmentVariableContext(), null).waitForExit(); assertThat(out.getAllOutput().trim(), endsWith("subFolder")); }
Example #29
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldBeAbleToRunCommandsInSubdirectoriesWithNoWorkingDir() throws IOException { File shellScript = createScript("hello-world.sh", "echo 'Hello World!'"); assertThat(shellScript.setExecutable(true), is(true)); CommandLine line = CommandLine.createCommandLine("subFolder/hello-world.sh").withWorkingDir(temporaryFolder.getRoot()).withEncoding("utf-8"); InMemoryStreamConsumer out = new InMemoryStreamConsumer(); line.execute(out, new EnvironmentVariableContext(), null).waitForExit(); assertThat(out.getAllOutput(), containsString("Hello World!")); }
Example #30
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldNotRunLocalCommandsThatAreNotExecutable() throws IOException { createScript("echo", "echo 'this should not be here'"); CommandLine line = CommandLine.createCommandLine("echo") .withArg("Using the REAL echo") .withWorkingDir(subFolder) .withEncoding("utf-8"); InMemoryStreamConsumer out = new InMemoryStreamConsumer(); line.execute(out, new EnvironmentVariableContext(), null).waitForExit(); assertThat(out.getAllOutput(), containsString("Using the REAL echo")); }