import de.juplo.kafka.chat.backend.implementation.kafka.*;
import lombok.extern.slf4j.Slf4j;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.kafka.common.TopicPartition;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.kafka.core.KafkaTemplate;
-import org.springframework.kafka.support.SendResult;
import org.springframework.kafka.test.context.EmbeddedKafka;
-import java.util.List;
-
import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.DATA_TOPIC;
import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.INFO_TOPIC;
"chat.backend.kafka.data-channel-topic=" + DATA_TOPIC,
"chat.backend.kafka.num-partitions=10",
})
+@Import(KafkaTestUtils.KafkaTestConfiguration.class)
@EmbeddedKafka(
topics = { INFO_TOPIC, DATA_TOPIC },
partitions = 10)
{
KafkaTestUtils.joinConsumerTasks(consumerTaskRunner);
}
-
-
- @TestConfiguration
- @EnableConfigurationProperties(ChatBackendProperties.class)
- @Import(KafkaServicesConfiguration.class)
- static class KafkaConfigurationITConfiguration
- {
- @Bean
- WorkAssignor dataChannelWorkAssignor(DataChannel dataChannel)
- {
- return consumer ->
- {
- List<TopicPartition> assignedPartitions =
- List.of(new TopicPartition(DATA_TOPIC, 2));
- consumer.assign(assignedPartitions);
- dataChannel.onPartitionsAssigned(assignedPartitions);
- };
- }
- }
}
@TestConfiguration
@EnableConfigurationProperties(ChatBackendProperties.class)
@Import(KafkaServicesConfiguration.class)
- static class KafkaTestConfiguration
+ public static class KafkaTestConfiguration
{
@Bean
- WorkAssignor dataChannelWorkAssignor(
+ public WorkAssignor dataChannelWorkAssignor(
ChatBackendProperties properties,
DataChannel dataChannel)
{
return consumer ->
{
List<TopicPartition> assignedPartitions =
- List.of(new TopicPartition(properties.getKafka().getInfoChannelTopic(), 2));
+ List.of(new TopicPartition(properties.getKafka().getDataChannelTopic(), 2));
consumer.assign(assignedPartitions);
dataChannel.onPartitionsAssigned(assignedPartitions);
};
}
@Bean
- Clock clock()
+ public Clock clock()
{
return Clock.systemDefaultZone();
}