Search in sources :

Example 6 with ParsedCommandLine

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

the class PropertyReplacementTestCase method testUnresolvedCommandArgumentValue.

@Test
public // there is a different config option whether to resolve argument values
void testUnresolvedCommandArgumentValue() throws Exception {
    final ParsedCommandLine parsed = parse("command-name ${" + OP_PROP_PROP_NAME + "}=test");
    assertEquals("command-name", parsed.getOperationName());
    assertFalse(parsed.hasProperty(OP_PROP_PROP_VALUE));
    assertFalse(parsed.hasProperty("--" + OP_PROP_PROP_VALUE));
    assertEquals(1, parsed.getOtherProperties().size());
    assertEquals("${" + OP_PROP_PROP_NAME + "}=test", parsed.getOtherProperties().get(0));
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) Test(org.junit.Test)

Example 7 with ParsedCommandLine

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

the class PropertyReplacementTestCase method testOperationPropertyName.

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

Example 8 with ParsedCommandLine

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

the class PropertyReplacementTestCase method testSystemPropertiesInTheMix.

@Test
public void testSystemPropertiesInTheMix() throws Exception {
    final ParsedCommandLine parsed = parse("co${" + OP_PROP_NAME + "}${" + OP_PROP_NAME + "} " + "--${" + OP_PROP_PROP_NAME + "}_${" + OP_PROP_PROP_NAME + "}=${" + OP_PROP_PROP_NAME + "}");
    assertEquals("co" + OP_PROP_VALUE + OP_PROP_VALUE, parsed.getOperationName());
    assertTrue(parsed.getOtherProperties().isEmpty());
    assertEquals("${" + OP_PROP_PROP_NAME + "}", parsed.getPropertyValue("--" + OP_PROP_PROP_VALUE + "_" + OP_PROP_PROP_VALUE));
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) Test(org.junit.Test)

Example 9 with ParsedCommandLine

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

the class PropertyReplacementTestCase method testHeaderNameAndValue.

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

Example 10 with ParsedCommandLine

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

the class PropertyReplacementTestCase method testCommandName.

@Test
public void testCommandName() throws Exception {
    final ParsedCommandLine parsed = parse("${" + OP_PROP_NAME + "}");
    assertEquals(OP_PROP_VALUE, parsed.getOperationName());
}
Also used : ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) 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