Search in sources :

Example 11 with BasicPath

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);
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) BasicPath(org.jboss.shrinkwrap.impl.base.path.BasicPath) File(java.io.File) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl) BeforeClass(org.junit.BeforeClass)

Example 12 with BasicPath

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);
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) BasicPath(org.jboss.shrinkwrap.impl.base.path.BasicPath) File(java.io.File) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl) BeforeClass(org.junit.BeforeClass)

Example 13 with BasicPath

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;
}
Also used : ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) Node(org.jboss.shrinkwrap.api.Node) BasicPath(org.jboss.shrinkwrap.impl.base.path.BasicPath) Map(java.util.Map)

Aggregations

BasicPath (org.jboss.shrinkwrap.impl.base.path.BasicPath)13 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)11 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)10 File (java.io.File)8 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)8 ZipExporterImpl (org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl)8 BeforeClass (org.junit.BeforeClass)8 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)4 Node (org.jboss.shrinkwrap.api.Node)2 FileAsset (org.jboss.shrinkwrap.api.asset.FileAsset)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 URLPackageScanner (org.jboss.shrinkwrap.impl.base.URLPackageScanner)2 FilePermission (java.io.FilePermission)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URL (java.net.URL)1 FileVisitResult (java.nio.file.FileVisitResult)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1