From 588f84aa83d83da90f08144f9a6d8e98e6a43a36 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 24 Jun 2018 20:02:31 +0300 Subject: [PATCH] separate configs --- .../baeldung/{ => config}/scope/AppConfigFunctionBean.java | 3 +-- .../src/main/java/com/baeldung/scope/AppConfig.java | 2 +- .../scope/PrototypeFunctionBeanIntegrationTest.java | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) rename spring-core/src/main/java/com/baeldung/{ => config}/scope/AppConfigFunctionBean.java (89%) diff --git a/spring-core/src/main/java/com/baeldung/scope/AppConfigFunctionBean.java b/spring-core/src/main/java/com/baeldung/config/scope/AppConfigFunctionBean.java similarity index 89% rename from spring-core/src/main/java/com/baeldung/scope/AppConfigFunctionBean.java rename to spring-core/src/main/java/com/baeldung/config/scope/AppConfigFunctionBean.java index 80779b62fd..a3c5445698 100644 --- a/spring-core/src/main/java/com/baeldung/scope/AppConfigFunctionBean.java +++ b/spring-core/src/main/java/com/baeldung/config/scope/AppConfigFunctionBean.java @@ -1,8 +1,7 @@ -package com.baeldung.scope; +package com.baeldung.config.scope; import java.util.function.Function; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; diff --git a/spring-core/src/main/java/com/baeldung/scope/AppConfig.java b/spring-core/src/main/java/com/baeldung/scope/AppConfig.java index 18c53fee15..948cd60375 100644 --- a/spring-core/src/main/java/com/baeldung/scope/AppConfig.java +++ b/spring-core/src/main/java/com/baeldung/scope/AppConfig.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; @Configuration -@ComponentScan("com.baeldung.scope") +@ComponentScan(value="com.baeldung.scope") public class AppConfig { @Bean diff --git a/spring-core/src/test/java/com/baeldung/scope/PrototypeFunctionBeanIntegrationTest.java b/spring-core/src/test/java/com/baeldung/scope/PrototypeFunctionBeanIntegrationTest.java index 6c2309d86f..1e3c652599 100644 --- a/spring-core/src/test/java/com/baeldung/scope/PrototypeFunctionBeanIntegrationTest.java +++ b/spring-core/src/test/java/com/baeldung/scope/PrototypeFunctionBeanIntegrationTest.java @@ -9,19 +9,18 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; -import com.baeldung.factorybean.FactoryBeanAppConfig; +import com.baeldung.config.scope.AppConfigFunctionBean; import com.baeldung.scope.prototype.PrototypeBean; import com.baeldung.scope.singletone.SingletonFunctionBean; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = FactoryBeanAppConfig.class) +@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = AppConfigFunctionBean.class) public class PrototypeFunctionBeanIntegrationTest { - @Test public void givenPrototypeInjection_WhenFunction_ThenNewInstanceReturn() { - AbstractApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); + AbstractApplicationContext context = new AnnotationConfigApplicationContext(AppConfigFunctionBean.class); SingletonFunctionBean firstContext = context.getBean(SingletonFunctionBean.class); SingletonFunctionBean secondContext = context.getBean(SingletonFunctionBean.class);