use of org.jboss.shrinkwrap.impl.base.path.BasicPath in project eap-additional-testsuite by jboss-set.
the class ArchiveTestCase method before.
@BeforeClass
public static void before() throws Exception {
String tempDir = TestSuiteEnvironment.getTmpDir();
WebArchive[] wars = new WebArchive[3];
// deployment1
wars[0] = ShrinkWrap.create(WebArchive.class, "deployment0.war");
wars[0].addClass(SimpleServlet.class);
wars[0].addAsWebResource(new StringAsset("Version0"), "page.html");
// deployment2
wars[1] = ShrinkWrap.create(WebArchive.class, "deployment1.war");
wars[1].addClass(SimpleServlet.class);
wars[1].addAsWebResource(new StringAsset("Version1"), "page.html");
// deployment3 is included but not deployed
wars[2] = ShrinkWrap.create(WebArchive.class, "deployment2.war");
wars[2].addClass(SimpleServlet.class);
wars[2].addAsWebResource(new StringAsset("Version2"), "page.html");
// build cli archive
EnterpriseArchive cliArchive = ShrinkWrap.create(EnterpriseArchive.class, "archive.cli");
String deploy = "deploy deployment0.war\ndeploy deployment1.war";
String undeploy = "undeploy deployment0.war\nundeploy deployment1.war";
cliArchive.add(new StringAsset(deploy), new BasicPath("/", "install.scr"));
// add the default script which shouldn't be picked up
cliArchive.add(new StringAsset("deploy deployment0.war\ndeploy deployment1.war\ndeploy deployment2.war"), new BasicPath("/", "deploy.scr"));
cliArchive.add(new StringAsset(undeploy), new BasicPath("/", "uninstall.scr"));
cliArchive.add(new StringAsset("undeploy deployment0.war\nundeploy deployment1.war\nundeploy deployment2.war"), new BasicPath("/", "undeploy.scr"));
for (WebArchive war : wars) {
cliArchive.add(war, new BasicPath("/"), ZipExporter.class);
}
cliArchiveFile = new File(tempDir + File.separator + "archive.cli");
new ZipExporterImpl(cliArchive).exportTo(cliArchiveFile, true);
}
use of org.jboss.shrinkwrap.impl.base.path.BasicPath in project eap-additional-testsuite by jboss-set.
the class ArchiveDefaultScriptNamesTestCase method before.
@BeforeClass
public static void before() throws Exception {
String tempDir = TestSuiteEnvironment.getTmpDir();
WebArchive[] wars = new WebArchive[3];
// deployment1
wars[0] = ShrinkWrap.create(WebArchive.class, "deployment0.war");
wars[0].addClass(SimpleServlet.class);
wars[0].addAsWebResource(new StringAsset("Version0"), "page.html");
// deployment2
wars[1] = ShrinkWrap.create(WebArchive.class, "deployment1.war");
wars[1].addClass(SimpleServlet.class);
wars[1].addAsWebResource(new StringAsset("Version1"), "page.html");
// deployment3 is included but not deployed
wars[2] = ShrinkWrap.create(WebArchive.class, "deployment2.war");
wars[2].addClass(SimpleServlet.class);
wars[2].addAsWebResource(new StringAsset("Version2"), "page.html");
// build cli archive
EnterpriseArchive cliArchive = ShrinkWrap.create(EnterpriseArchive.class, "archive.cli");
String deploy = "deploy deployment0.war\ndeploy deployment1.war";
String undeploy = "undeploy deployment0.war\nundeploy deployment1.war";
cliArchive.add(new StringAsset(deploy), new BasicPath("/", "deploy.scr"));
cliArchive.add(new StringAsset(undeploy), new BasicPath("/", "undeploy.scr"));
for (WebArchive war : wars) {
cliArchive.add(war, new BasicPath("/"), ZipExporter.class);
}
cliArchiveFile = new File(tempDir + File.separator + "archive.cli");
new ZipExporterImpl(cliArchive).exportTo(cliArchiveFile, true);
}
use of org.jboss.shrinkwrap.impl.base.path.BasicPath in project wildfly-swarm by wildfly-swarm.
the class StaticContentContainer method mergeIgnoringDuplicates.
@SuppressWarnings("unchecked")
default T mergeIgnoringDuplicates(Archive<?> source, String base, Filter<ArchivePath> filter) {
if (!base.startsWith("/")) {
base = "/" + base;
}
// Get existing contents from source archive
final Map<ArchivePath, Node> sourceContent = source.getContent();
// Add each asset from the source archive
for (final Map.Entry<ArchivePath, Node> contentEntry : sourceContent.entrySet()) {
final Node node = contentEntry.getValue();
ArchivePath nodePath = contentEntry.getKey();
if (!nodePath.get().startsWith(base)) {
continue;
}
if (!filter.include(nodePath)) {
continue;
}
if (contains(nodePath)) {
continue;
}
nodePath = new BasicPath(nodePath.get().replaceFirst(base, ""));
// Delegate
if (node.getAsset() == null) {
addAsDirectory(nodePath);
} else {
add(node.getAsset(), nodePath);
}
}
return (T) this;
}
Aggregations