Package org.jboss.as.cli.operation.impl

Examples of org.jboss.as.cli.operation.impl.DefaultCallbackHandler


    @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());
View Full Code Here


        assertFalse(i.hasNext());
    }

    @Test
    public void testNoOperation() throws Exception {
        DefaultCallbackHandler handler = new DefaultCallbackHandler();

        try {
            parse("./subsystem=logging:", handler);
        } catch(OperationFormatException e) {
        }

        assertTrue(handler.hasAddress());
        assertFalse(handler.hasOperationName());
        assertFalse(handler.hasProperties());
        assertTrue(handler.endsOnAddressOperationNameSeparator());
        assertFalse(handler.endsOnPropertyListStart());
        assertFalse(handler.endsOnPropertySeparator());
        assertFalse(handler.endsOnPropertyValueSeparator());
        assertFalse(handler.endsOnNodeSeparator());
        assertFalse(handler.endsOnNodeTypeNameSeparator());
        assertFalse(handler.isRequestComplete());

        OperationRequestAddress address = handler.getAddress();
        Iterator<Node> i = address.iterator();
        assertTrue(i.hasNext());
        Node node = i.next();
        assertEquals("subsystem", node.getType());
        assertEquals("logging", node.getName());
View Full Code Here

    }

    @Test
    public void testSingleArgName() throws Exception {

        DefaultCallbackHandler cmd = parse("some-command --arg-name");
        assertEquals("some-command", cmd.getOperationName());
        assertTrue(cmd.hasProperties());
        assertNull(cmd.getOutputTarget());
        assertFalse(cmd.endsOnSeparator());
        assertFalse(cmd.endsOnPropertyListStart());
        assertFalse(cmd.endsOnPropertySeparator());
        assertFalse(cmd.endsOnPropertyValueSeparator());
        assertEquals(1, cmd.getPropertyNames().size());
        assertTrue(cmd.getOtherProperties().isEmpty());
        assertTrue(cmd.hasProperty("--arg-name"));
        assertNull(cmd.getPropertyValue("--arg-name"));
        assertEquals(13, cmd.getLastChunkIndex());
    }
View Full Code Here

    }

    @Test
    public void testSingleArgNameAndSeparator() throws Exception {

        DefaultCallbackHandler cmd = parse("some-command --arg-name ");
        assertEquals("some-command", cmd.getOperationName());
        assertTrue(cmd.hasProperties());
        assertNull(cmd.getOutputTarget());
        assertTrue(cmd.endsOnSeparator());
        assertFalse(cmd.endsOnPropertyListStart());
        assertTrue(cmd.endsOnPropertySeparator());
        assertFalse(cmd.endsOnPropertyValueSeparator());
        assertEquals(1, cmd.getPropertyNames().size());
        assertTrue(cmd.getOtherProperties().isEmpty());
        assertTrue(cmd.hasProperty("--arg-name"));
        assertNull(cmd.getPropertyValue("--arg-name"));
        assertEquals(13, cmd.getLastChunkIndex());
    }
View Full Code Here

    }

    @Test
    public void testSingleArgNameAndValueSeparator() throws Exception {

        DefaultCallbackHandler cmd = parse("some-command --arg-name=");
        assertEquals("some-command", cmd.getOperationName());
        assertTrue(cmd.hasProperties());
        assertNull(cmd.getOutputTarget());
        assertTrue(cmd.endsOnSeparator());
        assertFalse(cmd.endsOnPropertyListStart());
        assertFalse(cmd.endsOnPropertySeparator());
        assertTrue(cmd.endsOnPropertyValueSeparator());
        assertEquals(1, cmd.getPropertyNames().size());
        assertTrue(cmd.getOtherProperties().isEmpty());
        assertTrue(cmd.hasProperty("--arg-name"));
        assertNull(cmd.getPropertyValue("--arg-name"));
        assertEquals(23, cmd.getLastChunkIndex());
    }
View Full Code Here

    protected void addRequiredPath(String requiredPath) {
        if(requiredPath == null) {
            throw new IllegalArgumentException("Required path can't be null.");
        }
        DefaultOperationRequestAddress requiredAddress = new DefaultOperationRequestAddress();
        CommandLineParser.CallbackHandler handler = new DefaultCallbackHandler(requiredAddress);
        try {
            ParserUtil.parseOperationRequest(requiredPath, handler);
        } catch (CommandFormatException e) {
            throw new IllegalArgumentException("Failed to parse nodeType: " + e.getMessage());
        }
View Full Code Here

    }

    @Test
    public void testSingleArgNameWithValue() throws Exception {

        DefaultCallbackHandler cmd = parse("some-command --arg-name=value");
        assertEquals("some-command", cmd.getOperationName());
        assertTrue(cmd.hasProperties());
        assertNull(cmd.getOutputTarget());
        assertFalse(cmd.endsOnSeparator());
        assertFalse(cmd.endsOnPropertyListStart());
        assertFalse(cmd.endsOnPropertySeparator());
        assertFalse(cmd.endsOnPropertyValueSeparator());
        assertEquals(1, cmd.getPropertyNames().size());
        assertTrue(cmd.getOtherProperties().isEmpty());
        assertTrue(cmd.hasProperty("--arg-name"));
        assertEquals("value", cmd.getPropertyValue("--arg-name"));
        assertEquals(24, cmd.getLastChunkIndex());
    }
View Full Code Here

    }

    @Test
    public void testSingleArgNameWithValueAndSeparator() throws Exception {

        DefaultCallbackHandler cmd = parse("some-command --arg-name=value ");
        assertEquals("some-command", cmd.getOperationName());
        assertTrue(cmd.hasProperties());
        assertNull(cmd.getOutputTarget());
        assertTrue(cmd.endsOnSeparator());
        assertFalse(cmd.endsOnPropertyListStart());
        assertTrue(cmd.endsOnPropertySeparator());
        assertFalse(cmd.endsOnPropertyValueSeparator());
        assertEquals(1, cmd.getPropertyNames().size());
        assertTrue(cmd.getOtherProperties().isEmpty());
        assertTrue(cmd.hasProperty("--arg-name"));
        assertEquals("value", cmd.getPropertyValue("--arg-name"));
        assertEquals(24, cmd.getLastChunkIndex());
    }
View Full Code Here

    }

    @Test
    public void testEmptyString() throws Exception {

        DefaultCallbackHandler cmd = parse("");
        assertFalse(cmd.hasOperationName());
        assertFalse(cmd.hasProperties());
        assertNull(cmd.getOutputTarget());
        assertFalse(cmd.endsOnSeparator());
        assertFalse(cmd.endsOnAddressOperationNameSeparator());
        assertFalse(cmd.endsOnPropertyListStart());
        assertFalse(cmd.endsOnPropertySeparator());
        assertFalse(cmd.endsOnPropertyValueSeparator());
        assertTrue(cmd.getPropertyNames().isEmpty());
        assertTrue(cmd.getOtherProperties().isEmpty());
        assertEquals(0, cmd.getLastChunkIndex());
    }
View Full Code Here

            }
            Collections.sort(candidates);
            return 0;
        }

        final DefaultCallbackHandler parsedCmd = (DefaultCallbackHandler) ctx.getParsedCommandLine();
        try {
            parsedCmd.parse(ctx.getCurrentNodePath(), buffer, false);
        } catch(CommandFormatException e) {
            if(!parsedCmd.endsOnAddressOperationNameSeparator() || !parsedCmd.endsOnSeparator()) {
                return -1;
            }
        }

        OperationCandidatesProvider candidatesProvider = cmdProvider;
View Full Code Here

TOP

Related Classes of org.jboss.as.cli.operation.impl.DefaultCallbackHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.