KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ce > auction > test > TestCase


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 JavaDoc s) {
11         super(s);
12     }
13
14     protected void runTest() throws Throwable JavaDoc {
15         try {
16             System.out.println("Running test...");
17             super.runTest();
18         } catch (Throwable JavaDoc e) {
19             HibernateUtil.rollbackTransaction();
20             throw e;
21         } finally{
22             HibernateUtil.closeSession();
23         }
24     }
25
26     protected void setUp() throws Exception JavaDoc {
27         super.setUp();
28         SchemaExport ddlExport = new SchemaExport(HibernateUtil.getConfiguration());
29         ddlExport.create(false, true);
30     }
31
32     protected void tearDown() throws Exception JavaDoc {
33         super.tearDown();
34         SchemaExport ddlExport = new SchemaExport(HibernateUtil.getConfiguration());
35         ddlExport.drop(false, true);
36     }
37
38 }
39
Popular Tags