Java Code Examples for org.jboss.arquillian.container.spi.ContainerRegistry#getContainer()

The following examples show how to use org.jboss.arquillian.container.spi.ContainerRegistry#getContainer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeycloakContainerDeployController.java    From keycloak with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 2
Source File: LoadBalancerControllerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@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();
}