commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r830135 - in /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp: ./ cpdsadapter/ datasources/ managed/
Date Tue, 27 Oct 2009 11:25:14 GMT
Author: sebb
Date: Tue Oct 27 11:25:13 2009
New Revision: 830135

URL: http://svn.apache.org/viewvc?rev=830135&view=rev
Log:
assertTrue(var != null) => assertNotNull(var)
- simplifies code
- avoids later warnings of possible NPE

Modified:
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestPoolableConnection.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/cpdsadapter/TestDriverAdapterCPDS.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java Tue
Oct 27 11:25:13 2009
@@ -164,7 +164,7 @@
     
     public void testTransactionIsolationBehavior() throws Exception {
         Connection conn = getConnection();
-        assertTrue(conn != null);
+        assertNotNull(conn);
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn.getTransactionIsolation());
         conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
         conn.close();

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java Tue
Oct 27 11:25:13 2009
@@ -134,12 +134,12 @@
     public void testIsClosed() throws Exception {
         for(int i=0;i<getMaxActive();i++) {
             Connection conn = newConnection();
-            assertTrue(null != conn);
+            assertNotNull(conn);
             assertTrue(!conn.isClosed());
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
-            assertTrue(null != stmt);
+            assertNotNull(stmt);
             ResultSet rset = stmt.executeQuery();
-            assertTrue(null != rset);
+            assertNotNull(rset);
             assertTrue(rset.next());
             rset.close();
             stmt.close();
@@ -155,7 +155,7 @@
     public void testCanCloseConnectionTwice() throws Exception {
         for (int i = 0; i < getMaxActive(); i++) { // loop to show we *can* close again
once we've borrowed it from the pool again
             Connection conn = newConnection();
-            assertTrue(null != conn);
+            assertNotNull(conn);
             assertTrue(!conn.isClosed());
             conn.close();
             assertTrue(conn.isClosed());
@@ -166,7 +166,7 @@
 
     public void testCanCloseStatementTwice() throws Exception {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         assertTrue(!conn.isClosed());
         for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed
it from the pool again
             Statement stmt = conn.createStatement();
@@ -184,7 +184,7 @@
 
     public void testCanClosePreparedStatementTwice() throws Exception {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         assertTrue(!conn.isClosed());
         for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed
it from the pool again
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
@@ -202,7 +202,7 @@
 
     public void testCanCloseCallableStatementTwice() throws Exception {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         assertTrue(!conn.isClosed());
         for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed
it from the pool again
             PreparedStatement stmt = conn.prepareCall("select * from dual");
@@ -220,7 +220,7 @@
 
     public void testCanCloseResultSetTwice() throws Exception {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         assertTrue(!conn.isClosed());
         for(int i=0;i<2;i++) { // loop to show we *can* close again once we've borrowed
it from the pool again
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
@@ -315,11 +315,11 @@
 
     public void testSimple() throws Exception {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -329,11 +329,11 @@
     public void testRepeatedBorrowAndReturn() throws Exception {
         for(int i=0;i<100;i++) {
             Connection conn = newConnection();
-            assertTrue(null != conn);
+            assertNotNull(conn);
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
-            assertTrue(null != stmt);
+            assertNotNull(stmt);
             ResultSet rset = stmt.executeQuery();
-            assertTrue(null != rset);
+            assertNotNull(rset);
             assertTrue(rset.next());
             rset.close();
             stmt.close();
@@ -343,21 +343,21 @@
 
     public void testSimple2() throws Exception {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         {
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
-            assertTrue(null != stmt);
+            assertNotNull(stmt);
             ResultSet rset = stmt.executeQuery();
-            assertTrue(null != rset);
+            assertNotNull(rset);
             assertTrue(rset.next());
             rset.close();
             stmt.close();
         }
         {
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
-            assertTrue(null != stmt);
+            assertNotNull(stmt);
             ResultSet rset = stmt.executeQuery();
-            assertTrue(null != rset);
+            assertNotNull(rset);
             assertTrue(rset.next());
             rset.close();
             stmt.close();
@@ -371,21 +371,21 @@
         }
 
         conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         {
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
-            assertTrue(null != stmt);
+            assertNotNull(stmt);
             ResultSet rset = stmt.executeQuery();
-            assertTrue(null != rset);
+            assertNotNull(rset);
             assertTrue(rset.next());
             rset.close();
             stmt.close();
         }
         {
             PreparedStatement stmt = conn.prepareStatement("select * from dual");
-            assertTrue(null != stmt);
+            assertNotNull(stmt);
             ResultSet rset = stmt.executeQuery();
-            assertTrue(null != rset);
+            assertNotNull(rset);
             assertTrue(rset.next());
             rset.close();
             stmt.close();
@@ -431,7 +431,7 @@
     
     public void testAutoCommitBehavior() throws Exception {
         Connection conn = newConnection();
-        assertTrue(conn != null);
+        assertNotNull(conn);
         assertTrue(conn.getAutoCommit());
         conn.setAutoCommit(false);
         conn.close();
@@ -621,12 +621,12 @@
     public void testPrepareStatementOptions() throws Exception 
     {
         Connection conn = newConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual", 
             ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         
         assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, rset.getType());

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestPoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestPoolableConnection.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestPoolableConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestPoolableConnection.java
Tue Oct 27 11:25:13 2009
@@ -60,7 +60,7 @@
             fail("Could not fetch Connection from pool: " + e.getMessage());
         }
 
-        assertTrue("Connection should be created and should not be null", c != null);
+        assertNotNull("Connection should be created and should not be null", c);
         assertEquals("There should be exactly one active object in the pool", 1, pool.getNumActive());
 
         // Now return the connection by closing it

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/cpdsadapter/TestDriverAdapterCPDS.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/cpdsadapter/TestDriverAdapterCPDS.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/cpdsadapter/TestDriverAdapterCPDS.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/cpdsadapter/TestDriverAdapterCPDS.java
Tue Oct 27 11:25:13 2009
@@ -88,11 +88,11 @@
 
     public void testSimple() throws Exception {
         Connection conn = pcds.getPooledConnection().getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -101,11 +101,11 @@
 
     public void testSimpleWithUsername() throws Exception {
         Connection conn = pcds.getPooledConnection("u1", "p1").getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
Tue Oct 27 11:25:13 2009
@@ -119,11 +119,11 @@
     public void testSimple() throws Exception 
     {
         Connection conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -133,11 +133,11 @@
     public void testSimpleWithUsername() throws Exception 
     {
         Connection conn = ds.getConnection("u1", "p1");
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -180,21 +180,21 @@
         throws Exception 
     {
         Connection conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
 
         PreparedStatement stmt = 
             conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
         
         stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -211,20 +211,20 @@
         }
 
         conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
 
         stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
 
         stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -441,12 +441,12 @@
                     state = "Getting Connection";
                     conn = getConnection();
                     state = "Using Connection";
-                    assertTrue(null != conn);
+                    assertNotNull(conn);
                     PreparedStatement stmt =
                         conn.prepareStatement("select * from dual");
-                    assertTrue(null != stmt);
+                    assertNotNull(stmt);
                     ResultSet rset = stmt.executeQuery();
-                    assertTrue(null != rset);
+                    assertNotNull(rset);
                     assertTrue(rset.next());
                     state = "Holding Connection";
                     Thread.sleep(connHoldTime);
@@ -473,7 +473,7 @@
 
     public void testTransactionIsolationBehavior() throws Exception {
         Connection conn = getConnection();
-        assertTrue(conn != null);
+        assertNotNull(conn);
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, 
                      conn.getTransactionIsolation());
         conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
Tue Oct 27 11:25:13 2009
@@ -122,11 +122,11 @@
     public void testSimple() throws Exception 
     {
         Connection conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -136,11 +136,11 @@
     public void testSimpleWithUsername() throws Exception 
     {
         Connection conn = ds.getConnection("u1", "p1");
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -183,21 +183,21 @@
         throws Exception 
     {
         Connection conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
 
         PreparedStatement stmt = 
             conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
         
         stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -214,20 +214,20 @@
         }
 
         conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
 
         stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
 
         stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -444,12 +444,12 @@
                     state = "Getting Connection";
                     conn = getConnection();
                     state = "Using Connection";
-                    assertTrue(null != conn);
+                    assertNotNull(conn);
                     PreparedStatement stmt =
                         conn.prepareStatement("select * from dual");
-                    assertTrue(null != stmt);
+                    assertNotNull(stmt);
                     ResultSet rset = stmt.executeQuery();
-                    assertTrue(null != rset);
+                    assertNotNull(rset);
                     assertTrue(rset.next());
                     state = "Holding Connection";
                     Thread.sleep(connHoldTime);
@@ -486,7 +486,7 @@
 
     public void testTransactionIsolationBehavior() throws Exception {
         Connection conn = getConnection();
-        assertTrue(conn != null);
+        assertNotNull(conn);
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, 
                      conn.getTransactionIsolation());
         conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
@@ -510,11 +510,11 @@
         pcds.setPoolPreparedStatements(true);
 
         Connection conn = ds.getConnection();
-        assertTrue(null != conn);
+        assertNotNull(conn);
         PreparedStatement stmt = conn.prepareStatement("select * from dual");
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         ResultSet rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -585,22 +585,22 @@
         PreparedStatement stmt = null;
         ResultSet rset = null;
 
-        assertTrue(null != conn);
+        assertNotNull(conn);
 
         stmt = callBack.getPreparedStatement();
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         long l1HashCode = stmt.hashCode();
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
 
         stmt = callBack.getPreparedStatement();
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         long l2HashCode = stmt.hashCode();
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
@@ -614,19 +614,19 @@
         callBack.setConnection(conn);
 
         stmt = callBack.getPreparedStatement();
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         long l3HashCode = stmt.hashCode();
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();
 
         stmt = callBack.getPreparedStatement();
-        assertTrue(null != stmt);
+        assertNotNull(stmt);
         long l4HashCode = stmt.hashCode();
         rset = stmt.executeQuery();
-        assertTrue(null != rset);
+        assertNotNull(rset);
         assertTrue(rset.next());
         rset.close();
         stmt.close();

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java?rev=830135&r1=830134&r2=830135&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java
Tue Oct 27 11:25:13 2009
@@ -127,7 +127,7 @@
     public void testClearWarnings() throws Exception {
         // open a connection
         Connection connection = newConnection();
-        assertTrue(connection != null);
+        assertNotNull(connection);
 
         // generate SQLWarning on connection
         connection.prepareCall("warning");



Mime
View raw message