package .dao; import java.util.List; import .dao.BaseDaoTestCase; import .; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.orm.ObjectRetrievalFailureException; public class DaoTest extends BaseDaoTestCase { private Id = new ("1"); private Dao dao = null; public void setDao(Dao dao) { this.dao = dao; } public void testAdd() throws Exception { = new (); // set required fields = ; .(); = ; .(); dao.save(); // verify a primary key was assigned assertNotNull(.()); // verify set fields are same after save assertEquals(, .()); } public void testGet() throws Exception { = dao.get(Id); assertNotNull(); } public void testGets() throws Exception { = new (); //set value for primary key .("1"); List results = dao.gets(); assertTrue(results.size() > 0); } public void testSave() throws Exception { = dao.get(Id); // update required fields = ; .(); dao.save(); assertEquals(, .()); } public void testRemove() throws Exception { removeId = new ("3"); dao.remove(removeId); try { dao.get(removeId); fail(" found in database"); } catch (ObjectRetrievalFailureException e) { assertNotNull(e.getMessage()); } catch (InvalidDataAccessApiUsageException e) { // Spring 2.0 throws this one assertNotNull(e.getMessage()); } } }