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;
}
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);
}
}
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;
}
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());
}
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;
}
Aggregations