GH-1110 - Register AssertablePublishedEvents in ApplicationContext if AssertJ is on the classpath.
We now check for the presence of AssertJ on the classpath and rather register an instance of ApplicationPublishedEvents in the ApplicationContext if present.
This commit is contained in:
@@ -21,9 +21,12 @@ import example.module.SampleTestA;
|
||||
import example.module.SampleTestB;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.modulith.core.ApplicationModule;
|
||||
import org.springframework.modulith.core.ApplicationModuleIdentifier;
|
||||
import org.springframework.modulith.test.ModuleContextCustomizerFactory.ModuleContextCustomizer;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ModuleTypeExcludeFilter}.
|
||||
@@ -65,4 +68,18 @@ class ModuleContextCustomizerUnitTests {
|
||||
assertThat(right).isEqualTo(left);
|
||||
assertThat(left).hasSameHashCodeAs(right);
|
||||
}
|
||||
|
||||
@Test // GH-1110
|
||||
void registersAssertablePublishedEvents() {
|
||||
|
||||
var context = new AnnotationConfigApplicationContext();
|
||||
var loader = new AnnotationConfigContextLoader();
|
||||
|
||||
new ModuleContextCustomizer(SampleTestA.class)
|
||||
.customizeContext(context, new MergedContextConfiguration(SampleTestA.class, null, null, null, loader));
|
||||
|
||||
assertThat(context.getApplicationListeners()).hasSize(1)
|
||||
.element(0)
|
||||
.isInstanceOf(AssertablePublishedEvents.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user