Search in sources :

Example 1 with ConsumerFactory

use of org.springframework.kafka.core.ConsumerFactory in project loc-framework by lord-of-code.

the class LocKafkaTest method testConsumer.

@Test
@SuppressWarnings("unchecked")
public void testConsumer() throws Exception {
    assertThat(concurrentKafkaListenerContainerFactory).isNotNull();
    ContainerProperties containerProperties = concurrentKafkaListenerContainerFactory.getContainerProperties();
    assertThat(containerProperties).isNotNull();
    assertThat(containerProperties.getGenericErrorHandler()).isNotNull();
    assertThat(containerProperties.getAckMode()).isEqualTo(AckMode.RECORD);
    ConsumerFactory consumerFactory = concurrentKafkaListenerContainerFactory.getConsumerFactory();
    assertThat(consumerFactory).isNotNull();
    assertThat(consumerFactory.getConfigurationProperties()).isNotNull();
    assertThat(consumerFactory.getConfigurationProperties()).isNotNull();
    assertThat(consumerFactory.getConfigurationProperties().get("group.id")).isEqualTo("loc-kafka-unittest");
    assertThat(consumerFactory.getConfigurationProperties().get("bootstrap.servers")).isEqualTo(Lists.newArrayList("127.0.0.1:9092"));
    assertThat(consumerFactory.getConfigurationProperties().get("enable.auto.commit")).isEqualTo(false);
    assertThat(consumerFactory.getConfigurationProperties().get("key.deserializer")).isEqualTo(org.apache.kafka.common.serialization.ByteArrayDeserializer.class);
    assertThat(consumerFactory.getConfigurationProperties().get("value.deserializer")).isEqualTo(org.apache.kafka.common.serialization.ByteArrayDeserializer.class);
}
Also used : ConsumerFactory(org.springframework.kafka.core.ConsumerFactory) ContainerProperties(org.springframework.kafka.listener.config.ContainerProperties) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Aggregations

Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1 ConsumerFactory (org.springframework.kafka.core.ConsumerFactory)1 ContainerProperties (org.springframework.kafka.listener.config.ContainerProperties)1