Tested yet another way to manage transactions through the user transaction.
[utils] / test / enterprise / src / test / java / org / wamblee / test / persistence / DatabaseUtilsLeakTest.java
1 package org.wamblee.test.persistence;
2
3 import static junit.framework.Assert.*;
4
5 import javax.sql.DataSource;
6
7 import org.junit.After;
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.wamblee.test.persistence.Database;
11 import org.wamblee.test.persistence.DatabaseBuilder;
12 import org.wamblee.test.persistence.DatabaseUtils;
13
14 public class DatabaseUtilsLeakTest {
15
16     private Database db;
17     private DatabaseUtils dbutils; 
18     
19     @Before
20     public void setUp() { 
21         db = DatabaseBuilder.getDatabase();
22         DataSource ds = db.start(); 
23         
24         dbutils = new DatabaseUtils(ds);
25     }
26     
27     @After
28     public void tearDown() { 
29         db.stop(); 
30     }
31     
32     @Test
33     public void testLeak() throws Exception {
34         assertEquals(0, db.getActiveConnections()); 
35         dbutils.dropTables(new MyTables());
36         assertEquals(0, db.getActiveConnections());
37     }
38     
39     
40 }