diff --git a/pom.xml b/pom.xml index 9a692b2..03c510e 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,12 @@ influxdb-java 2.7 + + junit + junit + 4.12 + test + diff --git a/src/main/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporter.java b/src/main/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporter.java index bb41f78..3218e0f 100644 --- a/src/main/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporter.java +++ b/src/main/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporter.java @@ -50,7 +50,7 @@ public synchronized void startReporter(long pollingPeriodSecs) { if (initialized && !running) { reporter.start(pollingPeriodSecs, TimeUnit.SECONDS); running = true; - LOG.info("Started Kafka Graphite metrics reporter with polling period {} seconds", pollingPeriodSecs); + LOG.info("Started Kafka InfluxDB metrics reporter with polling period {} seconds", pollingPeriodSecs); } } diff --git a/src/test/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporterTest.java b/src/test/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporterTest.java new file mode 100644 index 0000000..3070e71 --- /dev/null +++ b/src/test/java/com/github/jasper/kafka/KafkaInfluxDBMetricsReporterTest.java @@ -0,0 +1,38 @@ +package com.github.jasper.kafka; + +import kafka.utils.VerifiableProperties; + +import java.util.Properties; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class KafkaInfluxDBMetricsReporterTest { + + @Test + public void initWithoutPropertiesSet() { + KafkaInfluxDBMetricsReporter reporter = new KafkaInfluxDBMetricsReporter(); + reporter.init(new VerifiableProperties()); + } + + @Test + public void initStartStopWithPropertiesSet() { + KafkaInfluxDBMetricsReporter reporter = new KafkaInfluxDBMetricsReporter(); + Properties properties = new Properties(); + properties.setProperty("kafka.graphite.metrics.reporter.enabled", "true"); + + reporter.init(new VerifiableProperties(properties)); + + reporter.startReporter(1L); + reporter.stopReporter(); + } + + + @Test + public void getMBeanName() { + KafkaInfluxDBMetricsReporter reporter = new KafkaInfluxDBMetricsReporter(); + assertEquals("kafka:type=com.github.jasper.kafka.KafkaInfluxDBMetricsReporter", reporter.getMBeanName()); + + } +}