use of org.jboss.arquillian.container.test.api.ContainerController in project keycloak by keycloak.
the class AuthServerTestEnricher method afterClass.
public void afterClass(@Observes(precedence = 1) AfterClass event) throws Exception {
// check if a test accidentally left the auth-server not running
ContainerController controller = containerConroller.get();
if (!controller.isStarted(suiteContext.getAuthServerInfo().getQualifier())) {
log.warn("Auth server wasn't running. Starting " + suiteContext.getAuthServerInfo().getQualifier());
controller.start(suiteContext.getAuthServerInfo().getQualifier());
}
TestContext testContext = testContextProducer.get();
Keycloak adminClient = testContext.getAdminClient();
KeycloakTestingClient testingClient = testContext.getTestingClient();
removeTestRealms(testContext, adminClient);
if (!isAuthServerRemote()) {
boolean wasUpdated = false;
if (event.getTestClass().isAnnotationPresent(SetDefaultProvider.class)) {
SpiProvidersSwitchingUtils.resetProvider(suiteContext, event.getTestClass().getAnnotation(SetDefaultProvider.class));
wasUpdated = true;
}
if (event.getTestClass().isAnnotationPresent(EnableVault.class) && !isAuthServerQuarkus()) {
VaultUtils.disableVault(suiteContext, event.getTestClass().getAnnotation(EnableVault.class).providerId());
wasUpdated = true;
}
if (wasUpdated) {
restartAuthServer();
testContext.reconnectAdminClient();
}
}
if (adminClient != null) {
adminClient.close();
}
if (testingClient != null) {
testingClient.close();
}
}
use of org.jboss.arquillian.container.test.api.ContainerController in project keycloak by keycloak.
the class AppServerTestEnricher method startAppServer.
public void startAppServer(@Observes(precedence = -1) BeforeClass event) throws MalformedURLException, InterruptedException, IOException {
// if testClass implements SelfManagedAppContainerLifecycle we skip starting container and let the test to manage the lifecycle itself
if (SelfManagedAppContainerLifecycle.class.isAssignableFrom(event.getTestClass().getJavaClass())) {
log.debug("Skipping starting App server. Server should be started by testClass.");
return;
}
if (testContext.isAdapterContainerEnabled() && !testContext.isRelativeAdapterTest()) {
if (isJBossBased()) {
prepareServerDir("standalone");
}
ContainerController controller = containerConrollerInstance.get();
if (!controller.isStarted(testContext.getAppServerInfo().getQualifier())) {
log.info("Starting app server: " + testContext.getAppServerInfo().getQualifier());
controller.start(testContext.getAppServerInfo().getQualifier());
}
if (isFuseAppServer()) {
FuseUtils.setUpFuse(ContainerConstants.APP_SERVER_PREFIX + CURRENT_APP_SERVER);
}
}
}
use of org.jboss.arquillian.container.test.api.ContainerController in project keycloak by keycloak.
the class AppServerTestEnricher method stopAppServer.
/*
* For Fuse: precedence = 2 - app server has to be stopped
* before AuthServerTestEnricher.afterClass is executed
*/
public void stopAppServer(@Observes(precedence = 2) AfterClass event) {
if (testContext.getAppServerInfo() == null) {
// no adapter test
return;
}
ContainerController controller = containerConrollerInstance.get();
if (controller.isStarted(testContext.getAppServerInfo().getQualifier())) {
log.info("Stopping app server: " + testContext.getAppServerInfo().getQualifier());
controller.stop(testContext.getAppServerInfo().getQualifier());
}
}
Aggregations