From f12497c18beb7e1156d3143a7d73daab469a4445 Mon Sep 17 00:00:00 2001 From: Raksha Rao Date: Sat, 27 Jan 2018 14:28:19 +0530 Subject: [PATCH] test case minor changes --- .../SampleBeanInjectionTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spring-core/src/test/java/com/baeldung/samplebeaninjectiontypes/SampleBeanInjectionTest.java b/spring-core/src/test/java/com/baeldung/samplebeaninjectiontypes/SampleBeanInjectionTest.java index f054a89a85..fb7234e5c5 100644 --- a/spring-core/src/test/java/com/baeldung/samplebeaninjectiontypes/SampleBeanInjectionTest.java +++ b/spring-core/src/test/java/com/baeldung/samplebeaninjectiontypes/SampleBeanInjectionTest.java @@ -4,6 +4,7 @@ import com.baeldung.dependencyinjectiontypes.ArticleWithSetterInjection; import com.baeldung.samplebeaninjectionypes.AccountDetails; import com.baeldung.samplebeaninjectionypes.BankAccountWithConstructorInjection; import com.baeldung.samplebeaninjectionypes.BankAccountWithSetterInjection; +import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -12,11 +13,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.junit.Assert.assertTrue; public class SampleBeanInjectionTest { + ApplicationContext context; + + @Before + public void before(){ + context = new ClassPathXmlApplicationContext("dependencyinjectiontypes-context.xml"); + } @Test - public void testSetterInjectionValid() { + public void givenAutowiredAnnotation_WhenSetOnSetter_ThenDependencyValid() { - ApplicationContext context = new ClassPathXmlApplicationContext("samplebeaninjectiontypes-context.xml"); BankAccountWithSetterInjection bankAccountWithSetterInjection = (BankAccountWithSetterInjection) context.getBean("bankAccountWithSetterInjection"); String owner = "John Doe"; @@ -27,9 +33,8 @@ public class SampleBeanInjectionTest { } @Test - public void testConstructorInjectionValid() { + public void givenAutowiredAnnotation_WhenSetOnConstructor_ThenDependencyValid() { - ApplicationContext context = new ClassPathXmlApplicationContext("samplebeaninjectiontypes-context.xml"); BankAccountWithConstructorInjection bankAccountWithConstructorInjection = (BankAccountWithConstructorInjection) context.getBean("bankAccountWithConstructorInjectionBean"); String owner = "John Doe";