use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestScanBinary method testConfigFile.
@Test
public void testConfigFile() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("scanbinary.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("binary", 0b110101);
Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf);
@SuppressWarnings("unchecked") Map<String, Number> value = (Map<String, Number>) sent.get("binary");
Assert.assertEquals(0b101, value.get("a").intValue());
Assert.assertEquals(0b10, value.get("b").intValue());
Assert.assertEquals(0b1, value.get("c").intValue());
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestScript method testJs.
@Test
public void testJs() throws IOException, ProcessorException {
Script s = new loghub.processors.Script();
URL scripturl = getClass().getClassLoader().getResource("script.js");
s.setScript(scripturl.getFile());
Assert.assertTrue("Script engine for Javascript not found", s.configure(new Properties(Collections.emptyMap())));
Event e = Tools.getEvent();
s.process(e);
Assert.assertTrue("event not transformed", (Boolean) e.get("done"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestScript method testPython.
@Test
public void testPython() throws IOException, ProcessorException {
Script s = new loghub.processors.Script();
URL scripturl = getClass().getClassLoader().getResource("script.py");
s.setScript(scripturl.getFile());
Assert.assertTrue("Script engine for Python not found", s.configure(new Properties(Collections.emptyMap())));
Event e = Tools.getEvent();
s.process(e);
Assert.assertTrue("event not transformed", (Boolean) e.get("done"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestScript method enumerateScript.
@Test
public void enumerateScript() {
Properties props = new Properties(Collections.emptyMap());
ScriptEngineManager factory = new ScriptEngineManager(props.classloader);
factory.getEngineFactories().stream().forEach(i -> {
Assert.assertNotNull(i.getScriptEngine());
logger.debug("{}/{}: {}/{}", () -> i.getEngineName(), () -> i.getEngineVersion(), () -> i.getLanguageName(), () -> i.getLanguageVersion());
});
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class Tools method loadConf.
public static Properties loadConf(String configname, boolean dostart) throws ConfigException, IOException {
String conffile = Configuration.class.getClassLoader().getResource(configname).getFile();
Properties props = Configuration.parse(conffile);
for (Pipeline pipe : props.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(props));
}
return props;
}
Aggregations