Exemple #1
0
 @Test
 public void test() {
   EntityManagerFactory emf = Persistence.createEntityManagerFactory("FormationJPA");
   assertNotNull(emf);
   EntityManager em = emf.createEntityManager();
   assertNotNull(em);
 }
 @Before
 public void setUp() throws Exception {
   try {
     Class.forName("org.hsqldb.jdbcDriver");
     connection = DriverManager.getConnection("jdbc:hsqldb:mem:unit-testing-jpa", "sa", "");
   } catch (Exception ex) {
     ex.printStackTrace();
     fail("Exception during HSQL database startup.");
   }
   try {
     emFactory = Persistence.createEntityManagerFactory("MyPersistence");
     em = emFactory.createEntityManager();
   } catch (Exception ex) {
     ex.printStackTrace();
     fail("Exception during JPA EntityManager instanciation.");
   }
 }