Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-zhang committed Jan 11, 2018
1 parent 885c32d commit 3128d29
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
<artifactId>influxdb-java</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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());

}
}

0 comments on commit 3128d29

Please sign in to comment.