Author: markt
Date: Mon Sep  9 11:27:10 2013
New Revision: 1521050

URL: http://svn.apache.org/r1521050
Log:
Fix checkstyle failures
 - no License header
 - invalid (old JUnit) imports
 - trailing whitespace
 - missing @Overrides

Modified:
    
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java

Modified: 
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java?rev=1521050&r1=1521049&r2=1521050&view=diff
==============================================================================
--- 
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestValidationQueryTimeout.java
 Mon Sep  9 11:27:10 2013
@@ -1,3 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  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.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
@@ -10,73 +26,74 @@ import java.sql.Statement;
 import java.util.Properties;
 import java.util.logging.Logger;
 
-import junit.framework.Assert;
-
-import org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor;
+
 public class TestValidationQueryTimeout extends DefaultTestCase {
-    
+
     private static int TIMEOUT = 10;
     private static boolean isTimeoutSet;
     private static final String longQuery = "select * from test as A, test as 
B, test as C, test as D, test as E";
-    
+
     @Before
     public void setUp() throws SQLException {
         DriverManager.registerDriver(new MockDriver());
-        
+
         // use our mock driver
         this.datasource.setDriverClassName(MockDriver.class.getName());
         this.datasource.setUrl(MockDriver.url);
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setInitialSize(1);
         this.datasource.setTestOnBorrow(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery("SELECT 1");
         this.datasource.setValidationQueryTimeout(TIMEOUT);
-        
+
         TIMEOUT = 10;
         isTimeoutSet = false;
     }
-    
+
+    @Override
     @After
     public void tearDown() throws SQLException {
         DriverManager.deregisterDriver(new MockDriver());
     }
-    
+
     @Test
     public void testValidationQueryTimeoutEnabled() throws Exception {
         // because testOnBorrow is true, this triggers the validation query
         this.datasource.getConnection();
         Assert.assertTrue(isTimeoutSet);
     }
-    
+
     @Test
     public void testValidationQueryTimeoutDisabled() throws Exception {
         this.datasource.setValidationQueryTimeout(-1);
-        
+
         // because testOnBorrow is true, this triggers the validation query
         this.datasource.getConnection();
         Assert.assertFalse(isTimeoutSet);
     }
-    
+
     @Test
     public void testValidationQueryTimeoutWithQueryTimeoutInterceptor() throws 
Exception {
         int interceptorTimeout = 30;
         this.datasource.setJdbcInterceptors(
                             QueryTimeoutInterceptor.class.getName()+
                             "(queryTimeout="+ interceptorTimeout +")");
-        
+
         // because testOnBorrow is true, this triggers the validation query
         Connection con = this.datasource.getConnection();
         Assert.assertTrue(isTimeoutSet);
-        
+
         // increase the expected timeout to 30, which is what we set for the 
interceptor
         TIMEOUT = 30;
-        
+
         // now create a statement, make sure the query timeout is set by the 
interceptor
         Statement st = con.createStatement();
         Assert.assertEquals(interceptorTimeout, st.getQueryTimeout());
@@ -88,49 +105,49 @@ public class TestValidationQueryTimeout 
         Assert.assertEquals(interceptorTimeout, st.getQueryTimeout());
         st.close();
         con.close();
-        
+
         // pull another connection and check it
         TIMEOUT = 10;
         isTimeoutSet = false;
         this.datasource.getConnection();
         Assert.assertTrue(isTimeoutSet);
     }
-    
+
     // this test depends on the execution time of the validation query
     //   specifically, it needs to run for longer than 1 second to pass
     //   if this fails
-    @Test(expected=SQLException.class) 
+    @Test(expected=SQLException.class)
     public void testValidationQueryTimeoutOnConnection() throws Exception {
         // use our mock driver
         this.datasource.setDriverClassName("org.h2.Driver");
         
this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setTestOnConnect(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery(longQuery);
         this.datasource.setValidationQueryTimeout(1);
-        
+
         this.datasource.getConnection();
     }
-    
+
     @Test(expected=SQLException.class)
     public void testValidationInvalidOnConnection() throws Exception {
         // use our mock driver
         this.datasource.setDriverClassName("org.h2.Driver");
         
this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setTestOnBorrow(true);
         this.datasource.setInitialSize(1);
         this.datasource.setTestOnConnect(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery("SELECT");
         this.datasource.setValidationQueryTimeout(1);
-        
+
         this.datasource.getConnection();
     }
-    
+
     @Test
     public void testLongValidationQueryTime() throws Exception {
         // use our mock driver
@@ -151,27 +168,27 @@ public class TestValidationQueryTimeout 
         } catch (SQLException ex) {}
         finally {
             end = System.currentTimeMillis();
-        
+
             if (stmt != null) { stmt.close(); }
             if (con != null) { con.close(); }
-            
+
             Assert.assertTrue(start != 0 && end != 0);
             Assert.assertTrue((end - start) > 1000);
         }
     }
-    
+
     @Test
     public void testValidationQueryTimeoutOnBorrow() throws Exception {
         // use our mock driver
         this.datasource.setDriverClassName("org.h2.Driver");
         
this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
-        
-        // Required to trigger validation query's execution 
+
+        // Required to trigger validation query's execution
         this.datasource.setTestOnBorrow(true);
         this.datasource.setValidationInterval(-1);
         this.datasource.setValidationQuery(longQuery);
         this.datasource.setValidationQueryTimeout(1);
-        
+
         // assert that even though the validation query times out, we still 
get a connection
         Connection con = this.datasource.getConnection();
         Assert.assertNotNull(con);
@@ -181,7 +198,7 @@ public class TestValidationQueryTimeout 
         st.close();
         con.close();
     }
-    
+
     /**
      * Mock Driver, Connection and Statement implementations use to verify 
setQueryTimeout was called.
      */
@@ -226,7 +243,7 @@ public class TestValidationQueryTimeout 
             return null;
         }
     }
-    
+
     public static class MockConnection extends 
org.apache.tomcat.jdbc.test.driver.Connection {
         public MockConnection(Properties info) {
             super(info);
@@ -237,7 +254,7 @@ public class TestValidationQueryTimeout 
             return new MockStatement();
         }
     }
-    
+
     public static class MockStatement extends 
org.apache.tomcat.jdbc.test.driver.Statement {
         @Override
         public void setQueryTimeout(int seconds) throws SQLException {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to