commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1701614 - in /commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2: ./ managed/
Date Mon, 07 Sep 2015 12:40:10 GMT
Author: markt
Date: Mon Sep  7 12:40:09 2015
New Revision: 1701614

URL: http://svn.apache.org/r1701614
Log:
Fix some IDE warnings (use of <> and @Override)

Modified:
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
Mon Sep  7 12:40:09 2015
@@ -34,11 +34,11 @@ import org.apache.commons.logging.impl.S
  * @version $Id$
  */
 public class StackMessageLog extends SimpleLog {
-    
+
     private static final long serialVersionUID = 1L;
-    private static Stack<String> messageStack = new Stack<String>();
+    private static Stack<String> messageStack = new Stack<>();
     private static Lock lock = new ReentrantLock();
-    
+
     public StackMessageLog(String name) {
         super(name);
     }
@@ -66,8 +66,8 @@ public class StackMessageLog extends Sim
         } finally {
             lock.unlock();
         }
-    } 
-    
+    }
+
     /**
      * @return the most recent log message, or null if the log is empty
      */
@@ -83,13 +83,13 @@ public class StackMessageLog extends Sim
         }
         return ret;
     }
-    
+
     /**
      * Note: iterator is fail-fast, lock the stack first.
      */
     public static List<String> getAll() {
         final Iterator<String> iterator = messageStack.iterator();
-        final List<String> messages = new ArrayList<String>();
+        final List<String> messages = new ArrayList<>();
         while (iterator.hasNext()) {
             messages.add(iterator.next());
         }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
Mon Sep  7 12:40:09 2015
@@ -45,6 +45,7 @@ public class TestAbandonedBasicDataSourc
 
     private StringWriter sw;
 
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
Mon Sep  7 12:40:09 2015
@@ -437,7 +437,7 @@ public class TestBasicDataSource extends
 
         assertEquals(0, ds.getNumActive());
     }
-    
+
     /**
      * Verifies correct handling of exceptions generated by the underlying pool as it closes
      * connections in response to BDS#close. Exceptions have to be either swallowed by the
@@ -446,23 +446,23 @@ public class TestBasicDataSource extends
     @Test
     public void testPoolCloseCheckedException() throws Exception {
         ds.setAccessToUnderlyingConnectionAllowed(true);  // Allow dirty tricks
-        
+
         // Get an idle connection into the pool
         Connection conn = ds.getConnection();
         TesterConnection tc = (TesterConnection) ((DelegatingConnection<?>) conn).getInnermostDelegate();
         conn.close();
-        
+
         // After returning the connection to the pool, bork it.
         // Don't try this at home - bad violation of pool contract!
         tc.setFailure(new SQLException("bang"));
-        
+
         // Now close Datasource, which will cause tc to be closed, triggering SQLE
         // Pool 2.x swallows and logs exceptions on pool close.  Below verifies that
         // Either exceptions get logged or wrapped appropriately.
         try {
             StackMessageLog.lock();
             StackMessageLog.clear();
-            ds.close();  
+            ds.close();
             // Exception must have been swallowed by the pool - verify it is logged
             assertTrue(StackMessageLog.popMessage().indexOf("bang") > 0);
         } catch (SQLException ex) {
@@ -470,9 +470,9 @@ public class TestBasicDataSource extends
             assertTrue(ex.getCause().getMessage().indexOf("bang") > 0);
         } finally {
             StackMessageLog.unLock();
-        }     
+        }
     }
-    
+
     @Test
     public void testPoolCloseRTE() throws Exception {
         // RTE version of testPoolCloseCheckedException - see comments there.
@@ -484,7 +484,7 @@ public class TestBasicDataSource extends
         try {
             StackMessageLog.lock();
             StackMessageLog.clear();
-            ds.close();  
+            ds.close();
             assertTrue(StackMessageLog.popMessage().indexOf("boom") > 0);
         } catch (IllegalStateException ex) {
             assertTrue(ex.getMessage().indexOf("boom") > 0); // RTE is not wrapped by
BDS#close
@@ -546,7 +546,7 @@ public class TestBasicDataSource extends
             // test OK
         }
     }
-    
+
     @Test
     public void testInvalidateConnection() throws Exception {
     	ds.setMaxTotal(2);
@@ -560,7 +560,7 @@ public class TestBasicDataSource extends
     	conn2.close();
     	conn3.close();
     }
-    
+
     /**
      * JIRA DBCP-93: If an SQLException occurs after the GenericObjectPool is
      * initialized in createDataSource, the evictor task is not cleaned up.
@@ -654,7 +654,7 @@ public class TestBasicDataSource extends
         // make sure cleanup is complete
         assertNull(ds.getConnectionPool());
     }
-    
+
     @Test
     public void testMaxConnLifetimeExceeded() throws Exception {
         try {
@@ -672,7 +672,7 @@ public class TestBasicDataSource extends
             StackMessageLog.unLock();
         }
     }
-    
+
     @Test
     public void testMaxConnLifetimeExceededMutedLog() throws Exception {
         try {
@@ -691,33 +691,33 @@ public class TestBasicDataSource extends
             StackMessageLog.unLock();
         }
     }
-    
+
     @Test
     public void testConcurrentInitBorrow() throws Exception {
         ds.setDriverClassName("org.apache.commons.dbcp2.TesterConnectionDelayDriver");
         ds.setUrl("jdbc:apache:commons:testerConnectionDelayDriver:50");
         ds.setInitialSize(8);
-        
+
         // Launch a request to trigger pool initialization
         TestThread testThread = new TestThread(1,0);
         Thread t = new Thread(testThread);
         t.start();
-        
+
         // Get another connection (should wait for pool init)
         Thread.sleep(100); // Make sure t gets into init first
         ds.getConnection();
-        
+
         // Pool should have at least 6 idle connections now
         // Use underlying pool getNumIdle to avoid waiting for ds lock
         assertTrue(ds.getConnectionPool().getNumIdle() > 5);
-        
+
         // Make sure t completes successfully
         t.join();
         assertFalse(testThread.failed());
-        
+
         ds.close();
     }
-    
+
     /**
      * JIRA: DBCP-444
      * Verify that invalidate does not return closed connection to the pool.
@@ -774,7 +774,7 @@ public class TestBasicDataSource extends
         // Nothing should be registered
         assertEquals(0, mbs.queryNames(commons, null).size());
     }
-    
+
     /**
      * JIRA: DBCP-437
      * Verify that BasicDataSource sets disconnect codes properties.
@@ -782,17 +782,17 @@ public class TestBasicDataSource extends
      */
     @Test
     public void testDisconnectSqlCodes() throws Exception {
-        ArrayList<String> disconnectionSqlCodes = new ArrayList<String>();
+        ArrayList<String> disconnectionSqlCodes = new ArrayList<>();
         disconnectionSqlCodes.add("XXX");
         ds.setDisconnectionSqlCodes(disconnectionSqlCodes);
         ds.setFastFailValidation(true);
         ds.getConnection();  // Triggers initialization - pcf creation
         // Make sure factory got the properties
-        PoolableConnectionFactory pcf = 
+        PoolableConnectionFactory pcf =
                 (PoolableConnectionFactory) ds.getConnectionPool().getFactory();
         assertTrue(pcf.isFastFailValidation());
         assertTrue(pcf.getDisconnectionSqlCodes().contains("XXX"));
-        assertEquals(1, pcf.getDisconnectionSqlCodes().size());   
+        assertEquals(1, pcf.getDisconnectionSqlCodes().size());
     }
 }
 
@@ -846,5 +846,5 @@ class TesterConnectionDelayDriver extend
     public boolean acceptsURL(String url) throws SQLException {
         return url.startsWith(CONNECT_STRING);
     }
-    
+
 }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
Mon Sep  7 12:40:09 2015
@@ -40,6 +40,7 @@ import org.junit.Test;
  */
 public class TestPStmtPoolingBasicDataSource extends TestBasicDataSource {
 
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
@@ -234,7 +235,7 @@ public class TestPStmtPoolingBasicDataSo
         assertSame(inner1, inner2);
     }
 
-    /** 
+    /**
      * Tests high-concurrency contention for connections and pooled prepared statements.
      * DBCP-414
      */

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
Mon Sep  7 12:40:09 2015
@@ -51,7 +51,7 @@ public class TestPoolableConnection {
         pool = new GenericObjectPool<>(factory);
         factory.setPool(pool);
     }
-    
+
     @After
     public void tearDown() {
         pool.close();
@@ -124,7 +124,7 @@ public class TestPoolableConnection {
         factory.setFastFailValidation(true);
         PoolableConnection conn = pool.borrowObject();
         TesterConnection nativeConnection = (TesterConnection) conn.getInnermostDelegate();
-        
+
         // Set up non-fatal exception
         nativeConnection.setFailure(new SQLException("Not fatal error.", "Invalid syntax."));
         try {
@@ -164,21 +164,21 @@ public class TestPoolableConnection {
         assertEquals("The pool should have no idle connections",
                 0, pool.getNumIdle());
     }
-    
+
     @Test
     public void testFastFailValidationCustomCodes() throws Exception {
         pool.setTestOnReturn(true);
         PoolableConnectionFactory factory = (PoolableConnectionFactory) pool.getFactory();
         factory.setFastFailValidation(true);
-        ArrayList<String> disconnectionSqlCodes = new ArrayList<String>();
+        ArrayList<String> disconnectionSqlCodes = new ArrayList<>();
         disconnectionSqlCodes.add("XXX");
         factory.setDisconnectionSqlCodes(disconnectionSqlCodes);
         PoolableConnection conn = pool.borrowObject();
         TesterConnection nativeConnection = (TesterConnection) conn.getInnermostDelegate();
-        
+
         // Set up fatal exception
         nativeConnection.setFailure(new SQLException("Fatal connection error.", "XXX"));
-        
+
         try {
             conn.createStatement();
             fail("Should throw SQL exception.");
@@ -186,7 +186,7 @@ public class TestPoolableConnection {
             // cleanup failure
             nativeConnection.setFailure(null);
         }
-        
+
         // verify that bad connection does not get returned to the pool
         conn.close();  // testOnReturn triggers validate, which should fail
         assertEquals("The pool should have no active connections",

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
Mon Sep  7 12:40:09 2015
@@ -67,6 +67,7 @@ public class TestPoolingDataSource exten
         ds.setAccessToUnderlyingConnectionAllowed(true);
     }
 
+    @Override
     @After
     public void tearDown() throws Exception {
         ds.close();
@@ -145,7 +146,7 @@ public class TestPoolingDataSource exten
         assertTrue(con2.innermostDelegateEquals(inner));
         assertFalse(con.equals(con2));
     }
-    
+
     /**
      * DBCP-412
      * Verify that omitting factory.setPool(pool) when setting up PDS does not
@@ -171,7 +172,7 @@ public class TestPoolingDataSource exten
         assertTrue(f.getPool().equals(p));
         ds.getConnection();
     }
-    
+
     @Test
     public void testClose() throws Exception {
 
@@ -190,13 +191,12 @@ public class TestPoolingDataSource exten
         p.setMaxTotal(getMaxTotal());
         p.setMaxWaitMillis(getMaxWaitMillis());
 
-        try ( PoolingDataSource<PoolableConnection> dataSource =
-                new PoolingDataSource<PoolableConnection>(p) ) {
+        try ( PoolingDataSource<PoolableConnection> dataSource = new PoolingDataSource<>(p)
) {
             Connection connection = dataSource.getConnection();
             assertNotNull(connection);
             connection.close();
         }
-        
+
         assertTrue(p.isClosed());
         assertEquals(0, p.getNumIdle());
         assertEquals(0, p.getNumActive());

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
Mon Sep  7 12:40:09 2015
@@ -86,6 +86,7 @@ public class TestPoolingDriver extends T
         driver.registerPool("test",pool);
     }
 
+    @Override
     @After
     public void tearDown() throws Exception {
         driver.closePool("test");

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
Mon Sep  7 12:40:09 2015
@@ -45,6 +45,7 @@ public class TestDataSourceXAConnectionF
 
     public AtomicInteger closeCounter = new AtomicInteger();
 
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
Mon Sep  7 12:40:09 2015
@@ -92,6 +92,7 @@ public class TestManagedDataSource exten
         ds.setAccessToUnderlyingConnectionAllowed(true);
     }
 
+    @Override
     @After
     public void tearDown() throws Exception {
         pool.close();
@@ -242,20 +243,20 @@ public class TestManagedDataSource exten
         assertTrue(con2.innermostDelegateEquals(inner));
         assertFalse(con.equals(con2));
     }
-    
+
     @Test
     public void testNestedConnections() throws Exception {
         transactionManager.begin();
-        
+
         Connection c1 = null;
         Connection c2 = null;
-        
+
         c1 = newConnection();
         c2 = newConnection();
-        
+
         transactionManager.commit();
-        
+
         c1.close();
         c2.close();
-    }   
+    }
 }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java?rev=1701614&r1=1701613&r2=1701614&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
Mon Sep  7 12:40:09 2015
@@ -46,12 +46,14 @@ import javax.transaction.Transaction;
  */
 public class TestManagedDataSourceInTx extends TestManagedDataSource {
 
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
         transactionManager.begin();
     }
 
+    @Override
     @After
     public void tearDown() throws Exception {
         if (transactionManager.getTransaction() != null) {
@@ -70,7 +72,7 @@ public class TestManagedDataSourceInTx e
         // two connections to the same datasource are supposed to share
         // a single connection
     }
-    
+
     @Override
     @Test
     public void testNestedConnections() {



Mime
View raw message