use of org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig in project metron by apache.
the class SimpleHBaseAdapterTest method testMultiColumnFamiliesWrongCF.
@Test
public void testMultiColumnFamiliesWrongCF() throws Exception {
SimpleHBaseAdapter sha = new SimpleHBaseAdapter();
sha.lookup = lookup;
SensorEnrichmentConfig broSc = JSONUtils.INSTANCE.load(sourceConfigStr, SensorEnrichmentConfig.class);
JSONObject actualMessage = sha.enrich(new CacheKey("test", "test", broSc));
Assert.assertEquals(actualMessage, new JSONObject());
actualMessage = sha.enrich(new CacheKey("ip_dst_addr", "10.0.2.4", broSc));
Assert.assertNotNull(actualMessage);
Assert.assertEquals(new JSONObject(new HashMap<String, Object>()), actualMessage);
}
use of org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig in project metron by apache.
the class SimpleHBaseAdapterTest method testEnrich.
@Test
public void testEnrich() throws Exception {
SimpleHBaseAdapter sha = new SimpleHBaseAdapter();
sha.lookup = lookup;
SensorEnrichmentConfig broSc = JSONUtils.INSTANCE.load(sourceConfigStr, SensorEnrichmentConfig.class);
JSONObject actualMessage = sha.enrich(new CacheKey("test", "test", broSc));
Assert.assertEquals(actualMessage, new JSONObject());
actualMessage = sha.enrich(new CacheKey("ip_dst_addr", "10.0.2.3", broSc));
Assert.assertNotNull(actualMessage);
Assert.assertEquals(expectedMessage, actualMessage);
}
use of org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig in project metron by apache.
the class ThreatIntelAdapterTest method testEnrich.
@Test
public void testEnrich() throws Exception {
ThreatIntelAdapter tia = new ThreatIntelAdapter();
tia.lookup = lookup;
SensorEnrichmentConfig broSc = JSONUtils.INSTANCE.load(sourceConfigStr, SensorEnrichmentConfig.class);
JSONObject actualMessage = tia.enrich(new CacheKey("ip_dst_addr", "10.0.2.3", broSc));
Assert.assertNotNull(actualMessage);
Assert.assertEquals(expectedMessage, actualMessage);
}
use of org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig in project metron by apache.
the class ParallelEnricherTest method testCacheHit.
@Test
public void testCacheHit() throws Exception {
numAccesses.set(0);
JSONObject message = new JSONObject() {
{
put(Constants.SENSOR_TYPE, "test");
}
};
for (int i = 0; i < 10; ++i) {
SensorEnrichmentConfig config = JSONUtils.INSTANCE.load(goodConfig, SensorEnrichmentConfig.class);
config.getConfiguration().putIfAbsent("stellarContext", stellarContext);
ParallelEnricher.EnrichmentResult result = enricher.apply(message, EnrichmentStrategies.ENRICHMENT, config, null);
}
// we only want 2 actual instances of the adapter.enrich being run due to the cache.
Assert.assertTrue(2 >= numAccesses.get());
}
use of org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig in project metron by apache.
the class ParallelEnricherTest method testBadConfig.
@Test
public void testBadConfig() throws Exception {
SensorEnrichmentConfig config = JSONUtils.INSTANCE.load(badConfig, SensorEnrichmentConfig.class);
config.getConfiguration().putIfAbsent("stellarContext", stellarContext);
JSONObject message = new JSONObject() {
{
put(Constants.SENSOR_TYPE, "test");
}
};
ParallelEnricher.EnrichmentResult result = enricher.apply(message, EnrichmentStrategies.ENRICHMENT, config, null);
JSONObject ret = result.getResult();
Assert.assertEquals(ret + " is not what I expected", 8, ret.size());
Assert.assertEquals(1, ret.get("map.blah"));
Assert.assertEquals("test", ret.get("source.type"));
Assert.assertEquals(1, ret.get("one"));
Assert.assertEquals(2, ret.get("foo"));
Assert.assertEquals("TEST", ret.get("ALL_CAPS"));
Assert.assertEquals(1, result.getEnrichmentErrors().size());
}
Aggregations