?????????? ??context???ж??bean????????????????????ж??bean????ProductManager class???????????????Щbean??????setter????????????????????ж??bean????????????????????????????????????? ?????????????applicationContext.getBean(XXX)??????磺
public class MyTest extends AbstractDependencyInjectionSpringContextTests {
ProductManager productManager;
public String[] getConfigLocations() {
String[] configLocations = { "file:WebContent/WEB-INF/applicationContext.xml" };
return configLocations;
}
public void onSetUp() {
productManager = (ProductManager) applicationContext.getBean("productManager");
}
public void testGetProduct() {
assertEquals("tomson"??productManager.getProductByName("tomson").getName());
}
}
??????????TestCase?????????????????????κ?setters???????ɡ???????????? AbstractSpringContextTests ??????? org.springframework.test ???е????????????AbstractDependencyInjectionSpringContextTests???????????????????AbstractSpringContextTests ?????????????Spring Context?????????????????????????????