LongLivedProcess implements Runnable { public void setEnv(String envVar, String val) { Preconditions.checkArgument(envVar != null, "envVar"); Preconditions.checkArgument(val != null, "val"); processBuilder.environment().put(envVar, val); } LongLivedProcess(String name,
      Logger processLog,
      List<String> commands); void setRecentLineLimit(int recentLineLimit); void setLifecycleCallback(LongLivedProcessLifecycleEvent lifecycleCallback); void setEnv(String envVar, String val); void putEnvMap(Map<String, String> map); String getEnv(String variable); void setProcessLog(Logger processLog); Process getProcess(); ProcessBuilder getProcessBuilder(); List<String> getCommands(); String getCommand(); boolean isRunning(); Integer getExitCode(); Integer getExitCodeSignCorrected(); void stop(); void dumpEnv(StringBuilder buffer); @Override // Runnable void run(); void start(); synchronized List<String> getRecentOutput(); synchronized boolean isRecentOutputEmpty(); boolean isFinalOutputProcessed(); List<String> getRecentOutput(boolean finalOutput, int duration); static final int RECENT_LINE_LOG_LIMIT; }
@Test public void testSetenv() throws Throwable { String var = "TEST_RUN"; String val = "TEST-RUN-ENV-VALUE"; initProcess(commandFactory.env()); process.setEnv(var, val); process.start(); process.run(); assertTrue("process stop callback not received", stopped); assertEquals(0, process.getExitCode().intValue()); assertStringInOutput(val, getFinalOutput()); }