コード例 #1
0
  @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();
  }
コード例 #2
0
  @Test
  public void testGetSeance() {
    Seance seance = seanceDao.getSeance(3L);

    Assert.assertNotNull(seance);
    Assert.assertEquals(3L, seance.getId().longValue());
    Assert.assertEquals("tp1", seance.getTitre());
    Assert.assertEquals("tp de debuggage", seance.getDescription());
    Assert.assertEquals(TypeSeance.TP, seance.getType());
    Assert.assertEquals(new GregorianCalendar(2014, Calendar.JULY, 29).getTime(), seance.getDate());
    Assert.assertEquals(
        new GregorianCalendar(2014, Calendar.JULY, 29, 18, 0, 0).getTime(),
        seance.getDateLimiteRendu());
  }