use of org.apache.metron.common.configuration.writer.WriterConfiguration in project metron by apache.
the class KafkaWriterTest method testHappyPathGlobalConfig.
@Test
public void testHappyPathGlobalConfig() throws Exception {
KafkaWriter writer = new KafkaWriter();
WriterConfiguration configuration = createConfiguration(new HashMap<String, Object>() {
{
put("kafka.brokerUrl", "localhost:6667");
put("kafka.topic", SENSOR_TYPE);
put("kafka.producerConfigs", ImmutableMap.of("key1", 1, "key2", "value2"));
}
});
writer.configure(SENSOR_TYPE, configuration);
Map<String, Object> producerConfigs = writer.createProducerConfigs();
Assert.assertEquals(producerConfigs.get("bootstrap.servers"), "localhost:6667");
Assert.assertEquals(producerConfigs.get("key.serializer"), "org.apache.kafka.common.serialization.StringSerializer");
Assert.assertEquals(producerConfigs.get("value.serializer"), "org.apache.kafka.common.serialization.StringSerializer");
Assert.assertEquals(producerConfigs.get("request.required.acks"), 1);
Assert.assertEquals(producerConfigs.get("key1"), 1);
Assert.assertEquals(producerConfigs.get("key2"), "value2");
}
use of org.apache.metron.common.configuration.writer.WriterConfiguration in project metron by apache.
the class KafkaWriterTest method testHappyPathGlobalConfigWithPrefix.
@Test
public void testHappyPathGlobalConfigWithPrefix() throws Exception {
KafkaWriter writer = new KafkaWriter();
writer.withConfigPrefix("prefix");
WriterConfiguration configuration = createConfiguration(new HashMap<String, Object>() {
{
put("prefix.kafka.brokerUrl", "localhost:6667");
put("prefix.kafka.topic", SENSOR_TYPE);
put("prefix.kafka.producerConfigs", ImmutableMap.of("key1", 1, "key2", "value2"));
}
});
writer.configure(SENSOR_TYPE, configuration);
Map<String, Object> producerConfigs = writer.createProducerConfigs();
Assert.assertEquals(producerConfigs.get("bootstrap.servers"), "localhost:6667");
Assert.assertEquals(producerConfigs.get("key.serializer"), "org.apache.kafka.common.serialization.StringSerializer");
Assert.assertEquals(producerConfigs.get("value.serializer"), "org.apache.kafka.common.serialization.StringSerializer");
Assert.assertEquals(producerConfigs.get("request.required.acks"), 1);
Assert.assertEquals(producerConfigs.get("key1"), 1);
Assert.assertEquals(producerConfigs.get("key2"), "value2");
}
Aggregations