@Test public void testModifierSeance() throws Exception { Seance seance = new Seance( 1L, "monTitre", "maDescription", new GregorianCalendar(2014, Calendar.SEPTEMBER, 6).getTime(), true, new GregorianCalendar(2014, Calendar.SEPTEMBER, 6, 18, 5).getTime(), TypeSeance.TP); seanceDao.modifierSeance(seance); Connection connection = DataSourceProvider.getInstance().getDataSource().getConnection(); Statement stmt = connection.createStatement(); ResultSet results = stmt.executeQuery("SELECT * FROM seance WHERE id=1"); if (results.next()) { Assert.assertEquals(1L, results.getLong("id")); Assert.assertEquals("monTitre", results.getString("titre")); Assert.assertEquals("maDescription", results.getString("description")); Assert.assertEquals( new GregorianCalendar(2014, Calendar.SEPTEMBER, 6, 0, 0).getTime(), results.getTimestamp("date")); Assert.assertTrue(results.getBoolean("isnote")); Assert.assertEquals( new GregorianCalendar(2014, Calendar.SEPTEMBER, 6, 18, 5).getTime(), results.getTimestamp("datelimiterendu")); Assert.assertEquals(TypeSeance.TP, TypeSeance.valueOf(results.getString("type"))); } else { Assert.fail(); } stmt.close(); connection.close(); }
@Test public void testAjouterSeanceComplete() throws Exception { Seance seance = new Seance( null, "monTitre", "maDescription", new GregorianCalendar(2014, Calendar.SEPTEMBER, 6).getTime(), true, new GregorianCalendar(2014, Calendar.SEPTEMBER, 6, 18, 5).getTime(), TypeSeance.TP); Seance seanceCreee = seanceDao.ajouterSeance(seance); Assert.assertNotNull(seanceCreee.getId()); Connection connection = DataSourceProvider.getInstance().getDataSource().getConnection(); PreparedStatement stmt = connection.prepareStatement("SELECT * FROM seance WHERE id=?"); stmt.setLong(1, seanceCreee.getId()); ResultSet results = stmt.executeQuery(); if (results.next()) { Assert.assertEquals(seanceCreee.getId().longValue(), results.getLong("id")); Assert.assertEquals("monTitre", results.getString("titre")); Assert.assertEquals("maDescription", results.getString("description")); Assert.assertEquals( new GregorianCalendar(2014, Calendar.SEPTEMBER, 6, 0, 0).getTime(), results.getTimestamp("date")); Assert.assertTrue(results.getBoolean("isnote")); Assert.assertEquals( new GregorianCalendar(2014, Calendar.SEPTEMBER, 6, 18, 5).getTime(), results.getTimestamp("datelimiterendu")); Assert.assertEquals(TypeSeance.TP, TypeSeance.valueOf(results.getString("type"))); } else { Assert.fail(); } stmt.close(); connection.close(); }