@Test (timeout = 120000)
public void testSetClasspath() throws IOException {

  Configuration conf = new Configuration();
  conf.setBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, true);
  Job job = Job.getInstance(conf);
  Map<String, String> environment = new HashMap<String, String>();
  MRApps.setClasspath(environment, job.getConfiguration());
  assertTrue(environment.get(ApplicationConstants.Environment.CLASSPATH.
      name()).startsWith(ApplicationConstants.Environment.PWD.$$()
          + ApplicationConstants.CLASS_PATH_SEPARATOR));
  String yarnAppClasspath = job.getConfiguration().get(
      YarnConfiguration.YARN_APPLICATION_CLASSPATH,
      StringUtils.join(",",
          YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH));
  if (yarnAppClasspath != null) {
    yarnAppClasspath =
        yarnAppClasspath.replaceAll(",\\s*",
          ApplicationConstants.CLASS_PATH_SEPARATOR).trim();
  }
  assertTrue(environment.get(ApplicationConstants.Environment.
      CLASSPATH.name()).contains(yarnAppClasspath));
  String mrAppClasspath =
      job.getConfiguration().get(
          MRJobConfig.MAPREDUCE_APPLICATION_CLASSPATH,
          MRJobConfig.DEFAULT_MAPREDUCE_CROSS_PLATFORM_APPLICATION_CLASSPATH);
  if (mrAppClasspath != null) {
    mrAppClasspath =
        mrAppClasspath.replaceAll(",\\s*",
          ApplicationConstants.CLASS_PATH_SEPARATOR).trim();
  }
  assertTrue(environment.get(ApplicationConstants.Environment.CLASSPATH.
      name()).contains(mrAppClasspath));
}