Apps { public static void setEnvFromInputString(Map<String, String> env, String envString, String classPathSeparator) { if (envString != null && envString.length() > 0) { Matcher varValMatcher = VARVAL_SPLITTER.matcher(envString); while (varValMatcher.find()) { String envVar = varValMatcher.group(1); String varString = varValMatcher.group(2); setEnvFromString(env, envVar, varString, classPathSeparator); } } }  static ApplicationId toAppID(String aid); static ApplicationId toAppID(String prefix, String s, Iterator<String> it); static void shouldHaveNext(String prefix, String s, Iterator<String> it); static void throwParseException(String name, String s); static void setEnvFromInputString(Map<String, String> env,
      String envString,  String classPathSeparator); static void setEnvFromInputProperty(Map<String, String> env,
      String propName, String defaultPropValue, Configuration conf,
      String classPathSeparator); static Set<String> getEnvVarsFromInputProperty(
      String propName, String defaultPropValue, Configuration conf); @Deprecated static void setEnvFromInputString(Map<String, String> env,
      String envString); @Public @Unstable static void addToEnvironment(
      Map<String, String> environment,
      String variable, String value, String classPathSeparator); @Deprecated static void addToEnvironment(
      Map<String, String> environment,
      String variable, String value); static String crossPlatformify(String var); @Private @Unstable static boolean shouldCountTowardsNodeBlacklisting(int exitStatus); static boolean isApplicationFinalState(YarnApplicationState appState); static final String APP; static final String ID; }
@Test public void testSetEnvFromInputString() { Map<String, String> environment = new HashMap<String, String>(); environment.put("JAVA_HOME", "/path/jdk"); String goodEnv = "a1=1,b_2=2,_c=3,d=4,e=,f_win=%JAVA_HOME%" + ",g_nix=$JAVA_HOME"; Apps.setEnvFromInputString(environment, goodEnv, File.pathSeparator); assertEquals("1", environment.get("a1")); assertEquals("2", environment.get("b_2")); assertEquals("3", environment.get("_c")); assertEquals("4", environment.get("d")); assertEquals("", environment.get("e")); if (Shell.WINDOWS) { assertEquals("$JAVA_HOME", environment.get("g_nix")); assertEquals("/path/jdk", environment.get("f_win")); } else { assertEquals("/path/jdk", environment.get("g_nix")); assertEquals("%JAVA_HOME%", environment.get("f_win")); } String badEnv = "1,,2=a=b,3=a=,4==,5==a,==,c-3=3,="; environment.clear(); Apps.setEnvFromInputString(environment, badEnv, File.pathSeparator); assertThat(environment).isEmpty(); environment.clear(); Apps.setEnvFromInputString(environment, "b1,e1==,e2=a1=a2,b2", File.pathSeparator); assertEquals("=", environment.get("e1")); assertEquals("a1=a2", environment.get("e2")); }