Search in sources :

Example 1 with DefaultCallbackHandler

use of org.jboss.as.cli.operation.impl.DefaultCallbackHandler in project eap-additional-testsuite by jboss-set.

the class AddressOnlyParsingTestCase method testRootCharInTheMiddle.

@Test
public void testRootCharInTheMiddle() throws Exception {
    OperationRequestAddress prefix = new DefaultOperationRequestAddress();
    prefix.toNode("a", "b");
    DefaultCallbackHandler handler = new DefaultCallbackHandler(prefix);
    parser.parse("/", handler);
    assertTrue(handler.hasAddress());
    assertFalse(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertTrue(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.isRequestComplete());
    OperationRequestAddress address = handler.getAddress();
    address.isEmpty();
    try {
        handler.reset();
        parser.parse("//", handler);
        Assert.fail("Shouldn't allow root character in the middle of the path");
    } catch (CommandFormatException e) {
    // expected
    }
    try {
        handler.reset();
        parser.parse("./a/", handler);
        Assert.fail("Shouldn't allow root character in the middle of the path");
    } catch (CommandFormatException e) {
    // expected
    }
    handler.reset();
    parser.parse("./a=b/", handler);
    try {
        handler.reset();
        parser.parse("./a=b//", handler);
        Assert.fail("Shouldn't allow root character in the middle of the path");
    } catch (CommandFormatException e) {
    // expected
    }
    try {
        handler.reset();
        parser.parse("./a=b//a=b", handler);
        Assert.fail("Shouldn't allow root character in the middle of the path");
    } catch (CommandFormatException e) {
    // expected
    }
}
Also used : DefaultOperationRequestAddress(org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress) CommandFormatException(org.jboss.as.cli.CommandFormatException) 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

CommandFormatException (org.jboss.as.cli.CommandFormatException)1 OperationRequestAddress (org.jboss.as.cli.operation.OperationRequestAddress)1 DefaultCallbackHandler (org.jboss.as.cli.operation.impl.DefaultCallbackHandler)1 DefaultOperationRequestAddress (org.jboss.as.cli.operation.impl.DefaultOperationRequestAddress)1 Test (org.junit.Test)1