|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
48 | 48 | import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
49 | 49 | import org.springframework.kafka.config.KafkaStreamsConfiguration;
|
50 | 50 | import org.springframework.kafka.config.StreamsBuilderFactoryBean;
|
| 51 | +import org.springframework.kafka.core.ConsumerFactory; |
51 | 52 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
|
52 | 53 | import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
53 | 54 | import org.springframework.kafka.core.KafkaAdmin;
|
@@ -476,6 +477,16 @@ public void testConcurrentKafkaListenerContainerFactoryWithKafkaTemplate() {
|
476 | 477 | });
|
477 | 478 | }
|
478 | 479 |
|
| 480 | + @Test |
| 481 | + public void testConcurrentKafkaListenerContainerFactoryWithCustomConsumerFactory() { |
| 482 | + this.contextRunner.withUserConfiguration(ConsumerFactoryConfiguration.class).run((context) -> { |
| 483 | + ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context |
| 484 | + .getBean(ConcurrentKafkaListenerContainerFactory.class); |
| 485 | + assertThat(kafkaListenerContainerFactory.getConsumerFactory()) |
| 486 | + .isNotSameAs(context.getBean(ConsumerFactoryConfiguration.class).consumerFactory); |
| 487 | + }); |
| 488 | + } |
| 489 | + |
479 | 490 | @Configuration
|
480 | 491 | protected static class MessageConverterConfiguration {
|
481 | 492 |
|
@@ -520,6 +531,18 @@ public AfterRollbackProcessor<Object, Object> afterRollbackProcessor() {
|
520 | 531 |
|
521 | 532 | }
|
522 | 533 |
|
| 534 | + @Configuration |
| 535 | + protected static class ConsumerFactoryConfiguration { |
| 536 | + |
| 537 | + private final ConsumerFactory<String, Object> consumerFactory = mock(ConsumerFactory.class); |
| 538 | + |
| 539 | + @Bean |
| 540 | + public ConsumerFactory<String, Object> myConsumerFactory() { |
| 541 | + return this.consumerFactory; |
| 542 | + } |
| 543 | + |
| 544 | + } |
| 545 | + |
523 | 546 | @Configuration
|
524 | 547 | @EnableKafkaStreams
|
525 | 548 | protected static class EnableKafkaStreamsConfiguration {
|
|
0 commit comments