@Test public void testDelete() { Collection<Cours> cours = null; boolean isdeleted = false; try { conn.beginTransaction(); cours = daoCours.findAll(); for (Cours c : cours) { if (c.getNom().compareTo("AnotherCour") == 0) { daoCours.delete(c); isdeleted = true; break; } } conn.commitTransaction(); } catch (DaoException e) { try { conn.rollbackTransaction(); } catch (DaoException ex) { ex.printStackTrace(); } } assertTrue(isdeleted); }
@Test public void testUpdate() { Collection<Cours> cours = null; boolean isupdated = false; try { conn.beginTransaction(); cours = daoCours.findAll(); for (Cours c : cours) { if (c.getEnseignant().getId() == 2) { c.setNom("AnotherCour"); daoCours.update(c); isupdated = true; break; } } conn.commitTransaction(); } catch (DaoException e) { try { conn.rollbackTransaction(); } catch (DaoException ex) { ex.printStackTrace(); } } assertTrue(isupdated); }