Search in sources :

Example 1 with LoadBalancerController

use of org.keycloak.testsuite.arquillian.LoadBalancerController 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

Annotation (java.lang.annotation.Annotation)1 Container (org.jboss.arquillian.container.spi.Container)1 ContainerRegistry (org.jboss.arquillian.container.spi.ContainerRegistry)1 LoadBalancerController (org.keycloak.testsuite.arquillian.LoadBalancerController)1