@Test public void testEnvironmentModification() { Map<String, String> processEnvironment = Maps.newHashMap(); processEnvironment.put("foo", "bar"); processEnvironment.put("bletch", "spam"); processEnvironment.put("spam", "blorg"); Map<String, String> modificationEnvironment = Maps.newHashMap(); modificationEnvironment.put("foo", "yowza"); modificationEnvironment.put("hiya", "there"); modificationEnvironment.put("spam", null); runner.modifyEnvironment(processEnvironment, modificationEnvironment); Assert.assertEquals("yowza", processEnvironment.get("foo")); Assert.assertEquals("spam", processEnvironment.get("bletch")); Assert.assertEquals("there", processEnvironment.get("hiya")); Assert.assertFalse(processEnvironment.containsKey("spam")); }
@VisibleForTesting void modifyEnvironment(Map<String, String> processEnvironment, Map<String, String> modificationEnvironment) { for (Entry<String, String> entry : modificationEnvironment.entrySet()) { String value = entry.getValue(); if (value != null) { processEnvironment.put(entry.getKey(), value); } else { processEnvironment.remove(entry.getKey()); } } }
BaseNativeApplicationRunner implements NativeApplicationRunner { @VisibleForTesting void modifyEnvironment(Map<String, String> processEnvironment, Map<String, String> modificationEnvironment) { for (Entry<String, String> entry : modificationEnvironment.entrySet()) { String value = entry.getValue(); if (value != null) { processEnvironment.put(entry.getKey(), value); } else { processEnvironment.remove(entry.getKey()); } } } }
BaseNativeApplicationRunner implements NativeApplicationRunner { @VisibleForTesting void modifyEnvironment(Map<String, String> processEnvironment, Map<String, String> modificationEnvironment) { for (Entry<String, String> entry : modificationEnvironment.entrySet()) { String value = entry.getValue(); if (value != null) { processEnvironment.put(entry.getKey(), value); } else { processEnvironment.remove(entry.getKey()); } } } BaseNativeApplicationRunner(NativeApplicationRunnerParser runnerParser,
      InteractiveSpacesEnvironment spaceEnvironment, Log log); }
BaseNativeApplicationRunner implements NativeApplicationRunner { @VisibleForTesting void modifyEnvironment(Map<String, String> processEnvironment, Map<String, String> modificationEnvironment) { for (Entry<String, String> entry : modificationEnvironment.entrySet()) { String value = entry.getValue(); if (value != null) { processEnvironment.put(entry.getKey(), value); } else { processEnvironment.remove(entry.getKey()); } } } BaseNativeApplicationRunner(NativeApplicationRunnerParser runnerParser,
      InteractiveSpacesEnvironment spaceEnvironment, Log log); @Override void setCleanEnvironment(boolean cleanEnvironment); @Override NativeApplicationRunner setExecutablePath(String executablePath); @Override NativeApplicationRunner addEnvironmentVariables(Map<String, String> environmentVariables); @Override NativeApplicationRunner addCommandArguments(String... arguments); @Override NativeApplicationRunner parseCommandArguments(String arguments); @Override NativeApplicationRunner parseEnvironment(String variables); @Override void configure(NativeApplicationDescription description); @SuppressWarnings("unchecked") @Override void configure(Map<String, Object> config); @Override void startup(); @Override void shutdown(); @Override boolean isRunning(); @Override NativeApplicationRunnerState getState(); abstract boolean handleProcessExit(int exitValue, String[] commands); @Override void attemptRestart(); @Override boolean isRestarted(); @Override void restartComplete(boolean success); @Override void setRestartStrategy(RestartStrategy<NativeApplicationRunner> restartStrategy); @Override RestartStrategy<NativeApplicationRunner> getRestartStrategy(); @Override void setRestartDurationMaximum(long restartDurationMaximum); @Override void addNativeApplicationRunnerListener(NativeApplicationRunnerListener listener); @Override void removeNativeApplicationRunnerListener(NativeApplicationRunnerListener listener); String[] getCommandLine(); Map<String, String> getEnvironment(); InteractiveSpacesEnvironment getSpaceEnvironment(); Log getLog(); }
BaseNativeApplicationRunner implements NativeApplicationRunner { @VisibleForTesting void modifyEnvironment(Map<String, String> processEnvironment, Map<String, String> modificationEnvironment) { for (Entry<String, String> entry : modificationEnvironment.entrySet()) { String value = entry.getValue(); if (value != null) { processEnvironment.put(entry.getKey(), value); } else { processEnvironment.remove(entry.getKey()); } } } BaseNativeApplicationRunner(NativeApplicationRunnerParser runnerParser,
      InteractiveSpacesEnvironment spaceEnvironment, Log log); @Override void setCleanEnvironment(boolean cleanEnvironment); @Override NativeApplicationRunner setExecutablePath(String executablePath); @Override NativeApplicationRunner addEnvironmentVariables(Map<String, String> environmentVariables); @Override NativeApplicationRunner addCommandArguments(String... arguments); @Override NativeApplicationRunner parseCommandArguments(String arguments); @Override NativeApplicationRunner parseEnvironment(String variables); @Override void configure(NativeApplicationDescription description); @SuppressWarnings("unchecked") @Override void configure(Map<String, Object> config); @Override void startup(); @Override void shutdown(); @Override boolean isRunning(); @Override NativeApplicationRunnerState getState(); abstract boolean handleProcessExit(int exitValue, String[] commands); @Override void attemptRestart(); @Override boolean isRestarted(); @Override void restartComplete(boolean success); @Override void setRestartStrategy(RestartStrategy<NativeApplicationRunner> restartStrategy); @Override RestartStrategy<NativeApplicationRunner> getRestartStrategy(); @Override void setRestartDurationMaximum(long restartDurationMaximum); @Override void addNativeApplicationRunnerListener(NativeApplicationRunnerListener listener); @Override void removeNativeApplicationRunnerListener(NativeApplicationRunnerListener listener); String[] getCommandLine(); Map<String, String> getEnvironment(); InteractiveSpacesEnvironment getSpaceEnvironment(); Log getLog(); static final int RESTART_DURATION_MAXIMUM_DEFAULT; }