From c6daa9cdc177385cc4ed60ad4286497a26f5988f Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Tue, 11 May 2010 21:16:36 +0000 Subject: [PATCH] --- .../persistence/DatabaseUtilsLeakTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsLeakTest.java diff --git a/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsLeakTest.java b/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsLeakTest.java new file mode 100644 index 00000000..75cabee6 --- /dev/null +++ b/test/enterprise/src/test/java/org/wamblee/support/persistence/DatabaseUtilsLeakTest.java @@ -0,0 +1,44 @@ +package org.wamblee.support.persistence; + +import javax.sql.DataSource; + +import org.dbunit.dataset.DataSetException; +import org.dbunit.dataset.filter.ITableFilterSimple; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.TestCase.*; + +public class DatabaseUtilsLeakTest { + + private Database db; + private DatabaseUtils dbutils; + + @Before + public void setUp() { + db = DatabaseBuilder.getDatabase(); + DataSource ds = db.start(); + + dbutils = new DatabaseUtils(ds, new ITableFilterSimple() { + @Override + public boolean accept(String aTableName) throws DataSetException { + return false; + } + }); + } + + @After + public void tearDown() { + db.stop(); + } + + @Test + public void testLeak() throws Exception { + assertEquals(0, db.getActiveConnections()); + dbutils.dropTables(); + assertEquals(0, db.getActiveConnections()); + } + + +} -- 2.31.1