List of usage examples for org.apache.commons.lang SystemUtils IS_OS_LINUX
boolean IS_OS_LINUX
To view the source code for org.apache.commons.lang SystemUtils IS_OS_LINUX.
Click Source Link
Is true
if this is Linux.
The field will return false
if OS_NAME
is null
.
From source file:com.vmware.identity.interop.idm.UserInfoNative.java
@Override protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) { if ((type == Memory.class) && (SystemUtils.IS_OS_LINUX)) { // memory derives from pointer, but somehow the base implementation misses // this fact and believes alignment unknown ,,,, return super.getNativeAlignment(Pointer.class, null, isFirstElement); } else {// w ww. j a v a 2 s . c o m return super.getNativeAlignment(type, value, isFirstElement); } }
From source file:com.vmware.identity.idm.CommonUtil.java
/** * Returns host IP address/*from w w w. j a v a2s . c om*/ * @return * @throws SocketException * @throws IOException */ public static synchronized String getHostIPAddress(String configDirPath) throws SocketException, IOException { ValidateUtil.validateNotEmpty(configDirPath, "configDirPath"); String configFileName = configDirPath; if (configDirPath.endsWith(File.separator) == false) { configFileName += File.separator; } configFileName += HOSTNAME_FILE_NAME; String ipAddress = null; String CONFIG_IDENTITY_ROOT_KEY = ""; if (SystemUtils.IS_OS_LINUX) { CONFIG_IDENTITY_ROOT_KEY = "Software\\VMware\\Identity\\Configuration"; } else if (SystemUtils.IS_OS_WINDOWS) { CONFIG_IDENTITY_ROOT_KEY = "Software\\VMware\\Identity\\Configuration"; } IRegistryKey registryRootKey = null; try { IRegistryAdapter registryAdpater = RegistryAdapterFactory.getInstance().getRegistryAdapter(); registryRootKey = registryAdpater.openRootKey((int) RegKeyAccess.KEY_READ); if (registryRootKey == null) { throw new NullPointerException("Unable to open Root Key"); } ipAddress = registryAdpater.getStringValue(registryRootKey, CONFIG_IDENTITY_ROOT_KEY, "Hostname", true); if (ipAddress == null) { ipAddress = ReadHostNameFile(configFileName); } } catch (Exception ex) { // failed to retrieve ipaddress from hostname.txt, fall back to // original solution ipAddress = null; try { ipAddress = ReadHostNameFile(configFileName); } catch (Exception exp) { _logger.info("Failed to read hostname file"); } if (ipAddress == null) { ipAddress = findInetAddress(new Predicate<InetAddress>() { @Override public boolean matches(InetAddress addr) { return ((addr != null) && (addr.getClass() == Inet4Address.class)); } }); } if (ipAddress == null) { _logger.info("Failed to find local IPV4 Address."); ipAddress = findInetAddress(new Predicate<InetAddress>() { @Override public boolean matches(InetAddress addr) { return ((addr != null) && (addr.getClass() == Inet6Address.class)); } }); if (ipAddress == null) { _logger.info("Failed to find local IPV6 Address."); } } if (ipAddress == null) { logAndThrow("Error : Failed to find local either IPV4 or IPV6 Inet Address."); } } finally { if (registryRootKey != null) registryRootKey.close(); } return ipAddress; }
From source file:com.cloud.utils.ScriptTest.java
@Test public void testLogger() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); Logger mock = Mockito.mock(Logger.class); Mockito.doNothing().when(mock).debug(Matchers.any()); Script script = new Script("/bin/echo", mock); script.execute();/*from ww w.ja v a 2 s. c om*/ }
From source file:com.kurento.test.selenium.MixerTst.java
private WebDriver createDriver(Class<? extends WebDriver> driverClass) { WebDriver driver = null;//from w w w . j a v a 2s. c o m if (driverClass.equals(FirefoxDriver.class)) { driver = new FirefoxDriver(); } else if (driverClass.equals(ChromeDriver.class)) { String chromedriver = null; if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) { chromedriver = "chromedriver"; } else if (SystemUtils.IS_OS_WINDOWS) { chromedriver = "chromedriver.exe"; } System.setProperty("webdriver.chrome.driver", new File("target/webdriver/" + chromedriver).getAbsolutePath()); ChromeOptions options = new ChromeOptions(); driver = new ChromeDriver(options); } return driver; }
From source file:com.seyren.core.service.notification.ScriptNotificationServiceTest.java
@Test public void notificationServiceCanHandleScriptSubscription() { assertThat(notificationService.canHandle(SubscriptionType.SCRIPT), is(SystemUtils.IS_OS_LINUX)); }
From source file:com.cloud.utils.ScriptTest.java
@Test public void testToString() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); Script script = new Script("/bin/echo"); script.add("foo"); Assert.assertEquals("/bin/echo foo ", script.toString()); }
From source file:com.cloud.utils.ProcessUtilTest.java
@Test(expected = ConfigurationException.class) public void pidCheckBadPid() throws ConfigurationException, IOException { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); FileUtils.writeStringToFile(pidFile, "intentionally not number"); ProcessUtil.pidCheck(pidFile.getParent(), pidFile.getName()); }
From source file:com.cloud.utils.ScriptTest.java
@Test public void testSet() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); Script script = new Script("/bin/echo"); script.add("foo"); script.add("bar", "baz"); script.set("blah", "blah"); Assert.assertEquals("/bin/echo foo bar baz blah blah ", script.toString()); }
From source file:com.cloud.utils.ProcessUtilTest.java
@Test(expected = ConfigurationException.class) public void pidCheckEmptyPid() throws ConfigurationException, IOException { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); FileUtils.writeStringToFile(pidFile, "intentionally not number"); ProcessUtil.pidCheck(pidFile.getParent(), pidFile.getName()); }
From source file:com.vmware.identity.idm.server.IdmLoginManager.java
private File getSecretFilePrivate() { if (SystemUtils.IS_OS_LINUX) { return getSecretFileLinux(); } else {/* w w w . j a v a 2 s . c o m*/ return getSecretFileWindows(); } }