← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16928: DhisSpringTest, clearing Hibernate cache before each test

 

------------------------------------------------------------
revno: 16928
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-02 11:41:32 +0200
message:
  DhisSpringTest, clearing Hibernate cache before each test
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorServiceTest.java
  dhis-2/dhis-support/dhis-support-test/pom.xml
  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-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java	2014-10-01 10:35:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java	2014-10-02 09:41:32 +0000
@@ -139,10 +139,25 @@
         assertNotNull( dataElementService.getDataElement( idD ) );
 
         dataElementService.deleteDataElement( dataElementB );
+        
         assertNotNull( dataElementService.getDataElement( idA ) );
         assertNull( dataElementService.getDataElement( idB ) );
         assertNotNull( dataElementService.getDataElement( idC ) );
         assertNotNull( dataElementService.getDataElement( idD ) );
+
+        dataElementService.deleteDataElement( dataElementC );
+        
+        assertNotNull( dataElementService.getDataElement( idA ) );
+        assertNull( dataElementService.getDataElement( idB ) );
+        assertNull( dataElementService.getDataElement( idC ) );
+        assertNotNull( dataElementService.getDataElement( idD ) );
+
+        dataElementService.deleteDataElement( dataElementD );
+        
+        assertNotNull( dataElementService.getDataElement( idA ) );
+        assertNull( dataElementService.getDataElement( idB ) );
+        assertNull( dataElementService.getDataElement( idC ) );
+        assertNull( dataElementService.getDataElement( idD ) );
     }
 
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java	2014-10-01 10:35:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java	2014-10-02 09:41:32 +0000
@@ -168,6 +168,11 @@
 
         assertNull( dataSetService.getDataSet( idA ) );
         assertNotNull( dataSetService.getDataSet( idB ) );
+
+        dataSetService.deleteDataSet( dataSetService.getDataSet( idB ) );
+
+        assertNull( dataSetService.getDataSet( idA ) );
+        assertNull( dataSetService.getDataSet( idB ) );
     }
 
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorServiceTest.java	2014-10-01 08:54:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorServiceTest.java	2014-10-02 09:41:32 +0000
@@ -28,14 +28,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.DhisSpringTest;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
-import static org.junit.Assert.*;
+import org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
 
 /**
  * @author Lars Helge Overland
@@ -385,9 +388,14 @@
         assertNotNull( indicatorService.getIndicator( idA ) );
         assertNotNull( indicatorService.getIndicator( idB ) );
 
+        indicatorService.deleteIndicator( indicatorA );
+
+        assertNull( indicatorService.getIndicator( idA ) );
+        assertNotNull( indicatorService.getIndicator( idB ) );
+
         indicatorService.deleteIndicator( indicatorB );
 
-        assertNotNull( indicatorService.getIndicator( idA ) );
+        assertNull( indicatorService.getIndicator( idA ) );
         assertNull( indicatorService.getIndicator( idB ) );
     }
 

=== modified file 'dhis-2/dhis-support/dhis-support-test/pom.xml'
--- dhis-2/dhis-support/dhis-support-test/pom.xml	2014-07-23 14:53:00 +0000
+++ dhis-2/dhis-support/dhis-support-test/pom.xml	2014-10-02 09:41:32 +0000
@@ -20,6 +20,10 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.hisp.dhis</groupId>
+      <artifactId>dhis-support-hibernate</artifactId>
+    </dependency>
 
     <!-- Other -->
 

=== 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-08-22 15:39:25 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java	2014-10-02 09:41:32 +0000
@@ -30,8 +30,10 @@
 
 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;
@@ -58,6 +60,9 @@
     {
         this.context = context;
     }
+    
+    @Autowired
+    private HibernateCacheManager cacheManager;
 
     // -------------------------------------------------------------------------
     // Fixture
@@ -66,7 +71,9 @@
     @Before
     public final void before()
         throws Exception
-    {       
+    {
+        cacheManager.clearCache();
+        
         executeStartupRoutines();
         
         setUpTest();