You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2008/03/22 03:49:46 UTC

svn commit: r639941 [10/17] - in /commons/proper/cli/trunk: ./ src/java/org/apache/commons/cli2/ src/java/org/apache/commons/cli2/builder/ src/java/org/apache/commons/cli2/commandline/ src/java/org/apache/commons/cli2/option/ src/java/org/apache/common...

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CpTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CpTest.java?rev=639941&r1=639940&r2=639941&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CpTest.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CpTest.java Fri Mar 21 19:49:41 2008
@@ -1,471 +1 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.cli2.application;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.commons.cli2.Argument;
-import org.apache.commons.cli2.CommandLine;
-import org.apache.commons.cli2.Group;
-import org.apache.commons.cli2.Option;
-import org.apache.commons.cli2.OptionException;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
-import org.apache.commons.cli2.builder.GroupBuilder;
-import org.apache.commons.cli2.commandline.Parser;
-import org.apache.commons.cli2.option.ArgumentImpl;
-import org.apache.commons.cli2.option.SourceDestArgument;
-import org.apache.commons.cli2.util.HelpFormatter;
-
-/**
- * <p>Test the <code>cp</code> command. Duplicated Option types are not
- * tested e.g. -a and -d are the same Option type.</p>
- * 
- * <p>The following is the man output for 'cp'. See
- * <a href="http://www.rt.com/man/cp.1.html">http://www.rt.com/man/cp.1.html</a>.</p>
- * 
- * <pre>
- *  CP(1) FSF CP(1)
- * 
- *  NAME cp - copy files and directories
- * 
- *  SYNOPSIS cp [OPTION]... SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY
- * 
- *  DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
- * 
- *  -a, --archive same as -dpR
- * 
- *  -b, --backup make backup before removal
- * 
- *  -d, --no-dereference preserve links
- * 
- *  -f, --force remove existing destinations, never prompt
- * 
- *  -i, --interactive prompt before overwrite
- * 
- *  -l, --link link files instead of copying
- * 
- *  -p, --preserve preserve file attributes if possible
- * 
- *  -P, --parents append source path to DIRECTORY
- * -r copy recursively, non-directories as files
- * 
- *  --sparse=WHEN control creation of sparse files
- * 
- *  -R, --recursive copy directories recursively
- * 
- *  -s, --symbolic-link make symbolic links instead of copying
- * 
- *  -S, --suffix=SUFFIX override the usual backup suffix
- * 
- *  -u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing
- * 
- *  -v, --verbose explain what is being done
- * 
- *  -V, --version-control=WORD override the usual version control
- * 
- *  -x, --one-file-system stay on this file system
- * 
- *  --help display this help and exit
- * 
- *  --version output version information and exit
- * 
- *  By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file when- ever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files.
- * 
- *  The backup suffix is ~, unless set with SIMPLE_BACKUP_SUF- FIX. The version control may be set with VERSION_CONTROL, values are:
- * t, numbered make numbered backups
- * 
- *  nil, existing numbered if numbered backups exist, simple other- wise
- * 
- *  never, simple always make simple backups
- * 
- *  As a special case, cp makes a backup of SOURCE when the force and backup options are given and SOURCE and DEST are the same name for an existing, regular file. * </pre>
- * </pre>
- * 
- * @author Rob Oxspring
- * @author John Keyes
- */
-public class CpTest extends TestCase {
-
-    /** Option Builder */
-    private static final DefaultOptionBuilder oBuilder =
-        new DefaultOptionBuilder();
-
-    /** Argument Builder */
-    private static final ArgumentBuilder aBuilder = new ArgumentBuilder();
-
-    /** Group Builder */
-    private static final GroupBuilder gBuilder = new GroupBuilder();
-
-    private Group options;
-
-    public static Test suite() {
-        return new TestSuite(CpTest.class);
-    }
-
-    private ArgumentImpl source;
-    private ArgumentImpl dest;
-    private Argument targets;
-
-    private Option archive;
-    private Option backup;
-    private Option noDereference;
-    private Option force;
-    private Option interactive;
-    private Option link;
-    private Option preserve;
-    private Option parents;
-    private Option recursive1;
-    private Option sparse;
-    private Option recursive2;
-    private Option symbolicLink;
-    private Option suffix;
-    private Option update;
-    private Option verbose;
-    private Option versionControl;
-    private Option oneFileSystem;
-    private Option help;
-    private Option version;
-
-    public void setUp() {
-        source =
-            (ArgumentImpl)aBuilder.withName("SOURCE").withMinimum(1).create();
-        dest =
-            (ArgumentImpl)aBuilder
-                .withName("DEST")
-                .withMinimum(1)
-                .withMaximum(1)
-                .create();
-        targets = new SourceDestArgument(source, dest);
-
-        archive =
-            oBuilder
-                .withShortName("a")
-                .withLongName("archive")
-                .withDescription("same as -dpR")
-                .create();
-
-        backup =
-            oBuilder
-                .withShortName("b")
-                .withLongName("backup")
-                .withDescription("make backup before removal")
-                .create();
-
-        noDereference =
-            oBuilder
-                .withShortName("d")
-                .withLongName("no-dereference")
-                .withDescription("preserve links")
-                .create();
-
-        force =
-            oBuilder
-                .withShortName("f")
-                .withLongName("force")
-                .withDescription("remove existing destinations, never prompt")
-                .create();
-
-        interactive =
-            oBuilder
-                .withShortName("i")
-                .withLongName("interactive")
-                .withDescription("prompt before overwrite")
-                .create();
-
-        link =
-            oBuilder
-                .withShortName("l")
-                .withLongName("link")
-                .withDescription("link files instead of copying")
-                .create();
-
-        preserve =
-            oBuilder
-                .withShortName("p")
-                .withLongName("preserve")
-                .withDescription("preserve file attributes if possible")
-                .create();
-
-        parents =
-            oBuilder
-                .withShortName("P")
-                .withLongName("parents")
-                .withDescription("append source path to DIRECTORY")
-                .create();
-
-        recursive1 =
-            oBuilder
-                .withShortName("r")
-                .withDescription("copy recursively, non-directories as files")
-                .create();
-
-        sparse =
-            oBuilder
-                .withLongName("sparse")
-                .withDescription("control creation of sparse files")
-                .withArgument(
-                    aBuilder
-                        .withName("WHEN")
-                        .withMinimum(1)
-                        .withMaximum(1)
-                        .withInitialSeparator('=')
-                        .create())
-                .create();
-
-        recursive2 =
-            oBuilder
-                .withShortName("R")
-                .withLongName("recursive")
-                .withDescription("copy directories recursively")
-                .create();
-
-        symbolicLink =
-            oBuilder
-                .withShortName("s")
-                .withLongName("symbolic-link")
-                .withDescription("make symbolic links instead of copying")
-                .create();
-
-        suffix =
-            oBuilder
-                .withShortName("S")
-                .withLongName("suffix")
-                .withDescription("override the usual backup suffix")
-                .withArgument(
-                    aBuilder
-                        .withName("SUFFIX")
-                        .withMinimum(1)
-                        .withMaximum(1)
-                        .create())
-                .create();
-
-        update =
-            oBuilder
-                .withShortName("u")
-                .withLongName("update")
-                .withDescription("copy only when the SOURCE file is newer than the destination file or when the destination file is missing")
-                .create();
-
-        verbose =
-            oBuilder
-                .withShortName("v")
-                .withLongName("verbose")
-                .withDescription("explain what is being done")
-                .create();
-
-        versionControl =
-            oBuilder
-                .withShortName("V")
-                .withLongName("version-contol")
-                .withDescription("explain what is being done")
-                .withArgument(
-                    aBuilder
-                        .withName("WORD")
-                        .withInitialSeparator('=')
-                        .withMinimum(1)
-                        .withMaximum(1)
-                        .create())
-                .create();
-
-        oneFileSystem =
-            oBuilder
-                .withShortName("x")
-                .withLongName("one-file-system")
-                .withDescription("stay on this file system")
-                .create();
-
-        help =
-            oBuilder
-                .withLongName("help")
-                .withDescription("display this help and exit")
-                .create();
-
-        version =
-            oBuilder
-                .withLongName("version")
-                .withDescription("output version information and exit")
-                .create();
-
-        options =
-            gBuilder
-                .withOption(archive)
-                .withOption(backup)
-                .withOption(noDereference)
-                .withOption(force)
-                .withOption(interactive)
-                .withOption(link)
-                .withOption(preserve)
-                .withOption(parents)
-                .withOption(recursive1)
-                .withOption(sparse)
-                .withOption(recursive2)
-                .withOption(symbolicLink)
-                .withOption(suffix)
-                .withOption(update)
-                .withOption(verbose)
-                .withOption(versionControl)
-                .withOption(oneFileSystem)
-                .withOption(help)
-                .withOption(version)
-                .withOption(targets)
-                .withName("OPTIONS")
-                .create();
-    }
-
-    public void testNoSource() {
-        Parser parser = new Parser();
-        parser.setGroup(options);
-        try {
-            parser.parse(new String[0]);
-        }
-        catch (OptionException mve) {
-            assertEquals(
-                "Missing value(s) SOURCE [SOURCE ...]",
-                mve.getMessage());
-        }
-    }
-
-    public void testOneSource() throws OptionException {
-        final String[] args = new String[] { "source1", "dest1" };
-        final Parser parser = new Parser();
-        parser.setGroup(options);
-        final CommandLine commandLine = parser.parse(args);
-
-        assertTrue(commandLine.getValues(source).contains("source1"));
-        assertEquals(1, commandLine.getValues(source).size());
-        assertTrue(commandLine.getValues(dest).contains("dest1"));
-        assertEquals(1, commandLine.getValues(dest).size());
-    }
-
-    public void testMultiSource() throws OptionException {
-        final String[] args =
-            new String[] { "source1", "source2", "source3", "dest1" };
-        final Parser parser = new Parser();
-        parser.setGroup(options);
-        final CommandLine commandLine = parser.parse(args);
-
-        assertTrue(commandLine.getValues(source).contains("source1"));
-        assertTrue(commandLine.getValues(source).contains("source2"));
-        assertTrue(commandLine.getValues(source).contains("source3"));
-        assertEquals(3, commandLine.getValues(source).size());
-
-        assertTrue(commandLine.getValues(dest).contains("dest1"));
-        assertEquals(1, commandLine.getValues(dest).size());
-    }
-
-    public void testHelp() throws IOException {
-        final StringWriter out = new StringWriter();
-        final HelpFormatter helpFormatter = new HelpFormatter();
-        helpFormatter.setGroup(options);
-        helpFormatter.setPrintWriter(new PrintWriter(out));
-        helpFormatter.print();
-
-        final BufferedReader in =
-            new BufferedReader(new StringReader(out.toString()));
-        assertEquals(
-            "Usage:                                                                          ",
-            in.readLine());
-        assertEquals(
-            " [-a -b -d -f -i -l -p -P -r --sparse <WHEN> -R -s -S <SUFFIX> -u -v -V <WORD>  ",
-            in.readLine());
-        assertEquals(
-            "-x --help --version] <SOURCE1> [<SOURCE2> ...] <DEST>                           ",
-            in.readLine());
-        assertEquals(
-            "OPTIONS                                                                         ",
-            in.readLine());
-        assertEquals(
-            "  -a (--archive)                same as -dpR                                    ",
-            in.readLine());
-        assertEquals(
-            "  -b (--backup)                 make backup before removal                      ",
-            in.readLine());
-        assertEquals(
-            "  -d (--no-dereference)         preserve links                                  ",
-            in.readLine());
-        assertEquals(
-            "  -f (--force)                  remove existing destinations, never prompt      ",
-            in.readLine());
-        assertEquals(
-            "  -i (--interactive)            prompt before overwrite                         ",
-            in.readLine());
-        assertEquals(
-            "  -l (--link)                   link files instead of copying                   ",
-            in.readLine());
-        assertEquals(
-            "  -p (--preserve)               preserve file attributes if possible            ",
-            in.readLine());
-        assertEquals(
-            "  -P (--parents)                append source path to DIRECTORY                 ",
-            in.readLine());
-        assertEquals(
-            "  -r                            copy recursively, non-directories as files      ",
-            in.readLine());
-        assertEquals(
-            "  --sparse WHEN                 control creation of sparse files                ",
-            in.readLine());
-        assertEquals(
-            "  -R (--recursive)              copy directories recursively                    ",
-            in.readLine());
-        assertEquals(
-            "  -s (--symbolic-link)          make symbolic links instead of copying          ",
-            in.readLine());
-        assertEquals(
-            "  -S (--suffix) SUFFIX          override the usual backup suffix                ",
-            in.readLine());
-        assertEquals(
-            "  -u (--update)                 copy only when the SOURCE file is newer than    ",
-            in.readLine());
-        assertEquals(
-            "                                the destination file or when the destination    ",
-            in.readLine());
-        assertEquals(
-            "                                file is missing                                 ",
-            in.readLine());
-        assertEquals(
-            "  -v (--verbose)                explain what is being done                      ",
-            in.readLine());
-        assertEquals(
-            "  -V (--version-contol) WORD    explain what is being done                      ",
-            in.readLine());
-        assertEquals(
-            "  -x (--one-file-system)        stay on this file system                        ",
-            in.readLine());
-        assertEquals(
-            "  --help                        display this help and exit                      ",
-            in.readLine());
-        assertEquals(
-            "  --version                     output version information and exit             ",
-            in.readLine());
-        assertEquals(
-            "  SOURCE [SOURCE ...]                                                           ",
-            in.readLine());
-        assertEquals(
-            "  DEST                                                                          ",
-            in.readLine());
-        assertNull(in.readLine());
-    }
-}
+/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2.application;import java.io.BufferedReader;import java.io.IOException;import java.io.PrintWriter;import java.io.StringReader;import java.io.StringWriter;import junit.frame
 work.Test;import junit.framework.TestCase;import junit.framework.TestSuite;import org.apache.commons.cli2.Argument;import org.apache.commons.cli2.CommandLine;import org.apache.commons.cli2.Group;import org.apache.commons.cli2.Option;import org.apache.commons.cli2.OptionException;import org.apache.commons.cli2.builder.ArgumentBuilder;import org.apache.commons.cli2.builder.DefaultOptionBuilder;import org.apache.commons.cli2.builder.GroupBuilder;import org.apache.commons.cli2.commandline.Parser;import org.apache.commons.cli2.option.ArgumentImpl;import org.apache.commons.cli2.option.SourceDestArgument;import org.apache.commons.cli2.util.HelpFormatter;/** * <p>Test the <code>cp</code> command. Duplicated Option types are not * tested e.g. -a and -d are the same Option type.</p> * * <p>The following is the man output for 'cp'. See * <a href="http://www.rt.com/man/cp.1.html">http://www.rt.com/man/cp.1.html</a>.</p> * * <pre> *  CP(1) FSF CP(1) * *  NAME cp - copy files and director
 ies * *  SYNOPSIS cp [OPTION]... SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY * *  DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. * *  -a, --archive same as -dpR * *  -b, --backup make backup before removal * *  -d, --no-dereference preserve links * *  -f, --force remove existing destinations, never prompt * *  -i, --interactive prompt before overwrite * *  -l, --link link files instead of copying * *  -p, --preserve preserve file attributes if possible * *  -P, --parents append source path to DIRECTORY * -r copy recursively, non-directories as files * *  --sparse=WHEN control creation of sparse files * *  -R, --recursive copy directories recursively * *  -s, --symbolic-link make symbolic links instead of copying * *  -S, --suffix=SUFFIX override the usual backup suffix * *  -u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing * *  -v, --verbose explain what is being done * *  -V, --ver
 sion-control=WORD override the usual version control * *  -x, --one-file-system stay on this file system * *  --help display this help and exit * *  --version output version information and exit * *  By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file when- ever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. * *  The backup suffix is ~, unless set with SIMPLE_BACKUP_SUF- FIX. The version control may be set with VERSION_CONTROL, values are: * t, numbered make numbered backups * *  nil, existing numbered if numbered backups exist, simple other- wise * *  never, simple always make simple backups * *  As a special case, cp makes a backup of SOURCE when the force and backup options are given and SOURCE and DEST are the same name for an exist
 ing, regular file. * </pre> * </pre> * * @author Rob Oxspring * @author John Keyes */public class CpTest extends TestCase {    /** Option Builder */    private static final DefaultOptionBuilder oBuilder =        new DefaultOptionBuilder();    /** Argument Builder */    private static final ArgumentBuilder aBuilder = new ArgumentBuilder();    /** Group Builder */    private static final GroupBuilder gBuilder = new GroupBuilder();    private Group options;    public static Test suite() {        return new TestSuite(CpTest.class);    }    private ArgumentImpl source;    private ArgumentImpl dest;    private Argument targets;    private Option archive;    private Option backup;    private Option noDereference;    private Option force;    private Option interactive;    private Option link;    private Option preserve;    private Option parents;    private Option recursive1;    private Option sparse;    private Option recursive2;    private Option symbolicLink;    private Option su
 ffix;    private Option update;    private Option verbose;    private Option versionControl;    private Option oneFileSystem;    private Option help;    private Option version;    public void setUp() {        source =            (ArgumentImpl)aBuilder.withName("SOURCE").withMinimum(1).create();        dest =            (ArgumentImpl)aBuilder                .withName("DEST")                .withMinimum(1)                .withMaximum(1)                .create();        targets = new SourceDestArgument(source, dest);        archive =            oBuilder                .withShortName("a")                .withLongName("archive")                .withDescription("same as -dpR")                .create();        backup =            oBuilder                .withShortName("b")                .withLongName("backup")                .withDescription("make backup before removal")                .create();        noDereference =            oBuilder                .withShortName("d")        
         .withLongName("no-dereference")                .withDescription("preserve links")                .create();        force =            oBuilder                .withShortName("f")                .withLongName("force")                .withDescription("remove existing destinations, never prompt")                .create();        interactive =            oBuilder                .withShortName("i")                .withLongName("interactive")                .withDescription("prompt before overwrite")                .create();        link =            oBuilder                .withShortName("l")                .withLongName("link")                .withDescription("link files instead of copying")                .create();        preserve =            oBuilder                .withShortName("p")                .withLongName("preserve")                .withDescription("preserve file attributes if possible")                .create();        parents =            oBuilder           
      .withShortName("P")                .withLongName("parents")                .withDescription("append source path to DIRECTORY")                .create();        recursive1 =            oBuilder                .withShortName("r")                .withDescription("copy recursively, non-directories as files")                .create();        sparse =            oBuilder                .withLongName("sparse")                .withDescription("control creation of sparse files")                .withArgument(                    aBuilder                        .withName("WHEN")                        .withMinimum(1)                        .withMaximum(1)                        .withInitialSeparator('=')                        .create())                .create();        recursive2 =            oBuilder                .withShortName("R")                .withLongName("recursive")                .withDescription("copy directories recursively")                .create();        symbolic
 Link =            oBuilder                .withShortName("s")                .withLongName("symbolic-link")                .withDescription("make symbolic links instead of copying")                .create();        suffix =            oBuilder                .withShortName("S")                .withLongName("suffix")                .withDescription("override the usual backup suffix")                .withArgument(                    aBuilder                        .withName("SUFFIX")                        .withMinimum(1)                        .withMaximum(1)                        .create())                .create();        update =            oBuilder                .withShortName("u")                .withLongName("update")                .withDescription("copy only when the SOURCE file is newer than the destination file or when the destination file is missing")                .create();        verbose =            oBuilder                .withShortName("v")                
 .withLongName("verbose")                .withDescription("explain what is being done")                .create();        versionControl =            oBuilder                .withShortName("V")                .withLongName("version-contol")                .withDescription("explain what is being done")                .withArgument(                    aBuilder                        .withName("WORD")                        .withInitialSeparator('=')                        .withMinimum(1)                        .withMaximum(1)                        .create())                .create();        oneFileSystem =            oBuilder                .withShortName("x")                .withLongName("one-file-system")                .withDescription("stay on this file system")                .create();        help =            oBuilder                .withLongName("help")                .withDescription("display this help and exit")                .create();        version =            oB
 uilder                .withLongName("version")                .withDescription("output version information and exit")                .create();        options =            gBuilder                .withOption(archive)                .withOption(backup)                .withOption(noDereference)                .withOption(force)                .withOption(interactive)                .withOption(link)                .withOption(preserve)                .withOption(parents)                .withOption(recursive1)                .withOption(sparse)                .withOption(recursive2)                .withOption(symbolicLink)                .withOption(suffix)                .withOption(update)                .withOption(verbose)                .withOption(versionControl)                .withOption(oneFileSystem)                .withOption(help)                .withOption(version)                .withOption(targets)                .withName("OPTIONS")                .create();    
 }    public void testNoSource() {        Parser parser = new Parser();        parser.setGroup(options);        try {            parser.parse(new String[0]);        }        catch (OptionException mve) {            assertEquals(                "Missing value(s) SOURCE [SOURCE ...]",                mve.getMessage());        }    }    public void testOneSource() throws OptionException {        final String[] args = new String[] { "source1", "dest1" };        final Parser parser = new Parser();        parser.setGroup(options);        final CommandLine commandLine = parser.parse(args);        assertTrue(commandLine.getValues(source).contains("source1"));        assertEquals(1, commandLine.getValues(source).size());        assertTrue(commandLine.getValues(dest).contains("dest1"));        assertEquals(1, commandLine.getValues(dest).size());    }    public void testMultiSource() throws OptionException {        final String[] args =            new String[] { "source1", "source2", "so
 urce3", "dest1" };        final Parser parser = new Parser();        parser.setGroup(options);        final CommandLine commandLine = parser.parse(args);        assertTrue(commandLine.getValues(source).contains("source1"));        assertTrue(commandLine.getValues(source).contains("source2"));        assertTrue(commandLine.getValues(source).contains("source3"));        assertEquals(3, commandLine.getValues(source).size());        assertTrue(commandLine.getValues(dest).contains("dest1"));        assertEquals(1, commandLine.getValues(dest).size());    }    public void testHelp() throws IOException {        final StringWriter out = new StringWriter();        final HelpFormatter helpFormatter = new HelpFormatter();        helpFormatter.setGroup(options);        helpFormatter.setPrintWriter(new PrintWriter(out));        helpFormatter.print();        final BufferedReader in =            new BufferedReader(new StringReader(out.toString()));        assertEquals(            "Usage:   
                                                                        ",            in.readLine());        assertEquals(            " [-a -b -d -f -i -l -p -P -r --sparse <WHEN> -R -s -S <SUFFIX> -u -v -V <WORD>  ",            in.readLine());        assertEquals(            "-x --help --version] <SOURCE1> [<SOURCE2> ...] <DEST>                           ",            in.readLine());        assertEquals(            "OPTIONS                                                                         ",            in.readLine());        assertEquals(            "  -a (--archive)                same as -dpR                                    ",            in.readLine());        assertEquals(            "  -b (--backup)                 make backup before removal                      ",            in.readLine());        assertEquals(            "  -d (--no-dereference)         preserve links                                  ",            in.readLine());        assertEquals(          
   "  -f (--force)                  remove existing destinations, never prompt      ",            in.readLine());        assertEquals(            "  -i (--interactive)            prompt before overwrite                         ",            in.readLine());        assertEquals(            "  -l (--link)                   link files instead of copying                   ",            in.readLine());        assertEquals(            "  -p (--preserve)               preserve file attributes if possible            ",            in.readLine());        assertEquals(            "  -P (--parents)                append source path to DIRECTORY                 ",            in.readLine());        assertEquals(            "  -r                            copy recursively, non-directories as files      ",            in.readLine());        assertEquals(            "  --sparse WHEN                 control creation of sparse files                ",            in.readLine());        assertEqual
 s(            "  -R (--recursive)              copy directories recursively                    ",            in.readLine());        assertEquals(            "  -s (--symbolic-link)          make symbolic links instead of copying          ",            in.readLine());        assertEquals(            "  -S (--suffix) SUFFIX          override the usual backup suffix                ",            in.readLine());        assertEquals(            "  -u (--update)                 copy only when the SOURCE file is newer than    ",            in.readLine());        assertEquals(            "                                the destination file or when the destination    ",            in.readLine());        assertEquals(            "                                file is missing                                 ",            in.readLine());        assertEquals(            "  -v (--verbose)                explain what is being done                      ",            in.readLine());       
  assertEquals(            "  -V (--version-contol) WORD    explain what is being done                      ",            in.readLine());        assertEquals(            "  -x (--one-file-system)        stay on this file system                        ",            in.readLine());        assertEquals(            "  --help                        display this help and exit                      ",            in.readLine());        assertEquals(            "  --version                     output version information and exit             ",            in.readLine());        assertEquals(            "  SOURCE [SOURCE ...]                                                           ",            in.readLine());        assertEquals(            "  DEST                                                                          ",            in.readLine());        assertNull(in.readLine());    }}
\ No newline at end of file

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CvsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CvsTest.java?rev=639941&r1=639940&r2=639941&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CvsTest.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/CvsTest.java Fri Mar 21 19:49:41 2008
@@ -1,312 +1 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.cli2.application;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.cli2.Group;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.CommandBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
-import org.apache.commons.cli2.builder.GroupBuilder;
-import org.apache.commons.cli2.option.ArgumentTest;
-
-//TODO Build up CvsTest like CpTest
-public class CvsTest extends TestCase {
-    public void testCVS() {
-        final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
-        final ArgumentBuilder abuilder = new ArgumentBuilder();
-        final CommandBuilder cbuilder = new CommandBuilder();
-        final GroupBuilder gbuilder = new GroupBuilder();
-
-        final Group commands =
-            gbuilder
-                .withName("commands")
-                .withOption(
-                    cbuilder
-                        .withName("add")
-                        .withName("ad")
-                        .withName("new")
-                        .withDescription("Add a new file/directory to the repository")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("admin")
-                        .withName("adm")
-                        .withName("rcs")
-                        .withDescription("Administration front end for rcs")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("annotate")
-                        .withName("ann")
-                        .withDescription("Show last revision where each line was modified")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("checkout")
-                        .withName("co")
-                        .withName("get")
-                        .withDescription("Checkout sources for editing")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("commit")
-                        .withName("ci")
-                        .withName("com")
-                        .withDescription("Check files into the repository")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("diff")
-                        .withName("di")
-                        .withName("dif")
-                        .withDescription("Show differences between revisions")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("edit")
-                        .withDescription("Get ready to edit a watched file")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("editors")
-                        .withDescription("See who is editing a watched file")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("export")
-                        .withName("exp")
-                        .withName("ex")
-                        .withDescription("Export sources from CVS, similar to checkout")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("history")
-                        .withName("hi")
-                        .withName("his")
-                        .withDescription("Show repository access history")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("import")
-                        .withName("im")
-                        .withName("imp")
-                        .withDescription("Import sources into CVS, using vendor branches")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("init")
-                        .withDescription("Create a CVS repository if it doesn't exist")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("log")
-                        .withName("lo")
-                        .withName("rlog")
-                        .withDescription("Print out history information for files")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("login")
-                        .withName("logon")
-                        .withName("lgn")
-                        .withDescription("Prompt for password for authenticating server")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("logout")
-                        .withDescription("Removes entry in .cvspass for remote repository")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("rdiff")
-                        .withName("patch")
-                        .withName("pa")
-                        .withDescription("Create 'patch' format diffs between releases")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("release")
-                        .withName("re")
-                        .withName("rel")
-                        .withDescription("Indicate that a Module is no longer in use")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("remove")
-                        .withName("rm")
-                        .withName("delete")
-                        .withDescription("Remove an entry from the repository")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("rtag")
-                        .withName("rt")
-                        .withName("rfreeze")
-                        .withDescription("Add a symbolic tag to a module")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("status")
-                        .withName("st")
-                        .withName("stat")
-                        .withDescription("Display status information on checked out files")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("tag")
-                        .withName("ta")
-                        .withName("freeze")
-                        .withDescription("Add a symbolic tag to checked out version of files")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("unedit")
-                        .withDescription("Undo an edit command")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("update")
-                        .withName("up")
-                        .withName("upd")
-                        .withDescription("Bring work tree in sync with repository")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("watch")
-                        .withDescription("Set watches")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("watchers")
-                        .withDescription("See who is watching a file")
-                        .create())
-                .withOption(
-                    cbuilder
-                        .withName("version")
-                        .withName("ve")
-                        .withName("ver")
-                        .withDescription("????")
-                        .create())
-                .withOption(ArgumentTest.buildTargetsArgument())
-                .create();
-
-        final Group cvsOptions =
-            new GroupBuilder()
-                .withName("cvs-options")
-                .withOption(
-                    obuilder
-                        .withShortName("H")
-                        .withDescription("Displays usage information for command.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("Q")
-                        .withDescription("Cause CVS to be really quiet.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("q")
-                        .withDescription("Cause CVS to be somewhat quiet.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("r")
-                        .withDescription("Make checked-out files read-only.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("w")
-                        .withDescription("Make checked-out files read-write (default).")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("l")
-                        .withDescription("Turn history logging off.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("n")
-                        .withDescription("Do not execute anything that will change the disk.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("t")
-                        .withDescription("Show trace of program execution -- try with -n.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("v")
-                        .withDescription("CVS version and copyright.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withLongName("crlf")
-                        .withDescription("Use the Dos line feed for text files (default).")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withLongName("lf")
-                        .withDescription("Use the Unix line feed for text files.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("T")
-                        .withDescription("Use 'tmpdir' for temporary files.")
-                        .withArgument(abuilder.withName("tmpdir").create())
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("e")
-                        .withDescription("Use 'editor' for editing log information.")
-                        .withArgument(abuilder.withName("editor").create())
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("d")
-                        .withDescription("Overrides $CVSROOT as the root of the CVS tree.")
-                        .withArgument(abuilder.withName("CVS_root").create())
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("f")
-                        .withDescription("Do not use the ~/.cvsrc file.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("z")
-                        .withDescription("Use compression level '#' for net traffic.")
-                        .withArgument(abuilder.withName("#").create())
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("a")
-                        .withDescription("Authenticate all net traffic.")
-                        .create())
-                .withOption(
-                    obuilder
-                        .withShortName("s")
-                        .withDescription("Set CVS user variable.")
-                        .withArgument(abuilder.withName("VAR=VAL").create())
-                        .create())
-                .withOption(commands)
-                .create();
-
-        assertNotNull(cvsOptions);
-    }
-}
+/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2.application;import junit.framework.TestCase;import org.apache.commons.cli2.Group;import org.apache.commons.cli2.builder.ArgumentBuilder;import org.apache.commons.cli2.bui
 lder.CommandBuilder;import org.apache.commons.cli2.builder.DefaultOptionBuilder;import org.apache.commons.cli2.builder.GroupBuilder;import org.apache.commons.cli2.option.ArgumentTest;//TODO Build up CvsTest like CpTestpublic class CvsTest extends TestCase {    public void testCVS() {        final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();        final ArgumentBuilder abuilder = new ArgumentBuilder();        final CommandBuilder cbuilder = new CommandBuilder();        final GroupBuilder gbuilder = new GroupBuilder();        final Group commands =            gbuilder                .withName("commands")                .withOption(                    cbuilder                        .withName("add")                        .withName("ad")                        .withName("new")                        .withDescription("Add a new file/directory to the repository")                        .create())                .withOption(                    cbuilder             
            .withName("admin")                        .withName("adm")                        .withName("rcs")                        .withDescription("Administration front end for rcs")                        .create())                .withOption(                    cbuilder                        .withName("annotate")                        .withName("ann")                        .withDescription("Show last revision where each line was modified")                        .create())                .withOption(                    cbuilder                        .withName("checkout")                        .withName("co")                        .withName("get")                        .withDescription("Checkout sources for editing")                        .create())                .withOption(                    cbuilder                        .withName("commit")                        .withName("ci")                        .withName("com")                        .withDescription
 ("Check files into the repository")                        .create())                .withOption(                    cbuilder                        .withName("diff")                        .withName("di")                        .withName("dif")                        .withDescription("Show differences between revisions")                        .create())                .withOption(                    cbuilder                        .withName("edit")                        .withDescription("Get ready to edit a watched file")                        .create())                .withOption(                    cbuilder                        .withName("editors")                        .withDescription("See who is editing a watched file")                        .create())                .withOption(                    cbuilder                        .withName("export")                        .withName("exp")                        .withName("ex")                        .withDescrip
 tion("Export sources from CVS, similar to checkout")                        .create())                .withOption(                    cbuilder                        .withName("history")                        .withName("hi")                        .withName("his")                        .withDescription("Show repository access history")                        .create())                .withOption(                    cbuilder                        .withName("import")                        .withName("im")                        .withName("imp")                        .withDescription("Import sources into CVS, using vendor branches")                        .create())                .withOption(                    cbuilder                        .withName("init")                        .withDescription("Create a CVS repository if it doesn't exist")                        .create())                .withOption(                    cbuilder                        .withName("log")
                         .withName("lo")                        .withName("rlog")                        .withDescription("Print out history information for files")                        .create())                .withOption(                    cbuilder                        .withName("login")                        .withName("logon")                        .withName("lgn")                        .withDescription("Prompt for password for authenticating server")                        .create())                .withOption(                    cbuilder                        .withName("logout")                        .withDescription("Removes entry in .cvspass for remote repository")                        .create())                .withOption(                    cbuilder                        .withName("rdiff")                        .withName("patch")                        .withName("pa")                        .withDescription("Create 'patch' format diffs between releases
 ")                        .create())                .withOption(                    cbuilder                        .withName("release")                        .withName("re")                        .withName("rel")                        .withDescription("Indicate that a Module is no longer in use")                        .create())                .withOption(                    cbuilder                        .withName("remove")                        .withName("rm")                        .withName("delete")                        .withDescription("Remove an entry from the repository")                        .create())                .withOption(                    cbuilder                        .withName("rtag")                        .withName("rt")                        .withName("rfreeze")                        .withDescription("Add a symbolic tag to a module")                        .create())                .withOption(                    cbuilder                
         .withName("status")                        .withName("st")                        .withName("stat")                        .withDescription("Display status information on checked out files")                        .create())                .withOption(                    cbuilder                        .withName("tag")                        .withName("ta")                        .withName("freeze")                        .withDescription("Add a symbolic tag to checked out version of files")                        .create())                .withOption(                    cbuilder                        .withName("unedit")                        .withDescription("Undo an edit command")                        .create())                .withOption(                    cbuilder                        .withName("update")                        .withName("up")                        .withName("upd")                        .withDescription("Bring work tree in sync with repos
 itory")                        .create())                .withOption(                    cbuilder                        .withName("watch")                        .withDescription("Set watches")                        .create())                .withOption(                    cbuilder                        .withName("watchers")                        .withDescription("See who is watching a file")                        .create())                .withOption(                    cbuilder                        .withName("version")                        .withName("ve")                        .withName("ver")                        .withDescription("????")                        .create())                .withOption(ArgumentTest.buildTargetsArgument())                .create();        final Group cvsOptions =            new GroupBuilder()                .withName("cvs-options")                .withOption(                    obuilder                        .withShortName("H")    
                     .withDescription("Displays usage information for command.")                        .create())                .withOption(                    obuilder                        .withShortName("Q")                        .withDescription("Cause CVS to be really quiet.")                        .create())                .withOption(                    obuilder                        .withShortName("q")                        .withDescription("Cause CVS to be somewhat quiet.")                        .create())                .withOption(                    obuilder                        .withShortName("r")                        .withDescription("Make checked-out files read-only.")                        .create())                .withOption(                    obuilder                        .withShortName("w")                        .withDescription("Make checked-out files read-write (default).")                        .create())                .withOption(   
                  obuilder                        .withShortName("l")                        .withDescription("Turn history logging off.")                        .create())                .withOption(                    obuilder                        .withShortName("n")                        .withDescription("Do not execute anything that will change the disk.")                        .create())                .withOption(                    obuilder                        .withShortName("t")                        .withDescription("Show trace of program execution -- try with -n.")                        .create())                .withOption(                    obuilder                        .withShortName("v")                        .withDescription("CVS version and copyright.")                        .create())                .withOption(                    obuilder                        .withLongName("crlf")                        .withDescription("Use the Dos line feed
  for text files (default).")                        .create())                .withOption(                    obuilder                        .withLongName("lf")                        .withDescription("Use the Unix line feed for text files.")                        .create())                .withOption(                    obuilder                        .withShortName("T")                        .withDescription("Use 'tmpdir' for temporary files.")                        .withArgument(abuilder.withName("tmpdir").create())                        .create())                .withOption(                    obuilder                        .withShortName("e")                        .withDescription("Use 'editor' for editing log information.")                        .withArgument(abuilder.withName("editor").create())                        .create())                .withOption(                    obuilder                        .withShortName("d")                        .withDescri
 ption("Overrides $CVSROOT as the root of the CVS tree.")                        .withArgument(abuilder.withName("CVS_root").create())                        .create())                .withOption(                    obuilder                        .withShortName("f")                        .withDescription("Do not use the ~/.cvsrc file.")                        .create())                .withOption(                    obuilder                        .withShortName("z")                        .withDescription("Use compression level '#' for net traffic.")                        .withArgument(abuilder.withName("#").create())                        .create())                .withOption(                    obuilder                        .withShortName("a")                        .withDescription("Authenticate all net traffic.")                        .create())                .withOption(                    obuilder                        .withShortName("s")                      
   .withDescription("Set CVS user variable.")                        .withArgument(abuilder.withName("VAR=VAL").create())                        .create())                .withOption(commands)                .create();        assertNotNull(cvsOptions);    }}
\ No newline at end of file

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/LsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/LsTest.java?rev=639941&r1=639940&r2=639941&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/LsTest.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/application/LsTest.java Fri Mar 21 19:49:41 2008
@@ -1,224 +1 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.cli2.application;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.commons.cli2.CommandLine;
-import org.apache.commons.cli2.Group;
-import org.apache.commons.cli2.Option;
-import org.apache.commons.cli2.OptionException;
-import org.apache.commons.cli2.builder.ArgumentBuilder;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
-import org.apache.commons.cli2.builder.GroupBuilder;
-import org.apache.commons.cli2.commandline.Parser;
-import org.apache.commons.cli2.validation.EnumValidator;
-
-/**
- * <p>Test the <code>ls</code> command. Duplicated Option types are not
- * tested e.g. -a and -d are the same Option type.</p>
- * 
- * <p>The following is the man output for 'ls'. See
- * <a href="http://www.rt.com/man/ls.1.html">http://www.rt.com/man/ls.1.html</a>.</p>
- * 
- * <pre>
- *  LS(1) FSF LS(1)
- * 
- *  NAME ls - list directory contents
- * 
- *  SYNOPSIS ls [OPTION]... [FILE]...
- * 
- *  DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuSUX nor --sort.
- * 
- *  -a, --all do not hide entries starting with .
- * 
- *  -A, --almost-all do not list implied . and ..
- * 
- *  -b, --escape print octal escapes for nongraphic characters
- * 
- *  --block-size=SIZE use SIZE-byte blocks
- * 
- *  -B, --ignore-backups do not list implied entries ending with ~ -c sort by change time; with -l: show ctime -C list entries by columns
- * 
- *  --color[=WHEN] control whether color is used to distinguish file types. WHEN may be `never', `always', or `auto'
- * 
- *  -d, --directory list directory entries instead of contents
- * 
- *  -D, --dired generate output designed for Emacs' dired mode -f do not sort, enable -aU, disable -lst
- * 
- *  -F, --classify append indicator (one of /=@|*) to entries
- * 
- *  --format=WORD across -x, commas -m, horizontal -x, long -l, sin- gle-column -1, verbose -l, vertical -C
- * 
- *  --full-time list both full date and full time -g (ignored)
- * 
- *  -G, --no-group inhibit display of group information
- * 
- *  -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
- * 
- *  -H, --si likewise, but use powers of 1000 not 1024
- * 
- *  --indicator-style=WORD append indicator with style WORD to entry names: none (default), classify (-F), file-type (-p)
- * 
- *  -i, --inode print index number of each file
- * 
- *  -I, --ignore=PATTERN do not list implied entries matching shell PATTERN
- * 
- *  -k, --kilobytes like --block-size=1024 -l use a long listing format
- * 
- *  -L, --dereference list entries pointed to by symbolic links -m fill width with a comma separated list of entries
- * 
- *  -n, --numeric-uid-gid list numeric UIDs and GIDs instead of names
- * 
- *  -N, --literal print raw entry names (don't treat e.g. control characters specially) -o use long listing format without group info
- * 
- *  -p, --file-type append indicator (one of /=@|) to entries
- * 
- *  -q, --hide-control-chars print ? instead of non graphic characters
- * 
- *  --show-control-chars show non graphic characters as-is (default)
- * 
- *  -Q, --quote-name enclose entry names in double quotes
- * 
- *  --quoting-style=WORD use quoting style WORD for entry names: literal, shell, shell-always, c, escape
- * 
- *  -r, --reverse reverse order while sorting
- * 
- *  -R, --recursive list subdirectories recursively
- * 
- *  -s, --size print size of each file, in blocks -S sort by file size
- * 
- *  --sort=WORD extension -X, none -U, size -S, time -t, version -v status -c, time -t, atime -u, access -u, use -u
- * 
- *  --time=WORD show time as WORD instead of modification time: atime, access, use, ctime or status; use specified time as sort key if --sort=time -t sort by modification time
- * 
- *  -T, --tabsize=COLS assume tab stops at each COLS instead of 8 -u sort by last access time; with -l: show atime -U do not sort; list entries in directory order -v sort by version
- * 
- *  -w, --width=COLS assume screen width instead of current value -x list entries by lines instead of by columns -X sort alphabetically by entry extension -1 list one file per line
- * 
- *  --help display this help and exit
- * 
- *  --version output version information and exit
- * 
- *  By default, color is not used to distinguish types of files. That is equivalent to using --color=none. Using the --color option without the optional WHEN argument is equivalent to using --color=always. With --color=auto, color codes are output only if standard output is con- nected to a terminal (tty).
- * </pre>
- * 
- * @author Rob Oxspring
- * @author John Keyes
- */
-public class LsTest extends TestCase {
-
-    /** Option Builder */
-    private static final DefaultOptionBuilder oBuilder =
-        new DefaultOptionBuilder();
-
-    /** Argument Builder */
-    private static final ArgumentBuilder aBuilder = new ArgumentBuilder();
-
-    /** Group Builder */
-    private static final GroupBuilder gBuilder = new GroupBuilder();
-
-    private static Group options;
-
-    public static Test suite() {
-        return new TestSuite(LsTest.class);
-    }
-
-    /**
-     * Required ctor.
-     * 
-     * @param name
-     *            the name of the TestCase
-     */
-    public LsTest(final String name) {
-        super(name);
-    }
-
-    public void setUp() {
-        if (LsTest.options == null) {
-            final Option a =
-                oBuilder
-                    .withShortName("a")
-                    .withLongName("all")
-                    .withDescription("do not hide entries starting with .")
-                    .create();
-
-            final Option blockSize =
-                oBuilder
-                    .withLongName("block-size")
-                    .withRequired(false)
-                    .withDescription("use SIZE-byte blocks")
-                    .withArgument(
-                        aBuilder
-                            .withMaximum(1)
-                            .withMinimum(1)
-                            .withInitialSeparator('=')
-                            .create())
-                    .create();
-
-            final Option c =
-                oBuilder
-                    .withShortName("c")
-                    .withRequired(false)
-                    .withDescription("with -lt: sort by, and show, ctime (time of last modification of file status information) with -l:show ctime and sort by name otherwise: sort by ctime")
-                    .create();
-
-            final Set colors = new HashSet();
-            colors.add("never");
-            colors.add("always");
-            colors.add("auto");
-            final Option color =
-                oBuilder
-                    .withLongName("color")
-                    .withRequired(false)
-                    .withDescription("control  whether  color is used to distinguish file types.  WHEN may be `never', `always', or `auto'")
-                    .withArgument(
-                        aBuilder
-                            .withMaximum(1)
-                            .withMinimum(1)
-                            .withInitialSeparator('=')
-                            .withValidator(new EnumValidator(colors))
-                            .create())
-                    .create();
-
-            LsTest.options =
-                gBuilder
-                    .withOption(a)
-                    .withOption(blockSize)
-                    .withOption(c)
-                    .withOption(color)
-                    .create();
-        }
-    }
-
-    public void testLs() throws OptionException {
-        // create the command line parser
-        Parser parser = new Parser();
-        parser.setGroup(options);
-        CommandLine line =
-            parser.parse(new String[] { "--block-size=10", "--color=never" });
-
-        assertTrue(line.hasOption("--block-size"));
-        assertEquals(line.getValue("--block-size"), "10");
-        assertFalse(line.hasOption("--ignore-backups"));
-    }
-}
+/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2.application;import java.util.HashSet;import java.util.Set;import junit.framework.Test;import junit.framework.TestCase;import junit.framework.TestSuite;import org.apache.c
 ommons.cli2.CommandLine;import org.apache.commons.cli2.Group;import org.apache.commons.cli2.Option;import org.apache.commons.cli2.OptionException;import org.apache.commons.cli2.builder.ArgumentBuilder;import org.apache.commons.cli2.builder.DefaultOptionBuilder;import org.apache.commons.cli2.builder.GroupBuilder;import org.apache.commons.cli2.commandline.Parser;import org.apache.commons.cli2.validation.EnumValidator;/** * <p>Test the <code>ls</code> command. Duplicated Option types are not * tested e.g. -a and -d are the same Option type.</p> * * <p>The following is the man output for 'ls'. See * <a href="http://www.rt.com/man/ls.1.html">http://www.rt.com/man/ls.1.html</a>.</p> * * <pre> *  LS(1) FSF LS(1) * *  NAME ls - list directory contents * *  SYNOPSIS ls [OPTION]... [FILE]... * *  DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuSUX nor --sort. * *  -a, --all do not hide entries starting with .
  * *  -A, --almost-all do not list implied . and .. * *  -b, --escape print octal escapes for nongraphic characters * *  --block-size=SIZE use SIZE-byte blocks * *  -B, --ignore-backups do not list implied entries ending with ~ -c sort by change time; with -l: show ctime -C list entries by columns * *  --color[=WHEN] control whether color is used to distinguish file types. WHEN may be `never', `always', or `auto' * *  -d, --directory list directory entries instead of contents * *  -D, --dired generate output designed for Emacs' dired mode -f do not sort, enable -aU, disable -lst * *  -F, --classify append indicator (one of /=@|*) to entries * *  --format=WORD across -x, commas -m, horizontal -x, long -l, sin- gle-column -1, verbose -l, vertical -C * *  --full-time list both full date and full time -g (ignored) * *  -G, --no-group inhibit display of group information * *  -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) * *  -H, --si likewise, but 
 use powers of 1000 not 1024 * *  --indicator-style=WORD append indicator with style WORD to entry names: none (default), classify (-F), file-type (-p) * *  -i, --inode print index number of each file * *  -I, --ignore=PATTERN do not list implied entries matching shell PATTERN * *  -k, --kilobytes like --block-size=1024 -l use a long listing format * *  -L, --dereference list entries pointed to by symbolic links -m fill width with a comma separated list of entries * *  -n, --numeric-uid-gid list numeric UIDs and GIDs instead of names * *  -N, --literal print raw entry names (don't treat e.g. control characters specially) -o use long listing format without group info * *  -p, --file-type append indicator (one of /=@|) to entries * *  -q, --hide-control-chars print ? instead of non graphic characters * *  --show-control-chars show non graphic characters as-is (default) * *  -Q, --quote-name enclose entry names in double quotes * *  --quoting-style=WORD use quoting style WORD fo
 r entry names: literal, shell, shell-always, c, escape * *  -r, --reverse reverse order while sorting * *  -R, --recursive list subdirectories recursively * *  -s, --size print size of each file, in blocks -S sort by file size * *  --sort=WORD extension -X, none -U, size -S, time -t, version -v status -c, time -t, atime -u, access -u, use -u * *  --time=WORD show time as WORD instead of modification time: atime, access, use, ctime or status; use specified time as sort key if --sort=time -t sort by modification time * *  -T, --tabsize=COLS assume tab stops at each COLS instead of 8 -u sort by last access time; with -l: show atime -U do not sort; list entries in directory order -v sort by version * *  -w, --width=COLS assume screen width instead of current value -x list entries by lines instead of by columns -X sort alphabetically by entry extension -1 list one file per line * *  --help display this help and exit * *  --version output version information and exit * *  By defau
 lt, color is not used to distinguish types of files. That is equivalent to using --color=none. Using the --color option without the optional WHEN argument is equivalent to using --color=always. With --color=auto, color codes are output only if standard output is con- nected to a terminal (tty). * </pre> * * @author Rob Oxspring * @author John Keyes */public class LsTest extends TestCase {    /** Option Builder */    private static final DefaultOptionBuilder oBuilder =        new DefaultOptionBuilder();    /** Argument Builder */    private static final ArgumentBuilder aBuilder = new ArgumentBuilder();    /** Group Builder */    private static final GroupBuilder gBuilder = new GroupBuilder();    private static Group options;    public static Test suite() {        return new TestSuite(LsTest.class);    }    /**     * Required ctor.     *     * @param name     *            the name of the TestCase     */    public LsTest(final String name) {        super(name);    }    public v
 oid setUp() {        if (LsTest.options == null) {            final Option a =                oBuilder                    .withShortName("a")                    .withLongName("all")                    .withDescription("do not hide entries starting with .")                    .create();            final Option blockSize =                oBuilder                    .withLongName("block-size")                    .withRequired(false)                    .withDescription("use SIZE-byte blocks")                    .withArgument(                        aBuilder                            .withMaximum(1)                            .withMinimum(1)                            .withInitialSeparator('=')                            .create())                    .create();            final Option c =                oBuilder                    .withShortName("c")                    .withRequired(false)                    .withDescription("with -lt: sort by, and show, ctime (time of last modi
 fication of file status information) with -l:show ctime and sort by name otherwise: sort by ctime")                    .create();            final Set colors = new HashSet();            colors.add("never");            colors.add("always");            colors.add("auto");            final Option color =                oBuilder                    .withLongName("color")                    .withRequired(false)                    .withDescription("control  whether  color is used to distinguish file types.  WHEN may be `never', `always', or `auto'")                    .withArgument(                        aBuilder                            .withMaximum(1)                            .withMinimum(1)                            .withInitialSeparator('=')                            .withValidator(new EnumValidator(colors))                            .create())                    .create();            LsTest.options =                gBuilder                    .withOption(a)            
         .withOption(blockSize)                    .withOption(c)                    .withOption(color)                    .create();        }    }    public void testLs() throws OptionException {        // create the command line parser        Parser parser = new Parser();        parser.setGroup(options);        CommandLine line =            parser.parse(new String[] { "--block-size=10", "--color=never" });        assertTrue(line.hasOption("--block-size"));        assertEquals(line.getValue("--block-size"), "10");        assertFalse(line.hasOption("--ignore-backups"));    }}
\ No newline at end of file

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug13886Test.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug13886Test.java?rev=639941&r1=639940&r2=639941&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug13886Test.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/Bug13886Test.java Fri Mar 21 19:49:41 2008
@@ -1,89 +1 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.cli2.bug;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.cli2.Group;
-import org.apache.commons.cli2.Option;
-import org.apache.commons.cli2.OptionException;
-import org.apache.commons.cli2.builder.DefaultOptionBuilder;
-import org.apache.commons.cli2.builder.GroupBuilder;
-import org.apache.commons.cli2.commandline.Parser;
-
-/**
- * @author John Keyes
- */
-public class Bug13886Test extends TestCase {
-
-    public Bug13886Test(final String name) {
-        super(name);
-    }
-
-    public void testMandatoryGroup() throws Exception {
-        final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
-        final GroupBuilder gbuilder = new GroupBuilder();
-
-        final Option a = obuilder.withShortName("a").create();
-
-        final Option b = obuilder.withShortName("b").create();
-
-        final Group options =
-            gbuilder
-                .withOption(a)
-                .withOption(b)
-                .withMaximum(1)
-                .withMinimum(1)
-                .create();
-
-        final Parser parser = new Parser();
-        parser.setGroup(options);
-
-        try {
-            parser.parse(new String[] {
-            });
-            fail("Expected MissingOptionException not caught");
-        }
-        catch (final OptionException exp) {
-            assertEquals("Missing option -a|-b", exp.getMessage());
-        }
-
-        try {
-            parser.parse(new String[] { "-a" });
-        }
-        catch (final OptionException exp) {
-            fail("Unexpected MissingOptionException caught");
-        }
-
-        try {
-            parser.parse(new String[] { "-b" });
-        }
-        catch (final OptionException exp) {
-            fail("Unexpected MissingOptionException caught");
-        }
-
-        try {
-            parser.parse(new String[] { "-a", "-b" });
-            fail("Expected UnexpectedOptionException not caught");
-        }
-        catch (final OptionException exp) {
-            assertEquals(
-                "Unexpected -b while processing -a|-b",
-                exp.getMessage());
-        }
-    }
-}
+/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.commons.cli2.bug;import junit.framework.TestCase;import org.apache.commons.cli2.Group;import org.apache.commons.cli2.Option;import org.apache.commons.cli2.OptionException;import org.a
 pache.commons.cli2.builder.DefaultOptionBuilder;import org.apache.commons.cli2.builder.GroupBuilder;import org.apache.commons.cli2.commandline.Parser;/** * @author John Keyes */public class Bug13886Test extends TestCase {    public Bug13886Test(final String name) {        super(name);    }    public void testMandatoryGroup() throws Exception {        final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();        final GroupBuilder gbuilder = new GroupBuilder();        final Option a = obuilder.withShortName("a").create();        final Option b = obuilder.withShortName("b").create();        final Group options =            gbuilder                .withOption(a)                .withOption(b)                .withMaximum(1)                .withMinimum(1)                .create();        final Parser parser = new Parser();        parser.setGroup(options);        try {            parser.parse(new String[] {            });            fail("Expected MissingOptionException 
 not caught");        }        catch (final OptionException exp) {            assertEquals("Missing option -a|-b", exp.getMessage());        }        try {            parser.parse(new String[] { "-a" });        }        catch (final OptionException exp) {            fail("Unexpected MissingOptionException caught");        }        try {            parser.parse(new String[] { "-b" });        }        catch (final OptionException exp) {            fail("Unexpected MissingOptionException caught");        }        try {            parser.parse(new String[] { "-a", "-b" });            fail("Expected UnexpectedOptionException not caught");        }        catch (final OptionException exp) {            assertEquals(                "Unexpected -b while processing -a|-b",                exp.getMessage());        }    }}
\ No newline at end of file