List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS
boolean IS_OS_WINDOWS
To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.
Click Source Link
Is true
if this is Windows.
The field will return false
if OS_NAME
is null
.
From source file:it.serverSystem.DevModeTest.java
/** * SONAR-4843/*from ww w .j a v a 2 s.c om*/ */ @Test public void restart_on_dev_mode() throws Exception { // server classloader locks Jar files on Windows if (!SystemUtils.IS_OS_WINDOWS) { orchestrator = Orchestrator.builderEnv().setServerProperty("sonar.web.dev", "true").build(); orchestrator.start(); orchestrator.getServer().adminWsClient().systemClient().restart(); assertThat(FileUtils.readFileToString(orchestrator.getServer().getLogs())).contains("Restart server") .contains("Server restarted"); } }
From source file:it.serverSystem.RestartTest.java
@Test public void restart_in_prod_mode_requires_sysadmin_permission_and_restarts() throws Exception { // server classloader locks Jar files on Windows if (!SystemUtils.IS_OS_WINDOWS) { orchestrator = Orchestrator.builderEnv().setOrchestratorProperty("orchestrator.keepWorkspace", "true") .build();/*from w w w.j a va 2 s. c o m*/ orchestrator.start(); verifyFailWith403(() -> newWsClient(orchestrator).system().restart()); createNonSystemAdministrator("john", "doe"); verifyFailWith403(() -> ItUtils.newUserWsClient(orchestrator, "john", "doe").system().restart()); createSystemAdministrator("big", "boss"); ItUtils.newUserWsClient(orchestrator, "big", "boss").system().restart(); WsResponse wsResponse = newAdminWsClient(orchestrator).wsConnector() .call(new GetRequest("/api/system/status")).failIfNotSuccessful(); assertThat(wsResponse.content()).contains("RESTARTING"); // we just wait five seconds, for a lack of a better approach to waiting for the restart process to start in SQ Thread.sleep(5000); assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs())) .contains("SonarQube restart requested by big"); } }
From source file:com.synopsys.arc.jenkinsci.plugins.cygwinprocesskiller.CygwinProcessKiller.java
@Override public boolean kill(ProcessTree.OSProcess process) throws IOException, InterruptedException { if (!SystemUtils.IS_OS_WINDOWS) { return false; }/*from w ww. j a v a2 s . c o m*/ try { KillReport report = SlaveComputer.getChannelToMaster().call(new KillerRemoteCall(process.getPid())); return report.isKilledSuccessfully(); } catch (CygwinKillerException ex) { //TODO: log errors in the local log return false; } }
From source file:de.tudarmstadt.ukp.csniper.webapp.search.tgrep.TgrepEngine.java
public String getCorpusPath(String aCollectionId) { File base = new File(new File(corpusService.getRepositoryPath(), aCollectionId), name); // try gzipped corpus file first File cFile = new File(base, aCollectionId + EXT_COMPRESSED); // workaround for cygwin: packed corpus files only work with this approach if (cFile.exists() && SystemUtils.IS_OS_WINDOWS) { return "/cygdrive/" + cFile.getAbsolutePath().replace("\\", "/").replace(":", ""); } else {//from w w w.j av a 2 s .c o m cFile = new File(base, aCollectionId + EXT_BINARY); return cFile.getAbsolutePath(); } }
From source file:com.vmware.identity.session.TomcatAccessLogCleaner.java
/** * Get the tomcat access log directory based on operating system. *///from w ww . ja va2 s . co m private File getLogDirectory() { File logDirectory = null; if (SystemUtils.IS_OS_LINUX) { logDirectory = new File(File.separator + "var" + File.separator + "log" + File.separator + "vmware" + File.separator + "sso"); } else if (SystemUtils.IS_OS_WINDOWS) { String WIN_VMWARE_CIS_VMIDENTITY_PATH = "C:" + File.separator + "ProgramData" + File.separator + "VMware" + File.separator + "vCenterServer" + File.separator + "runtime" + File.separator + "VMWareSTSService" + File.separator + "logs"; logDirectory = new File(WIN_VMWARE_CIS_VMIDENTITY_PATH); } else { logger.error("Failed to start tomcat access log cleaner for operatingSystem : {}", System.getProperty("os.name")); } return logDirectory; }
From source file:com.robin.utilities.config.RobinConfiguration.java
private String replaceBaseDirInString(final String path) { String out = path.replace("#basedir#", baseDir.getPath()); if (SystemUtils.IS_OS_WINDOWS) { out = separatorsToWindows(out);/*from w w w . jav a 2s . c om*/ } return out; }
From source file:freemarker.cache.FileTemplateLoaderTest.java
@Test public void testCaseSensitivity() throws Exception { for (boolean emuCaseSensFS : new boolean[] { false, true }) { for (String nameWithBadCase : new String[] { "SUB1/sub2/t.ftl", "sub1/SUB2/t.ftl", "sub1/sub2/T.FTL" }) { ((FileTemplateLoader) cfg.getTemplateLoader()).setEmulateCaseSensitiveFileSystem(emuCaseSensFS); cfg.clearTemplateCache();// w w w . j a v a2 s . co m if ((SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX) && !emuCaseSensFS) { assertEquals("foo", cfg.getTemplate(nameWithBadCase).toString()); } else { assertEquals("foo", cfg.getTemplate(nameWithBadCase.toLowerCase()).toString()); try { cfg.getTemplate(nameWithBadCase); fail(); } catch (TemplateNotFoundException e) { assertThat(e.getMessage(), containsString(nameWithBadCase)); assertNull(e.getCause()); } } } } }
From source file:com.zilotti.utils.NetworkUtils.java
/** * Provides the full path to the hosts file of the current * operational system.//from w ww . j ava 2 s . co m * * @return */ public static File getSystemHostsFilePath() { if (SystemUtils.IS_OS_LINUX) return new File("/etc/hosts"); if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) return new File("/private/etc/hosts"); if (SystemUtils.IS_OS_WINDOWS) { // TODO: Implement on Windows environment File[] roots = FileSystemView.getFileSystemView().getRoots(); for (File root : roots) System.out.println(root.getPath()); return new File("c:/Windows/system32/drivers/etc/hosts"); } throw new RuntimeException("Operational System not supported: " + System.getProperty("os.name")); }
From source file:com.sonar.orchestrator.build.MavenBuildExecutor.java
static String getMvnPath(File mvnHome) throws IOException { String program = "mvn"; if (SystemUtils.IS_OS_WINDOWS) { program += ".bat"; }//w ww .jav a2 s. c o m if (mvnHome != null) { program = new File(mvnHome, "bin/" + program).getCanonicalPath(); } return program; }
From source file:com.jayway.maven.plugins.android.AndroidNdk.java
private File findStripper(String toolchain) { List<String> osDirectories = new ArrayList<String>(); String extension = ""; if (SystemUtils.IS_OS_LINUX) { osDirectories.add("linux-x86"); osDirectories.add("linux-x86_64"); } else if (SystemUtils.IS_OS_WINDOWS) { osDirectories.add("windows"); osDirectories.add("windows-x86_64"); extension = ".exe"; } else if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) { osDirectories.add("darwin-x86"); osDirectories.add("darwin-x86_64"); }//from ww w . j a va 2 s.c om String fileName = ""; if (toolchain.startsWith("arm")) { fileName = "arm-linux-androideabi-strip" + extension; } else if (toolchain.startsWith("x86")) { fileName = "i686-linux-android-strip" + extension; } else if (toolchain.startsWith("mips")) { fileName = "mipsel-linux-android-strip" + extension; } for (String osDirectory : osDirectories) { String stripperLocation = String.format("toolchains/%s/prebuilt/%s/bin/%s", toolchain, osDirectory, fileName); final File stripper = new File(ndkPath, stripperLocation); if (stripper.exists()) { return stripper; } } return null; }