Search in sources :

Example 1 with ContainerRegistry

use of org.jboss.arquillian.container.spi.ContainerRegistry in project keycloak by keycloak.

the class KeycloakContainerDeployController method forEachDeployment.

private void forEachDeployment(List<Deployment> deployments, ContainerDeployController.Operation<Container, Deployment> operation) throws Exception {
    injector.get().inject(operation);
    ContainerRegistry containerRegistry = this.containerRegistry.get();
    if (containerRegistry == null) {
        return;
    }
    for (Deployment deployment : deployments) {
        Container container = containerRegistry.getContainer(deployment.getDescription().getTarget());
        operation.perform(container, deployment);
    }
}
Also used : ContainerRegistry(org.jboss.arquillian.container.spi.ContainerRegistry) Container(org.jboss.arquillian.container.spi.Container) DeployDeployment(org.jboss.arquillian.container.spi.event.DeployDeployment) Deployment(org.jboss.arquillian.container.spi.client.deployment.Deployment)

Example 2 with ContainerRegistry

use of org.jboss.arquillian.container.spi.ContainerRegistry in project keycloak by keycloak.

the class RegistryCreator method createRegistry.

public void createRegistry(@Observes ArquillianDescriptor event) {
    ContainerRegistry reg = new Registry(injector.get());
    ServiceLoader serviceLoader = loader.get();
    log.info("arquillian.xml: " + System.getProperty("arquillian.xml"));
    @SuppressWarnings("rawtypes") Collection<DeployableContainer> containers = serviceLoader.all(DeployableContainer.class);
    if (containers.isEmpty()) {
        throw new IllegalStateException("There are not any container adapters on the classpath");
    }
    // arquillian.xml
    List<ContainerDef> containersDefs = event.getContainers();
    // arquillian.xml
    List<GroupDef> groupDefs = event.getGroups();
    // dynamically loaded containers/groups
    addAppServerContainers(containersDefs, groupDefs);
    createRegistry(containersDefs, reg, serviceLoader);
    for (GroupDef group : groupDefs) {
        createRegistry(group.getGroupContainers(), reg, serviceLoader);
    }
    registry.set(reg);
}
Also used : ServiceLoader(org.jboss.arquillian.core.spi.ServiceLoader) DeployableContainer(org.jboss.arquillian.container.spi.client.container.DeployableContainer) ContainerRegistry(org.jboss.arquillian.container.spi.ContainerRegistry) ContainerDef(org.jboss.arquillian.config.descriptor.api.ContainerDef) ContainerRegistry(org.jboss.arquillian.container.spi.ContainerRegistry) GroupDef(org.jboss.arquillian.config.descriptor.api.GroupDef)

Example 3 with ContainerRegistry

use of org.jboss.arquillian.container.spi.ContainerRegistry in project keycloak by keycloak.

the class LoadBalancerControllerProvider method lookup.

@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    String balancerName = null;
    // Check for the presence of possible qualifiers
    for (Annotation a : qualifiers) {
        Class<? extends Annotation> annotationType = a.annotationType();
        if (annotationType.equals(LoadBalancer.class)) {
            balancerName = ((LoadBalancer) a).value();
        }
    }
    ContainerRegistry reg = registry.get();
    Container container = null;
    if (balancerName == null || "".equals(balancerName.trim())) {
        if (reg.getContainers().size() == 1) {
            container = reg.getContainers().get(0);
        } else {
            throw new IllegalArgumentException("Invalid load balancer configuration request - need to specify load balancer name in @LoadBalancerController");
        }
    } else {
        container = reg.getContainer(balancerName);
    }
    if (container == null) {
        throw new IllegalArgumentException("Invalid load balancer configuration - load balancer not found: '" + balancerName + "'");
    }
    if (!(container.getDeployableContainer() instanceof LoadBalancerController)) {
        throw new IllegalArgumentException("Invalid load balancer configuration - container " + container.getName() + " is not a load balancer");
    }
    return container.getDeployableContainer();
}
Also used : ContainerRegistry(org.jboss.arquillian.container.spi.ContainerRegistry) Container(org.jboss.arquillian.container.spi.Container) LoadBalancerController(org.keycloak.testsuite.arquillian.LoadBalancerController) Annotation(java.lang.annotation.Annotation)

Aggregations

ContainerRegistry (org.jboss.arquillian.container.spi.ContainerRegistry)3 Container (org.jboss.arquillian.container.spi.Container)2 Annotation (java.lang.annotation.Annotation)1 ContainerDef (org.jboss.arquillian.config.descriptor.api.ContainerDef)1 GroupDef (org.jboss.arquillian.config.descriptor.api.GroupDef)1 DeployableContainer (org.jboss.arquillian.container.spi.client.container.DeployableContainer)1 Deployment (org.jboss.arquillian.container.spi.client.deployment.Deployment)1 DeployDeployment (org.jboss.arquillian.container.spi.event.DeployDeployment)1 ServiceLoader (org.jboss.arquillian.core.spi.ServiceLoader)1 LoadBalancerController (org.keycloak.testsuite.arquillian.LoadBalancerController)1