Fix MySQL and PostgreSQL testsuite (was caused by uncommited transaction)

This commit is contained in:
mposolda 2014-07-22 07:52:51 +02:00
parent b3b46339a4
commit 3514d5cd78
3 changed files with 7 additions and 10 deletions

View file

@ -402,13 +402,6 @@
<artifactId>keycloak-model-tests</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
</dependencies>
<build>
<plugins>

View file

@ -363,7 +363,7 @@ public class ExportImportTest {
private void pushProperty(String name, String value) {
String currentValue = System.getProperty(name);
if (currentValue != null) {
previousValues.put(name, value);
previousValues.put(name, currentValue);
}
System.setProperty(name, value);
}

View file

@ -45,7 +45,9 @@ public abstract class AbstractKeycloakRule extends ExternalResource {
try {
RealmModel realmByName = session.realms().getRealmByName(realm);
UserModel user = session.users().getUserByUsername(name, realmByName);
return user != null ? ModelToRepresentation.toRepresentation(user) : null;
UserRepresentation userRep = user != null ? ModelToRepresentation.toRepresentation(user) : null;
session.getTransaction().commit();
return userRep;
} finally {
session.close();
}
@ -56,7 +58,9 @@ public abstract class AbstractKeycloakRule extends ExternalResource {
session.getTransaction().begin();
try {
RealmModel realmByName = session.realms().getRealmByName(realm);
return ModelToRepresentation.toRepresentation(session.users().getUserById(id, realmByName));
UserRepresentation userRep = ModelToRepresentation.toRepresentation(session.users().getUserById(id, realmByName));
session.getTransaction().commit();
return userRep;
} finally {
session.close();
}