### Question:
CommandUtils { public static CommandResult execute(List<String> commands) { return execute(commands, 10000); } private  CommandUtils(); static CommandResult execute(List<String> commands); static CommandResult execute(List<String> commands, long timeout); static CommandResult execute(List<String> commands, List<String> stdins); static CommandResult execute(List<String> commands, List<String> stdins, long timeout);  }### Answer:
@Test @Ignore public void testExecute() { List<String> commands = new ArrayList<String>(); commands.add("C:\\WINDOWS\\system32\\ping.exe"); commands.add("localhost"); CommandResult result = CommandUtils.execute(commands); assertEquals(0, result.getExitValue()); assertTrue(result.getStdouts().size() > 0); }
@Test @Ignore public void testExecute2() { List<String> commands = new ArrayList<String>(); commands.add("C:\\WINDOWS\\system32\\ping.exe"); commands.add("localhost"); try { CommandUtils.execute(commands, 1000); fail(); } catch (RuntimeException e) { assertTrue(e.getMessage().contains("timeout")); } }
@Test @Ignore public void testExecute3() { List<String> commands = new ArrayList<String>(); commands.add("C:\\WINDOWS\\system32\\nslookup.exe"); List<String> stdins = new ArrayList<String>(); stdins.add("exit"); CommandResult result = CommandUtils.execute(commands, stdins); assertEquals(0, result.getExitValue()); assertTrue(result.getStdouts().size() > 0); }