test case minor changes

This commit is contained in:
Raksha Rao 2018-01-27 14:28:19 +05:30
parent b21a3705b6
commit f12497c18b

View File

@ -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";