Search in sources :

Example 56 with Node

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

the class OpenEJBArchiveProcessor method createWebApp.

private static WebApp createWebApp(final Archive<?> archive) {
    WebApp webApp;
    final Node webXml = archive.get(WEB_INF + "web.xml");
    if (webXml == null) {
        webApp = new WebApp();
    } else {
        InputStream inputStream = null;
        try {
            inputStream = webXml.getAsset().openStream();
            webApp = Sxc.unmarshalJavaee(new WebApp$JAXB(), inputStream);
        } catch (final Exception e) {
            webApp = new WebApp();
        } finally {
            IO.close(inputStream);
        }
    }
    return webApp;
}
Also used : InputStream(java.io.InputStream) Node(org.jboss.shrinkwrap.api.Node) OpenEJBException(org.apache.openejb.OpenEJBException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) WebApp(org.apache.openejb.jee.WebApp) WebApp$JAXB(org.apache.openejb.jee.WebApp$JAXB)

Example 57 with Node

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

the class OpenEJBArchiveProcessor method addValidationXml.

private static void addValidationXml(final Archive<?> archive, final String prefix, final Map<String, Object> testDD, final EjbModule ejbModule) {
    Node validationXml = archive.get(prefix.concat(VALIDATION_XML));
    // bval tcks
    if (validationXml == null && WEB_INF == prefix) {
        // we can use == here
        validationXml = archive.get(WEB_INF_CLASSES.concat(META_INF).concat(VALIDATION_XML));
    }
    if (validationXml != null) {
        // use same config otherwise behavior is weird
        testDD.put(VALIDATION_XML, new AssetSource(validationXml.getAsset(), null));
        ejbModule.getAltDDs().put(VALIDATION_XML, new AssetSource(validationXml.getAsset(), null));
    }
}
Also used : Node(org.jboss.shrinkwrap.api.Node)

Example 58 with Node

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

the class OpenEJBArchiveProcessor method createEjbJar.

private static EjbJar createEjbJar(final String prefix, final Archive<?> webArchive) {
    final EjbJar webEjbJar;
    final Node webEjbJarXml = webArchive.get(prefix.concat(EJB_JAR_XML));
    if (webEjbJarXml != null) {
        try {
            webEjbJar = ReadDescriptors.readEjbJar(webEjbJarXml.getAsset().openStream());
        } catch (final OpenEJBException e) {
            throw new OpenEJBRuntimeException(e);
        }
    } else {
        webEjbJar = new EjbJar();
    }
    return webEjbJar;
}
Also used : OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) OpenEJBException(org.apache.openejb.OpenEJBException) Node(org.jboss.shrinkwrap.api.Node) EjbJar(org.apache.openejb.jee.EjbJar)

Example 59 with Node

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

the class MicroProfileOpenTracingTCKDeploymentPackager method generateDeployment.

@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);
}
Also used : ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) ThreadLocalScopeManager(io.opentracing.util.ThreadLocalScopeManager) TestDeployment(org.jboss.arquillian.container.test.spi.TestDeployment) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) Node(org.jboss.shrinkwrap.api.Node) MockTracer(io.opentracing.mock.MockTracer)

Aggregations

Node (org.jboss.shrinkwrap.api.Node)59 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)19 Archive (org.jboss.shrinkwrap.api.Archive)17 Test (org.junit.Test)17 Asset (org.jboss.shrinkwrap.api.asset.Asset)16 IOException (java.io.IOException)15 URL (java.net.URL)12 Map (java.util.Map)12 File (java.io.File)11 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)11 BufferedReader (java.io.BufferedReader)10 InputStream (java.io.InputStream)10 InputStreamReader (java.io.InputStreamReader)10 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 AnnotationNode (org.objectweb.asm.tree.AnnotationNode)6 ClassNode (org.objectweb.asm.tree.ClassNode)6 JAXRSArchive (org.wildfly.swarm.jaxrs.JAXRSArchive)6