tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r1055085 - in /tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test: AlternateUsernameTest.java DefaultTestCase.java
Date Tue, 04 Jan 2011 15:55:18 GMT
Author: fhanik
Date: Tue Jan  4 15:55:18 2011
New Revision: 1055085

URL: http://svn.apache.org/viewvc?rev=1055085&view=rev
Log:
Add a test case of no user name change

Modified:
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java?rev=1055085&r1=1055084&r2=1055085&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
Tue Jan  4 15:55:18 2011
@@ -38,13 +38,16 @@ public class AlternateUsernameTest exten
     public AlternateUsernameTest(String name) {
         super(name);
     }
-    
     public void testUsernameCompare() throws Exception {
-        
+        testUsername(true);
+    }
+    
+    private void testUsername(boolean allowUsernameChange) throws Exception {
+        long start = System.currentTimeMillis();
         this.init();
         this.datasource.setDriverClassName(Driver.class.getName());
         this.datasource.setUrl("jdbc:tomcat:test");
-        this.datasource.setAlternateUsernameAllowed(true);
+        this.datasource.setAlternateUsernameAllowed(allowUsernameChange);
         this.datasource.getConnection().close();
         int withoutuser =10;
         int withuser = withoutuser;
@@ -52,7 +55,7 @@ public class AlternateUsernameTest exten
         for (int i=0; i<withuser; i++) {
             TestRunner with = new TestRunner("foo","bar",datasource.getPoolProperties().getUsername(),datasource.getPoolProperties().getPassword());
             TestRunner without = new TestRunner(null,null,datasource.getPoolProperties().getUsername(),datasource.getPoolProperties().getPassword());
-            runners[i] = with;
+            runners[i] = allowUsernameChange?with:without;
             runners[i+withuser] = without;
         }
         ExecutorService svc = Executors.newFixedThreadPool(withuser+withoutuser);
@@ -65,12 +68,13 @@ public class AlternateUsernameTest exten
             failures += results.get(i+withuser).get().failures;
             total+=results.get(i+withuser).get().iterations;
         }
+        long stop = System.currentTimeMillis();
         assertEquals("Nr of failures was:"+failures,0, failures);
         svc.shutdownNow();
         this.datasource.close();
         System.out.println("Nr of connect() calls:"+Driver.connectCount.get());
         System.out.println("Nr of disconnect() calls:"+Driver.disconnectCount.get());
-        System.out.println("Nr of iterations:"+total);
+        System.out.println("Nr of iterations:"+total+" over "+(stop-start)+ " ms.");
 
     }
     
@@ -78,6 +82,10 @@ public class AlternateUsernameTest exten
         testUsernameCompare();
     }
     
+    public void testUsernameCompareNotAllowed() throws Exception {
+        testUsername(false);
+    }
+    
     public static class TestResult {
         public int iterations;
         public int failures;

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java?rev=1055085&r1=1055084&r2=1055085&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java Tue
Jan  4 15:55:18 2011
@@ -180,6 +180,7 @@ public class DefaultTestCase extends Tes
         tDatasource = null;
         //c3p0Datasource = null;
         System.gc();
+        org.apache.tomcat.jdbc.test.driver.Driver.reset();
     }
 
     private final static String PROP_DEFAULTAUTOCOMMIT = "defaultAutoCommit";



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


Mime
View raw message