Guest User

Untitled

a guest
May 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. @Ignore
  2. public class BaseTest {
  3.  
  4. public static EntityManagerFactory emf;
  5. public static EntityManager em;
  6.  
  7. @BeforeClass
  8. public static void runBeforeClass() throws Exception {
  9. emf = Persistence.createEntityManagerFactory("test-hsqldb");
  10. em = emf.createEntityManager();
  11. }
  12.  
  13. @AfterClass
  14. public static void runAfterClass() throws Exception {
  15. emf.close();
  16. }
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23. public class UsersTest extends BaseTest {
  24.  
  25. private static Logger log = Logger.getLogger(UsersTest.class);
  26. private static UserServiceBean slsb = new UserServiceBean();
  27.  
  28. @Test
  29. public void getUsers() throws Exception {
  30. List<User> users = slsb.getUsers();
  31. Assert.assertTrue(users.size() > 0);
  32. }
  33.  
  34. @BeforeClass
  35. public static void runBeforeClass() throws Exception {
  36. BaseTest.runBeforeClass();
  37. slsb.setEm(em);
  38. }
  39.  
  40. @AfterClass
  41. public static void runAfterClass() throws Exception {
  42. BaseTest.runAfterClass();
  43. }
  44.  
  45. }
Add Comment
Please, Sign In to add comment