public void testCompletionListener() { Exception expected = null; try { shell.addCompletionListener(null); } catch (IllegalArgumentException e) { expected = e; } assertNotNull(expected); class TestListener implements Runnable { int timesRun = 0; public void run() { timesRun++; } } TestListener listener = new TestListener(); shell.addCompletionListener(listener); shell.run(); for (int c = 0; c < 5 && (listener.timesRun == 0); c++) { new Threads().pause(10); } assertEquals(1, listener.timesRun); }
public void testCompletionListener() { Exception expected = null; try { shell.addCompletionListener(null); } catch (IllegalArgumentException e) { expected = e; } assertNotNull(expected); class TestListener implements Runnable { int timesRun = 0; public void run() { timesRun++; } } TestListener listener = new TestListener(); shell.addCompletionListener(listener); shell.run(); for (int c = 0; c < 5 && (listener.timesRun == 0); c++) { new Threads().pause(10); } assertEquals(1, listener.timesRun); }
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 testForThrownExceptions() throws Exception { shell = new Shell.Default(null, "foo", null, null); Exception expected = null; try { shell.run(); } catch (Exception e) { expected = e; } assertNotNull(expected); }
public void testShellReturnsWithReturnCode() { int returnCode = 7; setRuntime(returnCode); shell.run(); assertTrue(shell.hasReturned()); assertEquals(returnCode, shell.returnCode()); }
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 testForThrownExceptions() throws Exception { shell = new Shell.Default(null, "foo", null, null); Exception expected = null; try { shell.run(); } catch (Exception e) { expected = e; } assertNotNull(expected); }
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 testShellReturnsWithReturnCode() { int returnCode = 7; setRuntime(returnCode); shell.run(); assertTrue(shell.hasReturned()); assertEquals(returnCode, shell.returnCode()); }
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); }