Search in sources :

Example 1 with DeploymentPlanResult

use of org.jboss.as.controller.client.helpers.domain.DeploymentPlanResult 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)

Aggregations

InputStream (java.io.InputStream)1 DeploymentPlan (org.jboss.as.controller.client.helpers.domain.DeploymentPlan)1 DeploymentPlanResult (org.jboss.as.controller.client.helpers.domain.DeploymentPlanResult)1 DomainClient (org.jboss.as.controller.client.helpers.domain.DomainClient)1 DomainDeploymentManager (org.jboss.as.controller.client.helpers.domain.DomainDeploymentManager)1 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)1 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)1 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)1 Test (org.junit.Test)1