Search in sources :

Example 1 with Node

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

the class OperationParsingTestCase method testOperationNameOnly.

@Test
public void testOperationNameOnly() throws Exception {
    DefaultCallbackHandler handler = new DefaultCallbackHandler();
    parse("/subsystem=logging:read-resource", handler);
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.isRequestComplete());
    assertEquals("read-resource", handler.getOperationName());
    OperationRequestAddress address = handler.getAddress();
    Iterator<Node> i = address.iterator();
    assertTrue(i.hasNext());
    Node node = i.next();
    assertEquals("subsystem", node.getType());
    assertEquals("logging", node.getName());
    assertFalse(i.hasNext());
}
Also used : Node(org.jboss.as.cli.operation.OperationRequestAddress.Node) ModelNode(org.jboss.dmr.ModelNode) DefaultCallbackHandler(org.jboss.as.cli.operation.impl.DefaultCallbackHandler) DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) OperationRequestAddress(org.jboss.as.cli.operation.OperationRequestAddress) Test(org.junit.Test)

Example 2 with Node

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

the class OperationParsingTestCase method testOperationWithArgumentsAndWhitespaces.

@Test
public void testOperationWithArgumentsAndWhitespaces() throws Exception {
    DefaultCallbackHandler handler = new DefaultCallbackHandler();
    parse("   / subsystem  =  logging  :  read-resource  ( recursive = true , another = \"   \" )   ", handler);
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertTrue(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.isRequestComplete());
    assertEquals("read-resource", handler.getOperationName());
    OperationRequestAddress address = handler.getAddress();
    Iterator<Node> i = address.iterator();
    assertTrue(i.hasNext());
    Node node = i.next();
    assertEquals("subsystem", node.getType());
    assertEquals("logging", node.getName());
    assertFalse(i.hasNext());
    Set<String> args = handler.getPropertyNames();
    assertEquals(2, args.size());
    assertTrue(args.contains("recursive"));
    assertEquals("true", handler.getPropertyValue("recursive"));
    assertTrue(args.contains("another"));
    assertEquals("\"   \"", handler.getPropertyValue("another"));
}
Also used : Node(org.jboss.as.cli.operation.OperationRequestAddress.Node) ModelNode(org.jboss.dmr.ModelNode) DefaultCallbackHandler(org.jboss.as.cli.operation.impl.DefaultCallbackHandler) DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) OperationRequestAddress(org.jboss.as.cli.operation.OperationRequestAddress) Test(org.junit.Test)

Example 3 with Node

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

the class OperationParsingTestCase method testOperationWithArguments.

@Test
public void testOperationWithArguments() throws Exception {
    DefaultCallbackHandler handler = new DefaultCallbackHandler();
    parse("/subsystem=logging:read-resource(recursive=true)", handler);
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertTrue(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.isRequestComplete());
    assertEquals("read-resource", handler.getOperationName());
    OperationRequestAddress address = handler.getAddress();
    Iterator<Node> i = address.iterator();
    assertTrue(i.hasNext());
    Node node = i.next();
    assertEquals("subsystem", node.getType());
    assertEquals("logging", node.getName());
    assertFalse(i.hasNext());
    Set<String> args = handler.getPropertyNames();
    assertEquals(1, args.size());
    assertTrue(args.contains("recursive"));
    assertEquals("true", handler.getPropertyValue("recursive"));
}
Also used : Node(org.jboss.as.cli.operation.OperationRequestAddress.Node) ModelNode(org.jboss.dmr.ModelNode) DefaultCallbackHandler(org.jboss.as.cli.operation.impl.DefaultCallbackHandler) DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) OperationRequestAddress(org.jboss.as.cli.operation.OperationRequestAddress) Test(org.junit.Test)

Example 4 with Node

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

the class OperationParsingTestCase method testOperationNameWithPrefix.

@Test
public void testOperationNameWithPrefix() throws Exception {
    OperationRequestAddress prefix = new DefaultOperationRequestAddress();
    prefix.toNodeType("subsystem");
    DefaultCallbackHandler handler = new DefaultCallbackHandler(prefix);
    parse("./logging:read-resource", handler);
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.isRequestComplete());
    assertEquals("read-resource", handler.getOperationName());
    OperationRequestAddress address = handler.getAddress();
    Iterator<Node> i = address.iterator();
    assertTrue(i.hasNext());
    Node node = i.next();
    assertEquals("subsystem", node.getType());
    assertEquals("logging", node.getName());
    assertFalse(i.hasNext());
}
Also used : DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) Node(org.jboss.as.cli.operation.OperationRequestAddress.Node) ModelNode(org.jboss.dmr.ModelNode) DefaultCallbackHandler(org.jboss.as.cli.operation.impl.DefaultCallbackHandler) DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) OperationRequestAddress(org.jboss.as.cli.operation.OperationRequestAddress) Test(org.junit.Test)

Example 5 with Node

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

the class OperationParsingTestCase method testOperationNameEndsWithDash.

@Test
public void testOperationNameEndsWithDash() throws Exception {
    DefaultCallbackHandler handler = new DefaultCallbackHandler(false);
    parse("/subsystem=threads/thread-factory=*:validate-", handler);
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.isRequestComplete());
    assertEquals("validate-", handler.getOperationName());
    OperationRequestAddress address = handler.getAddress();
    Iterator<Node> i = address.iterator();
    assertTrue(i.hasNext());
/*        Node node = i.next();
        assertEquals("subsystem", node.getType());
        assertEquals("logging", node.getName());
        assertFalse(i.hasNext());
*/
}
Also used : Node(org.jboss.as.cli.operation.OperationRequestAddress.Node) ModelNode(org.jboss.dmr.ModelNode) DefaultCallbackHandler(org.jboss.as.cli.operation.impl.DefaultCallbackHandler) DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) OperationRequestAddress(org.jboss.as.cli.operation.OperationRequestAddress) Test(org.junit.Test)

Aggregations

Node (org.jboss.as.cli.operation.OperationRequestAddress.Node)36 OperationRequestAddress (org.jboss.as.cli.operation.OperationRequestAddress)35 DefaultOperationRequestAddress (org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress)32 DefaultCallbackHandler (org.jboss.as.cli.operation.impl.DefaultCallbackHandler)29 Test (org.junit.Test)28 ModelNode (org.jboss.dmr.ModelNode)14 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)4 IOException (java.io.IOException)3 TerminalString (org.aesh.readline.terminal.formatting.TerminalString)1 CommandArgument (org.jboss.as.cli.CommandArgument)1 CommandContext (org.jboss.as.cli.CommandContext)1 CommandFormatException (org.jboss.as.cli.CommandFormatException)1 CommandLineException (org.jboss.as.cli.CommandLineException)1 ArgumentWithoutValue (org.jboss.as.cli.impl.ArgumentWithoutValue)1 ParsedOperationRequestHeader (org.jboss.as.cli.operation.ParsedOperationRequestHeader)1 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)1