You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/12/04 00:04:54 UTC
svn commit: r1547634 - in
/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2: ./ managed/
Author: markt
Date: Tue Dec 3 23:04:54 2013
New Revision: 1547634
URL: http://svn.apache.org/r1547634
Log:
More work to address generics warnings in test packages
Modified:
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestBasicDataSource.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestConnectionPool.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingConnection.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingStatement.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@ import junit.framework.TestSuite;
/**
* TestSuite for BasicDataSource with abandoned connection trace enabled
- *
+ *
* @author Dirk Verbeeck
* @version $Revision$ $Date$
*/
@@ -71,7 +71,7 @@ public class TestAbandonedBasicDataSourc
assertNotNull(ds.getConnection());
}
}
-
+
public void testAbandonedClose() throws Exception {
// force abandoned
ds.setRemoveAbandonedTimeout(0);
@@ -81,18 +81,18 @@ public class TestAbandonedBasicDataSourc
Connection conn1 = getConnection();
assertNotNull(conn1);
assertEquals(1, ds.getNumActive());
-
+
Connection conn2 = getConnection();
// Attempt to borrow object triggers abandoned cleanup
// conn1 should be closed by the pool to make room
assertNotNull(conn2);
assertEquals(1, ds.getNumActive());
// Verify that conn1 is closed
- assertTrue(((DelegatingConnection) conn1).getInnermostDelegate().isClosed());
-
+ assertTrue(((DelegatingConnection<?>) conn1).getInnermostDelegate().isClosed());
+
conn2.close();
assertEquals(0, ds.getNumActive());
-
+
// Second close on conn1 is OK as of dbcp 1.3
conn1.close();
assertEquals(0, ds.getNumActive());
@@ -107,24 +107,24 @@ public class TestAbandonedBasicDataSourc
Connection conn1 = getConnection();
assertNotNull(conn1);
assertEquals(1, ds.getNumActive());
-
- Connection conn2 = getConnection();
+
+ Connection conn2 = getConnection();
assertNotNull(conn2);
assertEquals(1, ds.getNumActive());
-
+
// set an IO failure causing the isClosed mathod to fail
- TesterConnection tconn1 = (TesterConnection) ((DelegatingConnection)conn1).getInnermostDelegate();
+ TesterConnection tconn1 = (TesterConnection) ((DelegatingConnection<?>)conn1).getInnermostDelegate();
tconn1.setFailure(new IOException("network error"));
- TesterConnection tconn2 = (TesterConnection) ((DelegatingConnection)conn2).getInnermostDelegate();
+ TesterConnection tconn2 = (TesterConnection) ((DelegatingConnection<?>)conn2).getInnermostDelegate();
tconn2.setFailure(new IOException("network error"));
-
+
try { conn2.close(); } catch (SQLException ex) { }
assertEquals(0, ds.getNumActive());
-
+
try { conn1.close(); } catch (SQLException ex) { }
assertEquals(0, ds.getNumActive());
}
-
+
/**
* Verify that lastUsed property is updated when a connection
* creates or prepares a statement
@@ -143,9 +143,9 @@ public class TestAbandonedBasicDataSourc
conn1.prepareStatement("SELECT 1 FROM DUAL"); // reset
Thread.sleep(800);
ds.getConnection(); // trigger abandoned cleanup again
- conn1.createStatement();
+ conn1.createStatement();
}
-
+
/**
* Verify that lastUsed property is updated when a connection
* prepares a callable statement.
@@ -164,9 +164,9 @@ public class TestAbandonedBasicDataSourc
conn1.prepareCall("{call home}"); // reset
Thread.sleep(800);
ds.getConnection(); // trigger abandoned cleanup again
- conn1.createStatement();
+ conn1.createStatement();
}
-
+
/**
* DBCP-343 - verify that using a DelegatingStatement updates
* the lastUsed on the parent connection
@@ -175,7 +175,7 @@ public class TestAbandonedBasicDataSourc
ds.setRemoveAbandonedTimeout(1);
ds.setMaxTotal(2);
Connection conn1 = ds.getConnection();
- Statement st = conn1.createStatement();
+ Statement st = conn1.createStatement();
String querySQL = "SELECT 1 FROM DUAL";
Thread.sleep(500);
st.executeQuery(querySQL); // Should reset lastUsed
@@ -187,15 +187,15 @@ public class TestAbandonedBasicDataSourc
st.executeUpdate(""); // Should also reset
Thread.sleep(800);
ds.getConnection(); // trigger abandoned cleanup again
- conn1.createStatement(); // Connection should still be good
+ conn1.createStatement(); // Connection should still be good
}
-
+
/**
* DBCP-343 - verify additional operations reset lastUsed on
* the parent connection
*/
public void testLastUsedUpdate() throws Exception {
- DelegatingConnection conn = (DelegatingConnection) ds.getConnection();
+ DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
PreparedStatement ps = conn.prepareStatement("");
CallableStatement cs = conn.prepareCall("");
Statement st = conn.prepareStatement("");
@@ -203,13 +203,13 @@ public class TestAbandonedBasicDataSourc
checkLastUsedPreparedStatement(ps, conn);
checkLastUsedStatement(cs, conn);
checkLastUsedPreparedStatement(cs, conn);
- checkLastUsedStatement(st, conn);
+ checkLastUsedStatement(st, conn);
}
-
+
/**
* Verifies that Statement executeXxx methods update lastUsed on the parent connection
*/
- private void checkLastUsedStatement(Statement st, DelegatingConnection conn) throws Exception {
+ private void checkLastUsedStatement(Statement st, DelegatingConnection<?> conn) throws Exception {
st.execute("");
assertAndReset(conn);
st.execute("", new int[] {});
@@ -229,11 +229,11 @@ public class TestAbandonedBasicDataSourc
st.executeUpdate("", new String[] {});
assertAndReset(conn);
}
-
+
/**
* Verifies that PreparedStatement executeXxx methods update lastUsed on the parent connection
*/
- private void checkLastUsedPreparedStatement(PreparedStatement ps, DelegatingConnection conn) throws Exception {
+ private void checkLastUsedPreparedStatement(PreparedStatement ps, DelegatingConnection<?> conn) throws Exception {
ps.execute();
assertAndReset(conn);
ps.executeQuery();
@@ -241,12 +241,12 @@ public class TestAbandonedBasicDataSourc
ps.executeUpdate();
assertAndReset(conn);
}
-
+
/**
* Verifies that con.lastUsed has been updated and then resets it to 0
*/
- private void assertAndReset(DelegatingConnection con) {
+ private void assertAndReset(DelegatingConnection<?> con) {
assertTrue(con.getLastUsed() > 0);
- con.setLastUsed(0);
+ con.setLastUsed(0);
}
}
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestBasicDataSource.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestBasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestBasicDataSource.java Tue Dec 3 23:04:54 2013
@@ -86,13 +86,13 @@ public class TestBasicDataSource extends
// active connection is held open when ds is closed
Connection activeConnection = getConnection();
- Connection rawActiveConnection = ((DelegatingConnection) activeConnection).getInnermostDelegate();
+ Connection rawActiveConnection = ((DelegatingConnection<?>) activeConnection).getInnermostDelegate();
assertFalse(activeConnection.isClosed());
assertFalse(rawActiveConnection.isClosed());
// idle connection is in pool but closed
Connection idleConnection = getConnection();
- Connection rawIdleConnection = ((DelegatingConnection) idleConnection).getInnermostDelegate();
+ Connection rawIdleConnection = ((DelegatingConnection<?>) idleConnection).getInnermostDelegate();
assertFalse(idleConnection.isClosed());
assertFalse(rawIdleConnection.isClosed());
@@ -211,10 +211,10 @@ public class TestBasicDataSource extends
assertEquals(false, ds.isAccessToUnderlyingConnectionAllowed());
Connection conn = getConnection();
- Connection dconn = ((DelegatingConnection) conn).getDelegate();
+ Connection dconn = ((DelegatingConnection<?>) conn).getDelegate();
assertNull(dconn);
- dconn = ((DelegatingConnection) conn).getInnermostDelegate();
+ dconn = ((DelegatingConnection<?>) conn).getInnermostDelegate();
assertNull(dconn);
}
@@ -223,10 +223,10 @@ public class TestBasicDataSource extends
assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
Connection conn = getConnection();
- Connection dconn = ((DelegatingConnection) conn).getDelegate();
+ Connection dconn = ((DelegatingConnection<?>) conn).getDelegate();
assertNotNull(dconn);
- dconn = ((DelegatingConnection) conn).getInnermostDelegate();
+ dconn = ((DelegatingConnection<?>) conn).getInnermostDelegate();
assertNotNull(dconn);
assertTrue(dconn instanceof TesterConnection);
@@ -382,7 +382,7 @@ public class TestBasicDataSource extends
assertNotNull(conn);
assertEquals(false, conn.getAutoCommit());
- Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();
+ Connection dconn = ((DelegatingConnection<?>) conn).getInnermostDelegate();
assertNotNull(dconn);
assertEquals(false, dconn.getAutoCommit());
@@ -413,7 +413,7 @@ public class TestBasicDataSource extends
assertEquals(1, ds.getNumActive());
// set an IO failure causing the isClosed mathod to fail
- TesterConnection tconn = (TesterConnection) ((DelegatingConnection)conn).getInnermostDelegate();
+ TesterConnection tconn = (TesterConnection) ((DelegatingConnection<?>)conn).getInnermostDelegate();
tconn.setFailure(new IOException("network error"));
try {
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestConnectionPool.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestConnectionPool.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestConnectionPool.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestConnectionPool.java Tue Dec 3 23:04:54 2013
@@ -398,7 +398,7 @@ public abstract class TestConnectionPool
for (int i = 0; i < c.length; i++) {
c[i] = newConnection();
if (c[i] instanceof DelegatingConnection) {
- u[i] = ((DelegatingConnection) c[i]).getInnermostDelegate();
+ u[i] = ((DelegatingConnection<?>) c[i]).getInnermostDelegate();
} else {
for (int j = 0; j <= i; j++) {
c[j].close();
@@ -412,7 +412,7 @@ public abstract class TestConnectionPool
c[i].close();
Connection con = newConnection();
Connection underCon =
- ((DelegatingConnection) con).getInnermostDelegate();
+ ((DelegatingConnection<?>) con).getInnermostDelegate();
assertTrue("Failed to get connection", underCon != null);
boolean found = false;
for (int j = 0; j < c.length; j++) {
@@ -869,7 +869,7 @@ public abstract class TestConnectionPool
state = "Getting Connection";
preconnected = timeStamp();
Connection conn = getConnection();
- connHash = System.identityHashCode(((DelegatingConnection)conn).getInnermostDelegate());
+ connHash = System.identityHashCode(((DelegatingConnection<?>)conn).getInnermostDelegate());
connected = timeStamp();
state = "Using Connection";
assertNotNull(conn);
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,7 +36,7 @@ public class TestDelegatingCallableState
return new TestSuite(TestDelegatingCallableStatement.class);
}
- private DelegatingConnection conn = null;
+ private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingCallableStatement stmt = null;
private CallableStatement delegateStmt = null;
@@ -44,7 +44,7 @@ public class TestDelegatingCallableState
@Override
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
- conn = new DelegatingConnection(delegateConn);
+ conn = new DelegatingConnection<>(delegateConn);
}
public void testExecuteQueryReturnsNull() throws Exception {
@@ -69,7 +69,7 @@ public class TestDelegatingCallableState
stmt = new DelegatingCallableStatement(conn, null);
assertEquals(0, stmt.hashCode());
}
-
+
public void testHashCode() throws Exception {
delegateStmt = new TesterCallableStatement(delegateConn,"select * from foo");
DelegatingCallableStatement stmt1 = new DelegatingCallableStatement(conn,delegateStmt);
@@ -78,7 +78,7 @@ public class TestDelegatingCallableState
stmt1.close();
stmt2.close();
}
-
+
public void testEquals() {
delegateStmt = new TesterCallableStatement(delegateConn,"select * from foo");
CallableStatement del = new TesterCallableStatement(delegateConn,"select * from foo");
@@ -86,13 +86,13 @@ public class TestDelegatingCallableState
DelegatingCallableStatement stmt2 = new DelegatingCallableStatement(conn, delegateStmt);
DelegatingCallableStatement stmt3 = new DelegatingCallableStatement(conn, null);
DelegatingCallableStatement stmt4 = new DelegatingCallableStatement(conn, del);
-
+
// Nothing is equal to null
assertFalse(stmt1.equals(null));
assertFalse(stmt2.equals(null));
assertFalse(stmt3.equals(null));
assertFalse(stmt4.equals(null));
-
+
// 1 & 2 are equivalent
assertTrue(stmt1.equals(stmt2));
assertTrue(stmt2.equals(stmt1)); // reflexive
@@ -108,15 +108,15 @@ public class TestDelegatingCallableState
// Check self-equals
assertTrue(stmt1.equals(stmt1));
assertTrue(stmt2.equals(stmt2));
- assertTrue(stmt3.equals(stmt3));
+ assertTrue(stmt3.equals(stmt3));
assertTrue(stmt4.equals(stmt4));
-
+
DelegatingStatement dstmt1 = stmt1;
-
+
// 1 & 2 are equivalent
assertTrue(dstmt1.equals(stmt2));
assertTrue(stmt2.equals(dstmt1)); // reflexive
-
+
// innermost delegate itself - bugged behavior?
assertTrue(stmt1.equals(delegateStmt));
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingConnection.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingConnection.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingConnection.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@ public class TestDelegatingConnection ex
return new TestSuite(TestDelegatingConnection.class);
}
- private DelegatingConnection conn = null;
+ private DelegatingConnection<? extends Connection> conn = null;
private Connection delegateConn = null;
private Connection delegateConn2 = null;
@@ -47,7 +47,7 @@ public class TestDelegatingConnection ex
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
delegateConn2 = new TesterConnection("test", "test");
- conn = new DelegatingConnection(delegateConn);
+ conn = new DelegatingConnection<>(delegateConn);
}
@@ -62,21 +62,21 @@ public class TestDelegatingConnection ex
}
public void testHashCodeEqual() throws Exception {
- DelegatingConnection conn2 = new DelegatingConnection(delegateConn);
+ DelegatingConnection<Connection> conn2 = new DelegatingConnection<>(delegateConn);
assertEquals(conn.hashCode(), conn2.hashCode());
conn2.close();
}
public void testHashCodeNotEqual() throws Exception {
- DelegatingConnection conn2 = new DelegatingConnection(delegateConn2);
+ DelegatingConnection<Connection> conn2 = new DelegatingConnection<>(delegateConn2);
assertTrue(conn.hashCode() != conn2.hashCode());
conn2.close();
}
-
+
public void testEquals() {
- DelegatingConnection conn2 = new DelegatingConnection(delegateConn);
- DelegatingConnection conn3 = new DelegatingConnection(null);
-
+ DelegatingConnection<Connection> conn2 = new DelegatingConnection<>(delegateConn);
+ DelegatingConnection<Connection> conn3 = new DelegatingConnection<>(null);
+
assertTrue(!conn.equals(null));
assertTrue(conn.equals(conn2));
assertTrue(!conn.equals(conn3));
@@ -84,9 +84,9 @@ public class TestDelegatingConnection ex
assertTrue(conn3.equals(conn3));
assertTrue(conn.equals(conn));
assertTrue(conn2.equals(conn2));
- assertTrue(conn3.equals(new DelegatingConnection(null)));
+ assertTrue(conn3.equals(new DelegatingConnection<>(null)));
}
-
+
public void testCheckOpen() throws Exception {
conn.checkOpen();
conn.close();
@@ -95,9 +95,9 @@ public class TestDelegatingConnection ex
fail("Expecting SQLException");
} catch (SQLException ex) {
// expected
- }
+ }
}
-
+
/**
* Verify fix for DBCP-241
*/
@@ -111,8 +111,8 @@ public class TestDelegatingConnection ex
}
try {
- conn = new DelegatingConnection(null);
- conn._closed = true;
+ conn = new DelegatingConnection<>(null);
+ conn._closed = true;
conn.checkOpen();
fail("Expecting SQLException");
} catch (SQLException ex) {
@@ -122,17 +122,17 @@ public class TestDelegatingConnection ex
try {
PoolingConnection pc = new PoolingConnection(delegateConn2);
pc.setStatementPool(new GenericKeyedObjectPool<>(pc));
- conn = new DelegatingConnection(pc);
+ conn = new DelegatingConnection<>(pc);
pc.close();
conn.close();
conn.prepareStatement("");
fail("Expecting SQLException");
} catch (SQLException ex) {
assertTrue(ex.getMessage().endsWith("is closed."));
- }
-
+ }
+
try {
- conn = new DelegatingConnection(new RTEGeneratingConnection());
+ conn = new DelegatingConnection<>(new RTEGeneratingConnection());
conn.close();
conn.checkOpen();
fail("Expecting SQLException");
@@ -140,7 +140,7 @@ public class TestDelegatingConnection ex
assertTrue(ex.getMessage().endsWith("is closed."));
}
}
-
+
/**
* Delegate that will throw RTE on toString
* Used to validate fix for DBCP-241
@@ -153,6 +153,6 @@ public class TestDelegatingConnection ex
public String toString() {
throw new RuntimeException("bang!");
}
-
+
}
}
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,7 +38,7 @@ public class TestDelegatingDatabaseMetaD
return new TestSuite(TestDelegatingDatabaseMetaData.class);
}
- private DelegatingConnection conn = null;
+ private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingDatabaseMetaData meta = null;
private DatabaseMetaData delegateMeta = null;
@@ -47,7 +47,7 @@ public class TestDelegatingDatabaseMetaD
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
delegateMeta = delegateConn.getMetaData();
- conn = new DelegatingConnection(delegateConn);
+ conn = new DelegatingConnection<>(delegateConn);
meta = new DelegatingDatabaseMetaData(conn,delegateMeta);
}
@@ -67,7 +67,7 @@ public class TestDelegatingDatabaseMetaD
new DelegatingDatabaseMetaData(conn,delegateMeta);
assertEquals(meta1.hashCode(), meta2.hashCode());
}
-
+
public void testEquals() {
try {
delegateMeta = conn.getMetaData();
@@ -80,7 +80,7 @@ public class TestDelegatingDatabaseMetaD
new DelegatingDatabaseMetaData(conn,delegateMeta);
DelegatingDatabaseMetaData meta3 =
new DelegatingDatabaseMetaData(conn,null);
-
+
assertTrue(!meta1.equals(null));
assertTrue(meta1.equals(meta2));
assertTrue(!meta1.equals(meta3));
@@ -88,7 +88,7 @@ public class TestDelegatingDatabaseMetaD
assertTrue(meta2.equals(meta2));
assertTrue(meta3.equals(meta3));
}
-
+
/* JDBC_4_ANT_KEY_BEGIN */
public void testCheckOpen() throws Exception {
ResultSet rst = meta.getSchemas();
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,7 +38,7 @@ public class TestDelegatingPreparedState
return new TestSuite(TestDelegatingPreparedStatement.class);
}
- private DelegatingConnection conn = null;
+ private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingPreparedStatement stmt = null;
private PreparedStatement delegateStmt = null;
@@ -46,7 +46,7 @@ public class TestDelegatingPreparedState
@Override
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
- conn = new DelegatingConnection(delegateConn);
+ conn = new DelegatingConnection<>(delegateConn);
}
public void testExecuteQueryReturnsNull() throws Exception {
@@ -71,7 +71,7 @@ public class TestDelegatingPreparedState
stmt = new DelegatingPreparedStatement(conn, null);
assertEquals(0, stmt.hashCode());
}
-
+
public void testHashCode() throws Exception {
delegateStmt = new TesterPreparedStatement(delegateConn,"select * from foo");
DelegatingPreparedStatement stmt1 = new DelegatingPreparedStatement(conn,delegateStmt);
@@ -80,7 +80,7 @@ public class TestDelegatingPreparedState
stmt1.close();
stmt2.close();
}
-
+
public void testEquals() {
delegateStmt = new TesterPreparedStatement(delegateConn,"select * from foo");
PreparedStatement del = new TesterPreparedStatement(delegateConn,"select * from foo");
@@ -88,13 +88,13 @@ public class TestDelegatingPreparedState
DelegatingPreparedStatement stmt2 = new DelegatingPreparedStatement(conn, delegateStmt);
DelegatingPreparedStatement stmt3 = new DelegatingPreparedStatement(conn, null);
DelegatingPreparedStatement stmt4 = new DelegatingPreparedStatement(conn, del);
-
+
// Nothing is equal to null
assertFalse(stmt1.equals(null));
assertFalse(stmt2.equals(null));
assertFalse(stmt3.equals(null));
assertFalse(stmt4.equals(null));
-
+
// 1 & 2 are equivalent
assertTrue(stmt1.equals(stmt2));
assertTrue(stmt2.equals(stmt1)); // reflexive
@@ -110,15 +110,15 @@ public class TestDelegatingPreparedState
// Check self-equals
assertTrue(stmt1.equals(stmt1));
assertTrue(stmt2.equals(stmt2));
- assertTrue(stmt3.equals(stmt3));
+ assertTrue(stmt3.equals(stmt3));
assertTrue(stmt4.equals(stmt4));
-
+
DelegatingStatement dstmt1 = stmt1;
-
+
// 1 & 2 are equivalent
assertTrue(dstmt1.equals(stmt2));
assertTrue(stmt2.equals(dstmt1)); // reflexive
-
+
// innermost delegate itself - bugged behavior?
assertTrue(stmt1.equals(delegateStmt));
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingStatement.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingStatement.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDelegatingStatement.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@ public class TestDelegatingStatement ext
return new TestSuite(TestDelegatingStatement.class);
}
- private DelegatingConnection conn = null;
+ private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingStatement stmt = null;
private Statement delegateStmt = null;
@@ -48,7 +48,7 @@ public class TestDelegatingStatement ext
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
delegateStmt = new TesterStatement(delegateConn);
- conn = new DelegatingConnection(delegateConn);
+ conn = new DelegatingConnection<>(delegateConn);
stmt = new DelegatingStatement(conn,delegateStmt);
}
@@ -71,33 +71,33 @@ public class TestDelegatingStatement ext
stmt2.close();
stmt3.close();
}
-
+
public void testEquals() {
delegateStmt = new TesterPreparedStatement(delegateConn,"select * from foo");
DelegatingStatement stmt1 = new DelegatingStatement(conn, delegateStmt);
DelegatingStatement stmt2 = new DelegatingStatement(conn, delegateStmt);
DelegatingStatement stmt3 = new DelegatingStatement(conn, null);
DelegatingStatement stmt4 = new DelegatingStatement(conn, stmt1);
-
+
// not null
assertTrue(!stmt1.equals(null));
-
+
// same innermost delegate
assertTrue(stmt1.equals(stmt2));
assertTrue(stmt1.equals(stmt4));
-
+
// innermost delegate itself - bugged behavior?
assertTrue(stmt1.equals(delegateStmt));
-
+
// not same delegate
assertTrue(!stmt1.equals(stmt3));
-
+
// reflexive
assertTrue(stmt1.equals(stmt1));
assertTrue(stmt2.equals(stmt2));
assertTrue(stmt3.equals(stmt3));
}
-
+
public void testCheckOpen() throws Exception {
stmt.checkOpen();
stmt.close();
@@ -106,6 +106,6 @@ public class TestDelegatingStatement ext
fail("Expecting SQLException");
} catch (SQLException ex) {
// expected
- }
+ }
}
}
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java Tue Dec 3 23:04:54 2013
@@ -126,9 +126,9 @@ public class TestPStmtPooling extends Te
Connection conn = ds.getConnection();
conn.prepareStatement("select 1 from dual");
- Connection poolableConnection = ((DelegatingConnection) conn).getDelegate();
+ Connection poolableConnection = ((DelegatingConnection<?>) conn).getDelegate();
Connection poolingConnection =
- ((DelegatingConnection) poolableConnection).getDelegate();
+ ((DelegatingConnection<?>) poolableConnection).getDelegate();
poolingConnection.close();
try {
conn.prepareStatement("select 1 from dual");
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java Tue Dec 3 23:04:54 2013
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -76,7 +76,7 @@ public class TestPoolableConnection exte
// Now close our innermost delegate, simulating the case where the
// underlying connection closes itself
((PoolableConnection)conn).getInnermostDelegate().close();
-
+
// At this point, we can close the pooled connection. The
// PoolableConnection *should* realize that its underlying
// connection is gone and invalidate itself. The pool should have no
@@ -89,22 +89,22 @@ public class TestPoolableConnection exte
// should *NOT* be returned to the pool
}
- assertEquals("The pool should have no active connections",
+ assertEquals("The pool should have no active connections",
0, pool.getNumActive());
}
-
+
public void testClosingWrappedInDelegate() throws Exception {
Assert.assertEquals(0, pool.getNumActive());
-
+
Connection conn = pool.borrowObject();
- DelegatingConnection outer = new DelegatingConnection(conn);
-
+ DelegatingConnection<Connection> outer = new DelegatingConnection<>(conn);
+
Assert.assertFalse(outer.isClosed());
Assert.assertFalse(conn.isClosed());
Assert.assertEquals(1, pool.getNumActive());
outer.close();
-
+
Assert.assertTrue(outer.isClosed());
Assert.assertTrue(conn.isClosed());
Assert.assertEquals(0, pool.getNumActive());
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java Tue Dec 3 23:04:54 2013
@@ -81,7 +81,7 @@ public class TestPoolingDataSource exten
c[i] = newConnection();
}
// Close the delegate of one wrapper in the pool
- ((DelegatingConnection) c[0]).getDelegate().close();
+ ((DelegatingConnection<?>) c[0]).getDelegate().close();
// Grab a new connection - should get c[0]'s closed connection
// so should be delegate-equivalent, so equal
@@ -129,10 +129,10 @@ public class TestPoolingDataSource exten
public void testestPoolGuardConnectionWrapperEqualInnermost() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
- DelegatingConnection con = (DelegatingConnection) ds.getConnection();
+ DelegatingConnection<?> con = (DelegatingConnection<?>) ds.getConnection();
Connection inner = con.getInnermostDelegate();
ds.setAccessToUnderlyingConnectionAllowed(false);
- DelegatingConnection con2 = new DelegatingConnection(inner);
+ DelegatingConnection<Connection> con2 = new DelegatingConnection<>(inner);
assertTrue(con2.equals(con));
assertTrue(con.innermostDelegateEquals(con2.getInnermostDelegate()));
assertTrue(con2.innermostDelegateEquals(inner));
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java Tue Dec 3 23:04:54 2013
@@ -47,7 +47,7 @@ public class TestBasicManagedDataSource
public void testHashCode() throws Exception {
// TODO reenable... hashcode doesn't work when accessToUnderlyingConnectionAllowed is false
}
-
+
/**
* JIRA: DBCP-294
* Verify that PoolableConnections created by BasicManagedDataSource unregister themselves
@@ -60,11 +60,11 @@ public class TestBasicManagedDataSource
basicManagedDataSource.setUrl("jdbc:apache:commons:testdriver");
basicManagedDataSource.setUsername("username");
basicManagedDataSource.setPassword("password");
- basicManagedDataSource.setMaxIdle(1);
- // Create two connections
- ManagedConnection conn = (ManagedConnection) basicManagedDataSource.getConnection();
+ basicManagedDataSource.setMaxIdle(1);
+ // Create two connections
+ ManagedConnection<?> conn = (ManagedConnection<?>) basicManagedDataSource.getConnection();
assertNotNull(basicManagedDataSource.getTransactionRegistry().getXAResource(conn));
- ManagedConnection conn2 = (ManagedConnection) basicManagedDataSource.getConnection();
+ ManagedConnection<?> conn2 = (ManagedConnection<?>) basicManagedDataSource.getConnection();
conn2.close(); // Return one connection to the pool
conn.close(); // No room at the inn - this will trigger reallyClose(), which should unregister
try {
@@ -72,7 +72,7 @@ public class TestBasicManagedDataSource
fail("Expecting SQLException - XAResources orphaned");
} catch (SQLException ex) {
// expected
- }
+ }
conn2.close();
basicManagedDataSource.close();
}
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java Tue Dec 3 23:04:54 2013
@@ -103,14 +103,14 @@ public class TestManagedDataSource exten
*/
public void testAccessToUnderlyingConnectionAllowed() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
- ManagedConnection connection = (ManagedConnection) newConnection();
+ ManagedConnection<?> connection = (ManagedConnection<?>) newConnection();
assertTrue(connection.isAccessToUnderlyingConnectionAllowed());
assertNotNull(connection.getDelegate());
assertNotNull(connection.getInnermostDelegate());
connection.close();
ds.setAccessToUnderlyingConnectionAllowed(false);
- connection = (ManagedConnection) newConnection();
+ connection = (ManagedConnection<?>) newConnection();
assertFalse(connection.isAccessToUnderlyingConnectionAllowed());
assertNull(connection.getDelegate());
assertNull(connection.getInnermostDelegate());
@@ -121,8 +121,8 @@ public class TestManagedDataSource exten
* Verify that conection sharing is working (or not working) as expected.
*/
public void testSharedConnection() throws Exception {
- DelegatingConnection connectionA = (DelegatingConnection) newConnection();
- DelegatingConnection connectionB = (DelegatingConnection) newConnection();
+ DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
+ DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
assertFalse(connectionA.equals(connectionB));
assertFalse(connectionB.equals(connectionA));
@@ -140,7 +140,7 @@ public class TestManagedDataSource exten
c[i] = newConnection();
}
// Close the delegate of one wrapper in the pool
- ((DelegatingConnection) c[0]).getDelegate().close();
+ ((DelegatingConnection<?>) c[0]).getDelegate().close();
// Disable access for the new connection
ds.setAccessToUnderlyingConnectionAllowed(false);
@@ -162,7 +162,7 @@ public class TestManagedDataSource exten
c[i] = newConnection();
}
// Close the delegate of one wrapper in the pool
- ((DelegatingConnection) c[0]).getDelegate().close();
+ ((DelegatingConnection<?>) c[0]).getDelegate().close();
// Grab a new connection - should get c[0]'s closed connection
// so should be delegate-equivalent, so equal
@@ -210,10 +210,10 @@ public class TestManagedDataSource exten
public void testManagedConnectionEqualInnermost() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
- DelegatingConnection con = (DelegatingConnection) ds.getConnection();
+ DelegatingConnection<?> con = (DelegatingConnection<?>) ds.getConnection();
Connection inner = con.getInnermostDelegate();
ds.setAccessToUnderlyingConnectionAllowed(false);
- DelegatingConnection con2 = new DelegatingConnection(inner);
+ DelegatingConnection<Connection> con2 = new DelegatingConnection<>(inner);
assertTrue(con2.equals(con));
assertTrue(con.innermostDelegateEquals(con2.getInnermostDelegate()));
assertTrue(con2.innermostDelegateEquals(inner));
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java?rev=1547634&r1=1547633&r2=1547634&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java Tue Dec 3 23:04:54 2013
@@ -79,7 +79,7 @@ public class TestManagedDataSourceInTx e
for(int j=0;j<i;j++) {
// two connections should be distinct instances
assertNotSame(conn[j], conn[i]);
- // but they should be equivilant since they are sharing the same underlying connection
+ // but they should be equivilant since they are sharing the same underlying connection
assertEquals(conn[j], conn[i]);
}
}
@@ -160,8 +160,8 @@ public class TestManagedDataSourceInTx e
@Override
public void testSharedConnection() throws Exception {
- DelegatingConnection connectionA = (DelegatingConnection) newConnection();
- DelegatingConnection connectionB = (DelegatingConnection) newConnection();
+ DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
+ DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
assertTrue(connectionA.equals(connectionB));
assertTrue(connectionB.equals(connectionA));
@@ -173,8 +173,8 @@ public class TestManagedDataSourceInTx e
}
public void testSharedTransactionConversion() throws Exception {
- DelegatingConnection connectionA = (DelegatingConnection) newConnection();
- DelegatingConnection connectionB = (DelegatingConnection) newConnection();
+ DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
+ DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
// in a transaciton the connections should be equal
assertTrue(connectionA.equals(connectionB));
@@ -211,8 +211,8 @@ public class TestManagedDataSourceInTx e
}
public void testCloseInTransaction() throws Exception {
- DelegatingConnection connectionA = (DelegatingConnection) newConnection();
- DelegatingConnection connectionB = (DelegatingConnection) newConnection();
+ DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
+ DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
assertTrue(connectionA.equals(connectionB));
assertTrue(connectionB.equals(connectionA));
@@ -278,7 +278,7 @@ public class TestManagedDataSourceInTx e
Connection connection = newConnection();
// NOTE: This test class uses connections that are read-only by default
-
+
// conection should be read only
assertTrue("Connection be read-only", connection.isReadOnly());