Revert "AnnotationConfigRegistry exposes registerBean with supplier/qualifiers"

This reverts commit 18f2e6a1
This commit is contained in:
Juergen Hoeller
2019-04-02 14:55:13 +02:00
parent a94868158e
commit 03bda29032
5 changed files with 18 additions and 297 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@@ -83,54 +82,6 @@ public class AnnotationConfigWebApplicationContextTests {
assertThat(ctx.containsBean("custom-myConfig"), is(true));
}
@Test
@SuppressWarnings("resource")
public void registerBean() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.registerBean(TestBean.class);
ctx.refresh();
assertTrue(ctx.getBeanFactory().containsSingleton("annotationConfigWebApplicationContextTests.TestBean"));
TestBean bean = ctx.getBean(TestBean.class);
assertNotNull(bean);
}
@Test
@SuppressWarnings("resource")
public void registerBeanWithLazy() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.registerBean(TestBean.class, Lazy.class);
ctx.refresh();
assertFalse(ctx.getBeanFactory().containsSingleton("annotationConfigWebApplicationContextTests.TestBean"));
TestBean bean = ctx.getBean(TestBean.class);
assertNotNull(bean);
}
@Test
@SuppressWarnings("resource")
public void registerBeanWithSupplier() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.registerBean(TestBean.class, TestBean::new);
ctx.refresh();
assertTrue(ctx.getBeanFactory().containsSingleton("annotationConfigWebApplicationContextTests.TestBean"));
TestBean bean = ctx.getBean(TestBean.class);
assertNotNull(bean);
}
@Test
@SuppressWarnings("resource")
public void registerBeanWithSupplierAndLazy() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.registerBean(TestBean.class, TestBean::new, Lazy.class);
ctx.refresh();
assertFalse(ctx.getBeanFactory().containsSingleton("annotationConfigWebApplicationContextTests.TestBean"));
TestBean bean = ctx.getBean(TestBean.class);
assertNotNull(bean);
}
@Configuration("myConfig")
static class Config {