Improve exception message to include affected configuration class

Closes gh-32998
This commit is contained in:
Stéphane Nicoll
2024-06-11 14:23:54 +02:00
parent a6fb7e99a0
commit 89e894205a
2 changed files with 9 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.annotation.Gh23206Tests.ConditionalConfiguration.NestedConfiguration;
import org.springframework.context.annotation.componentscan.simple.SimpleComponent;
import org.springframework.core.type.AnnotatedTypeMetadata;
@@ -39,7 +40,9 @@ public class Gh23206Tests {
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(context::refresh)
.withMessageContaining(ConditionalComponentScanConfiguration.class.getName())
.havingCause().isInstanceOf(ApplicationContextException.class)
.withMessageContaining("Component scan could not be used with conditions in REGISTER_BEAN phase");
.withMessageStartingWith("Component scan for configuration class [")
.withMessageContaining(ConditionalComponentScanConfiguration.class.getName())
.withMessageContaining("could not be used with conditions in REGISTER_BEAN phase");
}
@Test
@@ -49,7 +52,9 @@ public class Gh23206Tests {
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(context::refresh)
.withMessageContaining(ConditionalConfiguration.class.getName())
.havingCause().isInstanceOf(ApplicationContextException.class)
.withMessageContaining("Component scan could not be used with conditions in REGISTER_BEAN phase");
.withMessageStartingWith("Component scan for configuration class [")
.withMessageContaining(NestedConfiguration.class.getName())
.withMessageContaining("could not be used with conditions in REGISTER_BEAN phase");
}