Search in sources :

Example 66 with WebArchive

use of org.jboss.shrinkwrap.api.spec.WebArchive in project wildfly by wildfly.

the class ModelPersistenceTestCase method getBrokenWar.

private static File getBrokenWar() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "malformedDeployment.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebInfResource(new StringAsset("Malformed"), "web.xml");
    File brokenWar = new File(System.getProperty("java.io.tmpdir") + File.separator + "malformedDeployment.war");
    brokenWar.deleteOnExit();
    new ZipExporterImpl(war).exportTo(brokenWar, true);
    return brokenWar;
}
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)

Example 67 with WebArchive

use of org.jboss.shrinkwrap.api.spec.WebArchive in project wildfly by wildfly.

the class ReadEnvironmentVariablesTestCase method testReadEnvironmentVariablesForServers.

@Test
public void testReadEnvironmentVariablesForServers() throws Exception {
    DomainClient client = domainMasterLifecycleUtil.createDomainClient();
    DomainDeploymentManager manager = client.getDeploymentManager();
    try {
        //Deploy the archive
        WebArchive archive = ShrinkWrap.create(WebArchive.class, "env-test.war").addClass(EnvironmentTestServlet.class);
        archive.addAsResource(new StringAsset("Manifest-Version: 1.0\nDependencies: org.jboss.dmr \n"), "META-INF/MANIFEST.MF");
        archive.addAsManifestResource(createPermissionsXmlAsset(new RuntimePermission("getenv.*")), "permissions.xml");
        final InputStream contents = archive.as(ZipExporter.class).exportAsInputStream();
        try {
            DeploymentPlan plan = manager.newDeploymentPlan().add("env-test.war", contents).deploy("env-test.war").toServerGroup("main-server-group").toServerGroup("other-server-group").build();
            DeploymentPlanResult result = manager.execute(plan).get();
            Assert.assertTrue(result.isValid());
        } finally {
            IoUtils.safeClose(contents);
        }
        Map<String, String> env = getEnvironmentVariables(client, "master", "main-one", "standard-sockets");
        checkEnvironmentVariable(env, "DOMAIN_TEST_MAIN_GROUP", "main_group");
        checkEnvironmentVariable(env, "DOMAIN_TEST_SERVER", "server");
        checkEnvironmentVariable(env, "DOMAIN_TEST_JVM", "jvm");
        env = getEnvironmentVariables(client, "slave", "main-three", "standard-sockets");
        checkEnvironmentVariable(env, "DOMAIN_TEST_MAIN_GROUP", "main_group");
        Assert.assertFalse(env.containsKey("DOMAIN_TEST_SERVER"));
        Assert.assertFalse(env.containsKey("DOMAIN_TEST_JVM"));
        env = getEnvironmentVariables(client, "slave", "other-two", "other-sockets");
        Assert.assertFalse(env.containsKey("DOMAIN_TEST_MAIN_GROUP"));
        Assert.assertFalse(env.containsKey("DOMAIN_TEST_SERVER"));
        Assert.assertFalse(env.containsKey("DOMAIN_TEST_JVM"));
    } finally {
        DeploymentPlanResult result = manager.execute(manager.newDeploymentPlan().undeploy("env-test.war").build()).get();
        Assert.assertTrue(result.isValid());
        IoUtils.safeClose(client);
    }
}
Also used : DomainClient(org.jboss.as.controller.client.helpers.domain.DomainClient) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) InputStream(java.io.InputStream) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) DeploymentPlanResult(org.jboss.as.controller.client.helpers.domain.DeploymentPlanResult) DeploymentPlan(org.jboss.as.controller.client.helpers.domain.DeploymentPlan) DomainDeploymentManager(org.jboss.as.controller.client.helpers.domain.DomainDeploymentManager) Test(org.junit.Test)

Example 68 with WebArchive

use of org.jboss.shrinkwrap.api.spec.WebArchive in project wildfly by wildfly.

the class DomainDeployWithRuntimeNameTestCase 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(System.getProperty("java.io.tmpdir"), "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 69 with WebArchive

use of org.jboss.shrinkwrap.api.spec.WebArchive in project wildfly by wildfly.

the class DomainDeploymentOverlayTestCase method before.

@BeforeClass
public static void before() throws Exception {
    String tempDir = System.getProperty("java.io.tmpdir");
    WebArchive war;
    // deployment1
    war = ShrinkWrap.create(WebArchive.class, "deployment0.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebInfResource("cli/deployment-overlay/web.xml", "web.xml");
    war1 = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(war1, true);
    war = ShrinkWrap.create(WebArchive.class, "deployment1.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebInfResource("cli/deployment-overlay/web.xml", "web.xml");
    war2 = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(war2, true);
    war = ShrinkWrap.create(WebArchive.class, "another.war");
    war.addClass(SimpleServlet.class);
    war.addAsWebInfResource("cli/deployment-overlay/web.xml", "web.xml");
    war3 = new File(tempDir + File.separator + war.getName());
    new ZipExporterImpl(war).exportTo(war3, true);
    final URL overrideXmlUrl = DomainDeploymentOverlayTestCase.class.getClassLoader().getResource("cli/deployment-overlay/override.xml");
    if (overrideXmlUrl == null) {
        Assert.fail("Failed to locate cli/deployment-overlay/override.xml");
    }
    overrideXml = new File(overrideXmlUrl.toURI());
    if (!overrideXml.exists()) {
        Assert.fail("Failed to locate cli/deployment-overlay/override.xml");
    }
    final URL webXmlUrl = DomainDeploymentOverlayTestCase.class.getClassLoader().getResource("cli/deployment-overlay/web.xml");
    if (webXmlUrl == null) {
        Assert.fail("Failed to locate cli/deployment-overlay/web.xml");
    }
    webXml = new File(webXmlUrl.toURI());
    if (!webXml.exists()) {
        Assert.fail("Failed to locate cli/deployment-overlay/web.xml");
    }
    // Launch the domain
    testSupport = CLITestSuite.createSupport(DomainDeploymentOverlayTestCase.class.getSimpleName());
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) File(java.io.File) ZipExporterImpl(org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 70 with WebArchive

use of org.jboss.shrinkwrap.api.spec.WebArchive in project wildfly by wildfly.

the class JCETestCase method deployment.

@Deployment
public static Archive<?> deployment() throws Exception {
    final JavaArchive jce = ShrinkWrap.create(JavaArchive.class, "jcetest.jar").addPackage(DummyProvider.class.getPackage());
    final File jceJar = new File("jcetest.jar");
    jce.as(ZipExporter.class).exportTo(jceJar, true);
    final File signedJceJar = new File("jcetestsigned.jar");
    JavaArchive signedJce;
    if (isJCETestable()) {
        // see genkey-jcetest-keystore in pom.xml for the keystore creation
        final JarSignerUtil signer = new JarSignerUtil(new File("../jcetest.keystore"), "password", "password", /* alias */
        "test");
        signer.sign(jceJar, signedJceJar);
        signer.verify(signedJceJar);
        signedJce = ShrinkWrap.create(ZipImporter.class, "jcetestsigned.jar").importFrom(signedJceJar).as(JavaArchive.class);
    } else {
        log.trace("skipping the test since it can run on Oracle JDK only");
        signedJce = jce;
    }
    final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").addClasses(ControllerServlet.class);
    final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jcetest.ear").addAsLibrary(signedJce).addAsModule(war).addAsManifestResource(JCETestCase.class.getPackage(), "jboss-deployment-structure.xml", "jboss-deployment-structure.xml");
    // ControllerServlet and DummyProvider need the following perms for their "dirty" game
    ear.addAsManifestResource(createPermissionsXmlAsset(new FilePermission("../jcetest.keystore", "read"), new RuntimePermission("accessDeclaredMembers"), new ReflectPermission("suppressAccessChecks"), new RuntimePermission("accessClassInPackage.sun.security.validator"), new SecurityPermission("putProviderProperty.DP"), new SecurityPermission("insertProvider"), new RuntimePermission("getProtectionDomain")), "permissions.xml");
    return ear;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) DummyProvider(org.jboss.as.test.integration.deployment.jcedeployment.provider.DummyProvider) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) FilePermission(java.io.FilePermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) ReflectPermission(java.lang.reflect.ReflectPermission) File(java.io.File) SecurityPermission(java.security.SecurityPermission) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)519 Deployment (org.jboss.arquillian.container.test.api.Deployment)421 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)170 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)110 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)89 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)80 HttpRequest (org.jboss.as.test.integration.common.HttpRequest)28 File (java.io.File)25 WebAppDescriptor (org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor)25 BatchTestHelper (org.javaee7.util.BatchTestHelper)13 PropertyPermission (java.util.PropertyPermission)11 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)11 SocketPermission (java.net.SocketPermission)10 ZipExporterImpl (org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl)10 CommonCriteria (org.jboss.as.test.categories.CommonCriteria)9 BeforeClass (org.junit.BeforeClass)9 Test (org.junit.Test)9 ClassLoaderAsset (org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)8 Runner (org.apache.openejb.arquillian.tests.Runner)7 Util (org.jboss.as.test.shared.integration.ejb.security.Util)7