1 package org.hibernate.ce.auction.test; 2 3 import org.hibernate.cfg.Environment; 4 import org.hibernate.tool.hbm2ddl.SchemaExport; 5 import org.hibernate.ce.auction.persistence.HibernateUtil; 6 7 8 public abstract class TestCase extends junit.framework.TestCase { 9 10 public TestCase(String s) { 11 super(s); 12 } 13 14 protected void runTest() throws Throwable { 15 try { 16 System.out.println("Running test..."); 17 super.runTest(); 18 } catch (Throwable e) { 19 HibernateUtil.rollbackTransaction(); 20 throw e; 21 } finally{ 22 HibernateUtil.closeSession(); 23 } 24 } 25 26 protected void setUp() throws Exception { 27 super.setUp(); 28 SchemaExport ddlExport = new SchemaExport(HibernateUtil.getConfiguration()); 29 ddlExport.create(false, true); 30 } 31 32 protected void tearDown() throws Exception { 33 super.tearDown(); 34 SchemaExport ddlExport = new SchemaExport(HibernateUtil.getConfiguration()); 35 ddlExport.drop(false, true); 36 } 37 38 } 39 | Popular Tags |