Fix all tests with MySQL. Removing nested transactions
This commit is contained in:
parent
1375e72cf7
commit
cec57b169e
8 changed files with 16 additions and 23 deletions
|
@ -78,7 +78,7 @@
|
|||
Once a user is logged in, they can visit any other application managed by the realm and not have to re-enter
|
||||
credentials. This also hold true for logging out. Roles can also be defined at the application level and
|
||||
assigned to specific users. Depending on the application type, you may also be able to view and manage
|
||||
user sessions from the adminstration console.
|
||||
user sessions from the administration console.
|
||||
</para>
|
||||
<para>
|
||||
An <emphasis>oauth client</emphasis> is similar to an application in that it can request something like a login
|
||||
|
|
|
@ -16,8 +16,6 @@ import javax.persistence.Persistence;
|
|||
*/
|
||||
public class JpaModelProvider implements ModelProvider {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JpaModelProvider.class);
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "jpa";
|
||||
|
@ -26,7 +24,6 @@ public class JpaModelProvider implements ModelProvider {
|
|||
@Override
|
||||
public KeycloakSessionFactory createFactory() {
|
||||
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa-keycloak-identity-store", getHibernateProperties());
|
||||
logger.info("RDBMS connection url: " + emf.getProperties().get("hibernate.connection.url"));
|
||||
return new JpaKeycloakSessionFactory(emf);
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,14 @@ public class AbstractModelTest {
|
|||
factory.close();
|
||||
}
|
||||
|
||||
protected void commit() {
|
||||
identitySession.getTransaction().commit();
|
||||
identitySession.close();
|
||||
identitySession = factory.createSession();
|
||||
identitySession.getTransaction().begin();
|
||||
realmManager = new RealmManager(identitySession);
|
||||
}
|
||||
|
||||
public static RealmRepresentation loadJson(String path) throws IOException {
|
||||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
|
|
@ -96,11 +96,7 @@ public class AdapterTest extends AbstractModelTest {
|
|||
String id = realmModel.getId();
|
||||
System.out.println("id: " + id);
|
||||
|
||||
identitySession.getTransaction().commit();
|
||||
identitySession.close();
|
||||
identitySession = factory.createSession();
|
||||
identitySession.getTransaction().begin();
|
||||
realmManager = new RealmManager(identitySession);
|
||||
commit();
|
||||
List<RealmModel> realms = identitySession.getRealms(null);
|
||||
System.out.println("num realms: " + realms.size());
|
||||
Assert.assertEquals(realms.size(), 1);
|
||||
|
|
|
@ -99,14 +99,6 @@ public class UserModelTest extends AbstractModelTest {
|
|||
Assert.assertTrue(user.getRequiredActions().isEmpty());
|
||||
}
|
||||
|
||||
protected void commit() {
|
||||
identitySession.getTransaction().commit();
|
||||
identitySession.close();
|
||||
identitySession = factory.createSession();
|
||||
identitySession.getTransaction().begin();
|
||||
realmManager = new RealmManager(identitySession);
|
||||
}
|
||||
|
||||
public static void assertEquals(UserModel expected, UserModel actual) {
|
||||
Assert.assertEquals(expected.getLoginName(), actual.getLoginName());
|
||||
Assert.assertEquals(expected.getFirstName(), actual.getFirstName());
|
||||
|
|
|
@ -29,7 +29,6 @@ public class KeycloakServerApplication extends KeycloakApplication {
|
|||
session.getTransaction().begin();
|
||||
RealmRepresentation rep = loadJson(new FileInputStream(importRealm), RealmRepresentation.class);
|
||||
importRealm(session, rep);
|
||||
session.getTransaction().commit();
|
||||
}
|
||||
|
||||
String themeDir = System.getProperty("keycloak.theme.dir");
|
||||
|
|
|
@ -96,7 +96,7 @@ public class KeycloakServer {
|
|||
}
|
||||
}
|
||||
|
||||
private static <T> T loadJson(InputStream is, Class<T> type) {
|
||||
public static <T> T loadJson(InputStream is, Class<T> type) {
|
||||
try {
|
||||
return JsonSerialization.readValue(is, type);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.keycloak.testsuite.pages.LoginPage;
|
|||
import org.keycloak.testsuite.rule.AbstractKeycloakRule;
|
||||
import org.keycloak.testsuite.rule.WebResource;
|
||||
import org.keycloak.testsuite.rule.WebRule;
|
||||
import org.keycloak.testutils.KeycloakServer;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
@ -55,12 +56,12 @@ public class CompositeImportRoleTest {
|
|||
public static AbstractKeycloakRule keycloakRule = new AbstractKeycloakRule(){
|
||||
@Override
|
||||
protected void configure(RealmManager manager, RealmModel adminRealm) {
|
||||
server.importRealm(getClass().getResourceAsStream("/testcomposite.json"));
|
||||
RealmModel realm = manager.getRealmByName("Test");
|
||||
RealmModel realm = manager.createRealm("Test");
|
||||
RealmRepresentation representation = KeycloakServer.loadJson(getClass().getResourceAsStream("/testcomposite.json"), RealmRepresentation.class);
|
||||
manager.importRealm(representation, realm);
|
||||
|
||||
realmPublicKey = realm.getPublicKey();
|
||||
|
||||
|
||||
|
||||
deployServlet("app", "/app", ApplicationServlet.class);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue