Testsuite PoC - Ability to configure server run-mode within the JUnit5 framework (#31109)

Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com>
This commit is contained in:
Lukas Hanusovsky 2024-07-09 14:19:03 +02:00 committed by GitHub
parent 932a92a316
commit 5fdb572f5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 59 additions and 6 deletions

View file

@ -7,7 +7,7 @@ import org.keycloak.test.framework.injection.Registry;
import org.keycloak.test.framework.injection.Supplier; import org.keycloak.test.framework.injection.Supplier;
import org.keycloak.test.framework.injection.SupplierHelpers; import org.keycloak.test.framework.injection.SupplierHelpers;
public class KeycloakTestServerSupplier implements Supplier<KeycloakTestServer, KeycloakIntegrationTest> { public abstract class AbstractKeycloakTestServerSupplier implements Supplier<KeycloakTestServer, KeycloakIntegrationTest> {
@Override @Override
public Class<KeycloakTestServer> getValueType() { public Class<KeycloakTestServer> getValueType() {
@ -23,8 +23,7 @@ public class KeycloakTestServerSupplier implements Supplier<KeycloakTestServer,
public InstanceWrapper<KeycloakTestServer, KeycloakIntegrationTest> getValue(Registry registry, KeycloakIntegrationTest annotation) { public InstanceWrapper<KeycloakTestServer, KeycloakIntegrationTest> getValue(Registry registry, KeycloakIntegrationTest annotation) {
KeycloakTestServerConfig serverConfig = SupplierHelpers.getInstance(annotation.config()); KeycloakTestServerConfig serverConfig = SupplierHelpers.getInstance(annotation.config());
// RemoteKeycloakTestServer keycloakTestServer = new RemoteKeycloakTestServer(); KeycloakTestServer keycloakTestServer = getServer();
EmbeddedKeycloakTestServer keycloakTestServer = new EmbeddedKeycloakTestServer();
keycloakTestServer.start(serverConfig); keycloakTestServer.start(serverConfig);
@ -37,8 +36,10 @@ public class KeycloakTestServerSupplier implements Supplier<KeycloakTestServer,
} }
@Override @Override
public void close(KeycloakTestServer remoteKeycloakTestServer) { public void close(KeycloakTestServer keycloakTestServer) {
remoteKeycloakTestServer.stop(); keycloakTestServer.stop();
} }
public abstract KeycloakTestServer getServer();
} }

View file

@ -0,0 +1,20 @@
package org.keycloak.test.framework.server;
public class DistributionKeycloakTestServer implements KeycloakTestServer {
@Override
public void start(KeycloakTestServerConfig serverConfig) {
throw new RuntimeException("Method not implemented!");
}
@Override
public void stop() {
throw new RuntimeException("Method not implemented!");
}
@Override
public String getBaseUrl() {
return "http://localhost:8080";
}
}

View file

@ -0,0 +1,10 @@
package org.keycloak.test.framework.server;
public class DistributionKeycloakTestServerSupplier extends AbstractKeycloakTestServerSupplier {
@Override
public KeycloakTestServer getServer() {
return new DistributionKeycloakTestServer();
}
}

View file

@ -0,0 +1,10 @@
package org.keycloak.test.framework.server;
public class EmbeddedKeycloakTestServerSupplier extends AbstractKeycloakTestServerSupplier {
@Override
public KeycloakTestServer getServer() {
return new EmbeddedKeycloakTestServer();
}
}

View file

@ -0,0 +1,10 @@
package org.keycloak.test.framework.server;
public class RemoteKeycloakTestServerSupplier extends AbstractKeycloakTestServerSupplier {
@Override
public KeycloakTestServer getServer() {
return new RemoteKeycloakTestServer();
}
}

View file

@ -1,6 +1,8 @@
org.keycloak.test.framework.admin.KeycloakAdminClientSupplier org.keycloak.test.framework.admin.KeycloakAdminClientSupplier
org.keycloak.test.framework.realm.ClientSupplier org.keycloak.test.framework.realm.ClientSupplier
org.keycloak.test.framework.realm.RealmSupplier org.keycloak.test.framework.realm.RealmSupplier
org.keycloak.test.framework.server.KeycloakTestServerSupplier org.keycloak.test.framework.server.EmbeddedKeycloakTestServerSupplier
org.keycloak.test.framework.server.DistributionKeycloakTestServerSupplier
org.keycloak.test.framework.server.RemoteKeycloakTestServerSupplier
org.keycloak.test.framework.webdriver.ChromeWebDriverSupplier org.keycloak.test.framework.webdriver.ChromeWebDriverSupplier
org.keycloak.test.framework.webdriver.FirefoxWebDriverSupplier org.keycloak.test.framework.webdriver.FirefoxWebDriverSupplier