Search in sources :

Example 21 with ParsedCommandLine

use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.

the class VariablesTestCase method testQuotedOperationValue.

@Test
public void testQuotedOperationValue() throws Exception {
    final ParsedCommandLine parsed = parse(":write-attribute(name=\"$" + OP_PROP_VAR_NAME + "\")");
    assertEquals("write-attribute", parsed.getOperationName());
    assertEquals("\"$" + OP_PROP_VAR_NAME + '\"', parsed.getPropertyValue("name"));
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) Test(org.junit.Test)

Example 22 with ParsedCommandLine

use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.

the class VariablesTestCase method testComplexArgumentValue.

@Test
public void testComplexArgumentValue() throws Exception {
    final ParsedCommandLine parsed = parse(":op(name={attr=$" + OP_PROP_VAR_NAME + "})");
    assertEquals("op", parsed.getOperationName());
    assertEquals("{attr=" + OP_PROP_VAR_VALUE + "}", parsed.getPropertyValue("name"));
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) Test(org.junit.Test)

Example 23 with ParsedCommandLine

use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.

the class VariablesTestCase method testCommandName.

@Test
public void testCommandName() throws Exception {
    final ParsedCommandLine parsed = parse("$" + OP_VAR_NAME);
    assertEquals(OP_VAR_VALUE, parsed.getOperationName());
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) Test(org.junit.Test)

Example 24 with ParsedCommandLine

use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.

the class VariablesTestCase method testQuotedArgumentValue.

@Test
public void testQuotedArgumentValue() throws Exception {
    final ParsedCommandLine parsed = parse(":op(name=\"$" + OP_PROP_VAR_NAME + "\")");
    assertEquals("op", parsed.getOperationName());
    assertEquals("\"$" + OP_PROP_VAR_NAME + "\"", parsed.getPropertyValue("name"));
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) Test(org.junit.Test)

Example 25 with ParsedCommandLine

use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.

the class VariablesTestCase method testHeaderNameAndValue.

@Test
public void testHeaderNameAndValue() throws Exception {
    ParsedCommandLine parsed = parse(":write-attribute{$" + OP_PROP_VAR_NAME + "=$" + OP_VAR_NAME + "}");
    assertEquals("write-attribute", parsed.getOperationName());
    assertTrue(parsed.hasHeaders());
    assertTrue(parsed.hasHeader(OP_PROP_VAR_VALUE));
    ModelNode headers = new ModelNode();
    parsed.getLastHeader().addTo(null, headers);
    assertEquals(OP_VAR_VALUE, headers.get(OP_PROP_VAR_VALUE).asString());
    parsed = parse(":write-attribute{$" + OP_PROP_VAR_NAME + " $" + OP_VAR_NAME + "}");
    assertEquals("write-attribute", parsed.getOperationName());
    assertTrue(parsed.hasHeaders());
    assertTrue(parsed.hasHeader(OP_PROP_VAR_VALUE));
    headers = new ModelNode();
    parsed.getLastHeader().addTo(null, headers);
    assertEquals(OP_VAR_VALUE, headers.get(OP_PROP_VAR_VALUE).asString());
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

ParsedCommandLine (org.jboss.as.cli.operation.ParsedCommandLine)95 Test (org.junit.Test)42 CommandFormatException (org.jboss.as.cli.CommandFormatException)38 ModelNode (org.jboss.dmr.ModelNode)26 CommandLineException (org.jboss.as.cli.CommandLineException)14 OperationRequestAddress (org.jboss.as.cli.operation.OperationRequestAddress)14 File (java.io.File)12 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)9 DefaultOperationRequestAddress (org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress)8 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)8 CommandArgument (org.jboss.as.cli.CommandArgument)4 CommandContext (org.jboss.as.cli.CommandContext)4 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)4 ZipException (java.util.zip.ZipException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 CommandException (org.aesh.command.CommandException)3 BatchManager (org.jboss.as.cli.batch.BatchManager)3 CommandLineParser (org.jboss.as.cli.operation.CommandLineParser)3 DefaultCallbackHandler (org.jboss.as.cli.operation.impl.DefaultCallbackHandler)3