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;
}
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();
}
Aggregations