protected TestFile addProcess(String processName, Class<?> clazz, int debugPort, boolean suspend)
     throws UnknownHostException {
   master.addProcess(
       processName,
       TestProcessUtils.createCommand(
           processName, clazz.getName(), master.getPort(), debugPort, suspend),
       System.getenv(),
       ".");
   processes.add(processName);
   return TestFileUtils.getOutputFile(processName);
 }
 protected void stopTestProcessListenerAndWait(TestProcessListenerStream listener)
     throws InterruptedException {
   WaitForStopProcessListener stopListener = new WaitForStopProcessListener();
   master.registerStopProcessListener(listener.getProcessName(), stopListener);
   testManager.stopProcessListener(listener.getProcessName());
   stopListener.waitForStop();
 }
 @After
 public void afterTest() {
   if (master != null) master.shutdown();
   if (testManager != null) testManager.shutdown();
   master = null;
   testManager = null;
   processes.clear();
   stoppedProcesses.clear();
   System.err.println("*Test - afterTest() - end");
 }
 protected void sendStdin(String recipient, String msg) {
   try {
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     new DataOutputStream(out).writeUTF(msg);
     out.flush();
     master.sendStdin(recipient, out.toByteArray());
   } catch (UnsupportedEncodingException e) {
   } catch (IOException e) {
   }
 }
  @Before
  public void beforeTest() throws IOException, UnknownHostException {
    testManager =
        TestProcessUtils.createStreamManager(
            new TestProcessController() {

              @Override
              public void stopProcess(String processName) {
                master.stopProcess(processName);
              }

              @Override
              public void startProcess(String processName) {
                master.startProcess(processName);
              }
            });

    master = new ProcessManagerMaster(InetAddress.getLocalHost(), 12967);
    master.start();
    TestFileUtils.cleanFiles();
  }
 protected List<String> getProcessNames(boolean onlyStarted) {
   return master.getProcessNames(onlyStarted);
 }
 protected void broadcastMessage(String sender, String msg) {
   master.broadcastMessage(sender, msg.getBytes());
 }
 protected void broadcastMessage(String sender, byte[] msg) {
   master.broadcastMessage(sender, msg);
 }
 protected void sendMessage(String sender, String recipient, String msg) {
   master.sendMessage(sender, recipient, msg.getBytes());
 }
 protected void sendMessage(String sender, String recipient, byte[] msg) {
   master.sendMessage(sender, recipient, msg);
 }
 protected void removeProcess(String name) {
   master.removeProcess(name);
 }
 protected ProcessExitCodeAndShutDownLatch getStopTestProcessListenerLatch(String processName) {
   WaitForStopProcessListener stopListener = new WaitForStopProcessListener();
   master.registerStopProcessListener(processName, stopListener);
   return new ProcessExitCodeAndShutDownLatch(stopListener);
 }
 protected void startProcess(String name, int waitMs) throws InterruptedException {
   master.startProcess(name);
   Thread.sleep(waitMs);
   processes.add(name);
   stoppedProcesses.remove(name);
 }