use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.
the class MPScriptTestCase method setupConfig.
private void setupConfig() throws Exception {
System.setProperty(CONFIG_FILE_PROP, currentConfig);
try {
Files.copy(CONFIG_DIR.resolve(currentConfig), CONFIG_DIR.resolve(PREFIX + currentConfig));
CommandContext ctx = CommandContextFactory.getInstance().newCommandContext();
for (String line : Files.readAllLines(SCRIPT_FILE, Charset.forName("UTF-8"))) {
ctx.handle(line);
}
} finally {
System.clearProperty(CONFIG_FILE_PROP);
}
}
use of org.jboss.as.cli.CommandContext in project wildfly by wildfly.
the class CLIServerSetupTask method executeCommands.
private void executeCommands(ManagementClient managementClient, List<String> commands, boolean useBatch, boolean reload) throws Exception {
if (commands.isEmpty())
return;
CommandContext context = CLITestUtil.getCommandContext();
context.connectController();
if (useBatch) {
context.getBatchManager().activateNewBatch();
Batch batch = context.getBatchManager().getActiveBatch();
for (String command : commands) {
batch.add(context.toBatchedCommand(command));
}
ModelNode commandModel = batch.toRequest();
// Add {allow-resource-service-restart=true} operation flag manually since its not exposed on the Batch
// Currently fails with: https://issues.jboss.org/browse/ARQ-1135
// commandModel.get(ModelDescriptionConstants.OPERATION_HEADERS).get(ModelDescriptionConstants.ALLOW_RESOURCE_SERVICE_RESTART).set(true);
ModelNode result = managementClient.getControllerClient().execute(commandModel);
LOG.debugf("Executed batch %s with result %s", commands, result.toJSONString(true));
this.checkResult(result);
} else {
for (String command : commands) {
ModelNode commandModel = context.buildRequest(command);
ModelNode result = managementClient.getControllerClient().execute(commandModel);
LOG.debugf("Executed single command %s with result %s", commands, result.toJSONString(true));
this.checkResult(result);
}
}
if (reload) {
LOG.debugf("Reloading server %s if its in a 'reload-required' state.", managementClient.getMgmtAddress());
ServerReload.reloadIfRequired(managementClient);
}
}
use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.
the class MultipleLinesCommandsTestCase method handleAsOneString.
protected void handleAsOneString(String[] arr) throws Exception {
final StringBuilder buf = new StringBuilder();
for (String line : arr) {
buf.append(line);
}
final CommandContext ctx = CLITestUtil.getCommandContext();
try {
ctx.connectController();
ctx.handle(buf.toString());
} finally {
ctx.terminateSession();
}
}
use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.
the class NonExistingPathComparisonTestCase method testLessThan.
@Test
public void testLessThan() throws Exception {
final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
try {
ctx.connectController();
ctx.handle(this.getAddPropertyReq("\"5\""));
assertEquals("5", runIf(ctx, "<", "&&", "\"7\""));
assertEquals("true", runIf(ctx, "<", "||", "\"7\""));
} finally {
ctx.handleSafe(this.getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
}
use of org.jboss.as.cli.CommandContext in project eap-additional-testsuite by jboss-set.
the class NonExistingPathComparisonTestCase method testUndefined.
// It does not work with 6.3.x
@Ignore
@Test
public void testUndefined() throws Exception {
final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
try {
ctx.connectController();
ctx.handle(this.getAddPropertyReqWithoutValue());
assertEquals("undefined", runIf(ctx, "==", "&&", "undefined"));
assertEquals("true", runIf(ctx, "==", "||", "undefined"));
} finally {
ctx.handleSafe(this.getRemovePropertyReq());
ctx.terminateSession();
cliOut.reset();
}
}
Aggregations