Search in sources :

Example 51 with StringAsset

use of org.jboss.shrinkwrap.api.asset.StringAsset in project wildfly by wildfly.

the class DeployTestCase 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)

Example 52 with StringAsset

use of org.jboss.shrinkwrap.api.asset.StringAsset in project wildfly by wildfly.

the class DeployWithRuntimeNameTestCase method createWarFile.

private File createWarFile(String content) throws IOException {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "HelloServlet.war");
    war.addClass(SimpleHelloWorldServlet.class);
    war.addAsWebInfResource(SimpleHelloWorldServlet.class.getPackage(), "web.xml", "web.xml");
    war.addAsWebResource(new StringAsset(content), "page.html");
    File tempFile = new File(TestSuiteEnvironment.getTmpDir(), "HelloServlet.war");
    new ZipExporterImpl(war).exportTo(tempFile, true);
    return tempFile;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) SimpleHelloWorldServlet(org.jboss.as.test.integration.management.util.SimpleHelloWorldServlet) File(java.io.File) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl)

Example 53 with StringAsset

use of org.jboss.shrinkwrap.api.asset.StringAsset in project wildfly by wildfly.

the class DeploymentArchiveTestCase method createCliArchive.

private static File createCliArchive() {
    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, WEB_ARCHIVE_NAME + ".war");
    webArchive.addClass(SimpleServlet.class);
    final JavaArchive moduleArchive = ShrinkWrap.create(JavaArchive.class, MODULE_ARCHIVE);
    moduleArchive.addClass(DeploymentArchiveTestCase.class);
    final GenericArchive cliArchive = ShrinkWrap.create(GenericArchive.class, "deploymentarchive.cli");
    cliArchive.add(new StringAsset(DEPLOY_SCR), "deploy.scr");
    cliArchive.add(new StringAsset(UNDEPLOY_SCR), "undeploy.scr");
    cliArchive.add(webArchive, "/", ZipExporter.class);
    cliArchive.add(moduleArchive, "/", ZipExporter.class);
    cliArchive.add(new StringAsset(MODULE_XML), "/", "module.xml");
    final String tempDir = TestSuiteEnvironment.getTmpDir();
    final File file = new File(tempDir, "deploymentarchive.cli");
    cliArchive.as(ZipExporter.class).exportTo(file, true);
    return file;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) File(java.io.File) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive)

Example 54 with StringAsset

use of org.jboss.shrinkwrap.api.asset.StringAsset in project wildfly by wildfly.

the class DeploymentOverlayCLITestCase method before.

@BeforeClass
public static void before() throws Exception {
    String tempDir = TestSuiteEnvironment.getTmpDir();
    WebArchive war;
    JavaArchive jar;
    jar = ShrinkWrap.create(JavaArchive.class, "lib.jar");
    jar.addClass(ReplacedLibraryServlet.class);
    jar.add(new StringAsset("replaced library"), "jar-info.txt");
    replacedLibrary = new File(tempDir + File.separator + jar.getName());
    new ZipExporterImpl(jar).exportTo(replacedLibrary, true);
    jar = ShrinkWrap.create(JavaArchive.class, "addedlib.jar");
    jar.addClass(AddedLibraryServlet.class);
    addedLibrary = new File(tempDir + File.separator + jar.getName());
    new ZipExporterImpl(jar).exportTo(addedLibrary, true);
    jar = ShrinkWrap.create(JavaArchive.class, "lib.jar");
    jar.addClass(OriginalLibraryServlet.class);
    // deployment1
    war = ShrinkWrap.create(WebArchive.class, "deployment0.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebResource(DeploymentOverlayCLITestCase.class.getPackage(), "a.jsp", "a.jsp");
    war.addAsWebInfResource(DeploymentOverlayCLITestCase.class.getPackage(), "web.xml", "web.xml");
    war.addAsLibraries(jar);
    File explodedwars_basedir = new File(tempDir + File.separator + "exploded_deployments");
    explodedwars_basedir.mkdirs();
    war1 = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(war1, true);
    war1_exploded = new ExplodedExporterImpl(war).exportExploded(explodedwars_basedir);
    war = ShrinkWrap.create(WebArchive.class, "deployment1.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebInfResource(DeploymentOverlayCLITestCase.class.getPackage(), "web.xml", "web.xml");
    war.addAsLibraries(jar);
    war2 = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(war2, true);
    war2_exploded = new ExplodedExporterImpl(war).exportExploded(explodedwars_basedir);
    war = ShrinkWrap.create(WebArchive.class, "another.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebInfResource(DeploymentOverlayCLITestCase.class.getPackage(), "web.xml", "web.xml");
    war.addAsLibraries(jar);
    war3 = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(war3, true);
    EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "eardeployment1.ear");
    ear.addAsModule(war1);
    ear1 = new File(tempDir + File.separator + ear.getName());
    new ZipExporterImpl(ear).exportTo(ear1, true);
    ear1_exploded = new ExplodedExporterImpl(ear).exportExploded(explodedwars_basedir);
    war = ShrinkWrap.create(WebArchive.class, "deployment0.war");
    war.addClass(SimpleServlet.class);
    war.addClass(EarServlet.class);
    war.addAsWebResource(DeploymentOverlayCLITestCase.class.getPackage(), "a.jsp", "a.jsp");
    war.addAsWebInfResource(DeploymentOverlayCLITestCase.class.getPackage(), "web.xml", "web.xml");
    jar = ShrinkWrap.create(JavaArchive.class, "lib.jar");
    jar.add(new StringAsset("original library"), "jar-info.txt");
    ear = ShrinkWrap.create(EnterpriseArchive.class, "eardeployment2.ear");
    ear.addAsModule(war);
    ear.addAsLibraries(jar);
    ear2 = new File(tempDir + File.separator + ear.getName());
    new ZipExporterImpl(ear).exportTo(ear2, true);
    ear2_exploded = new ExplodedExporterImpl(ear).exportExploded(explodedwars_basedir);
    final URL overrideXmlUrl = DeploymentOverlayCLITestCase.class.getResource("override.xml");
    if (overrideXmlUrl == null) {
        Assert.fail("Failed to locate override.xml");
    }
    overrideXml = new File(overrideXmlUrl.toURI());
    if (!overrideXml.exists()) {
        Assert.fail("Failed to locate override.xml");
    }
    final URL webXmlUrl = DeploymentOverlayCLITestCase.class.getResource("web.xml");
    if (webXmlUrl == null) {
        Assert.fail("Failed to locateweb.xml");
    }
    webXml = new File(webXmlUrl.toURI());
    if (!webXml.exists()) {
        Assert.fail("Failed to locate web.xml");
    }
    final URL ajsp = DeploymentOverlayCLITestCase.class.getResource("a-replaced.jsp");
    if (ajsp == null) {
        Assert.fail("Failed to locate a-replaced.jsp");
    }
    replacedAjsp = new File(ajsp.toURI());
    if (!replacedAjsp.exists()) {
        Assert.fail("Failed to locate a-replaced.jsp");
    }
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) File(java.io.File) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl) URL(java.net.URL) ExplodedExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.ExplodedExporterImpl) BeforeClass(org.junit.BeforeClass)

Example 55 with StringAsset

use of org.jboss.shrinkwrap.api.asset.StringAsset in project wildfly by wildfly.

the class DeployTestCase 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 " + warFile.getAbsolutePath(), true));
    // force redeploy
    cli.sendLine("deploy " + warFile.getAbsolutePath() + " --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)

Aggregations

StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)319 Deployment (org.jboss.arquillian.container.test.api.Deployment)259 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)180 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)180 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)60 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)44 ResourceAdapterArchive (org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive)38 WebAppDescriptor (org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor)25 AbstractMgmtTestBase (org.jboss.as.test.integration.management.base.AbstractMgmtTestBase)24 File (java.io.File)17 PropertyPermission (java.util.PropertyPermission)17 ZipExporterImpl (org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl)15 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)11 CommonCriteria (org.jboss.as.test.categories.CommonCriteria)10 Util (org.jboss.as.test.shared.integration.ejb.security.Util)10 BeforeClass (org.junit.BeforeClass)8 Test (org.junit.Test)8 SocketPermission (java.net.SocketPermission)7 Properties (java.util.Properties)7 Runner (org.apache.openejb.arquillian.tests.Runner)7