75cabee6da1e6ecd82a9456c36b5c4f0761c98bf
[utils] / test / enterprise / src / test / java / org / wamblee / support / persistence / DatabaseUtilsLeakTest.java
1 package org.wamblee.support.persistence;
2
3 import javax.sql.DataSource;
4
5 import org.dbunit.dataset.DataSetException;
6 import org.dbunit.dataset.filter.ITableFilterSimple;
7 import org.junit.After;
8 import org.junit.Before;
9 import org.junit.Test;
10
11 import static junit.framework.TestCase.*;
12
13 public class DatabaseUtilsLeakTest {
14
15     private Database db;
16     private DatabaseUtils dbutils; 
17     
18     @Before
19     public void setUp() { 
20         db = DatabaseBuilder.getDatabase();
21         DataSource ds = db.start(); 
22         
23         dbutils = new DatabaseUtils(ds, new ITableFilterSimple() {
24             @Override
25             public boolean accept(String aTableName) throws DataSetException {
26                 return false; 
27             }
28         });
29     }
30     
31     @After
32     public void tearDown() { 
33         db.stop(); 
34     }
35     
36     @Test
37     public void testLeak() throws Exception {
38         assertEquals(0, db.getActiveConnections()); 
39         dbutils.dropTables();
40         assertEquals(0, db.getActiveConnections());
41     }
42     
43     
44 }