Skip to content

Commit f12497c

Browse files
Raksha RaoRaksha Rao
authored andcommitted
test case minor changes
1 parent b21a370 commit f12497c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎spring-core/src/test/java/com/baeldung/samplebeaninjectiontypes/SampleBeanInjectionTest.java‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.baeldung.samplebeaninjectionypes.AccountDetails;
55
import com.baeldung.samplebeaninjectionypes.BankAccountWithConstructorInjection;
66
import com.baeldung.samplebeaninjectionypes.BankAccountWithSetterInjection;
7+
import org.junit.Before;
78
import org.junit.Test;
89
import org.springframework.context.ApplicationContext;
910
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -12,11 +13,16 @@
1213
import static org.junit.Assert.assertTrue;
1314

1415
public class SampleBeanInjectionTest {
16+
ApplicationContext context;
17+
18+
@Before
19+
public void before(){
20+
context = new ClassPathXmlApplicationContext("dependencyinjectiontypes-context.xml");
21+
}
1522

1623
@Test
17-
public void testSetterInjectionValid() {
24+
public void givenAutowiredAnnotation_WhenSetOnSetter_ThenDependencyValid() {
1825

19-
ApplicationContext context = new ClassPathXmlApplicationContext("samplebeaninjectiontypes-context.xml");
2026
BankAccountWithSetterInjection bankAccountWithSetterInjection = (BankAccountWithSetterInjection) context.getBean("bankAccountWithSetterInjection");
2127

2228
String owner = "John Doe";
@@ -27,9 +33,8 @@ public void testSetterInjectionValid() {
2733
}
2834

2935
@Test
30-
public void testConstructorInjectionValid() {
36+
public void givenAutowiredAnnotation_WhenSetOnConstructor_ThenDependencyValid() {
3137

32-
ApplicationContext context = new ClassPathXmlApplicationContext("samplebeaninjectiontypes-context.xml");
3338
BankAccountWithConstructorInjection bankAccountWithConstructorInjection = (BankAccountWithConstructorInjection) context.getBean("bankAccountWithConstructorInjectionBean");
3439

3540
String owner = "John Doe";

0 commit comments

Comments
 (0)