}
}
@Override
public SeleniumRunOptions initOptions(Computer computer) {
SeleniumRunOptions opt = super.initOptions(computer);
try {
final String filename = "selenium-temp-config-" + System.currentTimeMillis() + ".json";
if (jvmArgs != null) {
Properties p = new Properties();
p.load(new StringReader(jvmArgs.replace("\\", "\\\\")));
for (Entry<Object, Object> e : p.entrySet()) {
opt.getJVMArguments().put(e.getKey().toString(), e.getValue().toString());
}
}
if (seleniumArgs != null) {
for (Object l : IOUtils.readLines(new StringReader(seleniumArgs))) {
String line = (String) l;
if (line.contains(" ")) {
StringUtils.split(line, " ", 2);
} else {
opt.addOption(line);
}
}
}
String fullPath = computer.getNode().getRootPath().act(new FileCallable<String>() {
/**
*
*/
private static final long serialVersionUID = -288688398601004624L;
public String invoke(File f, VirtualChannel channel) throws IOException {
File conf = new File(f, filename);
FilePath urlConf = new FilePath(conf);
try {
urlConf.copyFrom(new ByteArrayInputStream(config.getBytes()));
} catch (InterruptedException e) {
throw new IOException2("Failed to write configuration to " + filename, e);
}
return conf.getAbsolutePath();
}
});
opt.addOptionIfSet("-nodeConfig", fullPath);
return opt;
} catch (Exception e) {
LOGGER.fine("Cannot write the specified configuration on the node. " + e.getMessage());
return null;