Search in sources :

Example 56 with ParserConfigurations

use of org.apache.metron.common.configuration.ParserConfigurations in project metron by apache.

the class KafkaWriterTest method createConfiguration.

public WriterConfiguration createConfiguration(final Map<String, Object> parserConfig) {
    ParserConfigurations configurations = new ParserConfigurations();
    configurations.updateSensorParserConfig(SENSOR_TYPE, new SensorParserConfig() {

        {
            setParserConfig(parserConfig);
        }
    });
    return new ParserWriterConfiguration(configurations);
}
Also used : ParserConfigurations(org.apache.metron.common.configuration.ParserConfigurations) ParserWriterConfiguration(org.apache.metron.common.configuration.writer.ParserWriterConfiguration) SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig)

Example 57 with ParserConfigurations

use of org.apache.metron.common.configuration.ParserConfigurations in project metron by apache.

the class ParserRunnerImplTest method setup.

@BeforeEach
@SuppressWarnings("unchecked")
public void setup() throws IOException {
    parserConfigurations = new ParserConfigurations();
    SensorParserConfig broConfig = SensorParserConfig.fromBytes(broConfigString.getBytes(StandardCharsets.UTF_8));
    SensorParserConfig snortConfig = SensorParserConfig.fromBytes(snortConfigString.getBytes(StandardCharsets.UTF_8));
    parserConfigurations.updateSensorParserConfig("bro", broConfig);
    parserConfigurations.updateSensorParserConfig("snort", snortConfig);
    parserConfigurations.updateGlobalConfig(JSONUtils.INSTANCE.load(globalConfigString, JSONUtils.MAP_SUPPLIER));
    parserRunner = new ParserRunnerImpl(new HashSet<>(Arrays.asList("bro", "snort")));
    broParser = mock(MessageParser.class);
    snortParser = mock(MessageParser.class);
    stellarFilter = mock(StellarFilter.class);
    // mockStatic(ReflectionUtils.class);
    // mockStatic(Filters.class);
    when(broParser.getReadCharset()).thenReturn(StandardCharsets.UTF_8);
// when(ReflectionUtils.createInstance("org.apache.metron.parsers.bro.BasicBroParser")).thenReturn(broParser);
// when(ReflectionUtils.createInstance("org.apache.metron.parsers.snort.BasicSnortParser")).thenReturn(snortParser);
// when(Filters.get("org.apache.metron.parsers.filters.StellarFilter", broConfig.getParserConfig()))
// .thenReturn(stellarFilter);
}
Also used : MessageParser(org.apache.metron.parsers.interfaces.MessageParser) ParserConfigurations(org.apache.metron.common.configuration.ParserConfigurations) StellarFilter(org.apache.metron.parsers.filters.StellarFilter) SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ParserConfigurations (org.apache.metron.common.configuration.ParserConfigurations)57 Test (org.junit.jupiter.api.Test)33 BaseBoltTest (org.apache.metron.test.bolt.BaseBoltTest)25 JSONObject (org.json.simple.JSONObject)24 SensorParserConfig (org.apache.metron.common.configuration.SensorParserConfig)20 Test (org.junit.Test)13 SensorParserGroup (org.apache.metron.common.configuration.SensorParserGroup)9 ParserWriterConfiguration (org.apache.metron.common.configuration.writer.ParserWriterConfiguration)8 Tuple (org.apache.storm.tuple.Tuple)8 IOException (java.io.IOException)7 BulkWriterResponse (org.apache.metron.common.writer.BulkWriterResponse)7 MetronError (org.apache.metron.common.error.MetronError)6 MetronErrorJSONMatcher (org.apache.metron.test.error.MetronErrorJSONMatcher)6 IndexingConfigurations (org.apache.metron.common.configuration.IndexingConfigurations)5 Context (org.apache.metron.stellar.dsl.Context)5 HashMap (java.util.HashMap)4 RawMessage (org.apache.metron.common.message.metadata.RawMessage)4 RestException (org.apache.metron.rest.RestException)4 TopologyContext (org.apache.storm.task.TopologyContext)4 Map (java.util.Map)3