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