openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1021384 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence: criteria/AbstractCriteriaTestCase.java test/FilteringJDBCListener.java
Date Mon, 11 Oct 2010 15:27:22 GMT
Author: mikedd
Date: Mon Oct 11 15:27:22 2010
New Revision: 1021384

URL: http://svn.apache.org/viewvc?rev=1021384&view=rev
Log:
Use filtering jdbc listener for criteria testcases

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/AbstractCriteriaTestCase.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/FilteringJDBCListener.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/AbstractCriteriaTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/AbstractCriteriaTestCase.java?rev=1021384&r1=1021383&r2=1021384&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/AbstractCriteriaTestCase.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/AbstractCriteriaTestCase.java
Mon Oct 11 15:27:22 2010
@@ -45,6 +45,7 @@ import org.apache.openjpa.lib.jdbc.JDBCL
 import org.apache.openjpa.lib.jdbc.ReportingSQLException;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.test.AllowFailure;
+import org.apache.openjpa.persistence.test.FilteringJDBCListener;
 
 public abstract class AbstractCriteriaTestCase extends TestCase {
 
@@ -371,22 +372,13 @@ public abstract class AbstractCriteriaTe
         return getClass().getAnnotation(AllowFailure.class);
     }
 
-    public class SQLAuditor extends AbstractJDBCListener {
-        private List<String> sqls = new ArrayList<String>();
-
-        @Override
-        public void beforeExecuteStatement(JDBCEvent event) {
-            if (event.getSQL() != null && sqls != null) {
-                sqls.add(event.getSQL());
-            }
-        }
-
-        void clear() {
-            sqls.clear();
+    public class SQLAuditor extends FilteringJDBCListener {
+        public SQLAuditor() {
+            super(new ArrayList<String>());
         }
 
         List<String> getSQLs() {
-            return new ArrayList<String>(sqls);
+            return getCopy();
         }
     }
     

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/FilteringJDBCListener.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/FilteringJDBCListener.java?rev=1021384&r1=1021383&r2=1021384&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/FilteringJDBCListener.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/FilteringJDBCListener.java
Mon Oct 11 15:27:22 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.persistence.test;
 
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -56,4 +57,12 @@ public class FilteringJDBCListener exten
             _sqlStatements.add(sql);
         }
     }
+    
+    public void clear() { 
+        _sqlStatements.clear(); 
+    }
+    
+    public List<String> getCopy() { 
+        return new ArrayList<String>(_sqlStatements);
+    }
 }



Mime
View raw message