コード例 #1
0
ファイル: UnitTest.java プロジェクト: titanix38/FormJPA
 @Test
 public void test() {
   EntityManagerFactory emf = Persistence.createEntityManagerFactory("FormationJPA");
   assertNotNull(emf);
   EntityManager em = emf.createEntityManager();
   assertNotNull(em);
 }
コード例 #2
0
 @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.");
   }
 }