use of org.apache.commons.exec.launcher.CommandLauncher in project opennms by OpenNMS.
the class MeasurementsRestServiceITCase method assumeRrdtoolExists.
protected static void assumeRrdtoolExists(final String libraryName) {
final String libraryPath = System.getProperty("java.library.path", "");
if (!libraryPath.contains(":/usr/local/lib")) {
System.setProperty("java.library.path", libraryPath + ":/usr/local/lib");
}
boolean rrdtoolExists = false;
try {
final CommandLauncher cl = CommandLauncherFactory.createVMLauncher();
final Process p = cl.exec(new CommandLine(findRrdtool()), EnvironmentUtils.getProcEnvironment());
final int returnCode = p.waitFor();
LOG.debug("Loading library from java.library.path={}", System.getProperty("java.library.path"));
System.loadLibrary(libraryName);
rrdtoolExists = returnCode == 0;
} catch (final Exception e) {
LOG.warn("Failed to run 'rrdtool' or libjrrd(2)? is missing.", e);
}
Assume.assumeTrue(rrdtoolExists);
}
Aggregations