KEYCLOAK-13070 UserConsentWithUserStorageModelTest failing with ModelDuplicateException

This commit is contained in:
mabartos 2020-02-27 11:39:55 +01:00 committed by Marek Posolda
parent aecfe251e4
commit 695fb92241

View file

@ -60,6 +60,7 @@ public class ConcurrentTransactionsTest extends AbstractTestRealmKeycloakTest {
AtomicReference<String> clientDBIdAtomic = new AtomicReference<>();
AtomicReference<Exception> exceptionHolder = new AtomicReference<>();
try {
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (KeycloakSession sessionSetup) -> {
RealmModel realm = sessionSetup.realms().getRealm("test");
@ -178,8 +179,10 @@ public class ConcurrentTransactionsTest extends AbstractTestRealmKeycloakTest {
session2.sessions().removeUserSessions(realm);
tearDownRealm(session2, "user1", "user2");
});
} finally {
tearDownRealm(session, "user1", "user2");
}
}
@ -188,6 +191,7 @@ public class ConcurrentTransactionsTest extends AbstractTestRealmKeycloakTest {
@ModelTest
public void removeUserAttribute(KeycloakSession session) throws Exception {
try {
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (KeycloakSession sessionSet) -> {
RealmModel realm = sessionSet.realms().createRealm("original");
@ -258,10 +262,9 @@ public class ConcurrentTransactionsTest extends AbstractTestRealmKeycloakTest {
Assert.fail("Exception happened in some of threads. Details: " + reference.get().getMessage());
}
});
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (KeycloakSession sessionTearDown) -> {
tearDownRealm(sessionTearDown, "john", "john2");
});
} finally {
tearDownRealm(session, "john", "john2");
}
}
private void tearDownRealm(KeycloakSession session, String user1, String user2) {