1、Jnit4测试
第一种测试:
第二种测试:
第一种测试:
@ContextConfiguration("classpath:beans.xml")
public class UserDAOTest extends AbstractJUnit4SpringContextTests{
@Resource(name="userDAO")
private UserDAO userDAO;
@Test
public void testSave() {
this.userDAO.save(new User());
}
}
第二种测试:
@Test
public void findFriend(){
ApplicationContext beanFactory=new ClassPathXmlApplicationContext("beans.xml");
FriendUserService friendUserService=(FriendUserService)beanFactory.getBean("FriendUserService");
UserFindDto userFindDto;
}