@Override
  public void run(RunNotifier notifier) {
    if (isTestScopedSessionFactoryRequired()) {
      testScopedSessionFactory = buildSessionFactory();
      injectSessionFactory(null, testScopedFactoryFields, testScopedSessionFactory);
    }

    try {
      super.run(notifier);
    } finally {
      if (testScopedSessionFactory != null) {
        cleanUpPendingTransactionIfRequired();
        TestHelper.dropSchemaAndDatabase(testScopedSessionFactory);
        testScopedSessionFactory.close();
      }
    }
  }
Exemplo n.º 2
0
 public static void dropSchemaAndDatabase(Session session) {
   if (session != null) {
     dropSchemaAndDatabase(session.getSessionFactory());
   }
 }
Exemplo n.º 3
0
 public static void dropSchemaAndDatabase(EntityManagerFactory emf) {
   dropSchemaAndDatabase(((HibernateEntityManagerFactory) emf).getSessionFactory());
 }
 @After
 public void tearDown() {
   dropSchemaAndDatabase(emf);
   em.close();
   emf.close();
 }