← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17088: Testing, disabling hibernate second level cache during tests

 

------------------------------------------------------------
revno: 17088
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-13 19:27:17 +0200
message:
  Testing, disabling hibernate second level cache during tests
modified:
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java	2014-10-13 17:27:17 +0000
@@ -142,9 +142,9 @@
         // Choose which properties file to look for
         // ---------------------------------------------------------------------
 
-        String testing = System.getProperty( "org.hisp.dhis.test", "false" );
+        boolean testing = "true".equals( System.getProperty( "org.hisp.dhis.test", "false" ) );
 
-        String propertiesFile = testing.equals( "true" ) ? testPropertiesFile : regularPropertiesFile;
+        String propertiesFile = testing ? testPropertiesFile : regularPropertiesFile;
 
         // ---------------------------------------------------------------------
         // Add custom properties from classpath
@@ -169,6 +169,16 @@
         {
             log.info( "Could not read external configuration from file system" );
         }
+
+        // ---------------------------------------------------------------------
+        // Disable second-level cache during testing
+        // ---------------------------------------------------------------------
+        
+        if ( testing )
+        {
+            configuration.setProperty( "hibernate.cache.use_second_level_cache", "false" );
+            configuration.setProperty( "hibernate.cache.use_query_cache", "false" );
+        }
         
         log.info( "Hibernate configuration loaded, using dialect: " + configuration.getProperty( "hibernate.dialect" ) );
         

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java	2014-10-02 09:41:32 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java	2014-10-13 17:27:17 +0000
@@ -30,10 +30,8 @@
 
 import java.lang.reflect.Method;
 
-import org.hisp.dhis.cache.HibernateCacheManager;
 import org.junit.Before;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.test.context.ContextConfiguration;
@@ -61,9 +59,6 @@
         this.context = context;
     }
     
-    @Autowired
-    private HibernateCacheManager cacheManager;
-
     // -------------------------------------------------------------------------
     // Fixture
     // -------------------------------------------------------------------------
@@ -72,8 +67,6 @@
     public final void before()
         throws Exception
     {
-        cacheManager.clearCache();
-        
         executeStartupRoutines();
         
         setUpTest();