Java 类org.apache.commons.lang.SystemUtils 实例源码

项目:hadoop-oss    文件:TestSharedFileDescriptorFactory.java   
@Test(timeout=10000)
public void testCleanupRemainders() throws Exception {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  File path = new File(TEST_BASE, "testCleanupRemainders");
  path.mkdirs();
  String remainder1 = path.getAbsolutePath() + 
      Path.SEPARATOR + "woot2_remainder1";
  String remainder2 = path.getAbsolutePath() +
      Path.SEPARATOR + "woot2_remainder2";
  createTempFile(remainder1);
  createTempFile(remainder2);
  SharedFileDescriptorFactory.create("woot2_", 
      new String[] { path.getAbsolutePath() });
  // creating the SharedFileDescriptorFactory should have removed 
  // the remainders
  Assert.assertFalse(new File(remainder1).exists());
  Assert.assertFalse(new File(remainder2).exists());
  FileUtil.fullyDelete(path);
}
项目:VASSAL-src    文件:Prefs.java   
/**
 * Initialize visible Global Preferences that are shared between the
 * Module Manager and the Editor/Player.
 *
 */
public static void initSharedGlobalPrefs() {
  getGlobalPrefs();

  // Option to disable D3D pipeline
  if (SystemUtils.IS_OS_WINDOWS) {
    final BooleanConfigurer d3dConf = new BooleanConfigurer(
      DISABLE_D3D,
      Resources.getString("Prefs.disable_d3d"),
      Boolean.FALSE
    );
    globalPrefs.addOption(d3dConf);
  }

  final BooleanConfigurer wizardConf = new BooleanConfigurer(
    WizardSupport.WELCOME_WIZARD_KEY,
    Resources.getString("WizardSupport.ShowWizard"),
    Boolean.TRUE
  );

  globalPrefs.addOption(wizardConf);
}
项目:VASSAL-src    文件:FileChooser.java   
/**
 * Creates a FileChooser appropriate for the user's OS.
 *
 * @param parent
 *          The Component over which the FileChooser should appear.
 * @param prefs
 *          A FileConfigure that stores the preferred starting directory of the FileChooser in preferences
 */
public static FileChooser createFileChooser(Component parent, DirectoryConfigurer prefs, int mode) {
  FileChooser fc;
  if (SystemUtils.IS_OS_MAC_OSX) {
    // Mac has a good native file dialog
    fc = new NativeFileChooser(parent, prefs, mode);
  }
  else if (mode == FILES_ONLY && SystemUtils.IS_OS_WINDOWS) {
    // Window has a good native file dialog, but it doesn't support selecting directories
    fc = new NativeFileChooser(parent, prefs, mode);
  }
  else {
    // Linux's native dialog is inferior to Swing's
    fc = new SwingFileChooser(parent, prefs, mode);
  }
  return fc;
}
项目:VASSAL-src    文件:FallbackImageTypeConverter.java   
private boolean tryConvertingInMemory(Reference<BufferedImage> ref) {
  /*
   * Having an OutOfMemoryException while converting in memory is
   * apparently catastrophic on Apple's Java 6 JVM (and possibly also
   * on their Java 5 JVM as well). In-memory tiling also uses far more
   * memory than it should on Apple's Java 6 JVM due to
   * Graphics2D.drawImage making an intermediate copy of the image data.
   * Hence, we ensure that when using Java 5 or 6 on Mac OS X, we never
   * try in-memory conversion for images which can't comfortably have
   * three copies existing simultaneously in memory.
   */
  return !SystemUtils.IS_OS_MAC_OSX ||
    (!SystemUtils.IS_JAVA_1_6 && !SystemUtils.IS_JAVA_1_5) ||
    4*ref.obj.getHeight()*ref.obj.getWidth() <=
      Runtime.getRuntime().maxMemory()/4;
}
项目:VASSAL-src    文件:MemoryUtilsTest.java   
@Test
public void testGetPhysicalMemoryUNIX() throws IOException {
  assumeTrue(SystemUtils.IS_OS_UNIX);

  // get the total RAM from the system, in kB
  final Process p = Runtime.getRuntime().exec(new String[] {
    "sh",
    "-c",
    "grep '^MemTotal:' /proc/meminfo | sed 's/[^0-9]//g'"
  });

  final BufferedReader r =
    new BufferedReader(new InputStreamReader(p.getInputStream()));

  final int eRAM = Integer.parseInt(r.readLine());
  r.close();

  // check that it's correct
  assertEquals(eRAM, MemoryUtils.getPhysicalMemory() >> 10);
}
项目:tifoon    文件:DockerExecutorPlugin.java   
private DockerClient getDockerClient() {
    /*
    TLS connection: ...

    DefaultDockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
            .withDockerHost("tcp://192.168.99.100:2376")
            .withDockerTlsVerify(true)
            .withDockerCertPath("/Users/jon/.docker/machine/machines/default")
            .build();
    */

    final String localDockerHost = SystemUtils.IS_OS_WINDOWS ? "tcp://localhost:2375" : "unix:///var/run/docker.sock";

    final DefaultDockerClientConfig config = DefaultDockerClientConfig
            .createDefaultConfigBuilder()
            .withDockerHost(localDockerHost)
            .build();

    return DockerClientBuilder
            .getInstance(config)
            .build();
}
项目:testcontainers-java-module-mariadb    文件:SimpleMariaDBTest.java   
@Test
public void testMariaDBWithCustomIniFile() throws SQLException {
    assumeFalse(SystemUtils.IS_OS_WINDOWS);
    MariaDBContainer mariadbCustomConfig = new MariaDBContainer("mariadb:10.1.16")
                                            .withConfigurationOverride("somepath/mariadb_conf_override");
    mariadbCustomConfig.start();

    try {
        ResultSet resultSet = performQuery(mariadbCustomConfig, "SELECT @@GLOBAL.innodb_file_format");
        String result = resultSet.getString(1);

        assertEquals("The InnoDB file format has been set by the ini file content", "Barracuda", result);
    } finally {
        mariadbCustomConfig.stop();
    }
}
项目:docker-dash    文件:DockerConnectionService.java   
/**
 * TODO delete and make method with serverId param after thinking about it
 *
 * @return default connection to system docker
 */
public DockerClient getDefaultConnection() {
    return connections.computeIfAbsent(DEFAULT_CONNECTION, id -> {
        DockerClientConfig config = null;

        if (SystemUtils.IS_OS_MAC_OSX) {
            config = DefaultDockerClientConfig.createDefaultConfigBuilder()
                    .withDockerHost("unix:///var/run/docker.sock")
                    .build();
        }
        if (SystemUtils.IS_OS_LINUX) {
            config = DefaultDockerClientConfig.createDefaultConfigBuilder()
                    .withDockerHost("unix:///var/run/docker.sock")
                    .build();
        }
        if (SystemUtils.IS_OS_WINDOWS) {
            config = DefaultDockerClientConfig.createDefaultConfigBuilder()
                    .withDockerHost("tcp://localhost:2376")
                    .withDockerTlsVerify(true)
                    .withDockerTlsVerify("1")
                    .build();
        }

        return DockerClientBuilder.getInstance(config).build();
    });
}
项目:flume-release-1.7.0    文件:TestExecSource.java   
@Test
public void testShellCommandScript() throws InterruptedException, LifecycleException,
                                            EventDeliveryException, IOException {
  // mini script
  if (SystemUtils.IS_OS_WINDOWS) {
    runTestShellCmdHelper("powershell -ExecutionPolicy Unrestricted -command",
                          "foreach ($i in 1..5) { $i }",
                          new String[] { "1", "2", "3", "4", "5" });
    // shell arithmetic
    runTestShellCmdHelper("powershell -ExecutionPolicy Unrestricted -command",
                          "if(2+2 -gt 3) { 'good' } else { 'not good' } ",
                          new String[] { "good" });
  } else {
    runTestShellCmdHelper("/bin/bash -c", "for i in {1..5}; do echo $i;done",
                          new String[] { "1", "2", "3", "4", "5" });
    // shell arithmetic
    runTestShellCmdHelper("/bin/bash -c",
                          "if ((2+2>3)); " + "then  echo good; else echo not good; fi",
                          new String[] { "good" });
  }
}
项目:lams    文件: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 getStackFrameList(Throwable t) {
    String stackTrace = getStackTrace(t);
    String linebreak = SystemUtils.LINE_SEPARATOR;
    StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
    List list = new ArrayList();
    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;
}
项目:otter-G    文件:VersionInfo.java   
/**
 * Returns the buildVersion which includes version, revision, user and date.
 */
public static String getBuildVersion() {
    StringBuilder buf = new StringBuilder();

    buf.append(SystemUtils.LINE_SEPARATOR);
    buf.append("[OTTER Version Info]").append(SystemUtils.LINE_SEPARATOR);
    buf.append("[version ]").append(VersionInfo.getVersion()).append(SystemUtils.LINE_SEPARATOR);
    buf.append("[revision]").append(VersionInfo.getRevision()).append(SystemUtils.LINE_SEPARATOR);
    buf.append("[compiler]").append(VersionInfo.getUser()).append(SystemUtils.LINE_SEPARATOR);
    buf.append("[date    ]").append(VersionInfo.getDate()).append(SystemUtils.LINE_SEPARATOR);
    buf.append("[checksum]").append(VersionInfo.getSrcChecksum()).append(SystemUtils.LINE_SEPARATOR);
    buf.append("[branch  ]").append(VersionInfo.getBranch()).append(SystemUtils.LINE_SEPARATOR);
    buf.append("[url     ]").append(VersionInfo.getUrl()).append(SystemUtils.LINE_SEPARATOR);

    return buf.toString();
}
项目:otter-G    文件:StreamCopier.java   
public void run() {
    try {
        StringBuffer buf = new StringBuffer();
        String line = null;

        while ((line = reader.readLine()) != null) {
            if (identifier != null) {
                line = identifier + line;
            }

            if (false == StringUtils.isBlank(line)) {
                buf.append(line).append(SystemUtils.LINE_SEPARATOR);
            }
        }

        out.write(buf.toString().getBytes());
        out.flush();
    } catch (IOException ioe) {
        //ignore
    } finally {
        IOUtils.closeQuietly(reader);
    }
}
项目:hadoop    文件:TestEnhancedByteBufferAccess.java   
public static HdfsConfiguration initZeroCopyTest() {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  HdfsConfiguration conf = new HdfsConfiguration();
  conf.setBoolean(DFSConfigKeys.DFS_CLIENT_READ_SHORTCIRCUIT_KEY, true);
  conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE);
  conf.setInt(DFSConfigKeys.DFS_CLIENT_MMAP_CACHE_SIZE, 3);
  conf.setLong(DFSConfigKeys.DFS_CLIENT_MMAP_CACHE_TIMEOUT_MS, 100);
  conf.set(DFSConfigKeys.DFS_DOMAIN_SOCKET_PATH_KEY,
      new File(sockDir.getDir(),
        "TestRequestMmapAccess._PORT.sock").getAbsolutePath());
  conf.setBoolean(DFSConfigKeys.
      DFS_CLIENT_READ_SHORTCIRCUIT_SKIP_CHECKSUM_KEY, true);
  conf.setLong(DFS_HEARTBEAT_INTERVAL_KEY, 1);
  conf.setLong(DFS_CACHEREPORT_INTERVAL_MSEC_KEY, 1000);
  conf.setLong(DFS_NAMENODE_PATH_BASED_CACHE_REFRESH_INTERVAL_MS, 1000);
  return conf;
}
项目:hadoop    文件:TestSharedFileDescriptorFactory.java   
@Test(timeout=10000)
public void testCleanupRemainders() throws Exception {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  File path = new File(TEST_BASE, "testCleanupRemainders");
  path.mkdirs();
  String remainder1 = path.getAbsolutePath() + 
      Path.SEPARATOR + "woot2_remainder1";
  String remainder2 = path.getAbsolutePath() +
      Path.SEPARATOR + "woot2_remainder2";
  createTempFile(remainder1);
  createTempFile(remainder2);
  SharedFileDescriptorFactory.create("woot2_", 
      new String[] { path.getAbsolutePath() });
  // creating the SharedFileDescriptorFactory should have removed 
  // the remainders
  Assert.assertFalse(new File(remainder1).exists());
  Assert.assertFalse(new File(remainder2).exists());
  FileUtil.fullyDelete(path);
}
项目:obevo    文件:H2JdbcDataSourceFactory.java   
public static String getUrlUncached(String dbName, boolean persistToFile) {
    Validate.notNull(dbName, "dbName parameter must be specified");
    String url;
    if (persistToFile) {
        // In order to allow access to the db from multiple processes, the FILE_LOCK=NO setting is needed.
        // This however, does not prevent concurrency issues from multiple writers.
        // Other options found in the docs that we are not using: MVCC=TRUE;FILE_LOCK=SERIALIZED
        String dbFileName = new File(SystemUtils.getJavaIoTmpDir(), dbName).getAbsolutePath();
        LOG.info("writing db to file:{}", dbFileName);
        url = String.format("jdbc:h2:file:%s;FILE_LOCK=NO", dbFileName);
    } else {
        // use DB_CLOSE_DELAY=-1 to keep the DB open for the duration of the JVM
        url = String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", dbName);
    }
    LOG.info("setting up in memory db: {}", url);
    return url;
}
项目:courier    文件:Main.java   
public static void main(String... args) {
    invisible = new JFrame();
    try {
        invisible.setIconImage(ImageIO.read(FileUtil.getResource("icon.png")));
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Our discord-rpc library doesn't support macOS yet
    if (!SystemTray.isSupported() || !Desktop.isDesktopSupported() || SystemUtils.IS_OS_MAC_OSX) { // We do this because if there is no sys-tray icon users can't terminate the program, which would be bad
        JOptionPane.showMessageDialog(null, "Your platform isn't supported currently!", "Unsupported platform!", JOptionPane.ERROR_MESSAGE);
        return;
    }

    new Courier();
}
项目:morf    文件:HumanReadableStatementHelper.java   
/**
 * Generates a human-readable description of a raw SQL operation.
 *
 * @param statement the data upgrade statement to describe.
 * @param preferredSQLDialect the SQL dialect to use, if available. If this is {@code null} or the preferred
 *          dialect is not available in the statement bundle then an arbitrary choice is made.
 * @return a string containing the human-readable description of the operation.
 */
private static String generatePortableSqlStatementString(final PortableSqlStatement statement, final String preferredSQLDialect) {
  final Map<String, String> sqlStrings = statement.getStatements();
  String sql = sqlStrings.get(preferredSQLDialect);
  if (sql == null) {
    sql = sqlStrings.values().iterator().next();
  }
  final StringBuilder sb = new StringBuilder("Run the following raw SQL statement");
  // Raw SQL fragments may have either "\n" written into them or use the platform separator
  final String[] lines = sql.split(SystemUtils.LINE_SEPARATOR + "|\\n");
  for (int i = 0; i < lines.length; i++) {
    if (i > 0) {
      sb.append(SystemUtils.LINE_SEPARATOR).append("      ");
    } else {
      sb.append(SystemUtils.LINE_SEPARATOR).append("    - ");
    }
    sb.append(lines[i]);
  }
  return sb.toString();
}
项目:ditb    文件:TestUser.java   
@Test
public void testCacheGetGroupsRoot() throws Exception {
  // Windows users don't have a root user.
  // However pretty much every other *NIX os will have root.
  if (!SystemUtils.IS_OS_WINDOWS) {
    Configuration conf = HBaseConfiguration.create();
    UserProvider up = UserProvider.instantiate(conf);


    String rootUserName = "root";

    // Create two UGI's for this username
    UserGroupInformation ugiOne = UserGroupInformation.createRemoteUser(rootUserName);
    UserGroupInformation ugiTwo = UserGroupInformation.createRemoteUser(rootUserName);

    // Now try and get the user twice.
    User uOne = up.create(ugiOne);
    User uTwo = up.create(ugiTwo);

    // Make sure that we didn't break groups and everything worked well.
    assertArrayEquals(uOne.getGroupNames(),uTwo.getGroupNames());
    String[] groupNames = ugiOne.getGroupNames();
    assertTrue(groupNames.length > 0);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestEnhancedByteBufferAccess.java   
public static HdfsConfiguration initZeroCopyTest() {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  HdfsConfiguration conf = new HdfsConfiguration();
  conf.setBoolean(HdfsClientConfigKeys.Read.ShortCircuit.KEY, true);
  conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE);
  conf.setInt(HdfsClientConfigKeys.Mmap.CACHE_SIZE_KEY, 3);
  conf.setLong(HdfsClientConfigKeys.Mmap.CACHE_TIMEOUT_MS_KEY, 100);
  conf.set(DFSConfigKeys.DFS_DOMAIN_SOCKET_PATH_KEY,
      new File(sockDir.getDir(),
        "TestRequestMmapAccess._PORT.sock").getAbsolutePath());
  conf.setBoolean(HdfsClientConfigKeys.Read.ShortCircuit.SKIP_CHECKSUM_KEY,
      true);
  conf.setLong(DFS_HEARTBEAT_INTERVAL_KEY, 1);
  conf.setLong(DFS_CACHEREPORT_INTERVAL_MSEC_KEY, 1000);
  conf.setLong(DFS_NAMENODE_PATH_BASED_CACHE_REFRESH_INTERVAL_MS, 1000);
  return conf;
}
项目:aliyun-oss-hadoop-fs    文件:TestSharedFileDescriptorFactory.java   
@Test(timeout=10000)
public void testCleanupRemainders() throws Exception {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  File path = new File(TEST_BASE, "testCleanupRemainders");
  path.mkdirs();
  String remainder1 = path.getAbsolutePath() + 
      Path.SEPARATOR + "woot2_remainder1";
  String remainder2 = path.getAbsolutePath() +
      Path.SEPARATOR + "woot2_remainder2";
  createTempFile(remainder1);
  createTempFile(remainder2);
  SharedFileDescriptorFactory.create("woot2_", 
      new String[] { path.getAbsolutePath() });
  // creating the SharedFileDescriptorFactory should have removed 
  // the remainders
  Assert.assertFalse(new File(remainder1).exists());
  Assert.assertFalse(new File(remainder2).exists());
  FileUtil.fullyDelete(path);
}
项目:apache-archiva    文件:DefaultFileUploadService.java   
@Override
public Boolean deleteFile( String fileName )
    throws ArchivaRestServiceException
{
    File file = new File( SystemUtils.getJavaIoTmpDir(), fileName );
    log.debug( "delete file:{},exists:{}", file.getPath(), file.exists() );
    boolean removed = getSessionFileMetadatas().remove( new FileMetadata( fileName ) );
    // try with full name as ui only know the file name
    if ( !removed )
    {
        /* unused */ getSessionFileMetadatas().remove( new FileMetadata( file.getPath() ) );
    }
    if ( file.exists() )
    {
        return file.delete();
    }
    return Boolean.FALSE;
}
项目:Gargoyle    文件:SVNCommandManager.java   
public SVNCommandManager() {
    ResourceLoader instance = ResourceLoader.getInstance();
    String userId = instance.get(SVN_USER_ID);
    String userPass = instance.get(SVN_USER_PASS);

    String osName = SystemUtils.OS_NAME;

    String svnPath = null;

    if (osName.contains("Windows")) {
        svnPath = ConfigResourceLoader.getInstance().get(SVN_PATH_WINDOW);
    }

    Properties properties = new Properties();
    properties.put(SVN_USER_ID, userId);
    properties.put(SVN_USER_PASS, userPass);
    properties.put(SVN_PATH, svnPath);

    init(properties);

}
项目:leopard    文件:ImageDfsServiceImpl.java   
@Override
public String save(final long uid, final String folder, final byte[] data, final String sizeList) throws IOException {
    if (SystemUtils.IS_OS_WINDOWS) {
        if (!this.isWeb()) {
            return super.save(uid, folder, data, sizeList);
        }
    }
    final String uri = folder + uuid() + ".jpg";
    logger.info("async save:" + uri);
    new Thread() {
        @Override
        public void run() {
            try {
                saveByUri(uid, uri, data, sizeList);
                logger.info("save:" + uri);
            }
            catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        };
    }.start();
    // saveByUri(uid, uri, data, sizeList);
    return uri;
}
项目:citrus-admin    文件:AbstractTerminalCommand.java   
@Override
public ProcessBuilder getProcessBuilder() {
    validateWorkingDirectory(workingDirectory);

    List<String> commands = new ArrayList<>();
    if (SystemUtils.IS_OS_UNIX) {
        commands.add(BASH);
        commands.add(BASH_OPTION_C);
    } else {
        commands.add(CMD);
        commands.add(CMD_OPTION_C);
    }

    commands.add(buildCommand());

    ProcessBuilder pb = new ProcessBuilder(commands);
    pb.directory(workingDirectory);

    LOG.debug("Process builder commands: " + commands);
    return pb;
}
项目:big-c    文件:TestEnhancedByteBufferAccess.java   
public static HdfsConfiguration initZeroCopyTest() {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  HdfsConfiguration conf = new HdfsConfiguration();
  conf.setBoolean(DFSConfigKeys.DFS_CLIENT_READ_SHORTCIRCUIT_KEY, true);
  conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE);
  conf.setInt(DFSConfigKeys.DFS_CLIENT_MMAP_CACHE_SIZE, 3);
  conf.setLong(DFSConfigKeys.DFS_CLIENT_MMAP_CACHE_TIMEOUT_MS, 100);
  conf.set(DFSConfigKeys.DFS_DOMAIN_SOCKET_PATH_KEY,
      new File(sockDir.getDir(),
        "TestRequestMmapAccess._PORT.sock").getAbsolutePath());
  conf.setBoolean(DFSConfigKeys.
      DFS_CLIENT_READ_SHORTCIRCUIT_SKIP_CHECKSUM_KEY, true);
  conf.setLong(DFS_HEARTBEAT_INTERVAL_KEY, 1);
  conf.setLong(DFS_CACHEREPORT_INTERVAL_MSEC_KEY, 1000);
  conf.setLong(DFS_NAMENODE_PATH_BASED_CACHE_REFRESH_INTERVAL_MS, 1000);
  return conf;
}
项目:big-c    文件:TestSharedFileDescriptorFactory.java   
@Test(timeout=10000)
public void testCleanupRemainders() throws Exception {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  File path = new File(TEST_BASE, "testCleanupRemainders");
  path.mkdirs();
  String remainder1 = path.getAbsolutePath() + 
      Path.SEPARATOR + "woot2_remainder1";
  String remainder2 = path.getAbsolutePath() +
      Path.SEPARATOR + "woot2_remainder2";
  createTempFile(remainder1);
  createTempFile(remainder2);
  SharedFileDescriptorFactory.create("woot2_", 
      new String[] { path.getAbsolutePath() });
  // creating the SharedFileDescriptorFactory should have removed 
  // the remainders
  Assert.assertFalse(new File(remainder1).exists());
  Assert.assertFalse(new File(remainder2).exists());
  FileUtil.fullyDelete(path);
}
项目:cosmic    文件:NetUtils.java   
public static String getDefaultEthDevice() {
    if (SystemUtils.IS_OS_MAC) {
        final String defDev = Script.runSimpleBashScript("/sbin/route -n get default 2> /dev/null | grep interface | awk '{print $2}'");
        return defDev;
    }
    final String defaultRoute = Script.runSimpleBashScript("/sbin/route | grep default");

    if (defaultRoute == null) {
        return null;
    }

    final String[] defaultRouteList = defaultRoute.split("\\s+");

    if (defaultRouteList.length != 8) {
        return null;
    }

    return defaultRouteList[7];
}
项目:cosmic    文件:ScriptTest.java   
@Test
public void executeWithOutputInterpreter() {
    Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
    final Script script = new Script("/bin/bash");
    script.add("-c");
    script.add("echo 'hello world!'");
    final String value = script.execute(new OutputInterpreter() {

        @Override
        public String interpret(final BufferedReader reader) throws IOException {
            throw new IllegalArgumentException();
        }
    });
    // it is a stack trace in this case as string
    Assert.assertNotNull(value);
}
项目:helicalinsight    文件:ReportsProcessor.java   
/**
 * The location of the phantom js is different for different os types. The
 * method returns the appropriate binary corresponding to the os. Currently
 * only Windows, Mac OS and Linux are supported.
 *
 * @return The location of the phantom js
 */
private static String getPhantomLocation() {
    String phantomLocation;
    String reportDirectory = ExportUtils.getReportDirectory() + File.separator;
    if (SystemUtils.IS_OS_WINDOWS) {
        phantomLocation = reportDirectory + "windows_phantomjs.exe";
    } else if (SystemUtils.IS_OS_MAC) {
        phantomLocation = reportDirectory + "macosx_phantomjs";
    } else if (SystemUtils.IS_OS_LINUX) {
        phantomLocation = reportDirectory + "linux_phantomjs";
    } else {
        logger.error("phantomLocation is null. Check phantomjs binary is present or not");
        throw new EfwException("PhantomJs Location is null. Can't process request.");
    }

    File file = new File(phantomLocation);
    phantomLocation = file.getAbsolutePath();
    return phantomLocation;
}
项目:ERDesignerNG    文件:Java3DUtils.java   
public static void initializeLibraryPath() throws Exception {
    File theJava3DFile = new File("java3d");
    File theJava3DLibraryFile = null;
    if (SystemUtils.IS_OS_WINDOWS) {
        if (VM_32_BIT) {
            theJava3DLibraryFile =  new File(theJava3DFile, "win32");
        } else {
            theJava3DLibraryFile =  new File(theJava3DFile, "win64");
        }
    }
    if (SystemUtils.IS_OS_LINUX) {
        if (VM_32_BIT) {
            theJava3DLibraryFile =  new File(theJava3DFile, "linux32");
        } else {
            theJava3DLibraryFile =  new File(theJava3DFile, "linux64");
        }
    }
    if (SystemUtils.IS_OS_MAC) {
        theJava3DLibraryFile =  new File(theJava3DFile, "macos-universal");
    }
    if (theJava3DLibraryFile != null) {
        addLibraryPath(theJava3DLibraryFile.getAbsolutePath());
    }
}
项目:ERDesignerNG    文件:DialectFactory.java   
public static synchronized DialectFactory getInstance() {
    if (me == null) {
        me = new DialectFactory();
        me.registerDialect(new DB2Dialect());
        me.registerDialect(new MSSQLDialect());
        me.registerDialect(new MySQLDialect());
        me.registerDialect(new MySQLInnoDBDialect());
        me.registerDialect(new OracleDialect());
        me.registerDialect(new PostgresDialect());
        me.registerDialect(new H2Dialect());
        me.registerDialect(new HSQLDBDialect());

        // provide MSAccessDialect only on Windows-Systems due to the
        // requirement of the JET/ACE-Engine
        if (SystemUtils.IS_OS_WINDOWS) {
            me.registerDialect(new MSAccessDialect());
        }
    }

    return me;
}
项目:ERDesignerNG    文件:ApplicationPreferences.java   
/**
 * Get the directory where the datatype configuration is located.
 *
 * @return the directory
 */
public File getDatatypeConfigDirectory() {
    File theUserHomeFile = SystemUtils.getUserHome();
    if (theUserHomeFile == null) {
        return getRelativeFile("dataTypes");
    }

    String theVersionNumber = MavenPropertiesLocator
            .getERDesignerVersionInfo();
    if (theVersionNumber
            .equals(MavenPropertiesLocator.CANNOT_IDENTIFY_VERSION)) {
        theVersionNumber = "development";
    }
    theVersionNumber = theVersionNumber.replace(".", "_");
    theVersionNumber = theVersionNumber.replace(" ", "_");
    theVersionNumber = theVersionNumber.replace("-", "_");

    File theMogwaiHome = new File(theUserHomeFile, ".mogwai");
    File theVersionHome = new File(theMogwaiHome, theVersionNumber);
    return new File(theVersionHome, "dataTypes");
}
项目:nbone    文件:ExceptionUtils.java   
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();

    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;
}
项目:phpstorm-plugin    文件:AtoumUtils.java   
public static String findAtoumBinPath(VirtualFile dir)
{
    String defaultBinPath = dir.getPath() + "/vendor/bin/atoum";
    String atoumBinPath = defaultBinPath;

    String binDir = getComposerBinDir(dir.getPath() + "/composer.json");
    String binPath = dir.getPath() + "/" + binDir + "/atoum";
    if (null != binDir && new File(binPath).exists()) {
        atoumBinPath = binPath;
    }

    if (SystemUtils.IS_OS_WINDOWS) {
        atoumBinPath += ".bat";
    }

    return atoumBinPath;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestEnhancedByteBufferAccess.java   
public static HdfsConfiguration initZeroCopyTest() {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  HdfsConfiguration conf = new HdfsConfiguration();
  conf.setBoolean(DFSConfigKeys.DFS_CLIENT_READ_SHORTCIRCUIT_KEY, true);
  conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE);
  conf.setInt(DFSConfigKeys.DFS_CLIENT_MMAP_CACHE_SIZE, 3);
  conf.setLong(DFSConfigKeys.DFS_CLIENT_MMAP_CACHE_TIMEOUT_MS, 100);
  conf.set(DFSConfigKeys.DFS_DOMAIN_SOCKET_PATH_KEY,
      new File(sockDir.getDir(),
        "TestRequestMmapAccess._PORT.sock").getAbsolutePath());
  conf.setBoolean(DFSConfigKeys.
      DFS_CLIENT_READ_SHORTCIRCUIT_SKIP_CHECKSUM_KEY, true);
  conf.setLong(DFS_HEARTBEAT_INTERVAL_KEY, 1);
  conf.setLong(DFS_CACHEREPORT_INTERVAL_MSEC_KEY, 1000);
  conf.setLong(DFS_NAMENODE_PATH_BASED_CACHE_REFRESH_INTERVAL_MS, 1000);
  return conf;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSharedFileDescriptorFactory.java   
@Test(timeout=10000)
public void testCleanupRemainders() throws Exception {
  Assume.assumeTrue(NativeIO.isAvailable());
  Assume.assumeTrue(SystemUtils.IS_OS_UNIX);
  File path = new File(TEST_BASE, "testCleanupRemainders");
  path.mkdirs();
  String remainder1 = path.getAbsolutePath() + 
      Path.SEPARATOR + "woot2_remainder1";
  String remainder2 = path.getAbsolutePath() +
      Path.SEPARATOR + "woot2_remainder2";
  createTempFile(remainder1);
  createTempFile(remainder2);
  SharedFileDescriptorFactory.create("woot2_", 
      new String[] { path.getAbsolutePath() });
  // creating the SharedFileDescriptorFactory should have removed 
  // the remainders
  Assert.assertFalse(new File(remainder1).exists());
  Assert.assertFalse(new File(remainder2).exists());
  FileUtil.fullyDelete(path);
}
项目:alfresco-bulk-filesystem-import    文件:AbstractBulkFilesystemImporter.java   
/**
 * Determines whether the given file is located in the given file content store.
 * @param fileContentStore The file content store to check <i>(must not be null)</i>.
 * @param source           The file to check <i>(must not be null)</i>.
 * @return True if the given file is in an Alfresco managed content store, false otherwise.
 */
private final boolean isInContentStore(final FileContentStore fileContentStore, final File source)
{
    boolean result            = false;
    String  storeRootLocation = fileContentStore.getRootLocation();
    String  sourcePath        = source.getAbsolutePath();   // Note: we don't use getCanonicalPath here because it dereferences symlinks (which we don't want)

    // Case insensitive comparison on Windows
    if (SystemUtils.IS_OS_WINDOWS)
    {
        result = sourcePath.toLowerCase().startsWith(storeRootLocation.toLowerCase());
    }
    else
    {
        result = sourcePath.startsWith(storeRootLocation);
    }

    return(result);
}
项目:alfresco-bulk-filesystem-import    文件:AbstractBulkFilesystemImporter.java   
private final String normaliseFilename(final String filename)
{
    String result = null;

    if (filename != null)
    {
        result = filename.replaceAll("\\\\", "/");  // Normalise all path separators to Unix-style (note: quadruple escaping is indeed required!)
        result = result.replaceAll("/+", "/");      // De-dupe duplicate separators

        // Ensure case insensitive comparison on Windows
        if (SystemUtils.IS_OS_WINDOWS)
        {
            result = result.toLowerCase();
        }
    }

    return(result);
}
项目:incubator-rya    文件:AccumuloInstanceDriver.java   
/**
 * Copies the HADOOP_HOME bin directory to the {@link MiniAccumuloCluster} temp directory.
 * {@link MiniAccumuloCluster} expects to find bin/winutils.exe in the MAC temp
 * directory instead of HADOOP_HOME for some reason.
 * @throws IOException
 */
private void copyHadoopHomeToTemp() throws IOException {
    if (IS_COPY_HADOOP_HOME_ENABLED && SystemUtils.IS_OS_WINDOWS) {
        final String hadoopHomeEnv = PathUtils.clean(System.getenv("HADOOP_HOME"));
        if (hadoopHomeEnv != null) {
            final File hadoopHomeDir = new File(hadoopHomeEnv);
            if (hadoopHomeDir.exists()) {
                final File binDir = Paths.get(hadoopHomeDir.getAbsolutePath(), "/bin").toFile();
                if (binDir.exists()) {
                    FileUtils.copyDirectoryToDirectory(binDir, tempDir);
                } else {
                    log.warn("The specified path for the Hadoop bin directory does not exist: " + binDir.getAbsolutePath());
                }
            } else {
                log.warn("The specified path for HADOOP_HOME does not exist: " + hadoopHomeDir.getAbsolutePath());
            }
        } else {
            log.warn("The HADOOP_HOME environment variable was not found.");
        }
    }
}
项目:incubator-rya    文件:AccumuloInstanceDriver.java   
/**
 * Copies the HADOOP_HOME bin directory to the {@link MiniAccumuloCluster} temp directory.
 * {@link MiniAccumuloCluster} expects to find bin/winutils.exe in the MAC temp
 * directory instead of HADOOP_HOME for some reason.
 * @throws IOException
 */
private void copyHadoopHomeToTemp() throws IOException {
    if (IS_COPY_HADOOP_HOME_ENABLED && SystemUtils.IS_OS_WINDOWS) {
        final String hadoopHomeEnv = PathUtils.clean(System.getenv("HADOOP_HOME"));
        if (hadoopHomeEnv != null) {
            final File hadoopHomeDir = new File(hadoopHomeEnv);
            if (hadoopHomeDir.exists()) {
                final File binDir = Paths.get(hadoopHomeDir.getAbsolutePath(), "/bin").toFile();
                if (binDir.exists()) {
                    FileUtils.copyDirectoryToDirectory(binDir, tempDir);
                } else {
                    log.warn("The specified path for the Hadoop bin directory does not exist: " + binDir.getAbsolutePath());
                }
            } else {
                log.warn("The specified path for HADOOP_HOME does not exist: " + hadoopHomeDir.getAbsolutePath());
            }
        } else {
            log.warn("The HADOOP_HOME environment variable was not found.");
        }
    }
}