ServiceClient extends AppAdminClient implements SliderExitCodes,
    YarnServiceConstants { @VisibleForTesting protected Map<String, String> addAMEnv() throws IOException { Map<String, String> env = new HashMap<>(); ClasspathConstructor classpath = buildClasspath( YarnServiceConstants.SUBMITTED_CONF_DIR, "lib", fs, getConfig().get(YarnServiceConf.YARN_SERVICE_CLASSPATH, ""), getConfig().getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)); env.put("CLASSPATH", classpath.buildClasspath()); env.put("LANG", "en_US.UTF-8"); env.put("LC_ALL", "en_US.UTF-8"); env.put("LANGUAGE", "en_US.UTF-8"); String jaas = System.getenv("HADOOP_JAAS_DEBUG"); if (jaas != null) { env.put("HADOOP_JAAS_DEBUG", jaas); } if (!UserGroupInformation.isSecurityEnabled()) { String userName = UserGroupInformation.getCurrentUser().getUserName(); LOG.debug("Run as user {}", userName); env.put("HADOOP_USER_NAME", userName); } LOG.debug("AM env: \n{}", stringifyMap(env)); return env; }  Service loadAppJsonFromLocalFS(String fileName, String serviceName,
      Long lifetime, String queue); @Override int actionSave(String fileName, String serviceName, Long lifetime,
      String queue); int actionBuild(Service service); @Override int actionUpgradeExpress(String appName, File path); int actionUpgradeExpress(Service service); @Override int initiateUpgrade(String appName, String fileName,
      boolean autoFinalize); int initiateUpgrade(Service service); @Override int actionUpgradeInstances(String appName,
      List<String> componentInstances); @Override int actionUpgradeComponents(String appName,
      List<String> components); @Override int actionCancelUpgrade(String appName); @Override int actionDecommissionInstances(String appName,
      List<String> componentInstances); @Override int actionCleanUp(String appName, String userName); @Override String getInstances(String appName,
      List<String> components, String version, List<String> containerStates); ComponentContainers[] getContainers(String appName,
      List<String> components,
      String version, List<ContainerState> containerStates); int actionUpgrade(Service service, List<Container> compInstances); int actionLaunch(String fileName, String serviceName, Long lifetime,
      String queue); ApplicationId actionCreate(Service service); int actionFlex(String serviceName, Map<String, String>
      componentCountStrings); Map<String, Long> flexByRestService(String serviceName,
      Map<String, Long> componentCounts); @Override int actionStop(String serviceName); int actionStop(String serviceName, boolean waitForAppStopped); @Override int actionDestroy(String serviceName); static File compressFiles(Collection<File> files, File output,
      String bundleRoot); @Override int actionStart(String serviceName); ApplicationId actionStartAndGetId(String serviceName); String updateLifetime(String serviceName, long lifetime); ServiceState convertState(YarnApplicationState state); @Override String getStatusString(String appIdOrName); Service getStatus(String serviceName); YarnClient getYarnClient(); int enableFastLaunch(String destinationFolder); int actionDependency(String destinationFolder, boolean overwrite); synchronized ApplicationId getAppId(String serviceName);  }
@Test public void testAMEnvCustomClasspath() throws Exception { Service service = createService(); service.getComponents().forEach(comp -> comp.setRestartPolicy(Component.RestartPolicyEnum.NEVER)); ServiceClient client = MockServiceClient.create(rule, service, true); String oldParam = client.getConfig().get("yarn.service.classpath", ""); String originalPath = client.addAMEnv().get("CLASSPATH"); client.getConfig().set("yarn.service.classpath", "{{VAR_1}},{{VAR_2}}"); String newPath = client.addAMEnv().get("CLASSPATH"); Assert.assertEquals(originalPath + "<CPS>{{VAR_1}}<CPS>{{VAR_2}}", newPath); client.getConfig().set("yarn.service.classpath", oldParam); newPath = client.addAMEnv().get("CLASSPATH"); Assert.assertEquals(originalPath, newPath); client.stop(); }