From 4ff6065093a4ce7adbfa81c0c83d085549d31302 Mon Sep 17 00:00:00 2001 From: Juraci Krohling Date: Tue, 21 Apr 2009 13:15:48 +0000 Subject: [PATCH] EJB-418 - Added tearDown method to EJB3TestCase, as the current behaviour was keeping some dirt in the database after the execution of the last test in the EJB3TestCase hierarquy. For trunk git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16377 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../test/java/org/hibernate/ejb/test/EJB3TestCase.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/EJB3TestCase.java b/entitymanager/src/test/java/org/hibernate/ejb/test/EJB3TestCase.java index 069796aec3..9fc51bfe70 100755 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/EJB3TestCase.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/EJB3TestCase.java @@ -113,11 +113,17 @@ public abstract class EJB3TestCase extends junit.framework.TestCase { } protected void setUp() throws Exception { - if ( getSessions() == null || lastTestClass != getClass() ) { + if ( getSessions() == null || lastTestClass != getClass() || getSessions().isClosed() ) { buildSessionFactory( getMappings() ); lastTestClass = getClass(); } } + + protected void tearDown() throws Exception { + if (getSessions() != null && !getSessions().isClosed()) { + getSessions().close(); + } + } protected void runTest() throws Throwable { final boolean stats = ( (SessionFactoryImplementor) sessions ).getStatistics().isStatisticsEnabled();