Fix test method names
This commit is contained in:
parent
1afcb22205
commit
c70a6d3be1
|
@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
public class TestBeanTests {
|
||||
|
||||
@Test
|
||||
void contextCustomizerCannotBeCreatedWithNoSuchBeanName() {
|
||||
void cannotOverrideBeanByNameWithNoSuchBeanName() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBean("anotherBean", String.class, () -> "example");
|
||||
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
|
||||
|
@ -45,7 +45,19 @@ public class TestBeanTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void contextCustomizerCannotBeCreatedWithNoSuchBeanType() {
|
||||
void cannotOverrideBeanByNameWithBeanOfWrongType() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBean("beanToOverride", Integer.class, () -> 42);
|
||||
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(context::refresh)
|
||||
.withMessage("""
|
||||
Unable to override bean: there is no bean definition \
|
||||
to replace with name [beanToOverride] and type [java.lang.String].""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void cannotOverrideBeanByTypeWithNoSuchBeanType() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByTypeLookup.class, context);
|
||||
assertThatIllegalStateException()
|
||||
|
@ -57,7 +69,7 @@ public class TestBeanTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void contextCustomizerCannotBeCreatedWithTooManyBeansOfThatType() {
|
||||
void cannotOverrideBeanByTypeWithTooManyBeansOfThatType() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBean("bean1", String.class, () -> "example1");
|
||||
context.registerBean("bean2", String.class, () -> "example2");
|
||||
|
@ -70,18 +82,6 @@ public class TestBeanTests {
|
|||
String.class.getName(), FailureByTypeLookup.class.getSimpleName(), List.of("bean1", "bean2")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextCustomizerCannotBeCreatedWithBeanOfWrongType() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.registerBean("beanToOverride", Integer.class, () -> 42);
|
||||
BeanOverrideContextCustomizerTestUtils.customizeApplicationContext(FailureByNameLookup.class, context);
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(context::refresh)
|
||||
.withMessage("""
|
||||
Unable to override bean: there is no bean definition \
|
||||
to replace with name [beanToOverride] and type [java.lang.String].""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextCustomizerCannotBeCreatedWithMissingOverrideMethod() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
@ -124,9 +124,10 @@ public class TestBeanTests {
|
|||
.formatted(FailureCompetingOverrideMethods.class.getName(), String.class.getName()));
|
||||
}
|
||||
|
||||
static class FailureByTypeLookup {
|
||||
|
||||
@TestBean(enforceOverride = true)
|
||||
static class FailureByNameLookup {
|
||||
|
||||
@TestBean(name = "beanToOverride", enforceOverride = true)
|
||||
private String example;
|
||||
|
||||
static String example() {
|
||||
|
@ -134,9 +135,9 @@ public class TestBeanTests {
|
|||
}
|
||||
}
|
||||
|
||||
static class FailureByNameLookup {
|
||||
static class FailureByTypeLookup {
|
||||
|
||||
@TestBean(name = "beanToOverride", enforceOverride = true)
|
||||
@TestBean(enforceOverride = true)
|
||||
private String example;
|
||||
|
||||
static String example() {
|
||||
|
|
Loading…
Reference in New Issue