类org.apache.commons.lang3.SystemUtils源码实例Demo

下面列出了怎么用org.apache.commons.lang3.SystemUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: astor   文件: MultiLineToStringStyleTest.java
@Test
public void testObject() {
    final Integer i3 = Integer.valueOf(3);
    final Integer i4 = Integer.valueOf(4);
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=3" + SystemUtils.LINE_SEPARATOR + "  b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<Integer>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3, false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=[]" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
}
 
源代码2 项目: hadoop-ozone   文件: StringUtils.java
public static void startupShutdownMessage(VersionInfo versionInfo,
    Class<?> clazz, String[] args, Logger log) {
  final String hostname = NetUtils.getHostname();
  final String className = clazz.getSimpleName();
  if (log.isInfoEnabled()) {
    log.info(createStartupShutdownMessage(versionInfo, className, hostname,
        args));
  }

  if (SystemUtils.IS_OS_UNIX) {
    try {
      SignalLogger.INSTANCE.register(log);
    } catch (Throwable t) {
      log.warn("failed to register any UNIX signal loggers: ", t);
    }
  }
  ShutdownHookManager.get().addShutdownHook(
      () -> log.info(toStartupShutdownString("SHUTDOWN_MSG: ",
          "Shutting down " + className + " at " + hostname)),
      SHUTDOWN_HOOK_PRIORITY);

}
 
源代码3 项目: grpc-nebula-java   文件: CheckGcpEnvironment.java
private static boolean isRunningOnGcp() {
  try {
    if (SystemUtils.IS_OS_LINUX) {
      // Checks GCE residency on Linux platform.
      return checkProductNameOnLinux(Files.newBufferedReader(Paths.get(DMI_PRODUCT_NAME), UTF_8));
    } else if (SystemUtils.IS_OS_WINDOWS) {
      // Checks GCE residency on Windows platform.
      Process p =
          new ProcessBuilder()
              .command(WINDOWS_COMMAND, "Get-WmiObject", "-Class", "Win32_BIOS")
              .start();
      return checkBiosDataOnWindows(
          new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8)));
    }
  } catch (IOException e) {
    logger.log(Level.WARNING, "Fail to read platform information: ", e);
    return false;
  }
  // Platforms other than Linux and Windows are not supported.
  return false;
}
 
源代码4 项目: mvn-golang   文件: SysUtils.java
@Nullable
public static String findGoSdkOsType() {
  final String result;
  if (SystemUtils.IS_OS_WINDOWS) {
    result = "windows";
  } else if (SystemUtils.IS_OS_FREE_BSD) {
    result = "freebsd";
  } else if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
    result = "darwin";
  } else if (SystemUtils.IS_OS_LINUX) {
    result = "linux";
  } else {
    result = null;
  }
  return result;
}
 
源代码5 项目: astor   文件: ExceptionUtils.java
/**
 * <p>Produces a <code>List</code> of stack frames - the message
 * is not included. Only the trace of the specified exception is
 * returned, any caused by trace is stripped.</p>
 *
 * <p>This works in most cases - it will only fail if the exception
 * message contains a line that starts with:
 * <code>&quot;&nbsp;&nbsp;&nbsp;at&quot;.</code></p>
 * 
 * @param t is any throwable
 * @return List of stack frames
 */
static List<String> getStackFrameList(Throwable t) {
    String stackTrace = getStackTrace(t);
    String linebreak = SystemUtils.LINE_SEPARATOR;
    StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
    List<String> list = new ArrayList<String>();
    boolean traceStarted = false;
    while (frames.hasMoreTokens()) {
        String token = frames.nextToken();
        // Determine if the line starts with <whitespace>at
        int at = token.indexOf("at");
        if (at != -1 && token.substring(0, at).trim().length() == 0) {
            traceStarted = true;
            list.add(token);
        } else if (traceStarted) {
            break;
        }
    }
    return list;
}
 
源代码6 项目: java-client   文件: AppiumServiceBuilder.java
private static File findMainScript() {
    File npm = findNpm();
    List<String> cmdLine = SystemUtils.IS_OS_WINDOWS
            // npm is a batch script, so on windows we need to use cmd.exe in order to execute it
            ? Arrays.asList("cmd.exe", "/c", String.format("\"%s\" root -g", npm.getAbsolutePath()))
            : Arrays.asList(npm.getAbsolutePath(), "root", "-g");
    ProcessBuilder pb = new ProcessBuilder(cmdLine);
    String nodeModulesRoot;
    try {
        nodeModulesRoot = IOUtils.toString(pb.start().getInputStream(), StandardCharsets.UTF_8).trim();
    } catch (IOException e) {
        throw new InvalidServerInstanceException(
                "Cannot retrieve the path to the folder where NodeJS modules are located", e);
    }
    File mainAppiumJs = Paths.get(nodeModulesRoot, APPIUM_PATH_SUFFIX.toString()).toFile();
    if (!mainAppiumJs.exists()) {
        throw new InvalidServerInstanceException(APPIUM_JS_NOT_EXIST_ERROR.apply(mainAppiumJs));
    }
    return mainAppiumJs;
}
 
源代码7 项目: spring-boot   文件: MyPdfUtils.java
/**
 * 获取 pdfdecrypt.exe 文件路径
 *
 * @return
 * @throws IOException
 */
private static String getPdfPdfdecryptExec() {

    //命令行模式,只需要两个文件即可
    String exec1 = "/pdfdecrypt.exe";
    String exec2 = "/license.dat";

    String tempPath =
            SystemUtils.getJavaIoTmpDir()
                    + File.separator + MyConstants.JarTempDir + File.separator;

    String exec1Path = tempPath + exec1;
    String exec2Path = tempPath + exec2;

    //如果已经拷贝过,就不用再拷贝了
    if (!Files.exists(Paths.get(exec1Path)))
        MyFileUtils.copyResourceFileFromJarLibToTmpDir(exec1);

    if (!Files.exists(Paths.get(exec2Path)))
        MyFileUtils.copyResourceFileFromJarLibToTmpDir(exec2);


    return exec1Path;
}
 
源代码8 项目: beam   文件: LocalResourceIdTest.java
@Test
public void testResolveInWindowsOS() {
  if (!SystemUtils.IS_OS_WINDOWS) {
    // Skip tests
    return;
  }
  assertEquals(
      toResourceIdentifier("C:\\my home\\out put"),
      toResourceIdentifier("C:\\my home\\")
          .resolve("out put", StandardResolveOptions.RESOLVE_FILE));

  assertEquals(
      toResourceIdentifier("C:\\out put"),
      toResourceIdentifier("C:\\my home\\")
          .resolve("..", StandardResolveOptions.RESOLVE_DIRECTORY)
          .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
          .resolve("out put", StandardResolveOptions.RESOLVE_FILE));

  assertEquals(
      toResourceIdentifier("C:\\my home\\**\\*"),
      toResourceIdentifier("C:\\my home\\")
          .resolve("**", StandardResolveOptions.RESOLVE_DIRECTORY)
          .resolve("*", StandardResolveOptions.RESOLVE_FILE));
}
 
/**
 * Set the 755 permissions on the given script.
 * @param config - the instance config
 * @param scriptName - the name of the script (located in the bin directory) to make executable
 */
public static void setScriptPermission(InstanceConfiguration config, String scriptName)
{
    if (SystemUtils.IS_OS_WINDOWS)
    {
        // we do not have file permissions on windows
        return;
    }
    if (VersionUtil.isEqualOrGreater_7_0_0(config.getClusterConfiguration().getVersion())) {
        // ES7 and above is packaged as a .tar.gz, and as such the permissions are preserved
        return;
    }
    
    CommandLine command = new CommandLine("chmod")
            .addArgument("755")
            .addArgument(String.format("bin/%s", scriptName));
    ProcessUtil.executeScript(config, command);

    command = new CommandLine("sed")
            .addArguments("-i''")
            .addArgument("-e")
            .addArgument("1s:.*:#!/usr/bin/env bash:", false)
            .addArgument(String.format("bin/%s", scriptName));
    ProcessUtil.executeScript(config, command);
}
 
源代码10 项目: moneta   文件: SpringBootContractTest.java
public void run() {
	try {
	executor = new DaemonExecutor();
	resultHandler = new DefaultExecuteResultHandler();
	String javaHome = System.getProperty("java.home");
	String userDir = System.getProperty("user.dir");
	
	executor.setStreamHandler(new PumpStreamHandler(System.out));
	watchdog = new ExecuteWatchdog(15000);
	executor.setWatchdog(watchdog);
	executor.execute(new CommandLine(javaHome + SystemUtils.FILE_SEPARATOR 
			+ "bin"+ SystemUtils.FILE_SEPARATOR+"java.exe").addArgument("-version"));
	executor.execute(new CommandLine(javaHome + SystemUtils.FILE_SEPARATOR 
			+ "bin"+ SystemUtils.FILE_SEPARATOR+"java.exe")
		.addArgument("-jar")
		.addArgument(userDir + "/../moneta-springboot/target/moneta-springboot-" + ContractTestSuite.getProjectVersion() + ".jar"));
	
	}
	catch (Exception e) {
		e.printStackTrace();
	}
	
}
 
源代码11 项目: konduit-serving   文件: LauncherUtils.java
/**
 * Checks if there is a konduit server running with the given application id.
 * @param applicationId application id of the konduit server.
 * @return true if the server process exists, false otherwise.
 */
public static boolean isProcessExists(String applicationId) {
    List<String> args;

    if(SystemUtils.IS_OS_WINDOWS) {
        args = Arrays.asList("WMIC", "PROCESS", "WHERE", "\"CommandLine like '%serving.id=" + applicationId + "' and name!='wmic.exe'\"", "GET", "CommandLine", "/VALUE");
    } else {
        args = Arrays.asList("sh", "-c", "ps ax | grep \"Dserving.id=" + applicationId + "$\"");
    }

    String output = "";
    try {
        Process process = new ProcessBuilder(args).start();
        output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
    } catch (Exception exception) {
        log.error("An error occurred while checking for existing processes:", exception);
        System.exit(1);
    }

    return output.trim()
            .replace(System.lineSeparator(), "")
            .matches("(.*)Dserving.id=" + applicationId);
}
 
源代码12 项目: grpc-java   文件: CheckGcpEnvironment.java
private static boolean isRunningOnGcp() {
  try {
    if (SystemUtils.IS_OS_LINUX) {
      // Checks GCE residency on Linux platform.
      return checkProductNameOnLinux(Files.newBufferedReader(Paths.get(DMI_PRODUCT_NAME), UTF_8));
    } else if (SystemUtils.IS_OS_WINDOWS) {
      // Checks GCE residency on Windows platform.
      Process p =
          new ProcessBuilder()
              .command(WINDOWS_COMMAND, "Get-WmiObject", "-Class", "Win32_BIOS")
              .start();
      return checkBiosDataOnWindows(
          new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8)));
    }
  } catch (IOException e) {
    logger.log(Level.WARNING, "Fail to read platform information: ", e);
    return false;
  }
  // Platforms other than Linux and Windows are not supported.
  return false;
}
 
源代码13 项目: gocd   文件: GoConfigServiceTest.java
@Test
public void shouldThrowIfCruiseHasNoReadPermissionOnArtifactsDir() throws Exception {
    if (SystemUtils.IS_OS_WINDOWS) {
        return;
    }

    File artifactsDir = FileUtil.createTempFolder();
    artifactsDir.setReadable(false, false);
    cruiseConfig.setServerConfig(new ServerConfig(artifactsDir.getAbsolutePath(), new SecurityConfig()));
    expectLoad(cruiseConfig);

    try {
        goConfigService.initialize();
        fail("should throw when cruise has no read permission on artifacts dir " + artifactsDir.getAbsolutePath());
    } catch (Exception e) {
        assertThat(e.getMessage(), is("Cruise does not have read permission on " + artifactsDir.getAbsolutePath()));
    } finally {
        FileUtils.deleteQuietly(artifactsDir);
    }

}
 
源代码14 项目: astor   文件: ExceptionUtils.java
/**
 * <p>Produces a <code>List</code> of stack frames - the message
 * is not included. Only the trace of the specified exception is
 * returned, any caused by trace is stripped.</p>
 *
 * <p>This works in most cases - it will only fail if the exception
 * message contains a line that starts with:
 * <code>&quot;&nbsp;&nbsp;&nbsp;at&quot;.</code></p>
 * 
 * @param t is any throwable
 * @return List of stack frames
 */
static List<String> getStackFrameList(final Throwable t) {
    final String stackTrace = getStackTrace(t);
    final String linebreak = SystemUtils.LINE_SEPARATOR;
    final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
    final List<String> list = new ArrayList<String>();
    boolean traceStarted = false;
    while (frames.hasMoreTokens()) {
        final String token = frames.nextToken();
        // Determine if the line starts with <whitespace>at
        final int at = token.indexOf("at");
        if (at != -1 && token.substring(0, at).trim().isEmpty()) {
            traceStarted = true;
            list.add(token);
        } else if (traceStarted) {
            break;
        }
    }
    return list;
}
 
源代码15 项目: elasticsearch-maven-plugin   文件: ProcessUtil.java
/**
 * Build an OS dependent command line to kill the process with the given PID.
 * @param pid The ID of the process to kill
 * @return the command line required to kill the given process
 */
public static CommandLine buildKillCommandLine(String pid)
{
    CommandLine command;

    if (SystemUtils.IS_OS_WINDOWS)
    {
        command = new CommandLine("taskkill")
                .addArgument("/F")
                .addArgument("/pid")
                .addArgument(pid);
    }
    else
    {
        command = new CommandLine("kill").addArgument(pid);
    }
    
    return command;
}
 
源代码16 项目: archiva   文件: DefaultFileUploadService.java
@Override
public Boolean deleteFile(String fileName)
        throws ArchivaRestServiceException {
    log.debug("Deleting file {}", fileName);
    // we make sure, that there are no other path components in the filename:
    String checkedFileName = Paths.get(fileName).getFileName().toString();
    Path file = SystemUtils.getJavaIoTmpDir().toPath().resolve(checkedFileName);
    log.debug("delete file:{},exists:{}", file, Files.exists(file));
    boolean removed = getSessionFileMetadatas().remove(new FileMetadata(fileName));
    // try with full name as ui only know the file name
    if (!removed) {
        removed = getSessionFileMetadatas().remove(new FileMetadata(file.toString()));
    }
    if (removed) {
        try {
            Files.deleteIfExists(file);
            return Boolean.TRUE;
        } catch (IOException e) {
            log.error("Could not delete file {}: {}", file, e.getMessage(), e);
        }
    }
    return Boolean.FALSE;
}
 
源代码17 项目: astor   文件: MultiLineToStringStyleTest.java
public void testObject() {
    Integer i3 = new Integer(3);
    Integer i4 = new Integer(4);
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=3" + SystemUtils.LINE_SEPARATOR + "  b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<Integer>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3, false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=[]" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
    assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "  a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
}
 
源代码18 项目: pcgen   文件: DataLoadTest.java
private static void loadGameModes()
{
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		String configFolder = "testsuite";
		TestHelper.createDummySettingsFile(TEST_CONFIG_FILE, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}

	PropertyContextFactory configFactory =
			new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings
		.getInstance(TEST_CONFIG_FILE));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	PCGenTask gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	PCGenTask campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
源代码19 项目: collect-earth   文件: CollectEarthUtils.java
public static void openFolderInExplorer(String folder) throws IOException {
	if (Desktop.isDesktopSupported()) {
		Desktop.getDesktop().open(new File(folder));
	}else{
		if (SystemUtils.IS_OS_WINDOWS){
			new ProcessBuilder("explorer.exe", "/open," + folder).start(); //$NON-NLS-1$ //$NON-NLS-2$
		}else if (SystemUtils.IS_OS_MAC){
			new ProcessBuilder("usr/bin/open", folder).start(); //$NON-NLS-1$ //$NON-NLS-2$
		}else if ( SystemUtils.IS_OS_UNIX){
			tryUnixFileExplorers(folder);
		}
	}
}
 
源代码20 项目: RemoteSupportTool   文件: KeyboardTest.java
public static void main(String[] args) {

        final StringBuilder text = new StringBuilder();
        for (String arg : args) {
            text.append(arg).append(StringUtils.SPACE);
        }
        String txt = text.toString().trim();
        if (StringUtils.isBlank(txt))
            txt = "test123 - äöüß / ÄÖÜ @€ \\";

        try {
            if (SystemUtils.IS_OS_WINDOWS) {
                LOGGER.debug("Send text on Windows...");
                GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
                Robot robot = new Robot(device);
                WindowsUtils.sendText(txt, robot);
            } else if (SystemUtils.IS_OS_LINUX) {
                LOGGER.debug("Send text on Linux...");
                LinuxUtils.sendText(txt);
            } else if (SystemUtils.IS_OS_MAC) {
                LOGGER.debug("Send text on macOS...");
                MacUtils.sendText(txt);
            } else {
                throw new UnsupportedOperationException("Operating system is not supported.");
            }
        } catch (Exception ex) {
            LOGGER.error("Can't send text!", ex);
        }
    }
 
源代码21 项目: aceql-http   文件: SchemaInfoAccessor.java
public boolean isAccessible() {
String javaVersion = SystemUtils.JAVA_VERSION;
if (SystemUtils.JAVA_VERSION.compareTo("1.8") < 0) {
    failureReason = "Java version is " + javaVersion + ". Access to db_schema_download API info requires Java 8 or beyond on AceQL server";
    return false;
}

return true;
   }
 
源代码22 项目: match-trade   文件: SnowflakeIdWorker.java
private static Long getDataCenterId(){
    int[] ints = StringUtils.toCodePoints(SystemUtils.getHostName());
    int sums = 0;
    for (int i: ints) {
        sums += i;
    }
    return (long)(sums % 32);
}
 
源代码23 项目: sahagin-java   文件: CommonUtils.java
private static boolean filePathEquals(String path1, String path2) {
    // Mac is case-insensitive, but IOCase.SYSTEM.isCaseSenstive returns true,
    // so don't use this value for Mac.
    // (TODO but Mac can become case-sensitive if an user changes system setting..)
    if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        return StringUtils.equalsIgnoreCase(path1, path2);
    }
    if (IOCase.SYSTEM.isCaseSensitive()) {
        return StringUtils.equals(path1, path2);
    } else {
        return StringUtils.equalsIgnoreCase(path1, path2);
    }
}
 
源代码24 项目: lucene-solr   文件: SolrCLI.java
private void printAuthEnablingInstructions(String kerberosConfig) {
  if (SystemUtils.IS_OS_WINDOWS) {
    CLIO.out("\nAdd the following lines to the solr.in.cmd file so that the solr.cmd script can use subsequently.\n");
    CLIO.out("set SOLR_AUTH_TYPE=kerberos\n"
        + "set SOLR_AUTHENTICATION_OPTS=\"" + kerberosConfig + "\"\n");
  } else {
    CLIO.out("\nAdd the following lines to the solr.in.sh file so that the ./solr script can use subsequently.\n");
    CLIO.out("SOLR_AUTH_TYPE=\"kerberos\"\n"
        + "SOLR_AUTHENTICATION_OPTS=\"" + kerberosConfig + "\"\n");
  }
}
 
源代码25 项目: synopsys-detect   文件: DetectorFinderTest.java
@Test
@DisabledOnOs(WINDOWS) //TODO: See if we can fix on windows.
public void testSimple() throws DetectorFinderDirectoryListException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final File initialDirectory = initialDirectoryPath.toFile();
    final File subDir = new File(initialDirectory, "testSimple");
    subDir.mkdirs();

    final File subSubDir1 = new File(subDir, "subSubDir1");
    subSubDir1.mkdir();

    final File subSubDir2 = new File(subDir, "subSubDir2");
    subSubDir2.mkdir();

    final DetectorRuleSet detectorRuleSet = new DetectorRuleSet(new ArrayList<>(0), new HashMap<>(0), new HashMap<>());
    final Predicate<File> fileFilter = f -> true;
    final int maximumDepth = 10;
    final DetectorFinderOptions options = new DetectorFinderOptions(fileFilter, maximumDepth);

    final DetectorFinder finder = new DetectorFinder();
    final Optional<DetectorEvaluationTree> tree = finder.findDetectors(initialDirectory, detectorRuleSet, options);

    // make sure both dirs were found
    final Set<DetectorEvaluationTree> testDirs = tree.get().getChildren();
    DetectorEvaluationTree simpleTestDir = null;
    for (final DetectorEvaluationTree testDir : testDirs) {
        if (testDir.getDirectory().getName().equals("testSimple")) {
            simpleTestDir = testDir;
            break;
        }
    }
    final Set<DetectorEvaluationTree> subDirResults = simpleTestDir.getChildren();
    assertEquals(2, subDirResults.size());
    final String subDirContentsName = subDirResults.iterator().next().getDirectory().getName();
    assertTrue(subDirContentsName.startsWith("subSubDir"));
}
 
源代码26 项目: synopsys-detect   文件: DetectInfoUtility.java
public OperatingSystemType findOperatingSystemType() {
    if (SystemUtils.IS_OS_LINUX) {
        return OperatingSystemType.LINUX;
    } else if (SystemUtils.IS_OS_MAC) {
        return OperatingSystemType.MAC;
    } else if (SystemUtils.IS_OS_WINDOWS) {
        return OperatingSystemType.WINDOWS;
    }

    logger.warn("Your operating system is not supported. Linux will be assumed.");
    return OperatingSystemType.LINUX;
}
 
源代码27 项目: components   文件: DisablablePaxExam.java
@Override
public void run(final RunNotifier notifier) {
    if (!SystemUtils.JAVA_VERSION.startsWith("1.8.")) {
        notifier.fireTestAssumptionFailed(new Failure(
                Description.createSuiteDescription(clazz),
                new IllegalStateException("Java " + SystemUtils.JAVA_VERSION + " not yet supported")));
    } else {
        super.run(notifier);
    }
}
 
源代码28 项目: stevia   文件: Hardware.java
public static final String getSerialNumber() {
	// lets gather what we can
	String osString = System.getProperty("os.name") + "-"
			+ System.getProperty("os.version") + "-"
			+ System.getProperty("os.arch");
	try {
		if (SystemUtils.IS_OS_WINDOWS) {
			return H4W.getSerialNumber() + ":WIN";
		}
		if (SystemUtils.IS_OS_LINUX) {
			return H4N.getSerialNumber() + ":LIN";
		}
		if (SystemUtils.IS_OS_MAC_OSX) {
			return H4M.getSerialNumber() + ":MAC";
		}
		if (SystemUtils.IS_OS_SOLARIS) {
			return H4S.getSerialNumber()
					+ ":S"
					+ (SystemUtils.OS_VERSION == null ? "OL"
							: SystemUtils.OS_VERSION);
		}
	} catch (Exception e) {
		// if we're here, we dont know what this is.
		return osString + ":EXC";
	}
	// if we're here then lets note it's unknown
	return osString + ":UNK";
}
 
源代码29 项目: pcgen   文件: PCGenSettings.java
private static String unexpandRelativePath(String path)
{
	if (path.startsWith(SystemUtils.USER_DIR + File.separator))
	{
		path = '@' + path.substring(SystemUtils.USER_DIR.length() + 1);
	}
	return path;
}
 
源代码30 项目: components   文件: DisablablePaxExam.java
@Override
public void run(final RunNotifier notifier) {
    if (!SystemUtils.JAVA_VERSION.startsWith("1.8.")) {
        notifier.fireTestAssumptionFailed(new Failure(
                Description.createSuiteDescription(clazz),
                new IllegalStateException("Java " + SystemUtils.JAVA_VERSION + " not yet supported")));
    } else {
        super.run(notifier);
    }
}
 
 类所在包
 同包方法