Search in sources :

Example 6 with ClassLoaderAsset

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

the class TomcatNamingFailOnWriteConfigurationTest method createWebArchive.

private static WebArchive createWebArchive(String archiveName, String contextXmlLocation) {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).createServlet().servletName(SERVLET_NAME).servletClass(NamingServlet.class.getName()).up().createServletMapping().servletName(SERVLET_NAME).urlPattern("/" + TEST_NAME).up();
    WebArchive archive = ShrinkWrap.create(WebArchive.class, archiveName + ".war").addClass(TomcatNamingFailOnWriteConfigurationTest.class).addClass(NamingServlet.class).addClass(Runner.class).addAsLibraries(JarLocation.jarLocation(Test.class)).add(new ClassLoaderAsset(contextXmlLocation), RESOURCE_CONTEXT_XML).setWebXML(new StringAsset(descriptor.exportAsString()));
    return archive;
}
Also used : WebAppDescriptor(org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor) Runner(org.apache.openejb.arquillian.tests.Runner) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Test(org.junit.Test) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)

Example 7 with ClassLoaderAsset

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

the class DataSourceDefinitionTest method createDeployment.

@Deployment(testable = false)
public static WebArchive createDeployment() {
    WebAppDescriptor descriptor = Descriptors.create(WebAppDescriptor.class).version(WebAppVersionType._3_0).createServlet().servletName(SERVLET_NAME).servletClass(DataSourceServlet.class.getName()).up().createServletMapping().servletName(SERVLET_NAME).urlPattern("/" + TEST_NAME).up();
    WebArchive archive = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war").addClass(DataSourceDefinitionTest.class).addClass(DataSourceServlet.class).addClass(DataSourceBean.class).addClass(DataSourcePojo.class).addClass(Runner.class).addAsLibraries(JarLocation.jarLocation(Test.class)).addAsWebInfResource(new ClassLoaderAsset(CONTENT_LOCATION_EJB_JAR_XML), RESOURCE_EJB_JAR_XML).setWebXML(new StringAsset(descriptor.exportAsString()));
    return archive;
}
Also used : WebAppDescriptor(org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor) Runner(org.apache.openejb.arquillian.tests.Runner) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Test(org.junit.Test) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 8 with ClassLoaderAsset

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

the class SecuredTest method testExistingWebXml.

@Test
public void testExistingWebXml() {
    WARArchive archive = ShrinkWrap.create(WARArchive.class);
    ClassLoaderAsset asset = new ClassLoaderAsset("test-web.xml");
    archive.addAsWebInfResource(asset, "web.xml");
    archive.as(Secured.class).protect("/cheddar");
    Node webXml = archive.get("WEB-INF/web.xml");
    Asset newAsset = webXml.getAsset();
    InputStream in = newAsset.openStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    List<String> lines = reader.lines().map(String::trim).collect(Collectors.toList());
    assertThat(lines).contains("<servlet-name>comingsoon</servlet-name>");
    assertThat(lines).contains("<url-pattern>/cheddar</url-pattern>");
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Node(org.jboss.shrinkwrap.api.Node) BufferedReader(java.io.BufferedReader) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) WARArchive(org.wildfly.swarm.undertow.WARArchive) Test(org.junit.Test)

Example 9 with ClassLoaderAsset

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

the class TopologyWebAppDeploymentProducer method deployment.

@Produces
@Dependent()
Archive deployment() {
    String context = TopologyWebAppFraction.DEFAULT_CONTEXT;
    if (this.contextPath != null) {
        context = this.contextPath;
    }
    if (fraction.exposeTopologyEndpoint()) {
        WARArchive war = ShrinkWrap.create(WARArchive.class, "topology-webapp.war");
        war.addAsWebInfResource(new StringAsset(getWebXml(fraction)), "web.xml");
        war.addClass(TopologySSEServlet.class);
        war.addModule("swarm.application");
        war.addModule("org.wildfly.swarm.topology");
        war.addAsWebResource(new ClassLoaderAsset("topology.js", this.getClass().getClassLoader()), "topology.js");
        war.setContextRoot(context);
        war.as(TopologyArchive.class);
        return war;
    }
    return null;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) WARArchive(org.wildfly.swarm.undertow.WARArchive) Produces(javax.enterprise.inject.Produces) Dependent(javax.enterprise.context.Dependent)

Example 10 with ClassLoaderAsset

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

the class SWARM_513Test method createDeployment.

@Deployment(testable = true)
public static Archive createDeployment() throws Exception {
    URL url = Thread.currentThread().getContextClassLoader().getResource("project-test-defaults-path.yml");
    assertThat(url).isNotNull();
    File projectDefaults = new File(url.toURI());
    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class, "myapp.war");
    deployment.addResource(TicketEndpoint.class);
    deployment.addClass(Ticket.class);
    deployment.addClass(Tickets.class);
    deployment.addClass(TicketDTO.class);
    deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml", SWARM_513Test.class.getClassLoader()), "classes/META-INF/persistence.xml");
    deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/import.sql", SWARM_513Test.class.getClassLoader()), "classes/META-INF/import.sql");
    deployment.addAsResource(projectDefaults, "/project-defaults.yml");
    return deployment;
}
Also used : JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) ClassLoaderAsset(org.jboss.shrinkwrap.api.asset.ClassLoaderAsset) File(java.io.File) URL(java.net.URL) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

ClassLoaderAsset (org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)26 Deployment (org.jboss.arquillian.container.test.api.Deployment)20 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)20 File (java.io.File)15 SampleDataSourceDefinition (eu.ggnet.dwoss.mandator.tryout.SampleDataSourceDefinition)8 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)8 Test (org.junit.Test)7 Runner (org.apache.openejb.arquillian.tests.Runner)6 WebAppDescriptor (org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor)6 Coordinate (org.jboss.shrinkwrap.resolver.api.Coordinate)4 Asset (org.jboss.shrinkwrap.api.asset.Asset)3 WARArchive (org.wildfly.swarm.undertow.WARArchive)3 PersistenceIT (eu.ggnet.dwoss.customer.itest.PersistenceIT)1 CustomerTest (eu.ggnet.dwoss.customer.test.CustomerTest)1 RedTapeHelper (eu.ggnet.dwoss.redtape.itest.eao.RedTapeHelper)1 PersistenceIT (eu.ggnet.dwoss.spec.itest.PersistenceIT)1 SpecTest (eu.ggnet.dwoss.spec.test.SpecTest)1 PersistenceIT (eu.ggnet.dwoss.stock.ee.itest.PersistenceIT)1 ValidationTest (eu.ggnet.dwoss.stock.ee.test.ValidationTest)1 BufferedReader (java.io.BufferedReader)1