Lines 1-7
Link Here
|
1 |
/* |
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
3 |
* |
4 |
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. |
4 |
* Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
7 |
* General Public License Version 2 only ("GPL") or the Common |
Lines 24-30
Link Here
|
24 |
* Contributor(s): |
24 |
* Contributor(s): |
25 |
* |
25 |
* |
26 |
* The Original Software is NetBeans. The Initial Developer of the Original |
26 |
* The Original Software is NetBeans. The Initial Developer of the Original |
27 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
27 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun |
28 |
* Microsystems, Inc. All Rights Reserved. |
28 |
* Microsystems, Inc. All Rights Reserved. |
29 |
* |
29 |
* |
30 |
* If you wish your version of this file to be governed by only the CDDL |
30 |
* If you wish your version of this file to be governed by only the CDDL |
Lines 43-52
Link Here
|
43 |
|
43 |
|
44 |
import java.sql.Connection; |
44 |
import java.sql.Connection; |
45 |
import java.sql.SQLException; |
45 |
import java.sql.SQLException; |
46 |
import java.util.logging.Level; |
|
|
47 |
import org.netbeans.modules.db.test.Util; |
46 |
import org.netbeans.modules.db.test.Util; |
48 |
import org.netbeans.modules.db.test.DBTestBase; |
47 |
import org.netbeans.modules.db.test.DBTestBase; |
49 |
import org.openide.util.NbBundle; |
|
|
50 |
|
48 |
|
51 |
/** |
49 |
/** |
52 |
* |
50 |
* |
Lines 72-85
Link Here
|
72 |
|
70 |
|
73 |
DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true); |
71 |
DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true); |
74 |
ConnectionManager.getDefault().addConnection(dbconn); |
72 |
ConnectionManager.getDefault().addConnection(dbconn); |
75 |
|
73 |
|
76 |
assertTrue(ConnectionManager.getDefault().getConnections().length > 0); |
74 |
assertTrue(ConnectionManager.getDefault().getConnections().length > 0); |
77 |
|
75 |
|
78 |
Util.clearConnections(); |
76 |
Util.clearConnections(); |
79 |
|
77 |
|
80 |
assertTrue(ConnectionManager.getDefault().getConnections().length == 0); |
78 |
assertTrue(ConnectionManager.getDefault().getConnections().length == 0); |
81 |
} |
79 |
} |
82 |
|
80 |
|
|
|
81 |
public void testGetJDDCDriver() throws Exception{ |
82 |
Util.clearConnections(); |
83 |
Util.deleteDriverFiles(); |
84 |
|
85 |
JDBCDriver driver = Util.createDummyDriver(); |
86 |
assertEquals(1, JDBCDriverManager.getDefault().getDrivers().length); |
87 |
|
88 |
DatabaseConnection dbconn = DatabaseConnection.create(driver, "database", "user", "schema", "password", true); |
89 |
assertEquals ("Returns the correct driver", driver, dbconn.getJDBCDriver ()); |
90 |
} |
91 |
|
92 |
public void testGetJDDCDriverWhenAddOtherDriver() throws Exception{ |
93 |
Util.clearConnections(); |
94 |
Util.deleteDriverFiles(); |
95 |
|
96 |
JDBCDriver driver1 = Util.createDummyDriver(); |
97 |
assertEquals(1, JDBCDriverManager.getDefault().getDrivers().length); |
98 |
DatabaseConnection dbconn1 = DatabaseConnection.create(driver1, "database", "user", "schema", "password", true); |
99 |
assertEquals ("Returns the correct driver", driver1, dbconn1.getJDBCDriver ()); |
100 |
|
101 |
JDBCDriver driver2 = Util.createDummyDriverWithOtherJar (); |
102 |
assertEquals(2, JDBCDriverManager.getDefault().getDrivers().length); |
103 |
DatabaseConnection dbconn2 = DatabaseConnection.create(driver2, "database", "user", "schema", "password", true); |
104 |
assertEquals ("Returns the correct driver", driver1, dbconn1.getJDBCDriver ()); |
105 |
assertEquals ("Returns the correct driver", driver2, dbconn2.getJDBCDriver ()); |
106 |
} |
107 |
|
83 |
public void testSameDatabaseConnectionReturned() throws Exception { |
108 |
public void testSameDatabaseConnectionReturned() throws Exception { |
84 |
Util.clearConnections(); |
109 |
Util.clearConnections(); |
85 |
Util.deleteDriverFiles(); |
110 |
Util.deleteDriverFiles(); |