dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33173
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16913: Test, flush/clear session in createUserAndInjectSecurityContext
------------------------------------------------------------
revno: 16913
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-01 16:39:00 +0200
message:
Test, flush/clear session in createUserAndInjectSecurityContext
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dbms/DbmsManager.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.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-api/src/main/java/org/hisp/dhis/dbms/DbmsManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dbms/DbmsManager.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dbms/DbmsManager.java 2014-10-01 14:39:00 +0000
@@ -38,6 +38,8 @@
void emptyDatabase();
+ void flushSession();
+
void clearSession();
void emptyTable( String table );
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2014-08-04 14:27:32 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java 2014-10-01 14:39:00 +0000
@@ -211,6 +211,11 @@
log.debug( "Cleared Hibernate cache" );
}
+ public void flushSession()
+ {
+ sessionFactory.getCurrentSession().flush();
+ }
+
public void clearSession()
{
sessionFactory.getCurrentSession().clear();
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2014-10-01 09:50:38 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2014-10-01 14:39:00 +0000
@@ -81,6 +81,7 @@
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueAuditService;
import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.dbms.DbmsManager;
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.expression.Operator;
@@ -130,6 +131,7 @@
import org.hisp.dhis.validation.ValidationRuleService;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
@@ -217,6 +219,9 @@
protected IdentifiableObjectManager identifiableObjectManager;
+ @Autowired
+ protected DbmsManager dbmsManager;
+
static
{
Calendar calendar = Calendar.getInstance();
@@ -1624,6 +1629,9 @@
Authentication authentication = new UsernamePasswordAuthenticationToken( userDetails, "", authorities );
SecurityContextHolder.getContext().setAuthentication( authentication );
+ dbmsManager.flushSession();
+ dbmsManager.clearSession();
+
return user;
}
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisTest.java 2014-10-01 14:39:00 +0000
@@ -32,11 +32,9 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hisp.dhis.dbms.DbmsManager;
import org.junit.After;
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.orm.hibernate4.SessionFactoryUtils;
@@ -56,9 +54,6 @@
public abstract class DhisTest
extends DhisConvenienceTest implements ApplicationContextAware
{
- @Autowired
- protected DbmsManager dbmsManager;
-
// -------------------------------------------------------------------------
// ApplicationContextAware implementation
// -------------------------------------------------------------------------