Search in sources :

Example 16 with ZipExporterImpl

use of org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl in project wildfly by wildfly.

the class UndeployWildcardTestCase method before.

@BeforeClass
public static void before() throws Exception {
    String tempDir = TestSuiteEnvironment.getSystemProperty("java.io.tmpdir");
    appFiles = new File[4];
    // deployment1
    WebArchive war = ShrinkWrap.create(WebArchive.class, "cli-test-app1.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(new StringAsset("Version0"), "page.html");
    appFiles[0] = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(appFiles[0], true);
    // deployment2
    war = ShrinkWrap.create(WebArchive.class, "cli-test-app2.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(new StringAsset("Version1"), "page.html");
    appFiles[1] = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(appFiles[1], true);
    // deployment3
    war = ShrinkWrap.create(WebArchive.class, "cli-test-another.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(new StringAsset("Version2"), "page.html");
    appFiles[2] = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(appFiles[2], true);
    // deployment4
    war = ShrinkWrap.create(WebArchive.class, "cli-test-app3.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(new StringAsset("Version3"), "page.html");
    final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "cli-test-app.ear");
    ear.add(war, new BasicPath("/"), ZipExporter.class);
    appFiles[3] = new File(tempDir + File.separator + ear.getName());
    new ZipExporterImpl(ear).exportTo(appFiles[3], 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 17 with ZipExporterImpl

use of org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl in project wildfly by wildfly.

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 18 with ZipExporterImpl

use of org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl in project wildfly by wildfly.

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 19 with ZipExporterImpl

use of org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl in project wildfly by wildfly.

the class DeployURLTestCase method testRedeploy.

public void testRedeploy() throws Exception {
    // check we have original deployment
    String response = HttpRequest.get(getBaseURL(url) + "SimpleServlet/page.html", 10, TimeUnit.SECONDS);
    assertTrue("Invalid response: " + response, response.indexOf("Version1") >= 0);
    // update the deployment - replace page.html
    war = ShrinkWrap.create(WebArchive.class, "SimpleServlet.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(new StringAsset("Version2"), "page.html");
    new ZipExporterImpl(war).exportTo(warFile, true);
    // redeploy to server
    Assert.assertFalse(cli.sendLine("deploy --url=" + warFile.toURI().toURL().toExternalForm() + " --name=" + warFile.getName(), true));
    // force redeploy
    cli.sendLine("deploy --url=" + warFile.toURI().toURL().toExternalForm() + " --name=" + warFile.getName() + " --force");
    // check that new version is running
    final long firstTry = System.currentTimeMillis();
    response = HttpRequest.get(getBaseURL(url) + "SimpleServlet/page.html", 1000, 10, TimeUnit.SECONDS);
    while (response.indexOf("Version2") < 0) {
        if (System.currentTimeMillis() - firstTry >= 1000) {
            break;
        }
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            break;
        } finally {
            response = HttpRequest.get(getBaseURL(url) + "SimpleServlet/page.html", 1000, 10, TimeUnit.SECONDS);
        }
    }
    assertTrue("Invalid response: " + response, response.indexOf("Version2") >= 0);
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl)

Example 20 with ZipExporterImpl

use of org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl in project wildfly by wildfly.

the class DeployURLTestCase method before.

@BeforeClass
public static void before() throws Exception {
    war = ShrinkWrap.create(WebArchive.class, "SimpleServlet.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(new StringAsset("Version1"), "page.html");
    String tempDir = TestSuiteEnvironment.getTmpDir();
    warFile = new File(tempDir + File.separator + "SimpleServlet.war");
    new ZipExporterImpl(war).exportTo(warFile, true);
    AbstractCliTestBase.initCLI();
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) File(java.io.File) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl) BeforeClass(org.junit.BeforeClass)

Aggregations

ZipExporterImpl (org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl)20 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)18 File (java.io.File)16 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)15 BeforeClass (org.junit.BeforeClass)10 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)4 BasicPath (org.jboss.shrinkwrap.impl.base.path.BasicPath)3 URL (java.net.URL)2 SimpleHelloWorldServlet (org.jboss.as.test.integration.management.util.SimpleHelloWorldServlet)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 SocketPermission (java.net.SocketPermission)1 ITestConfigBuilder (org.apache.camel.itest.springboot.ITestConfigBuilder)1 FooDriver (org.jboss.as.test.integration.domain.driver.FooDriver)1 CLIOpResult (org.jboss.as.test.integration.management.util.CLIOpResult)1 ExplodedExporterImpl (org.jboss.shrinkwrap.impl.base.exporter.ExplodedExporterImpl)1 Test (org.junit.Test)1