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;
}
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;
}
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>");
}
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;
}
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;
}
Aggregations