use of org.apache.kafka.test.MockMetricsReporter in project kafka by apache.
the class KafkaProducerTest method testMetricsReporterAutoGeneratedClientId.
@Test
public void testMetricsReporterAutoGeneratedClientId() {
Properties props = new Properties();
props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
props.setProperty(ProducerConfig.METRIC_REPORTER_CLASSES_CONFIG, MockMetricsReporter.class.getName());
KafkaProducer<String, String> producer = new KafkaProducer<>(props, new StringSerializer(), new StringSerializer());
MockMetricsReporter mockMetricsReporter = (MockMetricsReporter) producer.metrics.reporters().get(0);
assertEquals(producer.getClientId(), mockMetricsReporter.clientId);
producer.close();
}
use of org.apache.kafka.test.MockMetricsReporter in project kafka by apache.
the class KafkaConsumerTest method testMetricsReporterAutoGeneratedClientId.
@Test
public void testMetricsReporterAutoGeneratedClientId() {
Properties props = new Properties();
props.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9999");
props.setProperty(ConsumerConfig.METRIC_REPORTER_CLASSES_CONFIG, MockMetricsReporter.class.getName());
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props, new StringDeserializer(), new StringDeserializer());
MockMetricsReporter mockMetricsReporter = (MockMetricsReporter) consumer.metrics.reporters().get(0);
assertEquals(consumer.getClientId(), mockMetricsReporter.clientId);
consumer.close();
}
Aggregations