← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22164: DhisSpringTest, autowire

 

------------------------------------------------------------
revno: 22164
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-03-07 19:18:23 +0100
message:
  DhisSpringTest, autowire
modified:
  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-test/src/main/java/org/hisp/dhis/DhisSpringTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java	2016-03-07 18:18:23 +0000
@@ -32,8 +32,8 @@
 
 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;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.transaction.annotation.Transactional;
@@ -46,19 +46,14 @@
 @ContextConfiguration( locations = { "classpath*:/META-INF/dhis/beans.xml", "classpath*:/META-INF/dhis/security.xml" } )
 @Transactional
 public abstract class DhisSpringTest
-    extends DhisConvenienceTest implements ApplicationContextAware
+    extends DhisConvenienceTest
 {
     // -------------------------------------------------------------------------
     // ApplicationContextAware implementation
     // -------------------------------------------------------------------------
 
+    @Autowired
     protected ApplicationContext context;
-
-    @Override
-    public void setApplicationContext( ApplicationContext context )
-    {
-        this.context = context;
-    }
     
     // -------------------------------------------------------------------------
     // Fixture
@@ -104,7 +99,7 @@
     {
         String id = "org.hisp.dhis.system.startup.StartupRoutineExecutor";
 
-        if ( context.containsBean( id ) )
+        if ( context != null && context.containsBean( id ) )
         {
             Object object = context.getBean( id );