use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class PropertyReplacementTestCase method testNodeType.
@Test
public void testNodeType() throws Exception {
final ParsedCommandLine parsed = parse("/${" + NODE_TYPE_PROP_NAME + "}=test:op");
final OperationRequestAddress address = parsed.getAddress();
assertNotNull(address);
assertEquals(NODE_TYPE_PROP_VALUE, address.getNodeType());
assertEquals("test", address.getNodeName());
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class PropertyReplacementTestCase method testOperationNameAndValue.
@Test
public void testOperationNameAndValue() throws Exception {
final ParsedCommandLine parsed = parse(":write-attribute(${" + OP_PROP_PROP_NAME + "}=${" + OP_PROP_PROP_NAME + "})");
assertEquals("write-attribute", parsed.getOperationName());
// variables unlike system properties are always resolved
assertEquals("${" + OP_PROP_PROP_NAME + "}", parsed.getPropertyValue(OP_PROP_PROP_VALUE));
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class PropertyReplacementTestCase method testCommandArgumentNameAndValue.
@Test
public void testCommandArgumentNameAndValue() throws Exception {
final ParsedCommandLine parsed = parse("command-name --${" + OP_PROP_PROP_NAME + "}=${" + OP_PROP_PROP_NAME + "}");
assertEquals("command-name", parsed.getOperationName());
// there is a different config option whether to resolve argument values
assertEquals(parsed.getPropertyValue("--" + OP_PROP_PROP_VALUE), "${" + OP_PROP_PROP_NAME + "}");
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class CommandLineArgumentsTestCase method testDefault.
@Test
public void testDefault() throws Exception {
ParsedCommandLine args = parse("deploy ../../../../testsuite/smoke/target/deployments/test-deployment.sar --name=my.sar --disabled --runtime-name=myrt.sar --force");
assertTrue(args.hasProperties());
assertTrue(args.hasProperty("--name"));
assertTrue(args.hasProperty("--runtime-name"));
assertTrue(args.hasProperty("--disabled"));
assertTrue(args.hasProperty("--force"));
List<String> otherArgs = args.getOtherProperties();
assertEquals(1, otherArgs.size());
assertEquals("../../../../testsuite/smoke/target/deployments/test-deployment.sar", otherArgs.get(0));
assertNull(args.getOutputTarget());
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class PatchHandler method createPatchOperationTarget.
private PatchOperationTarget createPatchOperationTarget(CommandContext ctx) throws CommandLineException {
final PatchOperationTarget target;
final ParsedCommandLine args = ctx.getParsedCommandLine();
if (ctx.getModelControllerClient() != null) {
if (distribution.isPresent(args)) {
throw new CommandFormatException(distribution.getFullName() + " is not allowed when connected to the controller.");
}
if (modulePath.isPresent(args)) {
throw new CommandFormatException(modulePath.getFullName() + " is not allowed when connected to the controller.");
}
if (bundlePath.isPresent(args)) {
throw new CommandFormatException(bundlePath.getFullName() + " is not allowed when connected to the controller.");
}
if (ctx.isDomainMode()) {
String hostName = host.getValue(args, true);
target = PatchOperationTarget.createHost(hostName, ctx.getModelControllerClient());
} else {
target = PatchOperationTarget.createStandalone(ctx.getModelControllerClient());
}
} else {
final String jbossHome = getJBossHome(args);
final File root = new File(jbossHome);
final List<File> modules = getFSArgument(modulePath, args, root, "modules");
final List<File> bundles = getFSArgument(bundlePath, args, root, "bundles");
try {
target = PatchOperationTarget.createLocal(root, modules, bundles);
} catch (Exception e) {
throw new CommandLineException("Unable to apply patch to local JBOSS_HOME=" + jbossHome, e);
}
}
return target;
}
Aggregations