MCPcopy Index your code
hub / github.com/oshi/oshi / ExecutingCommandTest

Class ExecutingCommandTest

oshi-core/src/test/java/oshi/util/ExecutingCommandTest.java:42–59  ·  view source on GitHub ↗

Test command line and returning the result of execution.

Source from the content-addressed store, hash-verified

40 * Test command line and returning the result of execution.
41 */
42class ExecutingCommandTest {
43
44 private static final String ECHO = SystemInfo.getCurrentPlatform().equals(PlatformEnum.WINDOWS)
45 ? "cmd.exe /C echo Test"
46 : "echo Test";
47 private static final String BAD_COMMAND = "noOSshouldHaveACommandNamedThis";
48
49 @Test
50 void testRunNative() {
51 List<String> test = ExecutingCommand.runNative(ECHO);
52 assertThat("echo output", test, hasSize(1));
53 assertThat("echo output", test.get(0), is("Test"));
54 assertThat("echo first answer", ExecutingCommand.getFirstAnswer(ECHO), is("Test"));
55
56 assertThat("bad command", ExecutingCommand.runNative(BAD_COMMAND), is(empty()));
57 assertThat("bad command first answer", ExecutingCommand.getFirstAnswer(BAD_COMMAND), is(emptyString()));
58 }
59}

Callers

nothing calls this directly

Calls 1

getCurrentPlatformMethod · 0.95

Tested by

no test coverage detected