ProcessUtil { @Deprecated public static int getCommandExitValue( final List<String> cmdWithArgs ) { if ( cmdWithArgs != null ) { int cmdsLength = cmdWithArgs.size(); if ( cmdsLength > 0 ) { String cmd = ProcessUtil.getCommand( cmdWithArgs ); cmd = maskPassword( cmd ); final Process process = ProcessUtil.execute( cmdWithArgs ); if ( process != null ) { int processId = ProcessUtil.getProcessId( process ); if ( processId != -1 ) { logger.debug( "Command '{}' running as Process: '{}'.", cmd, processId ); } try { logger.info( "Waiting for the command '{}' execution.", cmd ); int status = process.waitFor(); extractOutput( process ); extractException( process ); return status; } catch ( InterruptedException e ) { logger.error( "Error while waiting for the command '{}' execution, exception: {}", cmd, e ); } } } } return -1; } private  ProcessUtil(); @Deprecated static int getCommandExitValue( final List<String> cmdWithArgs ); static int executeCommand( final List<String> cmdWithArgs ); static Process execute( final List<String> cmdWithArgs ); static int getProcessId( Process process );  }
@Test @Ignore public void testgetCommandExitValue() { List<String> cmdWithArgs = new ArrayList<String>(); if ( SystemUtils.IS_OS_LINUX ) { cmdWithArgs.add( 0, "ls" ); } else if ( SystemUtils.IS_OS_WINDOWS ) { cmdWithArgs.add( 0, "dir" ); } cmdWithArgs.add( 1, userHome ); int exitValue = ProcessUtil.getCommandExitValue( cmdWithArgs ); assertTrue( exitValue != -1 ); assertTrue( exitValue == 0 ); cmdWithArgs.remove( 1 ); cmdWithArgs.add( 1, userHome + File.separator + timeInMillis + File.separator + timeInMillis ); exitValue = ProcessUtil.getCommandExitValue( cmdWithArgs ); assertTrue( exitValue != -1 ); assertTrue( exitValue == 1 ); }