Search in sources :

Example 21 with Node

use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.

the class DefaultApplicationDeploymentProcessorTest method testWebXmlApplicationServletMappingPresent.

@Test
public void testWebXmlApplicationServletMappingPresent() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MyResource.class);
    archive.setWebXML(new StringAsset("<web-app><servlet-mapping><servlet-name>Faces Servlet</servlet-name><url-pattern>*.jsf</url-pattern></servlet-mapping><servlet-mapping><servlet-name>javax.ws.rs.core.Application</servlet-name><url-pattern>/foo/*</url-pattern></servlet-mapping></web-app>"));
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
    processor.process();
    Node generated = archive.get(PATH);
    assertThat(generated).isNull();
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) AnnotationNode(org.objectweb.asm.tree.AnnotationNode) Node(org.jboss.shrinkwrap.api.Node) ClassNode(org.objectweb.asm.tree.ClassNode) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) Test(org.junit.Test)

Example 22 with Node

use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.

the class DefaultApplicationDeploymentProcessorTest method testApplicationPathAnnotation_DirectlyInArchive.

@Test
public void testApplicationPathAnnotation_DirectlyInArchive() throws Exception {
    JAXRSArchive archive = ShrinkWrap.create(JAXRSArchive.class);
    archive.addClass(MySampleApplication.class);
    DefaultApplicationDeploymentProcessor processor = new DefaultApplicationDeploymentProcessor(archive);
    processor.process();
    Node generated = archive.get(PATH);
    assertThat(generated).isNull();
}
Also used : AnnotationNode(org.objectweb.asm.tree.AnnotationNode) Node(org.jboss.shrinkwrap.api.Node) ClassNode(org.objectweb.asm.tree.ClassNode) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) Test(org.junit.Test)

Example 23 with Node

use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.

the class SwaggerWebAppDeploymentProducer method swaggerWebApp.

@Produces
public Archive swaggerWebApp() throws ModuleLoadException, IOException {
    // Load the swagger-ui webjars.
    Module module = Module.getBootModuleLoader().loadModule("org.webjars.swagger-ui");
    URL resource = module.getExportedResource("swagger-ui.jar");
    JARArchive webJar = ShrinkWrap.create(JARArchive.class);
    webJar.as(ZipImporter.class).importFrom(resource.openStream());
    JARArchive relocatedJar = ShrinkWrap.create(JARArchive.class);
    Map<ArchivePath, Node> content = webJar.getContent();
    for (ArchivePath path : content.keySet()) {
        Node node = content.get(path);
        Asset asset = node.getAsset();
        if (asset != null) {
            Matcher matcher = PATTERN.matcher(path.get());
            if (matcher.matches()) {
                MatchResult result = matcher.toMatchResult();
                String newPath = "/META-INF/resources/" + result.group(2);
                relocatedJar.add(asset, newPath);
            }
        }
    }
    WARArchive war = ShrinkWrap.create(WARArchive.class, "swagger-ui.war").addAsLibrary(relocatedJar).setContextRoot(this.fraction.getContext());
    war.addClass(SwaggerDefaultUrlChangerServlet.class);
    // If any user content has been provided, merge that with the swagger-ui bits
    Archive<?> userContent = this.fraction.getWebContent();
    if (userContent != null) {
        war.merge(userContent);
    }
    return war;
}
Also used : Matcher(java.util.regex.Matcher) Node(org.jboss.shrinkwrap.api.Node) MatchResult(java.util.regex.MatchResult) WARArchive(org.wildfly.swarm.undertow.WARArchive) URL(java.net.URL) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) Asset(org.jboss.shrinkwrap.api.asset.Asset) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Module(org.jboss.modules.Module) Produces(javax.enterprise.inject.Produces)

Example 24 with Node

use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.

the class SwaggerWebAppFractionTest method testAddWebContentFromDirectory.

@Test
public void testAddWebContentFromDirectory() {
    SwaggerWebAppFraction fraction = new SwaggerWebAppFraction();
    fraction.addWebContent("./src/test/user-content");
    Archive<?> archive = assertArchive(fraction);
    // make sure nested files are where they should be
    Node node = archive.get("/js/test.js");
    assertThat(node).isNotNull();
    node = archive.get("/js/lib/some-lib.js");
    assertThat(node).isNotNull();
}
Also used : Node(org.jboss.shrinkwrap.api.Node) Test(org.junit.Test)

Example 25 with Node

use of org.jboss.shrinkwrap.api.Node in project tomee by apache.

the class OpenEJBArchiveProcessor method addEnvEntries.

private static void addEnvEntries(final Archive<?> archive, final String prefix, final AppModule appModule, final EjbModule ejbModule) {
    final Node envEntriesProperties = archive.get(prefix.concat(ENV_ENTRIES_PROPERTIES));
    if (envEntriesProperties != null) {
        InputStream is = null;
        final Properties properties = new Properties();
        try {
            is = envEntriesProperties.getAsset().openStream();
            properties.load(is);
            ejbModule.getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties);
            // do it for test class too
            appModule.getEjbModules().iterator().next().getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties);
        } catch (final Exception e) {
            LOGGER.log(Level.SEVERE, "can't read env-entries.properties", e);
        } finally {
            IO.close(is);
        }
    }
}
Also used : InputStream(java.io.InputStream) Node(org.jboss.shrinkwrap.api.Node) Properties(java.util.Properties) OpenEJBException(org.apache.openejb.OpenEJBException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException)

Aggregations

Node (org.jboss.shrinkwrap.api.Node)66 Archive (org.jboss.shrinkwrap.api.Archive)20 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)20 IOException (java.io.IOException)19 Test (org.junit.Test)17 Asset (org.jboss.shrinkwrap.api.asset.Asset)16 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)15 File (java.io.File)14 Map (java.util.Map)14 InputStream (java.io.InputStream)13 URL (java.net.URL)13 BufferedReader (java.io.BufferedReader)10 InputStreamReader (java.io.InputStreamReader)10 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)8 JolokiaFraction (org.wildfly.swarm.jolokia.JolokiaFraction)8 ArrayList (java.util.ArrayList)7 ArchiveAsset (org.jboss.shrinkwrap.api.asset.ArchiveAsset)7 OpenEJBException (org.apache.openejb.OpenEJBException)6 ClassAsset (org.jboss.shrinkwrap.api.asset.ClassAsset)6 MalformedURLException (java.net.MalformedURLException)5