Java Code Examples for org.jboss.shrinkwrap.api.spec.WebArchive#addAsManifestResource()

The following examples show how to use org.jboss.shrinkwrap.api.spec.WebArchive#addAsManifestResource() . 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: Deployments.java    From arquillian-container-chameleon with Apache License 2.0 6 votes vote down vote up
static void enrichTomcatWithCdi(WebArchive archive) {
    String contextXml = "<Context>\n" +
        "   <Resource name=\"BeanManager\" \n" +
        "      auth=\"Container\"\n" +
        "      type=\"javax.enterprise.inject.spi.BeanManager\"\n" +
        "      factory=\"org.jboss.weld.resources.ManagerObjectFactory\"/>\n" +
        "</Context>\n";

    String webXml = "<web-app version=\"3.0\">\n" +
        "<listener>\n" +
        "      <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>\n" +
        "   </listener>" +
        "  <resource-env-ref>\n" +
        "    <resource-env-ref-name>BeanManager</resource-env-ref-name>\n" +
        "    <resource-env-ref-type>\n" +
        "            javax.enterprise.inject.spi.BeanManager\n" +
        "    </resource-env-ref-type>\n" +
        "  </resource-env-ref>\n" +
        "</web-app>";

    archive.addAsLibraries(WELD_SERVLET);
    archive.addAsManifestResource(new StringAsset(contextXml), "context.xml");
    archive.setWebXML(new StringAsset(webXml));
}
 
Example 2
Source File: IntegrationTestUtils.java    From trimou with Apache License 2.0 6 votes vote down vote up
public static WebArchive createTestArchiveBase() {
    WebArchive testArchive = ShrinkWrap.create(WebArchive.class);
    // Suppressing implicit bean archives without beans.xml
    testArchive.addAsManifestResource(CDI11_JBOSSALL_WORKAROUND_ASSET,
            "jboss-all.xml");
    // Add Weld servlet for embedded containers
    if (isServletContainer()) {
        testArchive.addAsLibraries(resolve("org.jboss.weld.servlet:weld-servlet"));
        testArchive.setWebXML(new StringAsset(Descriptors
                .create(WebAppDescriptor.class)
                .version(WebAppVersionType._3_0)
                .createListener()
                .listenerClass(
                        "org.jboss.weld.environment.servlet.Listener").up()
                .exportAsString()));
    }
    return testArchive;
}
 
Example 3
Source File: SmallRyeJWTArchiveProcessor.java    From smallrye-jwt with Apache License 2.0 5 votes vote down vote up
@Override
public void process(Archive<?> applicationArchive, TestClass testClass) {
    if (applicationArchive instanceof WebArchive) {
        WebArchive war = (WebArchive) applicationArchive;
        war.addClass(OptionalAwareSmallRyeJWTAuthCDIExtension.class);
        war.addClass(SmallRyeJWTAuthJaxRsFeature.class);
        war.addAsServiceProvider(Extension.class, OptionalAwareSmallRyeJWTAuthCDIExtension.class);

        if (!war.contains("META-INF/microprofile-config.properties")) {
            war.addAsManifestResource("microprofile-config-local.properties", "microprofile-config.properties");
        }

        // A few tests require the apps to be deployed in the root. Check PublicKeyAsJWKLocationURLTest and PublicKeyAsPEMLocationURLTest
        // Both tests set the public key location url to be in root.
        war.addAsWebInfResource("jboss-web.xml");

        String[] deps = {
                "io.smallrye:smallrye-jwt",
                "io.smallrye.config:smallrye-config",
                "org.jboss.resteasy:resteasy-servlet-initializer",
                "org.jboss.resteasy:resteasy-jaxrs",
                "org.jboss.resteasy:resteasy-client",
                "org.jboss.resteasy:resteasy-cdi",
                "org.jboss.resteasy:resteasy-json-binding-provider",
                "org.jboss.weld.servlet:weld-servlet-core"
        };
        File[] dependencies = Maven.resolver()
                .loadPomFromFile(new File("pom.xml"))
                .resolve(deps)
                .withTransitivity()
                .asFile();

        war.addAsLibraries(dependencies);
    }
}
 
Example 4
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 5
Source File: WFSwarmWarArchiveProcessor.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void process(Archive<?> appArchive, TestClass testClass) {
    if (!(appArchive instanceof WebArchive)) {
        return;
    }
    log.info("Preparing archive: " + appArchive);
    // Only augment archives with a node indicating a MP-JWT test
    WebArchive war = WebArchive.class.cast(appArchive);
    Node configProps = war.get("/META-INF/microprofile-config.properties");
    Node publicKeyNode = war.get("/WEB-INF/classes/publicKey.pem");
    Node publicKey4kNode = war.get("/WEB-INF/classes/publicKey4k.pem");
    Node mpJWT = war.get("MP-JWT");
    if (configProps == null && publicKeyNode == null && publicKey4kNode == null && mpJWT == null) {
        return;
    }

    if (configProps != null) {
        StringWriter sw = new StringWriter();
        InputStream is = configProps.getAsset().openStream();
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
            String line = reader.readLine();
            while(line != null) {
                sw.write(line);
                sw.write('\n');
                line = reader.readLine();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        log.info("mp-config.props: "+sw.toString());
    } else {
        log.info("NO mp-config.props, adding /META-INF/MP-JWT-SIGNER");
        if(publicKey4kNode != null) {
            war.addAsManifestResource(publicKey4kNode.getAsset(), "MP-JWT-SIGNER");
        } else if(publicKeyNode != null) {
            war.addAsManifestResource(publicKeyNode.getAsset(), "MP-JWT-SIGNER");
        }
    }
    // This allows for test specific web.xml files. Generally this should not be needed.
    String warName = war.getName();
    String webXmlName = "/WEB-INF/" + warName + ".xml";
    URL webXml = WFSwarmWarArchiveProcessor.class.getResource(webXmlName);
    if (webXml != null) {
        war.setWebXML(webXml);
    }
    //
    String projectDefaults = "project-defaults.yml";
    war.addAsResource(projectDefaults, "/project-defaults.yml")
            .addAsWebInfResource("jwt-roles.properties", "classes/jwt-roles.properties")
    ;
    log.info("Augmented war: \n"+war.toString(true));
}
 
Example 6
Source File: ServletFilterPersistenceInjectionTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void decorateArchive(WebArchive archive) {
    archive.addAsManifestResource("persistence.xml", ArchivePaths.create("persistence.xml"));
}
 
Example 7
Source File: TestContainer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void addContainerSpecificResourcesForNonPaWithoutWeld(WebArchive webArchive) {
  webArchive.addAsManifestResource("jboss-deployment-structure.xml");
}
 
Example 8
Source File: TestContainer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void addSpinJacksonJsonDataFormat(WebArchive webArchive) {
  webArchive.addAsManifestResource("jboss-deployment-structure-spin-json.xml", "jboss-deployment-structure.xml");
}
 
Example 9
Source File: TestContainer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void addCommonLoggingDependency(WebArchive webArchive) {
  webArchive.addAsManifestResource("jboss-deployment-structure-with-commons-logging.xml", "jboss-deployment-structure.xml");
}
 
Example 10
Source File: TestContainer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void addContainerSpecificResourcesForNonPaWithoutWeld(WebArchive webArchive) {
  webArchive.addAsManifestResource("jboss-deployment-structure.xml");
}
 
Example 11
Source File: TestContainer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void addSpinJacksonJsonDataFormat(WebArchive webArchive) {
  webArchive.addAsManifestResource("jboss-deployment-structure-spin-json.xml", "jboss-deployment-structure.xml");
}
 
Example 12
Source File: TestContainer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public static void addCommonLoggingDependency(WebArchive webArchive) {
  webArchive.addAsManifestResource("jboss-deployment-structure-with-commons-logging.xml", "jboss-deployment-structure.xml");
}