diff --git a/testsuite/integration-arquillian/pom.xml b/testsuite/integration-arquillian/pom.xml index 5266731c2f..ed794f13fd 100644 --- a/testsuite/integration-arquillian/pom.xml +++ b/testsuite/integration-arquillian/pom.xml @@ -45,7 +45,7 @@ 2.52.0 2.0.0.Beta1 2.1.0.Alpha3 - 8.2.0.Final + 2.0.0.Final 2.2.2 1.0.0.Alpha2 @@ -74,15 +74,20 @@ import - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-managed ${arquillian-wildfly-container.version} - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-remote ${arquillian-wildfly-container.version} + + org.wildfly.arquillian + wildfly-arquillian-container-domain-managed + ${arquillian-wildfly-container.version} + diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/Registry.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/Registry.java index c682597c9b..6bbe084117 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/Registry.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/Registry.java @@ -34,8 +34,11 @@ import org.jboss.arquillian.container.spi.client.deployment.TargetDescription; import org.jboss.arquillian.core.api.Injector; import org.jboss.arquillian.core.spi.ServiceLoader; import org.jboss.arquillian.core.spi.Validate; +import static org.keycloak.testsuite.arquillian.containers.RegistryCreator.ADAPTER_IMPL_CONFIG_STRING; import static org.keycloak.testsuite.arquillian.containers.RegistryCreator.getAdapterImplClassValue; import static org.keycloak.testsuite.arquillian.containers.RegistryCreator.getContainerAdapter; +import static org.keycloak.testsuite.arquillian.containers.SecurityActions.isClassPresent; +import static org.keycloak.testsuite.arquillian.containers.SecurityActions.loadClass; /** * This class registers all adapters which are specified in the arquillian.xml. @@ -78,6 +81,10 @@ public class Registry implements ContainerRegistry { // 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); } @@ -94,6 +101,42 @@ public class Registry implements ContainerRegistry { throw new ContainerCreationException("Could not create Container " + definition.getContainerName(), e); } } + + private Container domainContainer(ServiceLoader loader, ContainerDef definition) { + for (Container container : containers) { + String adapterImplClassValue = container.getContainerConfiguration().getContainerProperties() + .get(ADAPTER_IMPL_CONFIG_STRING); + + if (isServiceLoaderClassAssignableFromAdapterImplClass(loader, adapterImplClassValue.trim())) { + try { + return addContainer((Container) injector.inject( + new ContainerImpl( + definition.getContainerName(), + (DeployableContainer) loader.onlyOne(DeployableContainer.class), + definition))); + } catch (Exception ex) { + throw new ContainerCreationException( + "Could not create Container " + definition.getContainerName(), ex); + } + } + } + return null; + } + + private boolean isServiceLoaderClassAssignableFromAdapterImplClass(ServiceLoader loader, String adapterImplClassValue) { + if (adapterImplClassValue == null && loader == null) { + return false; + } + if (isClassPresent(adapterImplClassValue)) { + Class aClass = loadClass(adapterImplClassValue); + String loaderClassName = loader.getClass().getName(); + if (loaderClassName.contains("$")) { + loaderClassName = loaderClassName.substring(0, loaderClassName.indexOf("$")); + } + return loadClass(loaderClassName).isAssignableFrom(aClass); + } + return false; + } @Override public List getContainers() { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/RegistryCreator.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/RegistryCreator.java index f1aa524111..f330ab9b90 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/RegistryCreator.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/RegistryCreator.java @@ -17,6 +17,7 @@ package org.keycloak.testsuite.arquillian.containers; import java.util.Collection; +import java.util.List; import java.util.Map; import org.jboss.arquillian.config.descriptor.api.ArquillianDescriptor; @@ -71,7 +72,17 @@ public class RegistryCreator { throw new IllegalStateException("There are not any container adapters on the classpath"); } - for (ContainerDef container : event.getContainers()) { + createRegistry(event.getContainers(), containers, reg, serviceLoader); + + for (GroupDef group : event.getGroups()) { + createRegistry(group.getGroupContainers(), containers, reg, serviceLoader); + } + + registry.set(reg); + } + + private void createRegistry(List containerDefs, Collection containers, ContainerRegistry reg, ServiceLoader serviceLoader) { + for (ContainerDef container : containerDefs) { if (isCreatingContainer(container, containers)) { if (isEnabled(container)) { log.info("Registering container: " + container.getContainerName()); @@ -81,21 +92,6 @@ public class RegistryCreator { } } } - - for (GroupDef group : event.getGroups()) { - for (ContainerDef container : group.getGroupContainers()) { - if (isCreatingContainer(container, containers)) { - if (isEnabled(container)) { - log.info("Registering container: " + container.getContainerName()); - reg.create(container, serviceLoader); - } else { - log.info("Container is disabled: " + container.getContainerName()); - } - } - } - } - - registry.set(reg); } private static final String ENABLED = "enabled"; @@ -138,7 +134,7 @@ public class RegistryCreator { Validate.notNullOrEmpty(adapterImplClass, "The value of " + ADAPTER_IMPL_CONFIG_STRING + " can not be a null object " + "nor an empty string!"); - Class foundAdapter = null; + Class foundAdapter; if (isClassPresent(adapterImplClass)) { foundAdapter = loadClass(adapterImplClass); diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LogChecker.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LogChecker.java index ac1b059eb9..e968c7d5cf 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LogChecker.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/LogChecker.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.keycloak.testsuite.util; import org.apache.commons.io.FileUtils; @@ -21,20 +37,20 @@ public class LogChecker { log.info(String.format("Checking server log: '%s'", logFile.getAbsolutePath())); String[] logContent = FileUtils.readFileToString(logFile).split("\n"); - for (String log : logContent) { - boolean containsError = log.contains("ERROR") || log.contains("SEVERE") || log.contains("Exception "); + for (String logText : logContent) { + boolean containsError = logText.contains("ERROR") || logText.contains("SEVERE") || logText.contains("Exception "); //There is expected string "Exception" in server log: Adding provider //singleton org.keycloak.services.resources.ModelExceptionMapper if (containsError) { boolean ignore = false; for (String i : IGNORED) { - if (log.matches(i)) { + if (logText.matches(i)) { ignore = true; break; } } if (!ignore) { - throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", log)); + throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", logText)); } } } @@ -42,7 +58,15 @@ public class LogChecker { } public static void checkJBossServerLog(String jbossHome) throws IOException { - checkServerLog(new File(jbossHome + "/standalone/log/server.log")); + boolean domain = System.getProperty("auth.server.config.property.name", "standalone").contains("domain"); + if (domain) { + checkServerLog(new File(jbossHome + "/domain/log/process-controller.log")); + checkServerLog(new File(jbossHome + "/domain/log/host-controller.log")); + checkServerLog(new File(jbossHome + "/domain/servers/load-balancer/log/server.log")); + checkServerLog(new File(jbossHome + "/domain/servers/server-one/log/server.log")); + } else { + checkServerLog(new File(jbossHome + "/standalone/log/server.log")); + } } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml index 6ccaea4df7..215da8e498 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml @@ -57,9 +57,11 @@ ${auth.server.jboss} - org.jboss.as.arquillian.container.managed.ManagedDeployableContainer + ${auth.server.adapter.impl.class} ${auth.server.home} - ${auth.server.config} + ${auth.server.config.property.value} + + true -Djboss.socket.binding.port-offset=${auth.server.port.offset} -Djboss.bind.address=0.0.0.0 @@ -221,4 +223,4 @@ - + \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml b/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml index e073ae7aca..69869fa7ab 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml @@ -129,9 +129,8 @@ - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-${app.server.type} - ${arquillian-wildfly-container.version} diff --git a/testsuite/integration-arquillian/tests/other/clean-start/pom.xml b/testsuite/integration-arquillian/tests/other/clean-start/pom.xml index 72b74c1a47..1fb3ff90c2 100644 --- a/testsuite/integration-arquillian/tests/other/clean-start/pom.xml +++ b/testsuite/integration-arquillian/tests/other/clean-start/pom.xml @@ -62,8 +62,24 @@ standalone-ha - standalone-ha.xml + standalone-ha.xml + + domain + + domainConfig + domain.xml + ${auth.server.home}/domain/configuration + org.jboss.as.arquillian.container.domain.managed.ManagedDomainDeployableContainer + 9990 + + + + org.wildfly.arquillian + wildfly-arquillian-container-domain-managed + + + - \ No newline at end of file + diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index c5ab9541e5..c3b3ccd1ab 100755 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -56,7 +56,9 @@ false 60 -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m - + serverConfig + org.jboss.as.arquillian.container.managed.ManagedDeployableContainer + integration-arquillian-servers-auth-server-${auth.server} ${auth.server.undertow} 300 @@ -155,7 +157,10 @@ ${auth.server.ssl.required} ${auth.server.jboss.startup.timeout} ${auth.server.config.dir} - ${auth.server.config} + ${auth.server.config.property.name} + ${auth.server.config.property.value} + ${auth.server.adapter.impl.class} + ${frontend.console.output} ${backend.console.output} @@ -205,13 +210,13 @@ wildfly true false - standalone.xml + standalone.xml ${auth.server.home}/standalone/configuration 1.3.173 - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-managed @@ -223,13 +228,13 @@ eap true false - standalone.xml + standalone.xml ${auth.server.home}/standalone/configuration 1.3.173 - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-managed