Search in sources :

Example 1 with TargetDescription

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

the class DeploymentTargetModifier method generate.

@Override
public List<DeploymentDescription> generate(TestClass testClass) {
    TestContext context = testContext.get();
    if (context.isAdapterTest() && !context.isAdapterContainerEnabled() && !context.isAdapterContainerEnabledCluster()) {
        // adapter test will be skipped, no need to genarate dependencies
        return new ArrayList<>();
    }
    List<DeploymentDescription> deployments = super.generate(testClass);
    checkTestDeployments(deployments, testClass, context.isAdapterTest());
    Set<String> appServerQualifiers = getAppServerQualifiers(testClass.getJavaClass());
    // no adapter test
    if (appServerQualifiers.isEmpty())
        return deployments;
    String appServerQualifier = appServerQualifiers.stream().filter(q -> q.contains(AppServerTestEnricher.CURRENT_APP_SERVER)).findAny().orElse(null);
    if (appServerQualifier.contains(";"))
        return deployments;
    if (appServerQualifier != null && !appServerQualifier.isEmpty()) {
        for (DeploymentDescription deployment : deployments) {
            final boolean containerMatches = deployment.getTarget() != null && deployment.getTarget().getName().startsWith(appServerQualifier);
            if (deployment.getTarget() == null || Objects.equals(deployment.getTarget().getName(), "_DEFAULT_")) {
                log.debug("Setting target container for " + deployment.getName() + ": " + appServerQualifier);
                deployment.setTarget(new TargetDescription(appServerQualifier));
            } else if (!containerMatches && !deployment.getArchive().getName().equals("run-on-server-classes.war")) {
                // run-on-server deployment can have different target
                throw new RuntimeException("Inconsistency found: target container for " + deployment.getName() + " is set to " + deployment.getTarget().getName() + " but the test class targets " + appServerQualifier);
            }
        }
    }
    return deployments;
}
Also used : DeploymentDescription(org.jboss.arquillian.container.spi.client.deployment.DeploymentDescription) ArrayList(java.util.ArrayList) TargetDescription(org.jboss.arquillian.container.spi.client.deployment.TargetDescription)

Example 2 with TargetDescription

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

the class DeploymentTargetModifier method updateServerQualifier.

private void updateServerQualifier(DeploymentDescription deployment, TestClass testClass, String newServerQualifier) {
    log.infof("Setting target container for deployment %s.%s: %s", testClass.getName(), deployment.getName(), newServerQualifier);
    deployment.setTarget(new TargetDescription(newServerQualifier));
}
Also used : TargetDescription(org.jboss.arquillian.container.spi.client.deployment.TargetDescription)

Aggregations

TargetDescription (org.jboss.arquillian.container.spi.client.deployment.TargetDescription)2 ArrayList (java.util.ArrayList)1 DeploymentDescription (org.jboss.arquillian.container.spi.client.deployment.DeploymentDescription)1