Search in sources :

Example 1 with DeployableContainer

use of org.jboss.arquillian.container.spi.client.container.DeployableContainer 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 2 with DeployableContainer

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

the class Registry method create.

@Override
public Container create(ContainerDef definition, ServiceLoader loader) {
    Validate.notNull(definition, "Definition must be specified");
    try {
        logger.log(Level.FINE, "Registering container: {0}", definition.getContainerName());
        @SuppressWarnings("rawtypes") Collection<DeployableContainer> containerAdapters = loader.all(DeployableContainer.class);
        DeployableContainer<?> dcService = null;
        if (containerAdapters.size() == 1) {
            // just one container on cp
            dcService = containerAdapters.iterator().next();
        } else {
            Container domainContainer = domainContainer(loader, definition);
            if (domainContainer != null) {
                return domainContainer;
            }
            if (dcService == null) {
                dcService = getContainerAdapter(getAdapterImplClassValue(definition), containerAdapters);
            }
            if (dcService == null) {
                throw new ConfigurationException("Unable to get container adapter from Arquillian configuration.");
            }
        }
        // before a Container is added to a collection of containers, inject into its injection point
        return addContainer(injector.inject(new ContainerImpl(definition.getContainerName(), dcService, definition)));
    } catch (ConfigurationException e) {
        throw new ContainerCreationException("Could not create Container " + definition.getContainerName(), e);
    }
}
Also used : DeployableContainer(org.jboss.arquillian.container.spi.client.container.DeployableContainer) DeployableContainer(org.jboss.arquillian.container.spi.client.container.DeployableContainer) Container(org.jboss.arquillian.container.spi.Container) ConfigurationException(org.jboss.arquillian.container.spi.ConfigurationException) ContainerImpl(org.jboss.arquillian.container.impl.ContainerImpl) ContainerCreationException(org.jboss.arquillian.container.impl.ContainerCreationException)

Aggregations

DeployableContainer (org.jboss.arquillian.container.spi.client.container.DeployableContainer)2 ContainerDef (org.jboss.arquillian.config.descriptor.api.ContainerDef)1 GroupDef (org.jboss.arquillian.config.descriptor.api.GroupDef)1 ContainerCreationException (org.jboss.arquillian.container.impl.ContainerCreationException)1 ContainerImpl (org.jboss.arquillian.container.impl.ContainerImpl)1 ConfigurationException (org.jboss.arquillian.container.spi.ConfigurationException)1 Container (org.jboss.arquillian.container.spi.Container)1 ContainerRegistry (org.jboss.arquillian.container.spi.ContainerRegistry)1 ServiceLoader (org.jboss.arquillian.core.spi.ServiceLoader)1