TonyJob extends HadoopJavaJob { @Override protected List<String> getClassPaths() { List<String> classPath = super.getClassPaths(); classPath.add(tonyConfFile.getParent()); return classPath; } TonyJob(String jobid, Props sysProps, Props jobProps, Logger log); Configuration getTonyJobConf(); @Override void run(); @Override String getJavaClass(); static final String HADOOP_OPTS; static final String HADOOP_GLOBAL_OPTS; static final String WORKER_ENV_PREFIX; static final String TONY_APPLICATION_TAGS; }
@Test public void testClassPaths() { final Props sysProps = new Props(); final Props jobProps = new Props(); jobProps.put(TonyJob.WORKING_DIR, FilenameUtils.getFullPath(FileIOUtils.getSourcePathFromClass(Props.class))); sysProps.put("jobtype.classpath", "123,456,789"); sysProps.put("plugin.dir", "Plugins"); final TonyJob tonyJob = new TonyJob("test_tony_job_class_path", sysProps, jobProps, log) { @Override public String getWorkingDirectory() { return System.getProperty("java.io.tmpdir"); } }; List<String> paths = tonyJob.getClassPaths(); int counter = 0; for (String path : paths) { if (path.contains("Plugins/123") || path.contains("Plugins/456") || path.contains("Plugins/789")) { counter += 1; } } Assert.assertTrue(counter == 3); Assert.assertTrue(paths.contains(new File(tonyJob.getWorkingDirectory(), "_tony-conf-test_tony_job_class_path").toString())); }