public Utils() { this.shellFactory = new Shell.Factory(); this.str = new Str(); this.streams = new Streams(); this.threads = new Threads(); this.files = new Files(shellFactory, File.separatorChar, streams); }
public void testSetters() { shell.setRuntime(new RuntimeI.Default()); shell.setEnvironment(new String[0]); shell.setWorkingDir(new Files().testDir()); shell.run(); assertTrue(shell.hasReturned()); int rv = shell.returnCode(); // this is _not_ a prefect test. // With some JVMs we get '1', others we get '0' .... // however if the "java" command is missing we get 127 on most unix assertEquals("" + rv, true, rv == 1 || rv == 0); }
public void testSetters() { shell.setRuntime(new RuntimeI.Default()); shell.setEnvironment(new String[0]); shell.setWorkingDir(new FileUtil().tmp()); shell.run(); assertTrue(shell.hasReturned()); assertEquals(1, shell.returnCode()); }
public void testDestroy() throws Exception { processSleep = 2000; assertNull(testProcess); shell.start(); new Threads().pause(20); shell.destroyProcess(); assertEquals(1, testProcess.destroyCalled); }
public ProcessUtil(String pid, PrintStream out, PrintStream err) { this(new FileUtil(), pid, out, err, new Str(), new Shell.Factory(), new Streams(), new Threads()); }
public void testDoubleRun() { processSleep = 2000; shell.start(); new Threads().pause(20); Exception expected = null; try { shell.run(); } catch (IllegalStateException e) { expected = e; } assertNotNull(expected); }
public void testIsRunning() { String pid = "5234"; ProcessUtil kp = new ProcessUtil(pid, null, null); String[] args = kp.isRunningArgs(); new TestUtil().assertContainsIgnoreCase(args[0], "kill"); assertEquals("-0", args[1]); assertEquals(pid, args[2]); }
public void testNullSafeEquals() throws Exception { Equals equals = new Equals(); assertTrue(equals.nullSafe("a", "a")); assertTrue(equals.nullSafe(null, null)); assertFalse(equals.nullSafe("a", "b")); assertFalse(equals.nullSafe("a", null)); assertFalse(equals.nullSafe(null, "a")); } }
public void testGetAndGetDefault() throws Exception { assertEquals("bar", map.getDefault("foo")); assertEquals("baz", map.get("foo")); assertEquals("unchanged", map.get("stay")); }
public void testShellThrowsIfNotYetReturned() { assertFalse(shell.hasReturned()); Exception expected = null; try { shell.returnCode(); } catch (Exception e) { expected = e; } assertNotNull("Should have throws", expected); }
protected void setUp() { super.setUp(); processSleep = 0; String[] commandLineArgs = new String[] { "java" }; String threadName = "ShellTest" + shellName++; shell = new Shell.Default(commandLineArgs, threadName, System.out, System.err); setRuntime(0); }
protected void setUp() { super.setUp(); fileUtil = new FileUtil(); shellFactory = new Shell.Factory(); }
public void testStub() throws Exception { new TestUtil().assertObjStubsInterface(new RuntimeI.Stub(), RuntimeI.class); } }
public Utils() { this.shellFactory = new Shell.Factory(); this.str = new Str(); this.streams = new Streams(); this.threads = new Threads(); this.files = new Files(shellFactory, File.separatorChar, streams); }
public void testDestroy() throws Exception { processSleep = 2000; assertNull(testProcess); shell.start(); new Threads().pause(20); shell.destroyProcess(); assertEquals(1, testProcess.destroyCalled); }
public void testDoubleRun() { processSleep = 2000; shell.start(); new Threads().pause(20); Exception expected = null; try { shell.run(); } catch (IllegalStateException e) { expected = e; } assertNotNull(expected); }
public void testIsRunning() { String pid = "5234"; ProcessUtil kp = new ProcessUtil(pid, devNull, devNull, dir); String[] args = kp.isRunningArgs(); testUtil.assertContainsIgnoreCase(args[0], "kill"); assertEquals("-0", args[1]); assertEquals(pid, args[2]); }
protected void setUp() { super.setUp(); processSleep = 0; String[] commandLineArgs = new String[] { "java" }; String threadName = "ShellTest" + shellName++; shell = new Shell.Default(commandLineArgs, threadName, System.out, System.err); setRuntime(0); }