1 19 20 package org.netbeans.api.db.explorer; 21 22 import org.netbeans.modules.db.test.TestBase; 23 import org.netbeans.modules.db.test.Util; 24 25 29 public class DatabaseConnectionTest extends TestBase { 30 31 protected void setUp() throws Exception { 32 Util.deleteConnectionFiles(); 33 } 34 35 public DatabaseConnectionTest(String testName) { 36 super(testName); 37 } 38 39 public void testConnectionsRemovedWhenFilesDeleted() throws Exception { 40 JDBCDriver driver = JDBCDriverManager.getDefault().getDrivers("sun.jdbc.odbc.JdbcOdbcDriver")[0]; 41 DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true); 42 ConnectionManager.getDefault().addConnection(dbconn); 43 44 assertTrue(ConnectionManager.getDefault().getConnections().length > 0); 45 46 Util.deleteConnectionFiles(); 47 48 assertTrue(ConnectionManager.getDefault().getConnections().length == 0); 49 } 50 51 public void testSameDatabaseConnectionReturned() throws Exception { 52 assertEquals(0, ConnectionManager.getDefault().getConnections().length); 53 54 JDBCDriver driver = JDBCDriverManager.getDefault().getDrivers("sun.jdbc.odbc.JdbcOdbcDriver")[0]; 55 DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true); 56 ConnectionManager.getDefault().addConnection(dbconn); 57 58 assertEquals(dbconn, ConnectionManager.getDefault().getConnections()[0]); 59 } 60 } 61 | Popular Tags |