Merge pull request #13937 from dreis2211:fix-deprecation-kafka-tests

* pr/13937:
  Fix deprecation in KafkaAutoConfigurationIntegrationTests
pull/13933/merge
Stephane Nicoll 6 years ago
commit 3a3e7e31e1

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.KafkaHeaders; import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.kafka.test.rule.KafkaEmbedded; import org.springframework.kafka.test.rule.EmbeddedKafkaRule;
import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Header;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -49,7 +49,7 @@ public class KafkaAutoConfigurationIntegrationTests {
private static final String ADMIN_CREATED_TOPIC = "adminCreatedTopic"; private static final String ADMIN_CREATED_TOPIC = "adminCreatedTopic";
@ClassRule @ClassRule
public static final KafkaEmbedded kafkaEmbedded = new KafkaEmbedded(1, true, public static final EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, true,
TEST_TOPIC); TEST_TOPIC);
private AnnotationConfigApplicationContext context; private AnnotationConfigApplicationContext context;
@ -65,7 +65,7 @@ public class KafkaAutoConfigurationIntegrationTests {
@Test @Test
public void testEndToEnd() throws Exception { public void testEndToEnd() throws Exception {
load(KafkaConfig.class, load(KafkaConfig.class,
"spring.kafka.bootstrap-servers:" + kafkaEmbedded.getBrokersAsString(), "spring.kafka.bootstrap-servers:" + getEmbeddedKafkaBrokersAsString(),
"spring.kafka.consumer.group-id=testGroup", "spring.kafka.consumer.group-id=testGroup",
"spring.kafka.consumer.auto-offset-reset=earliest"); "spring.kafka.consumer.auto-offset-reset=earliest");
KafkaTemplate<String, String> template = this.context KafkaTemplate<String, String> template = this.context
@ -97,6 +97,10 @@ public class KafkaAutoConfigurationIntegrationTests {
return applicationContext; return applicationContext;
} }
private String getEmbeddedKafkaBrokersAsString() {
return embeddedKafka.getEmbeddedKafka().getBrokersAsString();
}
public static class KafkaConfig { public static class KafkaConfig {
@Bean @Bean

Loading…
Cancel
Save