Sync with 3.1.x
* 3.1.x: Demonstrate use of @Configuration as meta-annotation Prune dead code from JmsTransactionManager#doBegin Apply @Configuration BeanNameGenerator consistently Improve @Configuration bean name discovery Fix infinite recursion bug in nested @Configuration Polish static imports Minor fix in ServletResponseMethodArgumentResolver extracted ResourceUtils.useCachesIfNecessary(URLConnection) method (SP prepared for 3.1.1 release CustomSQLExceptionTranslatorRegistry/Registrar etc revised CustomSQLExceptionTranslatorRegistry/Registrar method naming use custom InputStream traversal instead of a full byte array (SPR-911 PathMatchingResourcePatternResolver preserves caching for JNLP jar con Resource "contentLength()" implementations work with OSGi bundle resou fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz
This commit is contained in:
@@ -19,9 +19,16 @@ package org.springframework.web.context.support;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
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 static org.hamcrest.CoreMatchers.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@@ -49,8 +56,24 @@ public class AnnotationConfigWebApplicationContextTests {
|
||||
assertNotNull(bean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withBeanNameGenerator() {
|
||||
AnnotationConfigWebApplicationContext ctx =
|
||||
new AnnotationConfigWebApplicationContext();
|
||||
ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() {
|
||||
@Override
|
||||
public String generateBeanName(BeanDefinition definition,
|
||||
BeanDefinitionRegistry registry) {
|
||||
return "custom-" + super.generateBeanName(definition, registry);
|
||||
}
|
||||
});
|
||||
ctx.setConfigLocation(Config.class.getName());
|
||||
ctx.refresh();
|
||||
assertThat(ctx.containsBean("custom-myConfig"), is(true));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@Configuration("myConfig")
|
||||
static class Config {
|
||||
@Bean
|
||||
public TestBean myTestBean() {
|
||||
|
||||
Reference in New Issue
Block a user