Search in sources :

Example 1 with TestCleanup

use of org.keycloak.testsuite.util.TestCleanup in project keycloak by keycloak.

the class TestContext method getOrCreateCleanup.

public TestCleanup getOrCreateCleanup(String realmName) {
    TestCleanup cleanup = cleanups.get(realmName);
    if (cleanup == null) {
        cleanup = new TestCleanup(this, realmName);
        TestCleanup existing = cleanups.putIfAbsent(realmName, cleanup);
        if (existing != null) {
            cleanup = existing;
        }
    }
    return cleanup;
}
Also used : TestCleanup(org.keycloak.testsuite.util.TestCleanup)

Example 2 with TestCleanup

use of org.keycloak.testsuite.util.TestCleanup in project keycloak by keycloak.

the class AbstractKeycloakTest method afterAbstractKeycloakTest.

@After
public void afterAbstractKeycloakTest() throws Exception {
    if (resetTimeOffset) {
        resetTimeOffset();
    }
    if (isImportAfterEachMethod()) {
        log.info("removing test realms after test method");
        for (RealmRepresentation testRealm : testRealmReps) {
            removeRealm(testRealm.getRealm());
        }
    } else {
        log.info("calling all TestCleanup");
        // Remove all sessions
        testContext.getTestRealmReps().stream().forEach((r) -> testingClient.testing().removeUserSessions(r.getRealm()));
        // Cleanup objects
        for (TestCleanup cleanup : testContext.getCleanups().values()) {
            try {
                if (cleanup != null)
                    cleanup.executeCleanup();
            } catch (Exception e) {
                log.error("failed cleanup!", e);
                throw new RuntimeException(e);
            }
        }
        testContext.getCleanups().clear();
    }
    postAfterAbstractKeycloak();
    // Remove all browsers from queue
    DroneUtils.resetQueue();
}
Also used : TestCleanup(org.keycloak.testsuite.util.TestCleanup) RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) URISyntaxException(java.net.URISyntaxException) NotFoundException(javax.ws.rs.NotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) TestTimedOutException(org.junit.runners.model.TestTimedOutException) IOException(java.io.IOException) After(org.junit.After)

Aggregations

TestCleanup (org.keycloak.testsuite.util.TestCleanup)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 NotFoundException (javax.ws.rs.NotFoundException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 After (org.junit.After)1 TestTimedOutException (org.junit.runners.model.TestTimedOutException)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1