@Test
  public void testPersistence() {
    try {

      em.getTransaction().begin();

      Student u = new Student();
      u.setScore(12);
      u.setName("eskatos");

      em.persist(u);
      assertTrue(em.contains(u));

      em.remove(u);

      assertFalse(em.contains(u));

      em.getTransaction().commit();

    } catch (Exception ex) {
      em.getTransaction().rollback();
      ex.printStackTrace();
      fail("Exception during testPersistence");
    }
  }
Ejemplo n.º 2
0
 /**
  * Sets a new score for the student.
  *
  * @param newScore Integer. The new score to set.
  */
 public void setScore(int newScore) {
   student.setScore(newScore);
 }
Ejemplo n.º 3
0
 /** When called; increases the students score by the amount set in REWARD_SCORE (10) */
 protected void increaseScore() {
   student.setScore(student.getScore() + REWARD_SCORE);
 }