|
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. |
|
50 | 50 | import org.springframework.kafka.config.KafkaListenerContainerFactory; |
51 | 51 | import org.springframework.kafka.config.KafkaStreamsConfiguration; |
52 | 52 | import org.springframework.kafka.config.StreamsBuilderFactoryBean; |
| 53 | +import org.springframework.kafka.core.ConsumerFactory; |
53 | 54 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; |
54 | 55 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; |
55 | 56 | import org.springframework.kafka.core.KafkaAdmin; |
@@ -569,6 +570,16 @@ void testConcurrentKafkaListenerContainerFactoryWithKafkaTemplate() { |
569 | 570 | }); |
570 | 571 | } |
571 | 572 |
|
| 573 | + @Test |
| 574 | + void testConcurrentKafkaListenerContainerFactoryWithCustomConsumerFactory() { |
| 575 | + this.contextRunner.withUserConfiguration(ConsumerFactoryConfiguration.class).run((context) -> { |
| 576 | + ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory = context |
| 577 | + .getBean(ConcurrentKafkaListenerContainerFactory.class); |
| 578 | + assertThat(kafkaListenerContainerFactory.getConsumerFactory()) |
| 579 | + .isNotSameAs(context.getBean(ConsumerFactoryConfiguration.class).consumerFactory); |
| 580 | + }); |
| 581 | + } |
| 582 | + |
572 | 583 | @Configuration(proxyBeanMethods = false) |
573 | 584 | static class MessageConverterConfiguration { |
574 | 585 |
|
@@ -633,6 +644,18 @@ AfterRollbackProcessor<Object, Object> afterRollbackProcessor() { |
633 | 644 |
|
634 | 645 | } |
635 | 646 |
|
| 647 | + @Configuration(proxyBeanMethods = false) |
| 648 | + static class ConsumerFactoryConfiguration { |
| 649 | + |
| 650 | + private final ConsumerFactory<String, Object> consumerFactory = mock(ConsumerFactory.class); |
| 651 | + |
| 652 | + @Bean |
| 653 | + ConsumerFactory<String, Object> myConsumerFactory() { |
| 654 | + return this.consumerFactory; |
| 655 | + } |
| 656 | + |
| 657 | + } |
| 658 | + |
636 | 659 | @Configuration(proxyBeanMethods = false) |
637 | 660 | static class RecordInterceptorConfiguration { |
638 | 661 |
|
|
0 commit comments