Skip to content

Commit 45d51dd

Browse files
committed
GH-149 - Tighten test cases for event publication registry auto-configuration.
Properly test for the activation of the auto-configuration as this seems to have become broken with d9e761e.
1 parent ac52f51 commit 45d51dd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/config/EventPublicationConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
113113
private boolean anyPropertyConfigured(String... properties) {
114114

115115
return Arrays.stream(properties)
116-
.map(it -> environment.containsProperty(it))
117-
.anyMatch(it -> it != null);
116+
.anyMatch(it -> environment.containsProperty(it));
118117
}
119118
}
120119
}

spring-modulith-events/spring-modulith-events-core/src/test/java/org/springframework/modulith/events/config/EventPublicationConfigurationIntegrationTests.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ class EventPublicationConfigurationIntegrationTests {
4848
void registersAsyncTerminationDefaulterByDefault() {
4949

5050
basicSetup()
51-
.run(context -> assertThat(context).hasSingleBean(AsyncPropertiesDefaulter.class));
51+
.run(context -> {
52+
assertThat(context).hasSingleBean(AsyncPropertiesDefaulter.class);
53+
54+
expect(Shutdown::isAwaitTermination, true).andThen(
55+
expect(Shutdown::getAwaitTerminationPeriod, Duration.ofSeconds(2)))
56+
.accept(context);
57+
});
5258
}
5359

5460
@Test // GH-149
@@ -63,7 +69,6 @@ void doesNotRegisterDefaulterIfDisabledExplicitly() {
6369
void doesNotApplyDefaultingIfShutdownTerminationPropertyConfigured() {
6470

6571
basicSetup()
66-
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
6772
.withPropertyValues("spring.task.execution.shutdown.await-termination=false")
6873
.run(expect(Shutdown::isAwaitTermination, false));
6974
}
@@ -72,7 +77,6 @@ void doesNotApplyDefaultingIfShutdownTerminationPropertyConfigured() {
7277
void doesNotApplyDefaultingIfShutdownTerminationPeriodPropertyConfigured() {
7378

7479
basicSetup()
75-
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class))
7680
.withPropertyValues("spring.task.execution.shutdown.await-termination-period=10m")
7781
.run(expect(Shutdown::getAwaitTerminationPeriod, Duration.ofMinutes(10)));
7882
}
@@ -88,7 +92,8 @@ private <T> ContextConsumer<AssertableApplicationContext> expect(Function<Shutdo
8892
private ApplicationContextRunner basicSetup() {
8993

9094
return new ApplicationContextRunner()
91-
.withConfiguration(AutoConfigurations.of(EventPublicationConfiguration.class))
95+
.withConfiguration(
96+
AutoConfigurations.of(EventPublicationConfiguration.class, TaskExecutionAutoConfiguration.class))
9297
.withBean(EventPublicationRepository.class, () -> repository);
9398
}
9499
}

0 commit comments

Comments
 (0)