use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.
the class ParserTopologyCLITest method testSecurityProtocol_fromCLI.
@Test
public void testSecurityProtocol_fromCLI() throws Exception {
testConfigOption(ParserTopologyCLI.ParserOptions.SECURITY_PROTOCOL, "PLAINTEXT", input -> input.getSecurityProtocol().equals("PLAINTEXT"), () -> {
SensorParserConfig config = getBaseConfig();
config.setSecurityProtocol("KERBEROS");
return Collections.singletonList(config);
}, input -> input.getSecurityProtocol().equals("KERBEROS"));
}
use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.
the class ParserTopologyCLITest method testErrorNumTasks.
@Test
public void testErrorNumTasks() throws Exception {
testConfigOption(ParserTopologyCLI.ParserOptions.ERROR_WRITER_NUM_TASKS, "10", input -> input.getErrorNumTasks().equals(10), () -> {
SensorParserConfig config = getBaseConfig();
config.setErrorWriterNumTasks(20);
return Collections.singletonList(config);
}, input -> input.getErrorNumTasks().equals(20));
}
use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.
the class ParserTopologyCLITest method testSpoutConfig.
@Test
public void testSpoutConfig() throws Exception {
File extraConfig = File.createTempFile("spoutConfig", "json");
extraConfig.deleteOnExit();
writeMap(extraConfig, new HashMap<String, Object>() {
{
put("extra_config", "from_file");
}
});
EnumMap<ParserTopologyCLI.ParserOptions, String> cliOptions = new EnumMap<ParserTopologyCLI.ParserOptions, String>(ParserTopologyCLI.ParserOptions.class) {
{
put(ParserTopologyCLI.ParserOptions.SPOUT_CONFIG, extraConfig.getAbsolutePath());
}
};
Predicate<ParserInput> cliOverrideExpected = input -> {
return input.getSpoutConfig().get(0).get("extra_config").equals("from_file");
};
Predicate<ParserInput> configOverrideExpected = input -> {
return input.getSpoutConfig().get(0).get("extra_config").equals("from_zk");
};
Supplier<List<SensorParserConfig>> configSupplier = () -> {
SensorParserConfig config = getBaseConfig();
config.setSpoutConfig(new HashMap<String, Object>() {
{
put("extra_config", "from_zk");
}
});
return Collections.singletonList(config);
};
testConfigOption(cliOptions, cliOverrideExpected, configSupplier, configOverrideExpected);
}
use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.
the class FieldTransformationTest method testSimpleMapping.
@Test
public void testSimpleMapping() throws IOException {
SensorParserConfig c = SensorParserConfig.fromBytes(Bytes.toBytes(config));
FieldTransformer handler = Iterables.getFirst(c.getFieldTransformations(), null);
assertNotNull(handler);
assertEquals(ImmutableMap.of("protocol", "TCP"), handler.transform(new JSONObject(ImmutableMap.of("protocol", 6)), Context.EMPTY_CONTEXT(), c.getParserConfig()));
}
use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.
the class FieldTransformationTest method testValidSerde_simple.
@Test
public void testValidSerde_simple() throws IOException {
SensorParserConfig c = SensorParserConfig.fromBytes(Bytes.toBytes(config));
assertEquals(1, c.getFieldTransformations().size());
assertEquals(IPProtocolTransformation.class, c.getFieldTransformations().get(0).getFieldTransformation().getClass());
assertEquals(ImmutableList.of("protocol"), c.getFieldTransformations().get(0).getInput());
}
Aggregations