@Test public void testList() throws Exception { log.info("testList"); ArrayList<Person> persons = null; daoUtils.truncateTable("persons"); Person p = personDAO.createPerson(testPerson); Person p2 = personDAO.createPerson(testPerson2); persons = personDAO.listPersons(); log.info("persons count : " + persons.size()); Assert.assertTrue(persons.size() > 0); personDAO.deletePerson(p.getPersonID()); personDAO.deletePerson(p2.getPersonID()); }
@Before public void setUp() throws Exception { log.info("setUp"); // createSequence(); // createTable(); log.info("buildtestPersons"); testPerson = new Person(); testPerson.setLastName("Windsor"); testPerson.setFirstName("William"); testPerson.setAddress("Kensington Palace"); testPerson2 = new Person(); testPerson2.setLastName("Windor"); testPerson2.setFirstName("Kate"); testPerson2.setAddress("Kensington Palace"); }
@Test public void testUpdate() throws Exception { log.info("testUpdate"); String oldLastname = "Windsor"; String newLastname = "Cambridge"; Person p = personDAO.createPerson(testPerson); Assert.assertNotNull(p); Person p1 = personDAO.readPerson(p.getPersonID()); Assert.assertNotNull(p1); Assert.assertEquals(testPerson.getFirstName(), p1.getFirstName()); Assert.assertEquals(oldLastname, p1.getLastName()); p.setLastName(newLastname); Person p2 = personDAO.updatePerson(p); Assert.assertNotNull(p2); Assert.assertEquals(testPerson.getFirstName(), p2.getFirstName()); Assert.assertEquals(newLastname, p2.getLastName()); personDAO.deletePerson(p.getPersonID()); }
@Test public void testCreateReadDelete() throws Exception { log.info("testCreate"); Person p = personDAO.createPerson(testPerson); log.info("p : " + p.toString()); Assert.assertNotNull(p); Person p2 = personDAO.readPerson(p.getPersonID()); log.info("p2 : " + p2.toString()); Assert.assertNotNull(p2); Assert.assertEquals(testPerson.getFirstName(), p2.getFirstName()); Assert.assertEquals(testPerson.getLastName(), p2.getLastName()); Assert.assertEquals(testPerson.getAddress(), p2.getAddress()); personDAO.deletePerson(p.getPersonID()); Person p3 = personDAO.readPerson(p.getPersonID()); Assert.assertEquals(0, p3.getPersonID()); Assert.assertNull(p3.getFirstName()); Assert.assertNull(p3.getLastName()); }