/* * Copyright (C) 2013 AXIA Studio (http://www.axiastudio.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Afffero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.axiastudio.suite; import com.axiastudio.pypapi.db.Database; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import java.util.HashMap; import java.util.Map; /** * * @author AXIA Studio (http://www.axiastudio.com) */ public class EntityBaseTest { private static EntityManagerFactory emf; protected EntityManager em; public EntityBaseTest() { } @BeforeClass public static void setUpClass() { String jdbcUrl = System.getProperty("jdbc.url"); String jdbcUser = System.getProperty("jdbc.user"); String jdbcPassword = System.getProperty("jdbc.password"); String jdbcDriver = System.getProperty("jdbc.driver"); Map properties = new HashMap(); if( jdbcUrl != null ){ properties.put("javax.persistence.jdbc.url", jdbcUrl); properties.put("eclipselink.ddl-generation", ""); } if( jdbcUser != null ){ properties.put("javax.persistence.jdbc.user", jdbcUser); } if( jdbcPassword != null ){ properties.put("javax.persistence.jdbc.password", jdbcPassword); } if( jdbcDriver != null ){ properties.put("javax.persistence.jdbc.driver", jdbcDriver); } Database db = new Database(); //db.open("SuitePU", properties); //Register.registerUtility(db, IDatabase.class); emf = Persistence.createEntityManagerFactory("SuitePU", properties); } @AfterClass public static void tearDownClass() { } @Before public void setUp() { em = emf.createEntityManager(); } @After public void tearDown() { } }