package rst.spring.mock;
/** * Class description. * * @author rst */ publicclass CustomerDaoTest extends SpringDAOTestCase {
? ? private CustomerDAOHibernateImpl customerDAO;
? ? protectedvoid onSetUpInTransaction()throwsException{ ? ? ? ? super.onSetUpInTransaction(); ? ? ? ? //this.setPopulateProtectedVariables(true); ? ? ? ? customerDAO = (CustomerDAOHibernateImpl) this.applicationContext.getBean("customerDAO"); ? ? }
? ? protectedvoid onTearDownInTransaction(){ ? ? ? ? customerDAO = null; ? ? }
? ? publicvoid testInsert(){ ? ? ? ? Customer customer = new Customer(); ? ? ? ? customer.setName("javaeye"); ? ? ? ? customerDAO.add(customer); ? ? ? ? String name = (String) jdbcTemplate.queryForObject("select name from customer where id=?", newObject[]{customer.getId()}, String.class); ? ? ? ? ? ? ? ? assertEquals(customer.getName(), name); ? ? }
}
|