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.cloud.utils.ScriptTest.java
@Test @Ignore/* w w w. jav a 2 s . c om*/ public void testExecute() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); Logger mock = Mockito.mock(Logger.class); Mockito.doNothing().when(mock).debug(Matchers.any()); for (int i = 0; i < 100000; i++) { Script script = new Script("/bin/false", mock); script.execute(); } }
From source file:com.vmware.identity.session.TomcatAccessLogCleaner.java
/** * Get the tomcat access log directory based on operating system. *///from w ww. j a v a 2 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.cloud.utils.ScriptTest.java
@Test public void testRunSimpleBashScript() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); Assert.assertEquals("hello world!", Script.runSimpleBashScript("echo 'hello world!'")); }
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 .c om*/ * * @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.sshtools.appframework.ui.IconStore.java
private IconStore() throws IOException, ParseException { aliasService = new DefaultAliasService(); globService = new DefaultGlobService(); magicService = new DefaultMagicService(); mimeService = new DefaultMIMEService(globService, aliasService, magicService); if (SystemUtils.IS_OS_LINUX) { if (System.getProperty("appframework.disableDefaultIconThemes", "false").equals("false")) { try { iconService = new LinuxIconService(); } catch (Exception e) { LOG.error("Failed to load icon theme.", e); }/* w ww . j a va 2s. c om*/ } try { globService = new LinuxGlobService(); } catch (Exception e) { LOG.error("Failed to globs.", e); } try { magicService = new LinuxMagicService(); } catch (Exception e) { LOG.error("Failed to magic.", e); } try { aliasService = new LinuxAliasService(); } catch (Exception e) { LOG.error("Failed to aliases.", e); } try { mimeService = new LinuxMIMEService(globService, aliasService, magicService); } catch (Exception e) { LOG.error("Failed to MIME.", e); } } if (iconService == null) { iconService = new DefaultIconService(); } iconService.setReturnMissingImage(false); // Add the default fallback icon addThemeJar("default-tango-theme"); setDefaultThemeName("default-tango-theme"); }
From source file:com.vmware.identity.idm.server.LocalOsIdentityProviderTest.java
@Test public void TestUsers() throws Exception { for (UserInfo userInfo : _users.values()) { // --------------------- // findUser // --------------------- PersonUser user = localOsProvider.findUser(new PrincipalId(userInfo.getName(), domainName)); Assert.assertNotNull(String.format("User '%s' should exist.", userInfo.getName()), user); validateUser(user, userInfo);//from ww w . j a v a 2s.c o m // --------------------- // IsActive // --------------------- boolean isActive = SystemUtils.IS_OS_LINUX ? true : !userInfo.isDisabled(); Assert.assertEquals(isActive, localOsProvider.IsActive(new PrincipalId(userInfo.getName(), domainName))); // --------------------- // getAttributes // --------------------- Collection<AttributeValuePair> attributes = localOsProvider .getAttributes(new PrincipalId(userInfo.getName(), domainName), getAttributes()); Assert.assertNotNull( String.format("Should be able to retrieve attributes for User '%s'.", userInfo.getName()), attributes); for (AttributeValuePair attr : attributes) { Assert.assertNotNull(attr); Assert.assertNotNull(attr.getAttrDefinition()); // new sids attributes comes without the friendly name. // Assert.assertNotNull( attr.getAttrDefinition().getFriendlyName() ); if (GROUPS_FRIENDLY_NAME.equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Set<GroupInfo> groups = _usersToGroups.get(userInfo.getName()); if (groups != null && groups.isEmpty() == false) { Assert.assertNotNull(attr.getValues()); Assert.assertTrue(groups.size() <= attr.getValues().size()); HashSet<String> attrGroups = new HashSet<String>(); for (String attributeValue : attr.getValues()) { Assert.assertNotNull(attributeValue); Assert.assertTrue(attributeValue.startsWith(domainName) || (providerHasAlias() && attributeValue.startsWith(domainAlias))); Assert.assertTrue(attributeValue.contains("\\")); String groupName = attributeValue; Assert.assertFalse(groupName.isEmpty()); attrGroups.add(groupName); } for (GroupInfo info : groups) { Assert.assertTrue( String.format("group '%s' is expected to be present", domainName + "\\" + info.getName()), attrGroups.contains(domainName + "\\" + info.getName())); if (providerHasAlias()) { Assert.assertTrue( String.format("group '%s' is expected to be present", domainAlias + "\\" + info.getName()), attrGroups.contains(domainAlias + "\\" + info.getName())); } } } } else if (LAST_NAME_FRIENDLY_NAME.equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString(userInfo.getLastName(), attr.getValues().get(0)); } else if (FIRST_NAME_FRIENDLY_NAME.equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString(userInfo.getFirstName(), attr.getValues().get(0)); } else if (SUBJECT_TYPE_FRIENDLY_NAME .equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString("false", attr.getValues().get(0)); } else if (USER_PRINCIPAL_NAME_FRIENDLY_NAME .equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString(userInfo.getName() + "@" + domainName, attr.getValues().get(0)); } } // --------------------- // findDirectParentGroups, findNestedParentGroups // --------------------- Set<GroupInfo> groups = _usersToGroups.get(userInfo.getName()); PrincipalGroupLookupInfo directParentGroups = localOsProvider .findDirectParentGroups(new PrincipalId(userInfo.getName(), domainName)); validateGroupsSubset(groups, ((directParentGroups == null) ? null : directParentGroups.getGroups()), domainName, domainAlias); PrincipalGroupLookupInfo userGroups = localOsProvider .findNestedParentGroups(new PrincipalId(userInfo.getName(), domainName)); validateGroupsSubset(groups, ((userGroups == null) ? null : userGroups.getGroups()), domainName, domainAlias); } }
From source file:com.cloud.utils.ScriptTest.java
@Test public void executeWithOutputInterpreter() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); Script script = new Script("/bin/bash"); script.add("-c"); script.add("echo 'hello world!'"); String value = script.execute(new OutputInterpreter() { @Override//from www . j av a 2 s . com public String interpret(BufferedReader reader) throws IOException { throw new IllegalArgumentException(); } }); // it is a stack trace in this case as string Assert.assertNotNull(value); }
From source file:com.yahoo.pulsar.discovery.service.DiscoveryService.java
public DiscoveryService(ServiceConfig serviceConfig) { checkNotNull(serviceConfig);/*from w w w .j av a 2 s . c om*/ this.config = serviceConfig; this.serviceUrl = serviceUrl(); this.serviceUrlTls = serviceUrlTls(); EventLoopGroup acceptorEventLoop, workersEventLoop; if (SystemUtils.IS_OS_LINUX) { try { acceptorEventLoop = new EpollEventLoopGroup(1, acceptorThreadFactory); workersEventLoop = new EpollEventLoopGroup(numThreads, workersThreadFactory); } catch (UnsatisfiedLinkError e) { acceptorEventLoop = new NioEventLoopGroup(1, acceptorThreadFactory); workersEventLoop = new NioEventLoopGroup(numThreads, workersThreadFactory); } } else { acceptorEventLoop = new NioEventLoopGroup(1, acceptorThreadFactory); workersEventLoop = new NioEventLoopGroup(numThreads, workersThreadFactory); } this.acceptorGroup = acceptorEventLoop; this.workerGroup = workersEventLoop; }
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 v a2s . c o m*/ 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; }
From source file:ddf.content.plugin.video.TestVideoThumbnailPlugin.java
private void setUpMockBundleContext() { mockBundleContext = mock(BundleContext.class); final Bundle mockBundle = mock(Bundle.class); doReturn(mockBundle).when(mockBundleContext).getBundle(); String ffmpegResourcePath;/* w w w.ja va2 s .com*/ URL ffmpegBinaryUrl; if (SystemUtils.IS_OS_LINUX) { ffmpegResourcePath = "linux/ffmpeg"; } else if (SystemUtils.IS_OS_MAC) { ffmpegResourcePath = "osx/ffmpeg"; } else if (SystemUtils.IS_OS_WINDOWS) { ffmpegResourcePath = "windows/ffmpeg.exe"; } else if (SystemUtils.IS_OS_SOLARIS) { ffmpegResourcePath = "solaris/ffmpeg"; } else { fail("Platform is not Linux, Mac, or Windows. No FFmpeg binaries are provided for this platform."); return; } ffmpegBinaryUrl = getClass().getClassLoader().getResource(ffmpegResourcePath); doReturn(ffmpegBinaryUrl).when(mockBundle).getEntry(ffmpegResourcePath); }