@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");
    }
  }
 @After
 public void tearDown() throws Exception {
   if (em != null) {
     em.close();
   }
   if (emFactory != null) {
     emFactory.close();
   }
   try {
     connection.createStatement().execute("SHUTDOWN");
   } catch (Exception ex) {
   }
 }