List of usage examples for org.apache.commons.lang SystemUtils IS_OS_UNIX
boolean IS_OS_UNIX
To view the source code for org.apache.commons.lang SystemUtils IS_OS_UNIX.
Click Source Link
Is true
if this is a POSIX compilant system, as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.
The field will return false
if OS_NAME
is null
.
From source file:org.sonarsource.scanner.cli.ConfTest.java
@Test public void shouldNotResolveSymlinks() throws IOException, URISyntaxException { assumeTrue(SystemUtils.IS_OS_UNIX); Path root = temp.getRoot().toPath(); Path realProjectHome = Paths .get(getClass().getResource("ConfTest/shouldLoadModuleConfiguration/project").toURI()); Path linkProjectHome = root.resolve("link"); try {/*from ww w . ja v a2 s . c o m*/ Files.createSymbolicLink(linkProjectHome, realProjectHome); args.setProperty("project.home", linkProjectHome.toAbsolutePath().toString()); Properties properties = conf.properties(); assertThat(properties.getProperty("module1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("Module 2"); assertThat(properties.getProperty("sonar.projectBaseDir")).isEqualTo(linkProjectHome.toString()); assertThat(properties.getProperty("module1.sonar.projectBaseDir")) .isEqualTo(linkProjectHome.resolve("module1").toString()); assertThat(properties.getProperty("module2.sonar.projectBaseDir")) .isEqualTo(linkProjectHome.resolve("module2").toString()); } finally { if (linkProjectHome != null) { Files.delete(linkProjectHome); } } }
From source file:org.sourcepit.common.maven.core.MavenProjectUtilsTest.java
@Test public void testGetOutputDir() { try {/*from ww w. j ava2s.c o m*/ MavenProjectUtils.getOutputDir(null); fail(); } catch (IllegalArgumentException e) { } MavenProject project = new MavenProject(); File outputDir = MavenProjectUtils.getOutputDir(project); assertThat(outputDir, nullValue()); project.getBuild().setOutputDirectory("target/classes"); try { MavenProjectUtils.getOutputDir(project); fail(); } catch (IllegalStateException e) { } final File pomFile = new File("pom.xml").getAbsoluteFile(); project.setFile(pomFile); outputDir = MavenProjectUtils.getOutputDir(project); assertThat(outputDir, notNullValue()); assertThat(outputDir, equalTo(new File(pomFile.getParentFile(), "target/classes"))); String absolutePath = SystemUtils.IS_OS_UNIX ? "/target/classes" : "c:/target/classes"; project.getBuild().setOutputDirectory(absolutePath); outputDir = MavenProjectUtils.getOutputDir(project); assertThat(outputDir, equalTo(new File(absolutePath))); }
From source file:org.sourcepit.common.maven.core.MavenProjectUtilsTest.java
@Test public void testGetTestOutputDir() { try {/*from w w w. ja v a2s. c o m*/ MavenProjectUtils.getTestOutputDir(null); fail(); } catch (IllegalArgumentException e) { } MavenProject project = new MavenProject(); File outputDir = MavenProjectUtils.getTestOutputDir(project); assertThat(outputDir, nullValue()); project.getBuild().setTestOutputDirectory("target/classes"); try { MavenProjectUtils.getTestOutputDir(project); fail(); } catch (IllegalStateException e) { } final File pomFile = new File("pom.xml").getAbsoluteFile(); project.setFile(pomFile); outputDir = MavenProjectUtils.getTestOutputDir(project); assertThat(outputDir, notNullValue()); assertThat(outputDir, equalTo(new File(pomFile.getParentFile(), "target/classes"))); String absolutePath = SystemUtils.IS_OS_UNIX ? "/target/classes" : "c:/target/classes"; project.getBuild().setTestOutputDirectory(absolutePath); outputDir = MavenProjectUtils.getTestOutputDir(project); assertThat(outputDir, equalTo(new File(absolutePath))); }
From source file:plugins.CompressArtifactsPluginTest.java
@Test @Issue("JENKINS-27042") public void archiveLargerThan4GInTotal() throws Exception { CompressingArtifactManager.setup(jenkins); FreeStyleJob job = jenkins.jobs.create(); job.configure();//from w ww .j a v a 2 s. c o m job.addPublisher(ArtifactArchiver.class).includes("*"); if (SystemUtils.IS_OS_UNIX) { job.addBuildStep(ShellBuildStep.class).command( // Generate archive larger than 4G "#!/bin/bash\nwget $JENKINS_URL/jnlpJars/jenkins-cli.jar -O stuff.jar; for i in {0..7000}; do cp stuff.jar stuff.${i}.jar; done"); } else { // On windows although we could create hard links this would exceed the number of hard links you can create for a given file. // and sparse files compress too well. //job.addBuildStep(BatchCommandBuildStep.class).command("for /l %%x in (0, 1, 7000) do fsutil file createnew stuff.%%x.jar 819200"); job.addBuildStep(BatchCommandBuildStep.class) .command("powershell -command \"& { " + "try { " + " Invoke-WebRequest %JENKINS_URL%/jnlpJars/jenkins-cli.jar -OutFile stuff.jar " + "} catch { " + " echo 'download of jenkins-cli.jar failed'; " + " exit 2 " + "}}\n " + "for /l %%x in (0, 1, 7000) do cp stuff.jar stuff.%%x.jar\n"); } job.save(); Build build = job.scheduleBuild().waitUntilFinished(10 * 60).shouldSucceed(); long length = Long.parseLong(jenkins.runScript( "new FilePath(Jenkins.instance.getJob('%s').lastBuild.artifactsDir).parent.child('archive.zip').length()", job.name)); assertThat(length, greaterThanOrEqualTo(4L * 1024 * 1024 * 1024)); }
From source file:plugins.CompressArtifactsPluginTest.java
private Build generateArtifact() { FreeStyleJob job = jenkins.jobs.create(); if (SystemUtils.IS_OS_UNIX) { job.addBuildStep(ShellBuildStep.class).command("echo 'content' > " + ARTIFACT_NAME); } else {/*from www. j a v a2s . c om*/ job.addBuildStep(BatchCommandBuildStep.class).command("echo 'content' > " + ARTIFACT_NAME); } job.addPublisher(ArtifactArchiver.class).includes(ARTIFACT_NAME); job.save(); return job.startBuild().shouldSucceed(); }
From source file:program.RunProgram.java
public static boolean isExecutableFound(workflow_properties prop) { if (config.getBoolean("UseAlternative")) { //-CASE Alternative String executable = prop.getAlternative(); if (!prop.isSet("AlternativeExecutable") || executable.equals("")) return false; return (Util.FileExists(executable)); }/*from ww w. j a v a2 s .c o m*/ //--CASE WebServices or internal application (java code) if (prop.getBoolean("WebServices") || prop.getBoolean("InternalArmadilloApplication")) { return true; } else if (SystemUtils.IS_OS_WINDOWS) { //--Windows String executable = prop.getExecutable(); if (!prop.isSet("Executable") || executable.equals("")) return false; return (Util.FileExists(executable)); } else if (config.getBoolean("MacOSX") || SystemUtils.IS_OS_MAC_OSX) { //--CASE MAC OS X String executable = prop.getExecutableMacOSX(); if (!prop.isSet("ExecutableMacOSX") || executable.equals("")) return false; return (Util.FileExists(executable)); } else if (config.getBoolean("Linux") || SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_UNIX) { //--CASE Linux? String executable = prop.getExecutableLinux(); if (!prop.isSet("ExecutableLinux") || executable.equals("")) return false; return (Util.FileExists(executable)); } return false; }
From source file:program.RunProgram.java
public String[] updateCommandLine(String[] cli) { //--Note: 50 is arbitrary number large enough... String[] command = new String[50]; //--Initialization for (int i = 0; i < 50; i++) { if (i < cli.length) { command[i] = cli[i];/*from w w w . ja v a 2 s .co m*/ } else command[i] = ""; } //--CASE 1. MacOSX (Warning, 1st because MAC_OSX is Linux (lol) if (config.getBoolean("MacOSX") || SystemUtils.IS_OS_MAC_OSX) { if (command[0].equalsIgnoreCase("cmd.exe")) for (int i = 0; i < command.length - 2; i++) command[i] = command[i + 2]; //--Hack if (command[0].equalsIgnoreCase("java")) { //--Any extra command? //--We locate the good spot if (command[2].startsWith("-Xmx") || command[2].startsWith("-classpath")) { command[3] = properties.getExecutableMacOSX(); } else { command[2] = properties.getExecutableMacOSX(); } } else { command[0] = properties.getExecutableMacOSX(); } // return command; } else if (config.getBoolean("Linux") || SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_UNIX) { //--or CASE 2.Linux? //--Test if we included the cmd.exe /C if (command[0].equalsIgnoreCase("cmd.exe")) for (int i = 0; i < command.length - 2; i++) command[i] = command[i + 2]; //--Hack //--Hack if (command[0].equalsIgnoreCase("java")) { command[2] = properties.getExecutableLinux(); } else { command[0] = properties.getExecutableLinux(); } } //--Change the - to -- if found... // for (int i=0; i<command.length;i++) { // if (command[i].startsWith("-")) command[i]="-"+command[i]; // } //--CASE 3. Use Alternative^ if (properties.getBoolean("UseAlternative")) { command[0] = properties.getAlternative(); } // Finally return the command return command; }
From source file:util.PosixComplianceUtil.java
private boolean isMostlyPosixCompliant() { return SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_UNIX; }
From source file:VASSAL.tools.lang.MemoryUtilsTest.java
@Test public void testGetPhysicalMemoryUNIX() throws IOException { assumeTrue(SystemUtils.IS_OS_UNIX && !SystemUtils.IS_OS_MAC_OSX); // get the total RAM from the system, in kB final Process p = Runtime.getRuntime() .exec(new String[] { "sh", "-c", "grep '^MemTotal:' /proc/meminfo | sed 's/[^0-9]//g'" }); final BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); final int eRAM = Integer.parseInt(r.readLine()); r.close();/*from w ww .j ava 2 s . c om*/ // check that it's correct assertEquals(eRAM, MemoryUtils.getPhysicalMemory() >> 10); }