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