EnvSet envset = new EnvSet();
envset.setLoadenvironment(true);
envset.addEnv(var);
// envset.addEnv(var2);
ProcessTester server = new ProcessTester();
XhExecBgTask task = new XhExecBgTask();
task.setProject(project);
task.setExecutable(JVM);
task.createArg().setValue("-cp");
Path classpath = new Path(project, getClassPath());
task.createArg().setPath(classpath);
task.createArg().setLine(ProcessTester.class.getName());
task.createArg().setLine("-p " + server.getPort());
task.createArg().setLine("-s user.dir");
task.createArg().setLine("-t 60");
task.setUseLauncher(true);
task.addEnvset(envset);
task.enableLogging(buffer, 0, 1);
try {
task.execute();
// wait 2sec for process to start
Thread.sleep(2000);
assertTrue("Process is not running", task.isRunning());
assertTrue("Process is not running", server.passed());
assertEquals("Wrong user dir",
System.getProperty("user.dir"),
server.getReceivedData());
Thread.sleep(500);
task.kill();
assertTrue("Process is still running", !task.isRunning());
// assertContains("Wrong commandline", "async_exec_launcher", task.getCommandline());
// assertEquals("Wrong stderr", "Welcome stderr!", buffer.toString(1));