|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -17,12 +17,9 @@ |
|
|
|
package org.springframework.context.annotation; |
|
|
|
package org.springframework.context.annotation; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.beans.factory.BeanCreationException; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.FactoryBean; |
|
|
|
import org.springframework.beans.factory.FactoryBean; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -35,8 +32,7 @@ public class ConfigurationWithFactoryBeanAndAutowiringTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void withConcreteFactoryBeanImplementationAsReturnType() { |
|
|
|
public void withConcreteFactoryBeanImplementationAsReturnType() { |
|
|
|
AnnotationConfigApplicationContext ctx = |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
new AnnotationConfigApplicationContext(); |
|
|
|
|
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(ConcreteFactoryBeanImplementationConfig.class); |
|
|
|
ctx.register(ConcreteFactoryBeanImplementationConfig.class); |
|
|
|
ctx.refresh(); |
|
|
|
ctx.refresh(); |
|
|
|
@ -44,8 +40,7 @@ public class ConfigurationWithFactoryBeanAndAutowiringTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void withParameterizedFactoryBeanImplementationAsReturnType() { |
|
|
|
public void withParameterizedFactoryBeanImplementationAsReturnType() { |
|
|
|
AnnotationConfigApplicationContext ctx = |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
new AnnotationConfigApplicationContext(); |
|
|
|
|
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(ParameterizedFactoryBeanImplementationConfig.class); |
|
|
|
ctx.register(ParameterizedFactoryBeanImplementationConfig.class); |
|
|
|
ctx.refresh(); |
|
|
|
ctx.refresh(); |
|
|
|
@ -53,8 +48,7 @@ public class ConfigurationWithFactoryBeanAndAutowiringTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void withParameterizedFactoryBeanInterfaceAsReturnType() { |
|
|
|
public void withParameterizedFactoryBeanInterfaceAsReturnType() { |
|
|
|
AnnotationConfigApplicationContext ctx = |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
new AnnotationConfigApplicationContext(); |
|
|
|
|
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(ParameterizedFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.register(ParameterizedFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.refresh(); |
|
|
|
ctx.refresh(); |
|
|
|
@ -62,31 +56,27 @@ public class ConfigurationWithFactoryBeanAndAutowiringTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void withNonPublicParameterizedFactoryBeanInterfaceAsReturnType() { |
|
|
|
public void withNonPublicParameterizedFactoryBeanInterfaceAsReturnType() { |
|
|
|
AnnotationConfigApplicationContext ctx = |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
new AnnotationConfigApplicationContext(); |
|
|
|
|
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(NonPublicParameterizedFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.register(NonPublicParameterizedFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.refresh(); |
|
|
|
ctx.refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected=BeanCreationException.class) |
|
|
|
@Test |
|
|
|
public void withRawFactoryBeanInterfaceAsReturnType() { |
|
|
|
public void withRawFactoryBeanInterfaceAsReturnType() { |
|
|
|
AnnotationConfigApplicationContext ctx = |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
new AnnotationConfigApplicationContext(); |
|
|
|
|
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(RawFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.register(RawFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.refresh(); |
|
|
|
ctx.refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected=BeanCreationException.class) |
|
|
|
@Test |
|
|
|
public void withWildcardParameterizedFactoryBeanInterfaceAsReturnType() { |
|
|
|
public void withWildcardParameterizedFactoryBeanInterfaceAsReturnType() { |
|
|
|
AnnotationConfigApplicationContext ctx = |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
new AnnotationConfigApplicationContext(); |
|
|
|
|
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(AppConfig.class); |
|
|
|
ctx.register(WildcardParameterizedFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.register(WildcardParameterizedFactoryBeanInterfaceConfig.class); |
|
|
|
ctx.refresh(); |
|
|
|
ctx.refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|