@Test publicvoid testRuntimeExecWithArray() throws Exception {
Process process = Runtime.getRuntime().exec(CMD_ARRAY, null, new File(TEST_CLASSES));
verifyProcessOutput(process);
}
@Test publicvoid testRuntimeExecWithString() throws Exception {
String cmd = String.join(" ", CMD_ARRAY);
@SuppressWarnings("deprecation")
Process process = Runtime.getRuntime().exec(cmd, null, new File(TEST_CLASSES));
verifyProcessOutput(process);
}
// Verify the process has executed by comparing its output with the expected privatevoid verifyProcessOutput(Process process) throws Exception {
process.waitFor();
assertTrue(process.exitValue() == 0);
try (BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream()))) {
String line = reader.readLine(); if (!line.startsWith(TEST_CLASSES)) {
String error = String.format("Expected process output first line: " + "'%s' Actual: '%s'", TEST_CLASSES, line); thrownew Exception(error);
}
}
}
// This class main will be the entry point for test subprocesses staticclass SimpleProcess { publicstaticvoid main (String[] args) throws Exception {
File dir = new File(".");
System.out.println(dir.getCanonicalPath());
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.