Search in sources :

Example 16 with CommandContext

use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.

the class ArchiveDefaultScriptNamesTestCase method testDeployUndeployArchive.

@Test
public void testDeployUndeployArchive() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    try {
        ctx.connectController();
        ctx.handle("deploy " + cliArchiveFile.getAbsolutePath());
        // check that now both wars are deployed
        String response = HttpRequest.get(getBaseURL(url) + "deployment0/SimpleServlet", 10, TimeUnit.SECONDS);
        assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
        response = HttpRequest.get(getBaseURL(url) + "deployment1/SimpleServlet", 10, TimeUnit.SECONDS);
        assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
        assertTrue(checkUndeployed(getBaseURL(url) + "deployment2/SimpleServlet"));
        ctx.handle("undeploy " + "--path=" + cliArchiveFile.getAbsolutePath());
        // check that both wars are undeployed
        assertTrue(checkUndeployed(getBaseURL(url) + "deployment0/SimpleServlet"));
        assertTrue(checkUndeployed(getBaseURL(url) + "deployment1/SimpleServlet"));
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) Test(org.junit.Test)

Example 17 with CommandContext

use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.

the class ModClusterSubsystemAddTestCase method testModClusterAdd.

@Test
@InSequence(1)
public void testModClusterAdd() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();
    try {
        ctx.connectController();
        // Add the mod_cluster extension first (not in this profile by default)
        ModelNode request = ctx.buildRequest("/extension=org.jboss.as.modcluster:add");
        ModelNode response = controllerClient.execute(request);
        String outcome = response.get("outcome").asString();
        Assert.assertEquals("Adding mod_cluster extension failed! " + request.toJSONString(false), "success", outcome);
        // Now lets execute subsystem add operation but we need to specify a connector
        ctx.getBatchManager().activateNewBatch();
        Batch b = ctx.getBatchManager().getActiveBatch();
        b.add(ctx.toBatchedCommand("/socket-binding-group=standard-sockets/socket-binding=modcluster:add(multicast-port=23364, multicast-address=224.0.1.105)"));
        b.add(ctx.toBatchedCommand("/subsystem=modcluster:add"));
        b.add(ctx.toBatchedCommand("/subsystem=modcluster/mod-cluster-config=configuration:add(connector=http,advertise-socket=modcluster)"));
        request = b.toRequest();
        b.clear();
        ctx.getBatchManager().discardActiveBatch();
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Adding mod_cluster subsystem failed! " + request.toJSONString(false), "success", outcome);
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) Batch(org.jboss.as.cli.batch.Batch) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 18 with CommandContext

use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.

the class ModClusterSubsystemAddTestCase method testModClusterRemove.

@Test
@InSequence(2)
public void testModClusterRemove() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();
    try {
        ctx.connectController();
        // Test subsystem remove
        ModelNode request = ctx.buildRequest("/subsystem=modcluster:remove");
        ModelNode response = controllerClient.execute(request);
        String outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing mod_cluster subsystem failed! " + request.toJSONString(false), "success", outcome);
        // Cleanup socket binding
        request = ctx.buildRequest("/socket-binding-group=standard-sockets/socket-binding=modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing socket binding failed! " + request.toJSONString(false), "success", outcome);
        // Cleanup and remove the extension
        request = ctx.buildRequest("/extension=org.jboss.as.modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing mod_cluster extension failed! " + request.toJSONString(false), "success", outcome);
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 19 with CommandContext

use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.

the class ModClusterSubsystemTestCase method testModClusterAddAndRemoveSequence.

@Test
public void testModClusterAddAndRemoveSequence() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();
    try {
        ctx.connectController();
        // Add the mod_cluster extension first (not in this profile by default)
        // n.b. extensions cannot be added in a batch
        ModelNode request = ctx.buildRequest("/extension=org.jboss.as.modcluster:add");
        ModelNode response = controllerClient.execute(request);
        String outcome = response.get("outcome").asString();
        Assert.assertEquals("Adding mod_cluster extension failed! " + response.toJSONString(false), SUCCESS, outcome);
        // Now lets execute subsystem add operation but we need to specify a connector
        ctx.getBatchManager().activateNewBatch();
        Batch b = ctx.getBatchManager().getActiveBatch();
        b.add(ctx.toBatchedCommand("/socket-binding-group=standard-sockets/socket-binding=modcluster:add(multicast-port=23364, multicast-address=224.0.1.105)"));
        b.add(ctx.toBatchedCommand("/subsystem=modcluster:add"));
        b.add(ctx.toBatchedCommand("/subsystem=modcluster/mod-cluster-config=configuration:add(connector=default, advertise-socket=modcluster)"));
        request = b.toRequest();
        b.clear();
        ctx.getBatchManager().discardActiveBatch();
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Adding mod_cluster subsystem failed! " + response.toJSONString(false), SUCCESS, outcome);
        // We need to reload the server here since the add operation leaves the server in 'reload-required' state
        ServerReload.executeReloadAndWaitForCompletion(managementClient);
        // Test subsystem remove
        request = ctx.buildRequest("/subsystem=modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing mod_cluster subsystem failed! " + response.toJSONString(false), SUCCESS, outcome);
        // Cleanup and remove the extension
        request = ctx.buildRequest("/extension=org.jboss.as.modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing mod_cluster extension failed! " + response.toJSONString(false), SUCCESS, outcome);
        // Cleanup socket binding
        request = ctx.buildRequest("/socket-binding-group=standard-sockets/socket-binding=modcluster:remove");
        response = controllerClient.execute(request);
        outcome = response.get("outcome").asString();
        Assert.assertEquals("Removing socket binding failed! " + response.toJSONString(false), SUCCESS, outcome);
        // Remove leaves the server in 'reload-required' state, we need to reload the server in order not to leave running services
        // around for subsequent tests
        ServerReload.executeReloadAndWaitForCompletion(managementClient);
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) Batch(org.jboss.as.cli.batch.Batch) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 20 with CommandContext

use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.

the class ArchiveTestCase method testUnDeployArchive.

@Test
public void testUnDeployArchive() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    try {
        ctx.connectController();
        ctx.handle("deploy " + cliArchiveFile.getAbsolutePath() + " --script=install.scr");
        // check that now both wars are deployed
        String response = HttpRequest.get(getBaseURL(url) + "deployment0/SimpleServlet", 10, TimeUnit.SECONDS);
        assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
        response = HttpRequest.get(getBaseURL(url) + "deployment1/SimpleServlet", 10, TimeUnit.SECONDS);
        assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
        ctx.handle("undeploy " + "--path=" + cliArchiveFile.getAbsolutePath() + " --script=uninstall.scr");
        // check that both wars are undeployed
        assertTrue(checkUndeployed(getBaseURL(url) + "deployment0/SimpleServlet"));
        assertTrue(checkUndeployed(getBaseURL(url) + "deployment1/SimpleServlet"));
    } finally {
        ctx.terminateSession();
    }
}
Also used : CommandContext(org.jboss.as.cli.CommandContext) Test(org.junit.Test)

Aggregations

CommandContext (org.jboss.as.cli.CommandContext)37 Test (org.junit.Test)33 ModelNode (org.jboss.dmr.ModelNode)7 CommandLineException (org.jboss.as.cli.CommandLineException)4 Batch (org.jboss.as.cli.batch.Batch)3 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)3 InSequence (org.jboss.arquillian.junit.InSequence)2 Property (org.jboss.dmr.Property)2 Ignore (org.junit.Ignore)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 CliEvent (org.jboss.as.cli.CliEvent)1 CliEventListener (org.jboss.as.cli.CliEventListener)1