Package org.apache.sling.crankstart.api

Examples of org.apache.sling.crankstart.api.CrankstartCommandLine


        final Iterator<CrankstartCommandLine> it = parser.parse(input);
       
        assertCommand("verb", "qualifier with several words", it.next());
        assertCommand("verb2", "single_qualifier", it.next());
       
        final CrankstartCommandLine config = it.next();
        assertCommand("config", "the.pid.goes.here", config);
        final Dictionary<String, Object> props = config.getProperties();
        assertEquals("Expecting 4 properties", 4, props.size());
        assertEquals("Expecting correct foo value", "bar", props.get("foo"));
        final Object o = props.get("array");
        assertTrue("Expecting array property", o instanceof String[]);
        final String [] a = (String[])o;
View Full Code Here


        final Dictionary<String, Object> properties = new Hashtable<String, Object>();
        properties.put(Configure.CRANKSTART_CONFIG_ID, UUID.randomUUID().toString());
       
        assertEquals("Expecting no configs initially", 0, count(factoryName));
       
        final CrankstartCommandLine commandLine = new CrankstartCommandLine(verb, factoryName, properties);
        cmd.execute(ctx, commandLine);
        assertEquals("Expecting one config after first excute call", 1, count(factoryName));
        cmd.execute(ctx, commandLine);
        assertEquals("Expecting only one config after second excute call", 1, count(factoryName));
    }
View Full Code Here

        assertEquals("Expecting stop processing attribute to match", expected, actual);
    }
   
    @Test(expected=IllegalArgumentException.class)
    public void testZeroStartupNoOption() throws Exception {
        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", null), 0false);
    }
View Full Code Here

        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", null), 0false);
    }
   
    @Test
    public void testFirstStartupNoOption() throws Exception {
        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", null), 1false);
    }
View Full Code Here

        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", null), 1false);
    }
   
    @Test
    public void testFirstStartupExitOption() throws Exception {
        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", EXIT_OPT), 1false);
    }
View Full Code Here

        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", EXIT_OPT), 1false);
    }
   
    @Test
    public void testSecondStartupNoOption() throws Exception {
        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", null), 12true);
    }
View Full Code Here

        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", null), 12true);
    }
   
    @Test
    public void testSecondStartupExitOption() throws Exception {
        assertStopProcessing(new CrankstartCommandLine(StartFramework.I_START_FRAMEWORK, "", EXIT_OPT), 42false);
    }
View Full Code Here

        // by properties
        if(!isVerb()) {
            throw new ParserException("Expecting verb, current line is " + line);
        }
       
        CrankstartCommandLine result = null;
       
        try {
            // Parse verb and qualifier from first line
            final String [] firstLine= takeLine().split(" ");
            final String verb = firstLine[0];
            final StringBuilder qualifier = new StringBuilder();
            for(int i=1; i < firstLine.length; i++) {
                if(qualifier.length() > 0) {
                    qualifier.append(' ');
                }
                qualifier.append(firstLine[i]);
            }
           
            // Parse properties from optional indented lines
            // that follow verb line
            Dictionary<String, Object> props = null;
            while(line != null && !isVerb()) {
                if(props == null) {
                    props = new Hashtable<String, Object>();
                }
                addProperty(props, takeLine());
            }
            result = new CrankstartCommandLine(verb, qualifier.toString(), props);
        } catch(IOException ioe) {
            line = null;
            throw new ParserException("IOException in takeLine()", ioe);
        }
        return result;
View Full Code Here

                return result;
            }
        };
        final Iterator<CrankstartCommandLine> it = parser.parse(input);
        while(it.hasNext()) {
            final CrankstartCommandLine cmdLine = it.next();
           
            // First try the built-in commands
            // If no command found try existing extension commands
            // If no command found reload extension commands and try them again
            // If no command found fail
            if(execute(cmdLine, builtinCommands) == 0) {
                if(execute(cmdLine, extensionCommands) == 0) {
                    reloadExtensionCommands();
                    if(execute(cmdLine, extensionCommands) == 0) {
                        throw new CrankstartException(
                                "Invalid command '" + cmdLine.getVerb()
                                + "', built-in commands:" + getDescriptions(builtinCommands)
                                + ", extension commands: " + getDescriptions(extensionCommands)
                                );
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.sling.crankstart.api.CrankstartCommandLine

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.