commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian A. Egge" <briane...@yahoo.com>
Subject Re: [CLI2] Writing source code unit tests (CvsTest)
Date Wed, 01 Aug 2007 00:25:14 GMT
Hi Karl,

I think you need to add the update options to the update command as children.  I.e.,

optionBuildDirectories = obuilder.withShortName("d")
                .withDescription("Build directories, like checkout does.")
                .withId(BUILD_DIRECTORIES_ID)
                .create();
        final Command updateCommand = cbuilder
                .withName("update")
                .withName("up")
                .withName("upd")
                .withDescription("Bring work tree in sync with repository")
                .withChildren(new GroupBuilder().withOption(
                        optionBuildDirectories)
                        .create()
                )
                .create();

...

    public void testChildCommandOptions() throws OptionException {
        Parser parser = new Parser();
        parser.setGroup(options);
        CommandLine commandLine = parser.parse(new String[]{
                "-d", "\"Parameter\"", "-nq", "update", "-d"
        });

        assertTrue(commandLine.hasOption(optionBuildDirectories));
        List list = commandLine.getValues(optionCvsRoot);
        assertEquals(1, list.size());
        assertEquals("Parameter", list.get(0));
    }

The only way I could figure out how to get the correct options out of the command line object
was be explicitly specifying the option objects, and not using a string lookup.

I think there should be a get by id lookup, as you can assign numeric ids to options.

Attached is a patch to CvsTest which includes above test.

-Brian

Karl Heinz Marbaise <khmarbaise@gmx.de> wrote: Hi there,

i have begun to write some Unit Tests (CvsTest in the Source-Code) to
understand the CLI2 correctly but now i have reached a point where i
can't get out....

May be someone can give me hint:

Ok.

I would like to simulate the following command line of CVS:

cvs -d "Parameter" -nq update -d

The "-nq" global options are working, but the second "-d" seemed not to be.
Here extracted some parts of the Code to create the command and it's
options:

//Global option
optiond = new DefaultOptionBuilder()
    .withName("d")
    .withArgument(new ArgumentBuilder()
    .withName("CVS_ROOT").create())
    .create();

updateCommand = new CommandBuilder().withName("update").create();
//update Command - Options
updateOptiond = new DefaultOptionBuilder().withName("d").create();

Group updateCommandOptions = GroupBuilder()
   .withName("Update-Options")
   .withOption(optionUpdated)
   .withOption(updateCommand)
   .create();

I'm not sure if i'm doing this correct...

Kind regards
Karl Heinz Marbaise
-- 
SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise        ICQ#: 135949029
Hauptstrasse 177                         USt.IdNr: DE191347579
52146 W├╝rselen                           http://www.soebes.de

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org



Mime
View raw message