@Test
public void testListConsumers() {

    // First need to create a topic.
    final String topicName = "AnotherTestTopic-" + System.currentTimeMillis();
    // Create topic
    sharedKafkaTestResource
        .getKafkaTestUtils()
        .createTopic(topicName, 1, (short) 1);
    // Publish data into the topic
    sharedKafkaTestResource
        .getKafkaTestUtils()
        .produceRecords(10, topicName, 0);
    final String consumerId1 = "ConsumerA";
    final String consumerId2 = "ConsumerB";
    final String consumerPrefix = "TestConsumer";
    consumeFromTopicAndClose(topicName, consumerId1, consumerPrefix);
    consumeFromTopicAndClose(topicName, consumerId2, consumerPrefix);
    // Ask for list of consumers.
    final List<ConsumerGroupIdentifier> consumerIds = kafkaOperations.listConsumers();
    // We should have two
    assertTrue("Should have at least 2 consumers listed", consumerIds.size() >= 2);
    // Results may contain other consumer groups, look for ours.
    boolean foundGroup1 = false;
    boolean foundGroup2 = false;
    for (final ConsumerGroupIdentifier foundConsumerGroupIds : consumerIds) {
        if (foundConsumerGroupIds.getId().equals(consumerPrefix + "-" + consumerId1)) {
            foundGroup1 = true;
        } else if (foundConsumerGroupIds.getId().equals(consumerPrefix + "-" + consumerId2)) {
            foundGroup2 = true;
        }
    }
    assertTrue("Found consumer group 1", foundGroup1);
    assertTrue("Found consumer group 2", foundGroup2);
}