jkeyes 2004/02/23 18:01:41 Modified: cli/src/java/org/apache/commons/cli2/impl Tag: RESEARCH_CLI_2_ROXSPRING Command.java DefaultOption.java PropertyOption.java Switch.java GroupImpl.java ArgumentImpl.java cli/src/test/org/apache/commons/cli2/impl Tag: RESEARCH_CLI_2_ROXSPRING SwitchTest.java GroupTest.java PropertyOptionTest.java CommandTest.java ParentTest.java ArgumentTest.java DefaultOptionTest.java cli/src/java/org/apache/commons/cli2 Tag: RESEARCH_CLI_2_ROXSPRING OptionException.java cli/src/test/org/apache/commons/cli2/bugs Tag: RESEARCH_CLI_2_ROXSPRING Bug13886Test.java cli/src/test/org/apache/commons/cli2 Tag: RESEARCH_CLI_2_ROXSPRING DocumentationTest.java HelpFormatterTest.java cli/src/test/org/apache/commons/cli2/apps Tag: RESEARCH_CLI_2_ROXSPRING CpTest.java cli/src/java/org/apache/commons/cli2/commandline Tag: RESEARCH_CLI_2_ROXSPRING Parser.java cli/src/test/org/apache/commons/cli2/jdepend Tag: RESEARCH_CLI_2_ROXSPRING JDependTest.java Added: cli/src/java/org/apache/commons/cli2 Tag: RESEARCH_CLI_2_ROXSPRING messages.properties Removed: cli/src/java/org/apache/commons/cli2/impl Tag: RESEARCH_CLI_2_ROXSPRING BadPropertyException.java MissingOptionException.java messages.properties UnexpectedOptionException.java UnexpectedValueException.java BurstException.java MissingValueException.java Log: - moved to a single exception for clarity and to keep all of the
functionality in the same location Revision Changes Path No revision No revision 1.1.2.5 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/Command.java Index: Command.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/Command.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- Command.java 8 Feb 2004 13:08:59 -0000 1.1.2.4 +++ Command.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -130,7 +130,7 @@ arguments.set(preferredName); } else { - throw new UnexpectedOptionException(this, arg); + throw new OptionException(this, "cli.error.unexpected", arg); } } @@ -151,7 +151,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { if (required && !commandLine.hasOption(this)) { - throw new MissingOptionException(this); + throw new OptionException(this); } super.validate(commandLine); 1.1.2.5 +3 -3 jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/DefaultOption.java Index: DefaultOption.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/DefaultOption.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- DefaultOption.java 8 Feb 2004 13:08:59 -0000 1.1.2.4 +++ DefaultOption.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -145,11 +145,11 @@ arguments.previous(); } else { - throw new BurstException(this, argument); + throw new OptionException(this, "cli.error.burst", argument); } } else { - throw new UnexpectedOptionException(this, argument); + throw new OptionException(this, "cli.error.unexpected", argument); } } @@ -178,7 +178,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { if (required && !commandLine.hasOption(this)) { - throw new MissingOptionException(this); + throw new OptionException(this); } super.validate(commandLine); 1.1.2.6 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/PropertyOption.java Index: PropertyOption.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/PropertyOption.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- PropertyOption.java 8 Feb 2004 14:01:46 -0000 1.1.2.5 +++ PropertyOption.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -89,7 +89,7 @@ final String arg = (String)arguments.next(); if (!canProcess(arg)) { - throw new UnexpectedOptionException(this, arg); + throw new OptionException(this, "cli.error.unexpected", arg); } final int propertyStart = optionString.length(); 1.1.2.5 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/Switch.java Index: Switch.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/Switch.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- Switch.java 8 Feb 2004 13:08:59 -0000 1.1.2.4 +++ Switch.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -129,7 +129,7 @@ } } else { - throw new UnexpectedOptionException(this, arg); + throw new OptionException(this, "cli.error.unexpected", arg); } } @@ -159,7 +159,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { if (required && !commandLine.hasOption(this)) { - throw new MissingOptionException(this); + throw new OptionException(this); } super.validate(commandLine); 1.1.2.6 +5 -4 jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java Index: GroupImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/GroupImpl.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- GroupImpl.java 8 Feb 2004 14:01:46 -0000 1.1.2.5 +++ GroupImpl.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -195,7 +195,7 @@ } if (!foundOption) { - throw new MissingOptionException(this); + throw new OptionException(this); } } @@ -216,13 +216,14 @@ } if (present.size() < minimum) { - throw new MissingOptionException(this); + throw new OptionException(this, "cli.error.missing.option"); } if (present.size() > maximum) { - throw new UnexpectedOptionException( + throw new OptionException( this, - (Option)present.get(maximum)); + "cli.error.unexpected", + ((Option)present.get(maximum)).getPreferredName()); } for (final Iterator i = present.iterator(); i.hasNext();) { 1.1.2.7 +10 -6 jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java Index: ArgumentImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- ArgumentImpl.java 17 Feb 2004 22:11:16 -0000 1.1.2.6 +++ ArgumentImpl.java 24 Feb 2004 02:01:40 -0000 1.1.2.7 @@ -192,8 +192,9 @@ } if (values.hasMoreTokens()) { - throw new UnexpectedValueException( + throw new OptionException( option, + "cli.error.unexpected.value", values.nextToken()); } } @@ -205,8 +206,7 @@ if (this.defaultValues == null && (argumentCount < minimum || initialCount == argumentCount)) { - - throw new MissingValueException(option); + throw new OptionException(option, "cli.error.missing.values"); } } @@ -283,12 +283,13 @@ final List values = commandLine.getValues(option); if (values.size() < minimum) { - throw new MissingValueException(option); + throw new OptionException(option, "cli.error.missing.values"); } if (values.size() > maximum) { - throw new UnexpectedValueException( + throw new OptionException( option, + "cli.error.unexpected.value", (String)values.get(maximum)); } @@ -297,7 +298,10 @@ validator.validate(values); } catch (InvalidArgumentException ive) { - throw new UnexpectedValueException(option, ive.getMessage()); + throw new OptionException( + option, + "cli.error.unexpected.value", + ive.getMessage()); } } } No revision No revision 1.1.2.6 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/SwitchTest.java Index: SwitchTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/SwitchTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- SwitchTest.java 17 Feb 2004 21:36:38 -0000 1.1.2.5 +++ SwitchTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -145,7 +145,7 @@ option.validate(commandLine); fail("Missing an option"); } - catch (MissingOptionException moe) { + catch (OptionException moe) { assertSame(option, moe.getOption()); } } 1.1.2.6 +2 -2 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/GroupTest.java Index: GroupTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/GroupTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- GroupTest.java 17 Feb 2004 21:36:38 -0000 1.1.2.5 +++ GroupTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -233,7 +233,7 @@ option.validate(commandLine); fail("Too many options"); } - catch (UnexpectedOptionException uoe) { + catch (OptionException uoe) { assertEquals(option, uoe.getOption()); } } @@ -246,7 +246,7 @@ option.validate(commandLine); fail("Missing an option"); } - catch (MissingOptionException moe) { + catch (OptionException moe) { assertEquals(option, moe.getOption()); } } 1.1.2.5 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/PropertyOptionTest.java Index: PropertyOptionTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/PropertyOptionTest.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- PropertyOptionTest.java 8 Feb 2004 13:09:01 -0000 1.1.2.4 +++ PropertyOptionTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -95,7 +95,7 @@ option.process(commandLine, iterator); fail("UnexpectedOption"); } - catch (final UnexpectedOptionException uoe) { + catch (final OptionException uoe) { assertEquals(option, uoe.getOption()); assertEquals( "Unexpected --help while processing -Dproperty=value", 1.1.2.6 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/CommandTest.java Index: CommandTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/CommandTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- CommandTest.java 17 Feb 2004 21:36:38 -0000 1.1.2.5 +++ CommandTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -170,7 +170,7 @@ option.validate(commandLine); fail("Missing an option"); } - catch (MissingOptionException moe) { + catch (OptionException moe) { assertSame(option, moe.getOption()); } } 1.1.2.5 +2 -2 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ParentTest.java Index: ParentTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ParentTest.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- ParentTest.java 17 Feb 2004 21:36:38 -0000 1.1.2.4 +++ ParentTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -235,7 +235,7 @@ try { option.validate(commandLine); fail("Missing a command"); - } catch (MissingOptionException moe) { + } catch (OptionException moe) { assertNotNull(moe.getOption()); assertNotSame(option, moe.getOption()); } @@ -252,7 +252,7 @@ try { option.validate(commandLine); fail("Missing a value"); - } catch (MissingValueException moe) { + } catch (OptionException moe) { assertSame(option, moe.getOption()); } } 1.1.2.7 +5 -5 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java Index: ArgumentTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- ArgumentTest.java 17 Feb 2004 22:11:16 -0000 1.1.2.6 +++ ArgumentTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.7 @@ -202,7 +202,7 @@ try { option.processValues(commandLine, iterator, option); } - catch (final MissingValueException mve) { + catch (final OptionException mve) { assertEquals(option, mve.getOption()); assertEquals( "Missing value(s) target [target ...]", @@ -253,7 +253,7 @@ option.processValues(commandLine, iterator, option); fail("Expected MissingValueException"); } - catch (MissingValueException mve) { + catch (OptionException mve) { assertSame(option, mve.getOption()); } } @@ -330,7 +330,7 @@ option.validate(commandLine); fail("UnexpectedValue"); } - catch (MissingValueException mve) { + catch (OptionException mve) { assertEquals(option, mve.getOption()); } } @@ -346,7 +346,7 @@ option.validate(commandLine); fail("UnexpectedValue"); } - catch (UnexpectedValueException uve) { + catch (OptionException uve) { assertEquals(option, uve.getOption()); } } @@ -483,7 +483,7 @@ option.process(commandLine, iterator); fail("Missing Value!"); } - catch (MissingValueException mve) { + catch (OptionException mve) { assertEquals(option, mve.getOption()); assertEquals("Missing value(s) path [path ...]", mve.getMessage()); } 1.1.2.6 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/DefaultOptionTest.java Index: DefaultOptionTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/DefaultOptionTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- DefaultOptionTest.java 17 Feb 2004 21:36:38 -0000 1.1.2.5 +++ DefaultOptionTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -157,7 +157,7 @@ option.validate(commandLine); fail("Missing an option"); } - catch (MissingOptionException moe) { + catch (OptionException moe) { assertSame(option, moe.getOption()); } } No revision No revision 1.1.2.5 +38 -2 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionException.java Index: OptionException.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionException.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- OptionException.java 8 Feb 2004 13:08:58 -0000 1.1.2.4 +++ OptionException.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -19,12 +19,14 @@ import java.util.HashSet; import java.util.Set; +import org.apache.commons.cli2.resources.ResourceHelper; + /** * A problem found while dealing with command line options. */ public class OptionException extends Exception { - protected static final Set HELP_SETTINGS; + public static final Set HELP_SETTINGS; static { final Set settings = new HashSet(); @@ -35,7 +37,13 @@ /** The Option the exception relates to */ protected final Option option; + + /** resource helper instance */ + private static final ResourceHelper helper = + ResourceHelper.getResourceHelper(OptionException.class); + protected final StringBuffer buffer = new StringBuffer(); + /** * Creates a new OptionException. * @@ -43,9 +51,33 @@ * The Option the exception relates to */ public OptionException(final Option option) { - this.option = option; + this(option, null, null); + } + + public OptionException(final Option option, final String messageKey) { + this(option, messageKey, null); } + public OptionException( + final Option option, + final String messageKey, + final String value) { + + this.option = option; + + if (messageKey != null) { + if (value != null) { + buffer.append(helper.getMessage(messageKey, value)); + } + else { + buffer.append(helper.getMessage(messageKey)); + } + buffer.append(" "); + + option.appendUsage(buffer, HELP_SETTINGS, null); + } + } + /** * Gets the Option the exception relates to * @@ -53,5 +85,9 @@ */ public Option getOption() { return option; + } + + public String getMessage() { + return this.buffer.toString(); } } No revision Index: OptionException.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionException.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- OptionException.java 8 Feb 2004 13:08:58 -0000 1.1.2.4 +++ OptionException.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -19,12 +19,14 @@ import java.util.HashSet; import java.util.Set; +import org.apache.commons.cli2.resources.ResourceHelper; + /** * A problem found while dealing with command line options. */ public class OptionException extends Exception { - protected static final Set HELP_SETTINGS; + public static final Set HELP_SETTINGS; static { final Set settings = new HashSet(); @@ -35,7 +37,13 @@ /** The Option the exception relates to */ protected final Option option; + + /** resource helper instance */ + private static final ResourceHelper helper = + ResourceHelper.getResourceHelper(OptionException.class); + protected final StringBuffer buffer = new StringBuffer(); + /** * Creates a new OptionException. * @@ -43,9 +51,33 @@ * The Option the exception relates to */ public OptionException(final Option option) { - this.option = option; + this(option, null, null); + } + + public OptionException(final Option option, final String messageKey) { + this(option, messageKey, null); } + public OptionException( + final Option option, + final String messageKey, + final String value) { + + this.option = option; + + if (messageKey != null) { + if (value != null) { + buffer.append(helper.getMessage(messageKey, value)); + } + else { + buffer.append(helper.getMessage(messageKey)); + } + buffer.append(" "); + + option.appendUsage(buffer, HELP_SETTINGS, null); + } + } + /** * Gets the Option the exception relates to * @@ -53,5 +85,9 @@ */ public Option getOption() { return option; + } + + public String getMessage() { + return this.buffer.toString(); } } No revision Index: OptionException.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionException.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- OptionException.java 8 Feb 2004 13:08:58 -0000 1.1.2.4 +++ OptionException.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -19,12 +19,14 @@ import java.util.HashSet; import java.util.Set; +import org.apache.commons.cli2.resources.ResourceHelper; + /** * A problem found while dealing with command line options. */ public class OptionException extends Exception { - protected static final Set HELP_SETTINGS; + public static final Set HELP_SETTINGS; static { final Set settings = new HashSet(); @@ -35,7 +37,13 @@ /** The Option the exception relates to */ protected final Option option; + + /** resource helper instance */ + private static final ResourceHelper helper = + ResourceHelper.getResourceHelper(OptionException.class); + protected final StringBuffer buffer = new StringBuffer(); + /** * Creates a new OptionException. * @@ -43,9 +51,33 @@ * The Option the exception relates to */ public OptionException(final Option option) { - this.option = option; + this(option, null, null); + } + + public OptionException(final Option option, final String messageKey) { + this(option, messageKey, null); } + public OptionException( + final Option option, + final String messageKey, + final String value) { + + this.option = option; + + if (messageKey != null) { + if (value != null) { + buffer.append(helper.getMessage(messageKey, value)); + } + else { + buffer.append(helper.getMessage(messageKey)); + } + buffer.append(" "); + + option.appendUsage(buffer, HELP_SETTINGS, null); + } + } + /** * Gets the Option the exception relates to * @@ -53,5 +85,9 @@ */ public Option getOption() { return option; + } + + public String getMessage() { + return this.buffer.toString(); } } 1.1.2.3 +1 -4 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/messages.properties No revision No revision 1.1.2.7 +5 -6 jakarta-commons/cli/src/test/org/apache/commons/cli2/bugs/Attic/Bug13886Test.java Index: Bug13886Test.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/bugs/Attic/Bug13886Test.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- Bug13886Test.java 8 Feb 2004 13:08:59 -0000 1.1.2.6 +++ Bug13886Test.java 24 Feb 2004 02:01:40 -0000 1.1.2.7 @@ -19,11 +19,10 @@ import org.apache.commons.cli2.Group; import org.apache.commons.cli2.Option; +import org.apache.commons.cli2.OptionException; import org.apache.commons.cli2.builders.DefaultOptionBuilder; import org.apache.commons.cli2.builders.GroupBuilder; import org.apache.commons.cli2.commandline.Parser; -import org.apache.commons.cli2.impl.MissingOptionException; -import org.apache.commons.cli2.impl.UnexpectedOptionException; /** * @author John Keyes @@ -58,21 +57,21 @@ }); fail("Expected MissingOptionException not caught"); } - catch (final MissingOptionException exp) { + catch (final OptionException exp) { assertEquals("Missing option -a|-b", exp.getMessage()); } try { parser.parse(new String[] { "-a" }); } - catch (final MissingOptionException exp) { + catch (final OptionException exp) { fail("Unexpected MissingOptionException caught"); } try { parser.parse(new String[] { "-b" }); } - catch (final MissingOptionException exp) { + catch (final OptionException exp) { fail("Unexpected MissingOptionException caught"); } @@ -80,7 +79,7 @@ parser.parse(new String[] { "-a", "-b" }); fail("Expected UnexpectedOptionException not caught"); } - catch (final UnexpectedOptionException exp) { + catch (final OptionException exp) { assertEquals( "Unexpected -b while processing -a|-b", exp.getMessage()); No revision No revision 1.1.2.6 +3 -4 jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/DocumentationTest.java Index: DocumentationTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/DocumentationTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- DocumentationTest.java 8 Feb 2004 13:09:00 -0000 1.1.2.5 +++ DocumentationTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -19,14 +19,13 @@ import java.io.PrintWriter; import java.io.StringWriter; +import junit.framework.TestCase; + import org.apache.commons.cli2.builders.ArgumentBuilder; import org.apache.commons.cli2.builders.DefaultOptionBuilder; import org.apache.commons.cli2.builders.GroupBuilder; import org.apache.commons.cli2.commandline.Parser; import org.apache.commons.cli2.impl.PropertyOption; -import org.apache.commons.cli2.impl.UnexpectedOptionException; - -import junit.framework.TestCase; /** * @author Rob @@ -140,7 +139,7 @@ commandLine = parser.parse(args); fail("Unexpected Option!"); } - catch (UnexpectedOptionException uoe) { + catch (OptionException uoe) { assertEquals( "Unexpected --bad-option while processing options", uoe.getMessage()); 1.1.2.6 +2 -2 jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/HelpFormatterTest.java Index: HelpFormatterTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/HelpFormatterTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- HelpFormatterTest.java 8 Feb 2004 13:09:00 -0000 1.1.2.5 +++ HelpFormatterTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -168,7 +168,7 @@ public void testPrintHelp_WithException() throws IOException { final StringWriter writer = new StringWriter(); - helpFormatter.setException(new MissingOptionException(verbose)); + helpFormatter.setException(new OptionException(verbose)); helpFormatter.printHelp(new PrintWriter(writer)); //System.out.println(writer); final BufferedReader reader = @@ -187,7 +187,7 @@ public void testPrintException() throws IOException { final StringWriter writer = new StringWriter(); - helpFormatter.setException(new MissingOptionException(verbose)); + helpFormatter.setException(new OptionException(verbose, "cli.error.missing.option")); helpFormatter.printException(new PrintWriter(writer)); //System.out.println(writer); final BufferedReader reader = No revision No revision 1.1.2.7 +1 -2 jakarta-commons/cli/src/test/org/apache/commons/cli2/apps/Attic/CpTest.java Index: CpTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/apps/Attic/CpTest.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- CpTest.java 8 Feb 2004 13:09:02 -0000 1.1.2.6 +++ CpTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.7 @@ -36,7 +36,6 @@ import org.apache.commons.cli2.builders.GroupBuilder; import org.apache.commons.cli2.commandline.Parser; import org.apache.commons.cli2.impl.ArgumentImpl; -import org.apache.commons.cli2.impl.MissingValueException; import org.apache.commons.cli2.impl.SourceDestArgument; /** @@ -341,7 +340,7 @@ try { parser.parse(new String[0]); } - catch (MissingValueException mve) { + catch (OptionException mve) { assertEquals( "Missing value(s) SOURCE [SOURCE ...]", mve.getMessage()); No revision No revision 1.1.2.6 +1 -2 jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/Parser.java Index: Parser.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/Parser.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- Parser.java 17 Feb 2004 22:08:25 -0000 1.1.2.5 +++ Parser.java 24 Feb 2004 02:01:40 -0000 1.1.2.6 @@ -28,7 +28,6 @@ import org.apache.commons.cli2.Option; import org.apache.commons.cli2.OptionException; import org.apache.commons.cli2.WriteableCommandLine; -import org.apache.commons.cli2.impl.UnexpectedOptionException; /** * A class that implements the <code>Parser</code> interface can parse a @@ -68,7 +67,7 @@ if (iterator.hasNext()) { final String arg = (String)iterator.next(); - throw new UnexpectedOptionException(group, arg); + throw new OptionException(group, "cli.error.unexpected", arg); } group.validate(commandLine); No revision No revision 1.1.2.5 +7 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/jdepend/Attic/JDependTest.java Index: JDependTest.java =================================================================== RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/jdepend/Attic/JDependTest.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- JDependTest.java 8 Feb 2004 13:09:02 -0000 1.1.2.4 +++ JDependTest.java 24 Feb 2004 02:01:40 -0000 1.1.2.5 @@ -82,7 +82,13 @@ dependancies.getPackage("org.apache.commons.cli2"); final Collection dependsUpon = cli2Packages(apiPackage.getEfferents()); - assertEquals("Api should depend on no packages", 0, dependsUpon.size()); + assertEquals("Api should depend on one package", 1, dependsUpon.size()); + + JavaPackage pkg = (JavaPackage) dependsUpon.iterator().next(); + assertEquals( + "Wrong package name", + "org.apache.commons.cli2.resources", + pkg.getName()); } private Collection cli2Packages(final Collection incoming) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]