mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Unignore condition tests
This commit is contained in:
parent
a4cb09c4eb
commit
4a60e3ccf6
@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.condition;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -45,6 +47,19 @@ public class ConditionalOnBeanTests {
|
||||
assertEquals("bar", this.context.getBean("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNameAndTypeOnBeanCondition() {
|
||||
this.context.register(FooConfiguration.class,
|
||||
OnBeanNameAndTypeConfiguration.class);
|
||||
this.context.refresh();
|
||||
/*
|
||||
* Arguably this should be true, but as things are implemented the conditions
|
||||
* specified in the different attributes of @ConditionalOnBean are combined with
|
||||
* logical OR (not AND) so if any of them match the condition is true.
|
||||
*/
|
||||
assertFalse(this.context.containsBean("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNameOnBeanConditionReverseOrder() {
|
||||
this.context.register(OnBeanNameConfiguration.class, FooConfiguration.class);
|
||||
@ -94,6 +109,15 @@ public class ConditionalOnBeanTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(name = "foo", value = Date.class)
|
||||
protected static class OnBeanNameAndTypeConfiguration {
|
||||
@Bean
|
||||
public String bar() {
|
||||
return "bar";
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(annotation = EnableScheduling.class)
|
||||
protected static class OnAnnotationConfiguration {
|
||||
|
@ -95,13 +95,13 @@ public class ConditionalOnClassTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ImportResource("org/springframework/boot/context/foo.xml")
|
||||
@ImportResource("org/springframework/boot/autoconfigure/condition/foo.xml")
|
||||
protected static class XmlConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import(BasicConfiguration.class)
|
||||
@ImportResource("org/springframework/boot/context/foo.xml")
|
||||
@ImportResource("org/springframework/boot/autoconfigure/condition/foo.xml")
|
||||
protected static class CombinedXmlConfiguration {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user