org.jboss.arquillian.container.spi.client.deployment.TargetDescription Java Examples

The following examples show how to use org.jboss.arquillian.container.spi.client.deployment.TargetDescription. 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: FurnaceDeploymentScenarioGenerator.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private TargetDescription generateTarget(Method deploymentMethod)
{
   if (deploymentMethod.isAnnotationPresent(TargetsContainer.class))
   {
      return new TargetDescription(deploymentMethod.getAnnotation(TargetsContainer.class).value());
   }
   return TargetDescription.DEFAULT;
}
 
Example #2
Source File: Registry.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public Container getContainer(TargetDescription target) {
    Validate.notNull(target, "Target must be specified");
    if (TargetDescription.DEFAULT.equals(target)) {
        return findDefaultContainer();
    }
    return findMatchingContainer(target.getName());
}
 
Example #3
Source File: DeploymentTargetModifier.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public List<DeploymentDescription> generate(TestClass testClass) {
    TestContext context = testContext.get();
    if (context.isAdapterTest() && !context.isAdapterContainerEnabled() && !context.isAdapterContainerEnabledCluster()) {
        return new ArrayList<>(); // adapter test will be skipped, no need to genarate dependencies
    }

    List<DeploymentDescription> deployments = super.generate(testClass);

    checkTestDeployments(deployments, testClass, context.isAdapterTest());
    Set<String> appServerQualifiers = getAppServerQualifiers(testClass.getJavaClass());
    if (appServerQualifiers.isEmpty()) return deployments; // no adapter test

    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;
}
 
Example #4
Source File: MicroProfileMetricsTCKDeploymentPackager.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public TargetDescription getTargetDescription() {
    return testDeployment.getTargetDescription();
}
 
Example #5
Source File: MicroProfileJWTTCKArchiveProcessor.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void process(final Archive<?> applicationArchive, final TestClass testClass) {
    if (!(applicationArchive instanceof WebArchive)) {
        return;
    }
    final WebArchive war = WebArchive.class.cast(applicationArchive);

    // Add Required Libraries
    war.addAsLibrary(JarLocation.jarLocation(TokenUtils.class))
       .addAsLibrary(JarLocation.jarLocation(JWSSigner.class))
       .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");

    // Provide keys required for tests (vendor specific way)
    war.addClass(JWTAuthContextInfoProvider.class);

    // Spec says that vendor specific ways to load the keys take precedence, so we need to remove it in test
    // cases that use the Config approach.
    Stream.of(
            PublicKeyAsPEMTest.class,
            PublicKeyAsPEMLocationTest.class,
            PublicKeyAsFileLocationURLTest.class,
            PublicKeyAsJWKTest.class,
            PublicKeyAsBase64JWKTest.class,
            PublicKeyAsJWKLocationTest.class,
            PublicKeyAsJWKLocationURLTest.class,
            PublicKeyAsJWKSTest.class,
            PublicKeyAsJWKSLocationTest.class,
            IssValidationTest.class,
            ExpClaimValidationTest.class,
            ExpClaimAllowMissingExpValidationTest.class,
            org.apache.tomee.microprofile.tck.jwt.config.PublicKeyAsPEMLocationTest.class,
            org.apache.tomee.microprofile.tck.jwt.config.PublicKeyAsJWKLocationURLTest.class)
          .filter(c -> c.equals(testClass.getJavaClass()))
          .findAny()
          .ifPresent(c -> war.deleteClass(JWTAuthContextInfoProvider.class));

    // MP Config in wrong place - See https://github.com/eclipse/microprofile/issues/46.
    final Map<ArchivePath, Node> content = war.getContent(object -> object.get().matches(".*META-INF/.*"));
    content.forEach((archivePath, node) -> war.addAsResource(node.getAsset(), node.getPath()));

    // Rewrite the correct server port in configuration
    final Container container = containerRegistry.get().getContainer(TargetDescription.DEFAULT);
    if (container.getDeployableContainer() instanceof RemoteTomEEContainer) {
        final RemoteTomEEContainer remoteTomEEContainer =
                (RemoteTomEEContainer) container.getDeployableContainer();
        final RemoteTomEEConfiguration configuration = remoteTomEEContainer.getConfiguration();
        final String httpPort = configuration.getHttpPort() + "";

        final Map<ArchivePath, Node> microprofileProperties = war.getContent(
                object -> object.get().matches(".*META-INF/microprofile-config\\.properties"));
        microprofileProperties.forEach((archivePath, node) -> {
            try {
                final Properties properties = new Properties();
                properties.load(node.getAsset().openStream());
                properties.replaceAll((key, value) -> ((String) value).replaceAll("8080", httpPort + "/" + "KeyEndpoint.war".replaceAll("\\.war", "")));
                final StringWriter stringWriter = new StringWriter();
                properties.store(stringWriter, null);
                war.delete(archivePath);
                war.add(new StringAsset(stringWriter.toString()), node.getPath());
            } catch (final IOException e) {
                e.printStackTrace();
            }
        });
    }

    System.out.println(war.toString(true));
}
 
Example #6
Source File: DeploymentTargetModifier.java    From keycloak with Apache License 2.0 4 votes vote down vote up
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));
}