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:org.nuxeo.ecm.platform.filemanager.TestFileManagerService.java
@Test public void testCreateNoteTwiceFromSameBlob() throws Exception { // create doc File file = getTestFile("test-data/hello.html"); Blob input = Blobs.createBlob(file, "text/html"); DocumentModel doc = service.createDocumentFromBlob(coreSession, input, workspace.getPathAsString(), true, "test-data/hello.html"); DocumentRef docRef = doc.getRef();/*ww w . ja v a 2 s . c o m*/ assertNotNull(doc); assertEquals("hello.html", doc.getProperty("dublincore", "title")); String expectedNoteTest = NOTE_HTML_CONTENT; String noteText = ((String) doc.getProperty("note", "note")); if (SystemUtils.IS_OS_WINDOWS) { expectedNoteTest = expectedNoteTest.trim(); expectedNoteTest = expectedNoteTest.replace("\n", ""); expectedNoteTest = expectedNoteTest.replace("\r", ""); noteText = expectedNoteTest.trim(); noteText = expectedNoteTest.replace("\n", ""); noteText = expectedNoteTest.replace("\r", ""); } assertEquals(expectedNoteTest, noteText); List<DocumentModel> versions = coreSession.getVersions(docRef); assertEquals(0, versions.size()); // create again with same file doc = service.createDocumentFromBlob(coreSession, input, workspace.getPathAsString(), true, "test-data/hello.html"); assertNotNull(doc); DocumentRef newDocRef = doc.getRef(); assertEquals(docRef, newDocRef); assertEquals("hello.html", doc.getProperty("dublincore", "title")); noteText = ((String) doc.getProperty("note", "note")); if (SystemUtils.IS_OS_WINDOWS) { noteText = expectedNoteTest.trim(); noteText = expectedNoteTest.replace("\n", ""); noteText = expectedNoteTest.replace("\r", ""); } assertEquals(expectedNoteTest, noteText); versions = coreSession.getVersions(docRef); assertEquals(1, versions.size()); }
From source file:org.nuxeo.ecm.platform.rendering.test.TestFreemarkerRendering.java
protected void assertTextEquals(String expected, String actual) { if (SystemUtils.IS_OS_WINDOWS) { // make tests pass under Windows expected = expected.trim();//from w ww.j a va 2s. c o m expected = expected.replace("\n", ""); expected = expected.replace("\r", ""); actual = actual.trim(); actual = actual.replace("\n", ""); actual = actual.replace("\r", ""); } assertEquals(expected, actual); }
From source file:org.nuxeo.elasticsearch.test.aggregates.TestAggregates.java
protected void assertEqualsEvenUnderWindows(String expected, String actual) { if (SystemUtils.IS_OS_WINDOWS) { // make tests pass under Windows expected = expected.trim();/*from www . java 2s .c om*/ expected = expected.replace("\n", ""); expected = expected.replace("\r", ""); actual = actual.trim(); actual = actual.replace("\n", ""); actual = actual.replace("\r", ""); } Assert.assertEquals(expected, actual); }
From source file:org.nuxeo.elasticsearch.test.nxql.TestNxqlConversion.java
private String normalizeString(String str) { if (SystemUtils.IS_OS_WINDOWS) { str = str.trim();//from w ww. j a va 2s.c o m str = str.replace("\n", ""); str = str.replace("\r", ""); } return str; }
From source file:org.nuxeo.functionaltests.drivers.ChromeDriverProvider.java
@Override public RemoteWebDriver init(DesiredCapabilities dc) throws Exception { if (System.getProperty(SYSPROP_CHROME_DRIVER_PATH) == null) { String chromeDriverDefaultPath = null; String chromeDriverExecutableName = CHROME_DRIVER_DEFAULT_EXECUTABLE_NAME; if (SystemUtils.IS_OS_LINUX) { chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_LINUX; } else if (SystemUtils.IS_OS_MAC) { chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_MAC; } else if (SystemUtils.IS_OS_WINDOWS_XP) { chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINXP; chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME; } else if (SystemUtils.IS_OS_WINDOWS_VISTA) { chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINVISTA; chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME; } else if (SystemUtils.IS_OS_WINDOWS) { // Unknown default path on other Windows OS. To be completed. chromeDriverDefaultPath = CHROME_DRIVER_DEFAULT_PATH_WINVISTA; chromeDriverExecutableName = CHROME_DRIVER_WINDOWS_EXECUTABLE_NAME; }// www . ja v a2 s . c om if (chromeDriverDefaultPath != null && new File(chromeDriverDefaultPath).exists()) { log.warn(String.format("Missing property %s but found %s. Using it...", SYSPROP_CHROME_DRIVER_PATH, chromeDriverDefaultPath)); System.setProperty(SYSPROP_CHROME_DRIVER_PATH, chromeDriverDefaultPath); } else { // Can't find chromedriver in default location, check system // path File chromeDriverExecutable = findExecutableOnPath(chromeDriverExecutableName); if ((chromeDriverExecutable != null) && (chromeDriverExecutable.exists())) { log.warn(String.format("Missing property %s but found %s. Using it...", SYSPROP_CHROME_DRIVER_PATH, chromeDriverExecutable.getCanonicalPath())); System.setProperty(SYSPROP_CHROME_DRIVER_PATH, chromeDriverExecutable.getCanonicalPath()); } else { log.error(String.format( "Could not find the Chrome driver looking at %s or system path." + " Download it from %s and set its path with " + "the System property %s.", chromeDriverDefaultPath, "http://code.google.com/p/chromedriver/downloads/list", SYSPROP_CHROME_DRIVER_PATH)); } } } ChromeOptions options = new ChromeOptions(); options.addArguments(Arrays.asList("--ignore-certificate-errors")); dc.setCapability(ChromeOptions.CAPABILITY, options); driver = new ChromeDriver(dc); return driver; }
From source file:org.nuxeo.launcher.config.ConfigurationGenerator.java
private void setBasicConfiguration(boolean save) throws ConfigurationException { try {//from w w w . j a v a 2s .c o m // Load default configuration defaultConfig = loadTrimmedProperties(nuxeoDefaultConf); // Add System properties defaultConfig.putAll(System.getProperties()); userConfig = new CryptoProperties(defaultConfig); // If Windows, replace backslashes in paths in nuxeo.conf if (SystemUtils.IS_OS_WINDOWS) { replaceBackslashes(); } // Load user configuration userConfig.putAll(loadTrimmedProperties(nuxeoConf)); onceGeneration = "once".equals(userConfig.getProperty(PARAM_FORCE_GENERATION)); forceGeneration = onceGeneration || Boolean.parseBoolean(userConfig.getProperty(PARAM_FORCE_GENERATION, "false")); checkForDeprecatedParameters(userConfig); // Synchronize directories between serverConfigurator and // userConfig/defaultConfig setDirectoryWithProperty(org.nuxeo.common.Environment.NUXEO_DATA_DIR); setDirectoryWithProperty(org.nuxeo.common.Environment.NUXEO_LOG_DIR); setDirectoryWithProperty(org.nuxeo.common.Environment.NUXEO_PID_DIR); setDirectoryWithProperty(org.nuxeo.common.Environment.NUXEO_TMP_DIR); setDirectoryWithProperty(org.nuxeo.common.Environment.NUXEO_MP_DIR); } catch (NullPointerException e) { throw new ConfigurationException("Missing file", e); } catch (FileNotFoundException e) { throw new ConfigurationException("Missing file: " + nuxeoDefaultConf + " or " + nuxeoConf, e); } catch (IOException e) { throw new ConfigurationException("Error reading " + nuxeoConf, e); } // Override default configuration with specific configuration(s) of // the chosen template(s) which can be outside of server filesystem try { includeTemplates(); checkForDeprecatedParameters(defaultConfig); extractDatabaseTemplateName(); extractNoSqlDatabaseTemplateName(); } catch (FileNotFoundException e) { throw new ConfigurationException("Missing file", e); } catch (IOException e) { throw new ConfigurationException("Error reading " + nuxeoConf, e); } Map<String, String> newParametersToSave = evalDynamicProperties(); if (save && newParametersToSave != null && !newParametersToSave.isEmpty()) { saveConfiguration(newParametersToSave, false, false); } logDebugInformation(); // Could be useful to initialize DEFAULT env... // initEnv(); }
From source file:org.objectstyle.woproject.maven2.wobootstrap.AbstractBootstrapMojo.java
void initializeLocator() throws MojoExecutionException { if (locator != null) { return;/*from ww w.j a va 2s .co m*/ } if (webObjectsLibFolder != null && webObjectsVersion != null) { locator = new CustomWebObjectsLocator(webObjectsLibFolder); } else if (illegalSetOfParameters()) { throw new MojoExecutionException( "You must provide both webObjectsLibFolder and webObjectsVersion to use a custom locator for WebObjects libraries"); } else if (SystemUtils.IS_OS_MAC_OSX) { locator = new MacOsWebObjectsLocator(); } else if (SystemUtils.IS_OS_WINDOWS) { locator = new WindowsWebObjectsLocator(); } else if (SystemUtils.IS_OS_UNIX) { locator = new UnixWebObjectsLocator(); } else { throw new MojoExecutionException("Unsupported OS platform."); } }
From source file:org.openbravo.configuration.ConfigurationApp.java
/** * This function returns the user.dir directory replacing backslashes for the case of Windows * operative systems.//w w w . ja v a2s .c o m * */ private static String getUserDir() { String userDir = System.getProperty("user.dir"); if (SystemUtils.IS_OS_WINDOWS) { userDir = userDir.replace("\\", "/"); } return userDir; }
From source file:org.opencms.workplace.tools.sites.CmsSitesWebserverDialog.java
/** * Initializes the values of the members.<p> * * @param params the parameter map to get a value from *//*from w w w .j av a 2s .c o m*/ protected void initMembers(Map<String, String> params) { clearDialogObject(); m_webserverscript = getParameter(params, PARAM_WEBSERVER_SCRIPT, DEFAULT_PARAM_WEBSERVER_SCRIPT); m_targetpath = getParameter(params, PARAM_TARGET_PATH, DEFAULT_PARAM_TARGET_PATH); m_configtemplate = getParameter(params, PARAM_CONFIG_TEMPLATE, DEFAULT_PARAM_CONFIG_TEMPLATE); m_securetemplate = getParameter(params, PARAM_SECURE_TEMPLATE, DEFAULT_PARAM_SECURE_TEMPLATE); m_filenameprefix = getParameter(params, PARAM_FILENAME_PREFIX, DEFAULT_PARAM_FILENAME_PREFIX); m_loggingdir = getParameter(params, PARAM_LOGGING_DIR, DEFAULT_PARAM_LOGGING_DIR); if (DEFAULT_PARAM_WEBSERVER_SCRIPT.equals(m_webserverscript) || DEFAULT_PARAM_CONFIG_TEMPLATE.equals(m_configtemplate) || DEFAULT_PARAM_SECURE_TEMPLATE.equals(m_securetemplate)) { for (CmsExportPoint point : OpenCms.getModuleManager().getModule(MODULE_NAME).getExportPoints()) { if (DEFAULT_PATH_TEMPLATE.equals(point.getUri())) { m_configtemplate = point.getDestinationPath(); } if (DEFAULT_PATH_SECURE_TEMPLATE.equals(point.getUri())) { m_securetemplate = point.getDestinationPath(); } if (DEFAULT_PARAM_WEBSERVER_SCRIPT.equals(m_webserverscript)) { if (DEFAULT_PATH_SCRIPT_WIDNOWS.equals(point.getUri()) && SystemUtils.IS_OS_WINDOWS) { // only take the windows script if the OS is a windows m_webserverscript = point.getDestinationPath(); } else if (DEFAULT_PATH_SCRIPT_LINUX.equals(point.getUri())) { m_webserverscript = point.getDestinationPath(); } } } } if (DEFAULT_PARAM_TARGET_PATH.equals(m_targetpath)) { m_targetpath = PATH_WEBSERVER_CONFIG; } if (DEFAULT_PARAM_LOGGING_DIR.equals(m_loggingdir)) { m_loggingdir = SystemUtils.IS_OS_WINDOWS ? "" : DEFAULT_PATH_LOG_LINUX; } setDialogObject(this); }
From source file:org.openecomp.sdc.asdctool.impl.DataMigration.java
private boolean initEsClient() { String configHome = System.getProperty("config.home"); URL url = null;/*from w w w . jav a 2s. c o m*/ Settings settings = null; try { if (SystemUtils.IS_OS_WINDOWS) { url = new URL("file:///" + configHome + "/elasticsearch.yml"); } else { url = new URL("file:" + configHome + "/elasticsearch.yml"); } log.debug("URL {}", url); settings = Settings.settingsBuilder().loadFromPath(Paths.get(url.toURI())).build(); } catch (MalformedURLException | URISyntaxException e1) { log.error("Failed to create URL in order to load elasticsearch yml", e1); return true; } this.elasticSearchClient = new ElasticSearchClient(); this.elasticSearchClient.setClusterName(settings.get("cluster.name")); this.elasticSearchClient.setLocal(settings.get("elasticSearch.local")); this.elasticSearchClient.setTransportClient(settings.get("elasticSearch.transportclient")); try { elasticSearchClient.initialize(); } catch (URISyntaxException e) { e.printStackTrace(); return false; } return true; }