org.jboss.arquillian.container.test.spi.TestDeployment Java Examples

The following examples show how to use org.jboss.arquillian.container.test.spi.TestDeployment. 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: ArchiveProcessor.java    From smallrye-metrics with Apache License 2.0 7 votes vote down vote up
@Override
public void process(TestDeployment testDeployment, Archive<?> protocolArchive) {
    WebArchive war = (WebArchive) protocolArchive;
    war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml");
    String[] deps = {
            "io.smallrye:smallrye-config",
            "io.smallrye:smallrye-metrics",
            "io.smallrye:smallrye-metrics-testsuite-common",
            "org.eclipse.microprofile.metrics:microprofile-metrics-api",
            "org.jboss.weld.servlet:weld-servlet-core"
    };

    File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile();

    war.addAsLibraries(dependencies);

    war.addClass(SmallRyeBeanArchiveHandler.class);
    war.addClass(MetricsHttpServlet.class);
    war.addClass(MetricsInitializer.class);
    war.addAsResource("io/smallrye/metrics/base-metrics.properties", "/io/smallrye/metrics/base-metrics.properties");
    war.addAsServiceProvider(BeanArchiveHandler.class, SmallRyeBeanArchiveHandler.class);
    war.addAsServiceProvider(Extension.class, ConfigExtension.class);
    war.addAsServiceProvider(ConfigProviderResolver.class, SmallRyeConfigProviderResolver.class);
}
 
Example #2
Source File: MicroProfileOpenAPITCKDeploymentPackager.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public Archive<?> generateDeployment(final TestDeployment testDeployment,
                                     final Collection<ProtocolArchiveProcessor> processors) {
    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "microprofile-openapi.war")
                                            .merge(testDeployment.getApplicationArchive())
                                            // TODO - This doesn't seem right. This is for the JAX-RS endpoints to be CDI scanned.
                                            // This is to use CDI events to filter endpoints with configuration.
                                            // Check org.apache.geronimo.microprofile.openapi.cdi.GeronimoOpenAPIExtension.findEndpointsAndApplication()
                                            // A beans.xml should not be required.
                                            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            ;

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

    return super.generateDeployment(
            new TestDeployment(null, webArchive, testDeployment.getAuxiliaryArchives()), processors);
}
 
Example #3
Source File: MicroProfileOpenTracingTCKDeploymentPackager.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public Archive<?> generateDeployment(final TestDeployment testDeployment,
                                     final Collection<ProtocolArchiveProcessor> processors) {

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "microprofile-opentracing.war")
                                            .merge(testDeployment.getApplicationArchive());

    // opentracing-api jar added by Geronimo Impl. Also added by TCK causes issues with same classes in different Classloaders
    final Map<ArchivePath, Node> content = webArchive.getContent(object -> object.get().matches(".*opentracing-api.*jar.*"));
    content.forEach((archivePath, node) -> webArchive.delete(archivePath));

    // TCK expects a MockTracer. Check org/eclipse/microprofile/opentracing/tck/application/TracerWebService.java:133
    webArchive.addAsLibrary(jarLocation(MockTracer.class));
    webArchive.addAsLibrary(jarLocation(ThreadLocalScopeManager.class));
    webArchive.addAsWebInfResource("META-INF/beans.xml");
    webArchive.addClass(MicroProfileOpenTracingTCKTracer.class);

    System.out.println(webArchive.toString(true));

    return super.generateDeployment(
            new TestDeployment(null, webArchive, testDeployment.getAuxiliaryArchives()), processors);
}
 
Example #4
Source File: TestDeploymentPackager.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public Archive<?> generateDeployment(TestDeployment testDeployment, Collection<ProtocolArchiveProcessor> collection) {
    Archive<?> applicationArchive = testDeployment.getApplicationArchive();
    boolean isClassPath = ClassPath.isRepresentedBy(applicationArchive);
    for (Archive<?> auxiliaryArchive : testDeployment.getAuxiliaryArchives()) {
        if (isClassPath) {
            applicationArchive.add(auxiliaryArchive, ClassPath.ROOT_ARCHIVE_PATH, ZipExporter.class);
        } else {
            applicationArchive.merge(auxiliaryArchive);
        }
    }
    return applicationArchive;
}
 
Example #5
Source File: JaxRsMetricsActivatingProcessor.java    From smallrye-metrics with Apache License 2.0 5 votes vote down vote up
@Override
public void process(TestDeployment testDeployment, Archive<?> archive) {
    WebArchive war = (WebArchive) archive;

    String[] deps = {
            "io.smallrye:smallrye-config",
            "io.smallrye:smallrye-metrics",
            "io.smallrye:smallrye-metrics-testsuite-common",
            "org.eclipse.microprofile.metrics:microprofile-metrics-api",
            "org.eclipse.microprofile.config:microprofile-config-api"
    };
    File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile();
    war.addAsLibraries(dependencies);

    war.addClass(MetricsHttpServlet.class);
    war.addClass(JaxRsMetricsFilter.class);
    war.addClass(JaxRsMetricsServletFilter.class);

    // change application context root to '/' because the TCK assumes that the metrics
    // will be available at '/metrics', and in our case the metrics servlet is located
    // within the application itself, we don't use WildFly's built-in support for metrics
    war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml");

    // activate the servlet filter
    war.setWebXML("WEB-INF/web.xml");

    // activate the JAX-RS request filter
    war.addAsServiceProvider(Providers.class.getName(), JaxRsMetricsFilter.class.getName());

    // exclude built-in Metrics and Config from WildFly
    war.addAsManifestResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml");
}
 
Example #6
Source File: MicroProfileMetricsTCKDeploymentPackager.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public Archive<?> generateDeployment(final TestDeployment testDeployment,
                                     final Collection<ProtocolArchiveProcessor> processors) {
    final Archive<?> applicationArchive = testDeployment.getApplicationArchive();
    if (applicationArchive instanceof JavaArchive) {
        final WebArchive wrapperWar =
                ShrinkWrap.create(WebArchive.class, "microprofile-metrics.war").addAsLibrary(applicationArchive);
        return super.generateDeployment(new TestDeploymentDelegate(testDeployment, wrapperWar), processors);
    }

    return super.generateDeployment(testDeployment, processors);
}
 
Example #7
Source File: TestDeployments.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public static void addToEarManifestIfExists(EnterpriseArchive archive, String resource)
{
    URL url = TestDeployment.class.getClassLoader().getResource(resource);
    if (url != null) {
        archive.addAsManifestResource(resource);
    }
}
 
Example #8
Source File: MicroProfileMetricsTCKDeploymentPackager.java    From tomee with Apache License 2.0 4 votes vote down vote up
public TestDeploymentDelegate(final TestDeployment testDeployment, final Archive<?> archive) {
    super(null, archive, testDeployment.getAuxiliaryArchives());
    this.testDeployment = testDeployment;
    this.archive = archive;
}