01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.components;
04:
05: import junit.swingui.TestRunner;
06: import fitnesse.testutil.RegexTest;
07:
08: public class CommandRunnerTest extends RegexTest {
09: public static void main(String[] args) {
10: TestRunner.main(new String[] { "CommandRunnerTest" });
11: }
12:
13: public void setUp() throws Exception {
14: }
15:
16: public void tearDown() throws Exception {
17: }
18:
19: public void testBasics() throws Exception {
20: CommandRunner runner = new CommandRunner(
21: "java -cp ./classes fitnesse.testutil.Echo",
22: "echo this!");
23: runner.run();
24: assertHasRegexp("echo this!", runner.getOutput());
25: assertEquals("", runner.getError());
26: assertEquals(false, runner.hasExceptions());
27: assertEquals(0, runner.getExitCode());
28: }
29:
30: public void testClassNotFound() throws Exception {
31: CommandRunner runner = new CommandRunner("java BadClass", null);
32: runner.run();
33: assertHasRegexp("java.lang.NoClassDefFoundError", runner
34: .getError());
35: assertEquals("", runner.getOutput());
36: assertTrue(0 != runner.getExitCode());
37: }
38: }
|