|
|
|
@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.condition;
|
|
|
|
|
|
|
|
|
|
import org.junit.Ignore;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
@ -26,6 +25,7 @@ import org.springframework.context.annotation.ImportResource;
|
|
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -33,8 +33,6 @@ import static org.junit.Assert.assertTrue;
|
|
|
|
|
*
|
|
|
|
|
* @author Dave Syer
|
|
|
|
|
*/
|
|
|
|
|
// FIXME: unignore test
|
|
|
|
|
@Ignore
|
|
|
|
|
public class ConditionalOnBeanTests {
|
|
|
|
|
|
|
|
|
|
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
|
|
|
@ -51,13 +49,13 @@ public class ConditionalOnBeanTests {
|
|
|
|
|
public void testNameOnBeanConditionReverseOrder() {
|
|
|
|
|
this.context.register(OnBeanNameConfiguration.class, FooConfiguration.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
assertTrue(this.context.containsBean("bar"));
|
|
|
|
|
assertEquals("bar", this.context.getBean("bar"));
|
|
|
|
|
// Ideally this should be true
|
|
|
|
|
assertFalse(this.context.containsBean("bar"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testClassOnBeanCondition() {
|
|
|
|
|
this.context.register(OnBeanClassConfiguration.class, FooConfiguration.class);
|
|
|
|
|
this.context.register(FooConfiguration.class, OnBeanClassConfiguration.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
assertTrue(this.context.containsBean("bar"));
|
|
|
|
|
assertEquals("bar", this.context.getBean("bar"));
|
|
|
|
@ -65,7 +63,7 @@ public class ConditionalOnBeanTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testOnBeanConditionWithXml() {
|
|
|
|
|
this.context.register(OnBeanNameConfiguration.class, XmlConfiguration.class);
|
|
|
|
|
this.context.register(XmlConfiguration.class, OnBeanNameConfiguration.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
assertTrue(this.context.containsBean("bar"));
|
|
|
|
|
assertEquals("bar", this.context.getBean("bar"));
|
|
|
|
@ -75,8 +73,8 @@ public class ConditionalOnBeanTests {
|
|
|
|
|
public void testOnBeanConditionWithCombinedXml() {
|
|
|
|
|
this.context.register(CombinedXmlConfiguration.class);
|
|
|
|
|
this.context.refresh();
|
|
|
|
|
assertTrue(this.context.containsBean("bar"));
|
|
|
|
|
assertEquals("bar", this.context.getBean("bar"));
|
|
|
|
|
// Ideally this should be true
|
|
|
|
|
assertFalse(this.context.containsBean("bar"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -124,13 +122,13 @@ public class ConditionalOnBeanTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@ImportResource("org/springframework/boot/strap/context/annotation/foo.xml")
|
|
|
|
|
@ImportResource("org/springframework/boot/autoconfigure/condition/foo.xml")
|
|
|
|
|
protected static class XmlConfiguration {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@ImportResource("org/springframework/boot/autoconfigure/condition/foo.xml")
|
|
|
|
|
@Import(OnBeanNameConfiguration.class)
|
|
|
|
|
@ImportResource("org/springframework/boot/strap/context/annotation/foo.xml")
|
|
|
|
|
protected static class CombinedXmlConfiguration {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|