Skip to content

Commit 2d0777f

Browse files
committed
Use profile instead of loading file
1 parent 6cf41f2 commit 2d0777f

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

generators/spring-cloud/generators/kafka/templates/src/test/java/_package_/config/KafkaTestContainersSpringContextCustomizerFactory.java.ejs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ package <%= packageName %>.config;
2121
import java.util.List;
2222
import org.slf4j.Logger;
2323
import org.slf4j.LoggerFactory;
24-
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
25-
import org.springframework.boot.test.util.TestPropertyValues;
2624
import org.springframework.context.ConfigurableApplicationContext;
2725
import org.springframework.core.annotation.AnnotatedElementUtils;
28-
import org.springframework.core.env.PropertySource;
29-
import org.springframework.core.io.ClassPathResource;
30-
import org.springframework.boot.env.YamlPropertySourceLoader;
3126
import org.springframework.test.context.ContextConfigurationAttributes;
3227
import org.springframework.test.context.ContextCustomizer;
3328
import org.springframework.test.context.ContextCustomizerFactory;
@@ -47,16 +42,7 @@ public class KafkaTestContainersSpringContextCustomizerFactory implements Contex
4742
EmbeddedKafka kafkaAnnotation = AnnotatedElementUtils.findMergedAnnotation(testClass, EmbeddedKafka.class);
4843
if (null != kafkaAnnotation) {
4944
log.debug("detected the EmbeddedKafka annotation on class {}", testClass.getName());
50-
try {
51-
YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
52-
List<PropertySource<?>> sources = loader.load("application-kafka", new ClassPathResource("config/application-kafka.yml"));
53-
for (PropertySource<?> source : sources) {
54-
context.getEnvironment().getPropertySources().addFirst(source);
55-
}
56-
} catch (Exception e) {
57-
log.error("Failed to load application-kafka.yml", e);
58-
throw new RuntimeException(e);
59-
}
45+
context.getEnvironment().addActiveProfile("kafka");
6046
}
6147
}
6248

0 commit comments

Comments
 (0)