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