public Default(String[] args, String name, PrintStream out, PrintStream err) { this.me = new Thread(this, name); /* Think of this just as if this were an extension of Thread */ /* * To avoid mysterious NullPointerExceptions, don't try to .start() * this thread here in the constructor. The RULE is: we must not * allow any other thread to obtain a reference to a * partly-constructed object. Since we pass a 'this' pointer in, if * we were to start the other thread, that very RULE could be * violated. */ this.args = args; this.out = out; this.err = err; this.envp = null; this.workingDir = null; this.returnCode = null; this.listeners = new ArrayList(); this.exceptions = new Exceptions(); this.runtime = new RuntimeI.Default(); }
public Default(String[] args, String name, PrintStream out, PrintStream err) { this.me = new Thread(this, name); /* Think of this just as if this were an extension of Thread */ /* * Don't try to .start() this thread here in the constructor. The * RULE is: you must not allow any other thread to obtain a * reference to a partly-constructed object. Since we pass a 'this' * pointer in, if we were to start the other thread, that very RULE * could be violated. */ this.args = args; this.out = out; this.err = err; this.envp = null; this.workingDir = null; this.returnCode = null; this.listeners = new ArrayList(); this.exceptions = new Exceptions(); this.runtime = new RuntimeI.Default(); }
public void testSome() { Runtime realRuntime = Runtime.getRuntime(); RuntimeI runtime = new RuntimeI.Default(); assertEquals(realRuntime.availableProcessors(), runtime .availableProcessors()); assertEquals(realRuntime.freeMemory(), runtime.freeMemory()); assertEquals(realRuntime.maxMemory(), runtime.maxMemory()); assertEquals(realRuntime.totalMemory(), runtime.totalMemory()); }
public Default(String[] args, String name, PrintStream out, PrintStream err) { super(name); this.args = args; this.out = out; this.err = err; this.envp = null; this.workingDir = null; this.returnCode = null; this.listeners = new ArrayList(); this.exceptions = new Exceptions(); this.runtime = new RuntimeI.Default(); }
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 testImplemented() { Runtime realRuntime = Runtime.getRuntime(); RuntimeI runtime = new RuntimeI.Default(); assertEquals(realRuntime.availableProcessors(), runtime .availableProcessors()); assertEquals(realRuntime.freeMemory(), runtime.freeMemory()); assertEquals(realRuntime.maxMemory(), runtime.maxMemory()); assertEquals(realRuntime.totalMemory(), runtime.totalMemory()); }
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); }