openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dazey...@apache.org
Subject svn commit: r1831594 - /openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparametrization.java
Date Mon, 14 May 2018 22:11:29 GMT
Author: dazeydev
Date: Mon May 14 22:11:29 2018
New Revision: 1831594

URL: http://svn.apache.org/viewvc?rev=1831594&view=rev
Log:
OPENJPA-2646: Fixing test bug to clear cache from other tests

Modified:
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparametrization.java

Modified: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparametrization.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparametrization.java?rev=1831594&r1=1831593&r2=1831594&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparametrization.java
(original)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestMultithreadedReparametrization.java
Mon May 14 22:11:29 2018
@@ -89,12 +89,17 @@ public class TestMultithreadedReparametr
         for (Thread thread : threads) {
             thread.join();
         }
-        QueryStatistics<String> stats = emf.getConfiguration().getQuerySQLCacheInstance().getStatistics();
-        for(Throwable t : exceptions) {
-            fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+        try {
+            QueryStatistics<String> stats = emf.getConfiguration().getQuerySQLCacheInstance().getStatistics();
+            for(Throwable t : exceptions) {
+                fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+            }
+            assertEquals(nThreads*nRepeats,stats.getExecutionCount(), stats.getExecutionCount(jpql));
+            assertEquals(nThreads*nRepeats-1,stats.getExecutionCount(), stats.getHitCount(jpql));
+        } finally {
+            //clear statistics for other tests
+            emf.getConfiguration().getQuerySQLCacheInstance().clear();
         }
-        assertEquals(nThreads*nRepeats,stats.getExecutionCount(), stats.getExecutionCount(jpql));
-        assertEquals(nThreads*nRepeats-1,stats.getExecutionCount(), stats.getHitCount(jpql));
     }
 
     /**
@@ -157,8 +162,12 @@ public class TestMultithreadedReparametr
                 }
             }
 
-            for(Throwable t : exceptions) {
-                fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+            try {
+                for(Throwable t : exceptions) {
+                    fail((t.getCause() != null ? t.getCause().toString() : t.toString()));
+                }
+            } finally {
+                emf.getConfiguration().getQuerySQLCacheInstance().clear();
             }
         }
     }



Mime
View raw message