[Japi-cvs] SF.net SVN: japi: [244] libs/argparser/trunk/src
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-12-02 22:52:54
|
Revision: 244 http://svn.sourceforge.net/japi/?rev=244&view=rev Author: christianhujer Date: 2006-12-02 14:52:52 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Added some more tests. Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java Added Paths: ----------- libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/CommandDummy.java libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java Removed Paths: ------------- libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTestCase.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java 2006-12-02 19:01:29 UTC (rev 243) +++ libs/argparser/trunk/src/net/sf/japi/io/args/OptionType.java 2006-12-02 22:52:52 UTC (rev 244) @@ -23,6 +23,7 @@ import java.util.ResourceBundle; import java.util.MissingResourceException; import java.util.Locale; +import org.jetbrains.annotations.NotNull; /** * The type of an option. @@ -54,7 +55,7 @@ * Returns the localized name of this OptionType in the default locale if available, otherwise the lowercase enum constant name. * @return The localized name of this OptionType. */ - public String getName() { + @NotNull public String getName() { String name; try { name = ResourceBundle.getBundle("net.sf.japi.io.args.messages").getString(getClass().getName() + "." + name()); @@ -69,7 +70,7 @@ * @param locale Locale * @return The localized name of this OptionType. */ - public String getName(final Locale locale) { + @NotNull public String getName(@NotNull final Locale locale) { String name; try { name = ResourceBundle.getBundle("net.sf.japi.io.args.messages", locale).getString(getClass().getName() + "." + name()); @@ -83,7 +84,7 @@ * {@inheritDoc} * Returns the same as {@link #getName()}. */ - @Override public String toString() { + @NotNull @Override public String toString() { return getName(); } @@ -91,7 +92,7 @@ * Returns the command line description of this option type. * @return The command line description of this option type. */ - public String getDescription() { + @NotNull public String getDescription() { String description; try { description = ResourceBundle.getBundle("net.sf.japi.io.args.messages").getString(getClass().getName() + "." + name() + ".description"); @@ -101,4 +102,19 @@ return description.length() == 0 ? description : " (" + description + ")"; } + /** + * Returns the command line description of this option type. + * @param locale Locale + * @return The command line description of this option type. + */ + @NotNull public String getDescription(@NotNull final Locale locale) { + String description; + try { + description = ResourceBundle.getBundle("net.sf.japi.io.args.messages", locale).getString(getClass().getName() + "." + name() + ".description"); + } catch (final MissingResourceException e) { + description = name(); + } + return description.length() == 0 ? description : " (" + description + ")"; + } + } // OptionType Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2006-12-02 19:01:29 UTC (rev 243) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -1,5 +1,8 @@ package test.net.sf.japi.io.args; +import java.util.List; +import java.util.Set; +import java.lang.reflect.Method; import net.sf.japi.io.args.ArgParser; import net.sf.japi.io.args.BasicCommand; import net.sf.japi.io.args.MissingArgumentException; @@ -8,10 +11,10 @@ import net.sf.japi.io.args.RequiredOptionsMissingException; import net.sf.japi.io.args.TerminalException; import net.sf.japi.io.args.UnknownOptionException; -import java.util.List; +import net.sf.japi.io.args.Command; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; import org.junit.Test; -import org.junit.Assert; -import org.jetbrains.annotations.NotNull; /** * Test for {@link ArgParser}. @@ -20,72 +23,46 @@ public class ArgParserTest { /** - * This MockCommand serves as a command for performing simple tests. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * Tests whether {@link ArgParser#getOptionMethods(Command)} works. + * @throws Exception (unexpected) */ - public static class MockCommand extends BasicCommand { + @Test + public void testGetOptionMethodsCommand() throws Exception { + final CommandDummy commandDummy = new CommandDummy(); + final Set<Method> optionMethods = ArgParser.getOptionMethods(commandDummy); + Assert.assertFalse(optionMethods.isEmpty()); + } - /** The input option value. */ - private String input; + /** + * Tests whether {@link ArgParser#getOptionMethods(Class)} works. + * @throws Exception (unexpected) + */ + @Test + public void testGetOptionMethodsClass() throws Exception { + final Set<Method> optionMethods = ArgParser.getOptionMethods(CommandDummy.class); + Assert.assertFalse(optionMethods.isEmpty()); + } - /** Remembers whether {@link #run(java.util.List<java.lang.String>)} was called. */ - private boolean runCalled; + /** + * Tests whether {@link ArgParser#simpleParseAndRun(Command, String[])} works. + * @throws Exception (unexpected) + */ + @Test + public void testSimpleParseAndRun() throws Exception { + final CommandDummy commandDummy = new CommandDummy(); + ArgParser.simpleParseAndRun(commandDummy); + } - /** The command line arguments received from the parser. */ - private List<String> args; + /** + * Tests whether {@link ArgParser#parseAndRun(Command, String[])} works. + * @throws Exception (unexpected) + */ + @Test + public void testParseAndRun() throws Exception { + final CommandDummy commandDummy = new CommandDummy(); + ArgParser.parseAndRun(commandDummy); + } - /** {@inheritDoc} */ - @SuppressWarnings({"InstanceMethodNamingConvention"}) - public int run(@NotNull final List<String> args) { - runCalled = true; - this.args = args; - return 0; - } - - /** - * Get the command line arguments. - * @return Command line arguments. - */ - private List<String> getArgs() { - return args; - } - - /** - * Set the value of the input option. - * @param input Value of the input option. - */ - @Option(value = {"i", "input"}, type = OptionType.REQUIRED) - public void setInput(final String input) { - this.input = input; - } - - /** - * Set the value of the foo option. - * @param foo Value of the foo option. - */ - @Option({"f", "b", "foo", "bar", "buzz"}) - public void setFoo(final String foo) { - // ignored - } - - /** - * Get the value of the input option. - * @return Value of the input option. - */ - private String getInput() { - return input; - } - - /** - * Return whether run was called. - * @return whether run was called. - */ - private boolean isRunCalled() { - return runCalled; - } - - } // class MockCommand - /** * Tests whether supplying a required option with argument in short form works. * @throws RequiredOptionsMissingException (unexpected) @@ -141,7 +118,7 @@ * @throws UnknownOptionException (unexpected) * @throws MissingArgumentException (unexpected) */ - @Test(expected=RequiredOptionsMissingException.class) + @Test(expected = RequiredOptionsMissingException.class) public void testCommandRequiredOptionMissing() throws RequiredOptionsMissingException, TerminalException, UnknownOptionException, MissingArgumentException { final MockCommand command = new MockCommand(); try { @@ -158,7 +135,7 @@ * @throws UnknownOptionException (expected) * @throws MissingArgumentException (unexpected) */ - @Test(expected=UnknownOptionException.class) + @Test(expected = UnknownOptionException.class) public void testCommandUnknownOption() throws RequiredOptionsMissingException, TerminalException, UnknownOptionException, MissingArgumentException { final MockCommand command = new MockCommand(); try { @@ -175,7 +152,7 @@ * @throws UnknownOptionException (unexpected) * @throws MissingArgumentException (expected) */ - @Test(expected=MissingArgumentException.class) + @Test(expected = MissingArgumentException.class) public void testCommandMissingArgument() throws RequiredOptionsMissingException, TerminalException, UnknownOptionException, MissingArgumentException { final MockCommand command = new MockCommand(); try { @@ -214,4 +191,71 @@ ArgParser.parseAndRun(command, "-h"); } + /** + * This MockCommand serves as a command for performing simple tests. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ + public static class MockCommand extends BasicCommand { + + /** The input option value. */ + private String input; + + /** Remembers whether {@link #run(java.util.List<java.lang.String>)} was called. */ + private boolean runCalled; + + /** The command line arguments received from the parser. */ + private List<String> args; + + /** {@inheritDoc} */ + @SuppressWarnings({"InstanceMethodNamingConvention"}) + public int run(@NotNull final List<String> args) { + runCalled = true; + this.args = args; + return 0; + } + + /** + * Get the command line arguments. + * @return Command line arguments. + */ + private List<String> getArgs() { + return args; + } + + /** + * Set the value of the input option. + * @param input Value of the input option. + */ + @Option(value = {"i", "input"}, type = OptionType.REQUIRED) + public void setInput(final String input) { + this.input = input; + } + + /** + * Set the value of the foo option. + * @param foo Value of the foo option. + */ + @Option({"f", "b", "foo", "bar", "buzz"}) + public void setFoo(final String foo) { + // ignored + } + + /** + * Get the value of the input option. + * @return Value of the input option. + */ + private String getInput() { + return input; + } + + /** + * Return whether run was called. + * @return whether run was called. + */ + private boolean isRunCalled() { + return runCalled; + } + + } // class MockCommand + } // class ArgParserTest Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,69 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.BasicCommand; +import org.junit.Assert; +import org.junit.Test; +import java.util.ArrayList; +import java.util.ResourceBundle; + +/** + * Test for {@link BasicCommand}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class BasicCommandTest { + + /** + * Tests whether {@link BasicCommand#BasicCommand()} works. + * @throws Exception (unexpected) + */ + @Test + public void testBasicCommand() throws Exception { + final BasicCommand basicCommand = new CommandDummy(); + Assert.assertEquals(0, basicCommand.run(new ArrayList<String>())); + } + + /** + * Tests whether {@link BasicCommand#setExiting(Boolean)} works. + * @throws Exception (unexpected) + */ + @Test + public void testSetExiting() throws Exception { + final BasicCommand basicCommand = new CommandDummy(); + basicCommand.setExiting(false); + Assert.assertFalse(basicCommand.isExiting()); + basicCommand.setExiting(true); + Assert.assertTrue(basicCommand.isExiting()); + } + + /** + * Tests whether {@link BasicCommand#isExiting()} works. + * @throws Exception (unexpected) + */ + @Test + public void testIsExiting() throws Exception { + testSetExiting(); + } + + /** + * Tests whether {@link BasicCommand#help()} works. + * @throws Exception (unexpected) + */ + @Test + public void testHelp() throws Exception { + final BasicCommand basicCommand = new CommandDummy(); + basicCommand.help(); + } + + /** + * Tests whether {@link BasicCommand#getBundle()} works. + * @throws Exception (unexpected) + */ + @Test + public void testGetBundle() throws Exception { + final BasicCommand basicCommand = new CommandDummy(); + final ResourceBundle bundle = basicCommand.getBundle(); + Assert.assertNotNull(bundle); + } + +} // class BasicCommandTest \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/CommandDummy.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/CommandDummy.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/CommandDummy.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,19 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.BasicCommand; +import org.jetbrains.annotations.NotNull; +import java.util.List; + +/** + * A simple BasicCommand implementation as a test mock. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +class CommandDummy extends BasicCommand { + + /** {@inheritDoc} */ + @SuppressWarnings({"InstanceMethodNamingConvention"}) + public int run(@NotNull List<String> args) throws Exception { + return 0; + } + +} // class CommandDummy Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/CommandDummy.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,33 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.MissingArgumentException; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link MissingArgumentException}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MissingArgumentExceptionTest { + + /** + * Tests whether {@link MissingArgumentException#MissingArgumentException(String)} works. + * @throws Exception (unexpected) + */ + @Test + public void testMissingArgumentException() throws Exception { + final MissingArgumentException exception = new MissingArgumentException("foo"); + Assert.assertEquals(exception.getOption(), "foo"); + } + + /** + * Tests whether {@link MissingArgumentException#getOption()} works. + * @throws Exception (unexpected) + */ + @Test + public void testGetOption() throws Exception { + testMissingArgumentException(); + } + +} // class MissingArgumentExceptionTest \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,54 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.OptionType; +import org.junit.Assert; +import org.junit.Test; +import java.util.Locale; + +/** + * Test for {@link OptionType}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class OptionTypeTest { + + /** + * Tests whether {@link OptionType#getName()} and {@link OptionType#getName(Locale)} work. + * @throws Exception (unexpected) + */ + @Test + public void testGetName() throws Exception { + for (final OptionType optionType : OptionType.values()) { + Assert.assertNotNull(optionType.getName()); + } + for (final OptionType optionType : OptionType.values()) { + Assert.assertNotNull(optionType.getName(Locale.getDefault())); + } + } + + /** + * Tests whether {@link OptionType#toString()} works. + * @throws Exception (unexpected) + */ + @Test + public void testToString() throws Exception { + for (final OptionType optionType : OptionType.values()) { + Assert.assertNotNull(optionType.toString()); + } + } + + /** + * Tests whether {@link OptionType#getDescription()} and {@link OptionType#getDescription(Locale)} work. + * @throws Exception (unexpected) + */ + @Test + public void testGetDescription() throws Exception { + for (final OptionType optionType : OptionType.values()) { + Assert.assertNotNull(optionType.getDescription()); + } + for (final OptionType optionType : OptionType.values()) { + Assert.assertNotNull(optionType.getDescription(Locale.getDefault())); + } + } + +} // class OptionTypeTest \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,35 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.RequiredOptionsMissingException; +import org.junit.Assert; +import org.junit.Test; +import java.util.Arrays; + +/** + * Test for {@link RequiredOptionsMissingException}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class RequiredOptionsMissingExceptionTest { + + /** + * Tests whether {@link RequiredOptionsMissingException#RequiredOptionsMissingException(String[])} works. + * @throws Exception (unexpected) + */ + @Test + public void testRequiredOptionsMissingException() throws Exception { + final String[] options = { "foo", "bar" }; + final RequiredOptionsMissingException exception = new RequiredOptionsMissingException(options.clone()); + Assert.assertTrue(Arrays.equals(exception.getMissingOptions(), options)); + } + + /** + * Tests whether {@link RequiredOptionsMissingException#getMissingOptions()} works. + * @throws Exception (unexpected) + */ + @Test + public void testGetMissingOptions() throws Exception { + testRequiredOptionsMissingException(); + } + +} // class RequiredOptionsMissingExceptionTest \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,59 @@ +package test.net.sf.japi.io.args; + +import java.util.Arrays; +import net.sf.japi.io.args.StringJoiner; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** + * Test for {@link StringJoiner}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class StringJoinerTest { + + /** + * Expected String. + */ + private static final String EXPECTED = "foo, bar, buzz"; + + /** + * Argument values. + */ + private static final String[] ARGS = {"foo", "bar", "buzz"}; + + /** + * Tests whether {@link StringJoiner#join(CharSequence,CharSequence...)} works. + */ + @Test + public void testJoinCSCS() { + final String[] nargs = ARGS.clone(); + final String actual = StringJoiner.join(", ", nargs); + assertEquals("arguments must be joined correctly.", EXPECTED, actual); + assertTrue("arguments must not be changed by join().", Arrays.equals(ARGS, nargs)); + } + + /** + * Tests whether {@link StringJoiner#join(CharSequence,Iterable<? extends java.lang.CharSequence>)} works. + */ + @Test + public void testJoinCSIe() { + final String[] nargs = ARGS.clone(); + final String actual = StringJoiner.join(", ", Arrays.asList(nargs)); + assertEquals("arguments must be joined correctly.", EXPECTED, actual); + assertTrue("arguments must not be changed by join().", Arrays.equals(ARGS, nargs)); + } + + /** + * Tests whether {@link StringJoiner#join(CharSequence,java.util.Iterator<? extends java.lang.CharSequence>)} works. + */ + @Test + public void testJoinCSIr() { + final String[] nargs = ARGS.clone(); + final String actual = StringJoiner.join(", ", Arrays.asList(nargs).iterator()); + assertEquals("arguments must be joined correctly.", EXPECTED, actual); + assertTrue("arguments must not be changed by join().", Arrays.equals(ARGS, nargs)); + } + +} // class StringJoinerTest Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Deleted: libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTestCase.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTestCase.java 2006-12-02 19:01:29 UTC (rev 243) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTestCase.java 2006-12-02 22:52:52 UTC (rev 244) @@ -1,58 +0,0 @@ -package test.net.sf.japi.io.args; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; -import net.sf.japi.io.args.StringJoiner; -import org.junit.Test; - -import java.util.Arrays; - -/** - * TestCase for {@link StringJoiner}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class StringJoinerTestCase { - - /** Expected String. */ - private static final String EXPECTED = "foo, bar, buzz"; - - /** Argument values. */ - private static final String[] ARGS = { "foo", "bar", "buzz" }; - - /** - * Empty constructor for JUnit. - */ - public StringJoinerTestCase() { - } - - /** - * Tests whether {@link StringJoiner#join(CharSequence, CharSequence...)} works. - */ - @Test public void testJoinCSCS() { - final String[] nargs = ARGS.clone(); - final String actual = StringJoiner.join(", ", nargs); - assertEquals("arguments must be joined correctly.", EXPECTED, actual); - assertTrue("arguments must not be changed by join().", Arrays.equals(ARGS, nargs)); - } - - /** - * Tests whether {@link StringJoiner#join(CharSequence, Iterable<? extends java.lang.CharSequence>)} works. - */ - @Test public void testJoinCSIe() { - final String[] nargs = ARGS.clone(); - final String actual = StringJoiner.join(", ", Arrays.asList(nargs)); - assertEquals("arguments must be joined correctly.", EXPECTED, actual); - assertTrue("arguments must not be changed by join().", Arrays.equals(ARGS, nargs)); - } - - /** - * Tests whether {@link StringJoiner#join(CharSequence, java.util.Iterator<? extends java.lang.CharSequence>)} works. - */ - @Test public void testJoinCSIr() { - final String[] nargs = ARGS.clone(); - final String actual = StringJoiner.join(", ", Arrays.asList(nargs).iterator()); - assertEquals("arguments must be joined correctly.", EXPECTED, actual); - assertTrue("arguments must not be changed by join().", Arrays.equals(ARGS, nargs)); - } - -} // class StringJoinerTestCase Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,34 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.TerminalException; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link TerminalException}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class TerminalExceptionTest { + + /** + * Tests whether {@link TerminalException#TerminalException()} works. + * @throws Exception (unexpected) + */ + @Test + public void testTerminalException() throws Exception { + final TerminalException exception = new TerminalException(); + Assert.assertEquals(exception.getReturnCode(), 0); + } + + /** + * Tests whether {@link TerminalException#getReturnCode()} works. + * @throws Exception (unexpected) + */ + @Test + public void testGetReturnCode() throws Exception { + final TerminalException exception = new TerminalException(1); + Assert.assertEquals(exception.getReturnCode(), 1); + } + +} // class TerminalExceptionTest \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java 2006-12-02 22:52:52 UTC (rev 244) @@ -0,0 +1,35 @@ +package test.net.sf.japi.io.args; + +import net.sf.japi.io.args.UnknownOptionException; +import org.junit.Assert; +import org.junit.Test; +import java.util.Arrays; + +/** + * Test for {@link UnknownOptionException}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class UnknownOptionExceptionTest { + + /** + * Tests whether {@link UnknownOptionException#UnknownOptionException(String[])} works. + * @throws Exception (unexpected) + */ + @Test + public void testUnknownOptionException() throws Exception { + final String[] options = { "foo", "bar" }; + final UnknownOptionException exception = new UnknownOptionException(options.clone()); + Assert.assertTrue(Arrays.equals(options, exception.getUnknownOptions())); + } + + /** + * Tests whether {@link UnknownOptionException#getUnknownOptions()} works. + * @throws Exception (unexpected) + */ + @Test + public void testGetUnknownOptions() throws Exception { + testUnknownOptionException(); + } + +} // class UnknownOptionExceptionTest \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |