@@ -34,34 +34,33 @@ public class KafkaTestContainersSpringContextCustomizerFactory implements Contex
3434
3535 private Logger log = LoggerFactory.getLogger(KafkaTestContainersSpringContextCustomizerFactory.class);
3636
37- private static KafkaTestContainer kafkaBean;
38-
3937 @Override
4038 public ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes > configAttributes) {
4139
4240 return new ContextCustomizer() {
4341 @Override
4442 public void customizeContext(ConfigurableApplicationContext context,
4543 MergedContextConfiguration mergedConfig) {
46- ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
4744 TestPropertyValues testValues = TestPropertyValues.empty();
4845 EmbeddedKafka kafkaAnnotation = AnnotatedElementUtils.findMergedAnnotation(testClass, EmbeddedKafka.class);
4946 if (null != kafkaAnnotation) {
5047 log.debug("detected the EmbeddedKafka annotation on class {}", testClass.getName());
51- log.info("Warming up the kafka broker");
52- if (null == kafkaBean) {
53- kafkaBean = beanFactory.createBean(KafkaTestContainer.class);
54- beanFactory.registerSingleton(KafkaTestContainer.class.getName(), kafkaBean);
55- }
56- testValues = testValues.and("spring.cloud.stream.kafka.binder.brokers=" + kafkaBean.getKafkaContainer().getHost() + ':' + kafkaBean.getKafkaContainer().getFirstMappedPort());
57- testValues = testValues.and("spring.cloud.stream.enabled=true");
48+ testValues = testValues.and("spring.cloud.function.scan.enabled=true");
49+ testValues = testValues.and("spring.cloud.function.definition=kafkaConsumer;kafkaProducer");
50+ testValues = testValues.and("spring.cloud.stream.bindings.binding-out-0.content-type=text/plain");
51+ testValues = testValues.and("spring.cloud.stream.bindings.binding-out-0.group=<%= dasherizedBaseName %> ");
52+ testValues = testValues.and("spring.cloud.stream.bindings.kafkaConsumer-in-0.destination=sse-topic");
53+ testValues = testValues.and("spring.cloud.stream.bindings.kafkaConsumer-in-0.content-type=text/plain");
54+ testValues = testValues.and("spring.cloud.stream.bindings.kafkaConsumer-in-0.group=<%= dasherizedBaseName %> ");
55+ testValues = testValues.and("spring.cloud.stream.bindings.kafkaProducer-out-0.content-type=text/plain");
56+ testValues = testValues.and("spring.cloud.stream.bindings.kafkaProducer-out-0.group=<%= dasherizedBaseName %> ");
5857 }
5958 testValues.applyTo(context);
6059 }
6160
6261 @Override
6362 public int hashCode() {
64- return KafkaTestContainer .class.getName().hashCode();
63+ return KafkaTestContainersSpringContextCustomizerFactory .class.getName().hashCode();
6564 }
6665
6766 @Override
0 commit comments