Thread: [Japi-cvs] SF.net SVN: japi:[869] libs/argparser/trunk/src/tst/test/net/sf/japi/io/ args
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2009-02-15 12:12:37
|
Revision: 869
http://japi.svn.sourceforge.net/japi/?rev=869&view=rev
Author: christianhujer
Date: 2009-02-15 11:58:33 +0000 (Sun, 15 Feb 2009)
Log Message:
-----------
Improved Unit tests, e.g. add messages, bring expected and actual in right order, use assertEquals.
Modified Paths:
--------------
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/BasicCommandTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MethodOptionComparatorTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/TerminalExceptionTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractConverterTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractPrimitiveConverterTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConstructorConverterTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConverterRegistryTest.java
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/BasicCommandTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/BasicCommandTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/BasicCommandTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -38,32 +38,23 @@
@Test
public void testBasicCommand() throws Exception {
final BasicCommand basicCommand = new CommandDummy();
- Assert.assertEquals(0, basicCommand.run(new ArrayList<String>()));
+ Assert.assertEquals("Command dummy must run successful.", 0, basicCommand.run(new ArrayList<String>()));
}
/**
- * Tests that {@link BasicCommand#setExiting(Boolean)} works.
+ * Tests that {@link BasicCommand#setExiting(Boolean)} and {@link BasicCommand#isExiting()} work.
* @throws Exception (unexpected)
*/
@Test
- public void testSetExiting() throws Exception {
+ public void testExiting() throws Exception {
final BasicCommand basicCommand = new CommandDummy();
basicCommand.setExiting(false);
- Assert.assertFalse(basicCommand.isExiting());
+ Assert.assertFalse("Exiting value must be stored.", basicCommand.isExiting());
basicCommand.setExiting(true);
- Assert.assertTrue(basicCommand.isExiting());
+ Assert.assertTrue("Exiting value must be stored.", basicCommand.isExiting());
}
/**
- * Tests that {@link BasicCommand#isExiting()} works.
- * @throws Exception (unexpected)
- */
- @Test
- public void testIsExiting() throws Exception {
- testSetExiting();
- }
-
- /**
* Tests that {@link BasicCommand#help()} works.
* @throws Exception (unexpected)
*/
@@ -81,7 +72,7 @@
public void testGetBundle() throws Exception {
final BasicCommand basicCommand = new CommandDummy();
final ResourceBundle bundle = basicCommand.getBundle();
- Assert.assertNotNull(bundle);
+ Assert.assertNotNull("CommandDummy must have a bundle.", bundle);
}
/**
@@ -95,61 +86,38 @@
public void testGetString() {
final RBMockCommand mock = new RBMockCommand();
mock.setReturnOwnBundle(false);
- Assert.assertEquals("String1FromDefaultBundle", mock.getString("testGetString1"));
- Assert.assertEquals("String2FromDefaultBundle", mock.getString("testGetString2"));
+ Assert.assertEquals("if setReturnOwnBundle(false), getString() must retrieve from default bundle.", "String1FromDefaultBundle", mock.getString("testGetString1"));
+ Assert.assertEquals("if setReturnOwnBundle(false), getString() must retrieve from default bundle.", "String2FromDefaultBundle", mock.getString("testGetString2"));
mock.setReturnOwnBundle(true);
- Assert.assertEquals("String1FromMyBundle", mock.getString("testGetString1"));
- Assert.assertEquals("String2FromDefaultBundle", mock.getString("testGetString2"));
+ Assert.assertEquals("if setReturnOwnBundle(true), getString() must retrieve from own bundle.", "String1FromMyBundle", mock.getString("testGetString1"));
+ Assert.assertEquals("if setReturnOwnBundle(true), getString() must retrieve from own bundle.", "String2FromDefaultBundle", mock.getString("testGetString2"));
}
/**
* Tests that {@link BasicCommand#getHelpHeader()} returns the value from the correct bundle.
+ * Also, the help header must always be terminated with '\n', which will be auto-appended by {@link BasicCommand#getHelpHeader()}.
+ * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1812417&group_id=149894&atid=776737">[ 1812417 ] auto-add newline to help header and footer</a>
*/
@Test
public void testGetHelpHeader() {
final RBMockCommand mock = new RBMockCommand();
mock.setReturnOwnBundle(false);
- Assert.assertEquals("HelpHeaderFromDefaultBundle", mock.getString("helpHeader"));
+ Assert.assertEquals("if setReturnOwnBundle(false), getHelpHeader() must retrieve from default bundle and end with newline.", "HelpHeaderFromDefaultBundle\n", mock.getHelpHeader());
mock.setReturnOwnBundle(true);
- Assert.assertEquals("HelpHeaderFromMyBundle", mock.getString("helpHeader"));
+ Assert.assertEquals("if setReturnOwnBundle(true), getHelpHeader() must retrieve from own bundle and end with newline.", "HelpHeaderFromMyBundle\n", mock.getHelpHeader());
}
/**
- * Tests that {@link BasicCommand#getHelpHeader()} returns either the empty String or a String ending on "\n".
+ * Tests that {@link BasicCommand#getHelpFooter()} returns either the empty String or a String ending on "\n".
* @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1812417&group_id=149894&atid=776737">[ 1812417 ] auto-add newline to help header and footer</a>
*/
@Test
- public void testGetHelpHeaderNewline() {
- final RBMockCommand mock = new RBMockCommand();
- mock.setReturnOwnBundle(false);
- Assert.assertEquals("HelpHeaderFromDefaultBundle\n", mock.getHelpHeader());
- mock.setReturnOwnBundle(true);
- Assert.assertEquals("HelpHeaderFromMyBundle\n", mock.getHelpHeader());
- }
-
- /**
- * Tests that {@link BasicCommand#getHelpFooter()} returns the value from the correct bundle.
- */
- @Test
public void testGetHelpFooter() {
final RBMockCommand mock = new RBMockCommand();
mock.setReturnOwnBundle(false);
- Assert.assertEquals("HelpFooterFromDefaultBundle", mock.getString("helpFooter"));
+ Assert.assertEquals("if setReturnOwnBundle(false), getHelpFooter() must retrieve from default bundle and end with newline.", "HelpFooterFromDefaultBundle\n", mock.getHelpFooter());
mock.setReturnOwnBundle(true);
- Assert.assertEquals("HelpFooterFromMyBundle", mock.getString("helpFooter"));
+ Assert.assertEquals("if setReturnOwnBundle(true), getHelpFooter() must retrieve from own bundle and end with newline.", "HelpFooterFromMyBundle\n", mock.getHelpFooter());
}
- /**
- * Tests that {@link BasicCommand#getHelpFooter()} returns either the empty String or a String ending on "\n".
- * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1812417&group_id=149894&atid=776737">[ 1812417 ] auto-add newline to help header and footer</a>
- */
- @Test
- public void testGetHelpFooterNewline() {
- final RBMockCommand mock = new RBMockCommand();
- mock.setReturnOwnBundle(false);
- Assert.assertEquals("HelpFooterFromDefaultBundle\n", mock.getHelpFooter());
- mock.setReturnOwnBundle(true);
- Assert.assertEquals("HelpFooterFromMyBundle\n", mock.getHelpFooter());
- }
-
} // class BasicCommandTest
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MethodOptionComparatorTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MethodOptionComparatorTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MethodOptionComparatorTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -62,7 +62,7 @@
final Class<MockCommand> cmdClass = MockCommand.class;
final Method mC1 = cmdClass.getMethod("c1");
final Method mC2 = cmdClass.getMethod("c2");
- Assert.assertTrue("-c and -C must not be the same.", comparator.compare(mC1, mC2) != 0);
+ Assert.assertNotSame("-c and -C must not be the same.", 0, comparator.compare(mC1, mC2));
}
/** Mock Command with methods that should be properly sorted.
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -37,7 +37,7 @@
@Test
public void testMissingArgumentException() throws Exception {
final MissingArgumentException exception = new MissingArgumentException("foo");
- Assert.assertEquals(exception.getOption(), "foo");
+ Assert.assertEquals("foo", exception.getOption());
}
/**
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/TerminalExceptionTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/TerminalExceptionTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/TerminalExceptionTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -37,7 +37,7 @@
@Test
public void testTerminalException() throws Exception {
final TerminalException exception = new TerminalException();
- Assert.assertEquals(exception.getReturnCode(), 0);
+ Assert.assertEquals("The default return code for TerminalException must be 0 (no error, e.g. for --help).", 0, exception.getReturnCode());
}
/**
@@ -48,7 +48,7 @@
@Test
public void testGetReturnCode() throws Exception {
final TerminalException exception = new TerminalException(1);
- Assert.assertEquals(exception.getReturnCode(), 1);
+ Assert.assertEquals("A specified return code must be stored.", 1, exception.getReturnCode());
}
} // class TerminalExceptionTest
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -39,7 +39,7 @@
public void testUnknownOptionException() throws Exception {
final String[] options = { "foo", "bar" };
final UnknownOptionException exception = new UnknownOptionException(options.clone());
- Assert.assertTrue(Arrays.equals(options, exception.getUnknownOptions()));
+ Assert.assertTrue("Options which have been unknown must be stored with the exceptions.", Arrays.equals(options, exception.getUnknownOptions()));
}
/**
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractConverterTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractConverterTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractConverterTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -80,7 +80,7 @@
*/
@Test
public void testGetTargetClass() throws Exception {
- Assert.assertSame(targetClass, converter.getTargetClass());
+ Assert.assertSame("The target class must be stored.", targetClass, converter.getTargetClass());
}
/**
@@ -90,9 +90,9 @@
@Test
public void testGetDescription() throws Exception {
final String description = converter.getDescription();
- Assert.assertNotNull(description);
- Assert.assertTrue(description.length() > 0);
- Assert.assertEquals(description, converter.getDescription(Locale.getDefault()));
+ Assert.assertNotNull("The description must not be null.", description);
+ Assert.assertTrue("The description must not be empty.", description.length() > 0);
+ Assert.assertEquals("The description must be returned in the default locale.", description, converter.getDescription(Locale.getDefault()));
}
/**
@@ -102,9 +102,9 @@
@Test
public void testGetDisplayName() throws Exception {
final String displayName = converter.getDisplayName();
- Assert.assertNotNull(displayName);
- Assert.assertTrue(displayName.length() > 0);
- Assert.assertEquals(displayName, converter.getDisplayName(Locale.getDefault()));
+ Assert.assertNotNull("The display name must not be null.", displayName);
+ Assert.assertTrue("The display name must not be empty.", displayName.length() > 0);
+ Assert.assertEquals("The display name must be returned in the default locale.", displayName, converter.getDisplayName(Locale.getDefault()));
}
/** Returns the converter that's being tested.
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractPrimitiveConverterTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractPrimitiveConverterTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/AbstractPrimitiveConverterTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -95,7 +95,7 @@
*/
@Test
public void testGetTargetClass() throws Exception {
- Assert.assertSame(targetClass, converter.getTargetClass());
+ Assert.assertSame("The target class must be stored.", targetClass, converter.getTargetClass());
}
/**
@@ -105,9 +105,9 @@
@Test
public void testGetDescription() throws Exception {
final String description = converter.getDescription();
- Assert.assertNotNull(description);
- Assert.assertTrue(description.length() > 0);
- Assert.assertEquals(description, converter.getDescription(Locale.getDefault()));
+ Assert.assertNotNull("The description must not be null.", description);
+ Assert.assertTrue("The description must not be empty.", description.length() > 0);
+ Assert.assertEquals("The description must be returned in the default locale.", description, converter.getDescription(Locale.getDefault()));
}
/**
@@ -117,9 +117,9 @@
@Test
public void testGetDisplayName() throws Exception {
final String displayName = converter.getDisplayName();
- Assert.assertNotNull(displayName);
- Assert.assertTrue(displayName.length() > 0);
- Assert.assertEquals(displayName, converter.getDisplayName(Locale.getDefault()));
+ Assert.assertNotNull("The display name must not be null.", displayName);
+ Assert.assertTrue("The display name must not be empty.", displayName.length() > 0);
+ Assert.assertEquals("The display name must be returned in the default locale.", displayName, converter.getDisplayName(Locale.getDefault()));
}
/** Returns the converter that's being tested.
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConstructorConverterTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConstructorConverterTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConstructorConverterTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -37,8 +37,8 @@
@Test
public void testConstructorConverter() throws Exception {
final ConstructorConverter<String> conv = new ConstructorConverter<String>(String.class);
- Assert.assertEquals("foo", conv.convert("foo"));
- Assert.assertEquals("foo", conv.convert(Locale.GERMANY, "foo"));
+ Assert.assertEquals("Correct String must be returned.", "foo", conv.convert("foo"));
+ Assert.assertEquals("Correct String must be returned.", "foo", conv.convert(Locale.GERMANY, "foo"));
}
/** Tests that creating a ConstructorConverter works.
@@ -47,8 +47,8 @@
@Test
public void testConstructorConverter2() throws Exception {
final ConstructorConverter<File> conv = new ConstructorConverter<File>(File.class);
- Assert.assertEquals(new File("foo"), conv.convert("foo"));
- Assert.assertEquals(new File("foo"), conv.convert(Locale.GERMANY, "foo"));
+ Assert.assertEquals("Correct file must be returned.", new File("foo"), conv.convert("foo"));
+ Assert.assertEquals("Correct file muts be returned.", new File("foo"), conv.convert(Locale.GERMANY, "foo"));
}
/** Tests that creating a ConstructorConverter for non-public constructors fails.
@@ -67,12 +67,12 @@
final ConstructorConverter<String> conv1 = new ConstructorConverter<String>(String.class);
final ConstructorConverter<String> conv2 = new ConstructorConverter<String>(String.class);
final ConstructorConverter<File> conv3 = new ConstructorConverter<File>(File.class);
- Assert.assertTrue(conv1.equals(conv2));
- Assert.assertFalse(conv1.equals(new Object()));
+ Assert.assertEquals("Two Converter constructed for the same type must be equal.", conv1, conv2);
+ Assert.assertFalse("A Converter must not be equal to an arbitrary Object.", conv1.equals(new Object()));
//noinspection ObjectEqualsNull
- Assert.assertFalse(conv1.equals(null));
+ Assert.assertFalse("A Converter must not be equal to null.", conv1.equals(null));
//noinspection EqualsBetweenInconvertibleTypes
- Assert.assertFalse(conv1.equals(conv3));
+ Assert.assertFalse("A Converter must not be equal to a Converter for a different type.", conv1.equals(conv3));
}
/** Tests that {@link ConstructorConverter#hashCode()} works.
@@ -82,7 +82,7 @@
public void testHashCode() throws Exception {
final ConstructorConverter<File> conv = new ConstructorConverter<File>(File.class);
final Constructor<File> constructor = File.class.getConstructor(String.class);
- Assert.assertEquals(conv.hashCode(), constructor.hashCode());
+ Assert.assertEquals("The hashCode of a ConstructorConverter must be the hashCode of the constructor used.", conv.hashCode(), constructor.hashCode());
}
/** Tests that {@link ConstructorConverter#getConstructor(Class)} works.
@@ -91,7 +91,7 @@
@Test
public void testGetConstructor() throws Exception {
final Constructor<File> constructor = ConstructorConverter.getConstructor(File.class);
- Assert.assertEquals(File.class.getConstructor(String.class), constructor);
+ Assert.assertEquals("The Constructor returned by a ConstructorConverter must be the correct Constructor.", File.class.getConstructor(String.class), constructor);
}
/** Tests that {@link ConstructorConverter#getConstructor(Class)} throws an Exception for non-public constructors.
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConverterRegistryTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConverterRegistryTest.java 2009-02-15 11:58:09 UTC (rev 868)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/ConverterRegistryTest.java 2009-02-15 11:58:33 UTC (rev 869)
@@ -120,7 +120,7 @@
@Test
public void testGetConstructorConverter() throws Exception {
Assert.assertEquals(new ConstructorConverter<String>(String.class), ConverterRegistry.getConstructorConverter(String.class));
- Assert.assertEquals(null, ConverterRegistry.getConstructorConverter(System.class));
+ Assert.assertNull(ConverterRegistry.getConstructorConverter(System.class));
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2009-02-21 20:44:07
|
Revision: 1005
http://japi.svn.sourceforge.net/japi/?rev=1005&view=rev
Author: christianhujer
Date: 2009-02-21 20:44:00 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Added unit tests to bring unit test coverage for ArgParser to 100% class, method and line coverage.
Modified Paths:
--------------
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/ArgParserTest.java
Added Paths:
-----------
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CharsetDispalynameComparatorTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CommandWithHelpTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.properties
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/LogCommandTest.java
Modified: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/ArgParserTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/ArgParserTest.java 2009-02-21 18:25:15 UTC (rev 1004)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/ArgParserTest.java 2009-02-21 20:44:00 UTC (rev 1005)
@@ -533,6 +533,23 @@
}
/**
+ * Tests that double-@ is unescaped to one single @.
+ * @throws RequiredOptionsMissingException (unexpected).
+ * @throws TerminalException (unexpected).
+ * @throws UnknownOptionException (unexpected).
+ * @throws MissingArgumentException (expected).
+ * @throws ArgumentFileNotFoundException (unexpected).
+ */
+ @Test
+ public void testDoubleAt() throws ArgumentFileNotFoundException, UnknownOptionException, MissingArgumentException, RequiredOptionsMissingException, TerminalException {
+ final MockCommand command = new MockCommand();
+ ArgParser.parseAndRun(command, "-i", "foo", "@@");
+ final List<String> args = command.getArgs();
+ Assert.assertEquals("Expecting '@' to be passed as argument.", 1, args.size());
+ Assert.assertEquals("Expecting '@' to be passed as argument.", "@", args.get(0));
+ }
+
+ /**
* This MockCommand serves as a command for performing simple tests.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CharsetDispalynameComparatorTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CharsetDispalynameComparatorTest.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CharsetDispalynameComparatorTest.java 2009-02-21 20:44:00 UTC (rev 1005)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 Christian Hujer.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package test.net.sf.japi.io.args;
+
+import java.nio.charset.Charset;
+import net.sf.japi.io.args.CharsetDisplaynameComparator;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link CharsetDisplaynameComparator}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class CharsetDispalynameComparatorTest {
+
+ /** Tests that {@link CharsetDisplaynameComparator#compare(Charset, Charset)} works. */
+ @Test
+ public void testCompare() {
+ @SuppressWarnings({"TypeMayBeWeakened"})
+ final CharsetDisplaynameComparator testling = new CharsetDisplaynameComparator();
+ final Charset charset1 = Charset.forName("utf-8");
+ final Charset charset2 = Charset.forName("iso-8859-1");
+ Assert.assertTrue("Expecting iso-8859-1 to be sorted before utf-8.", testling.compare(charset1, charset2) > 0);
+ }
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CharsetDispalynameComparatorTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CommandWithHelpTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CommandWithHelpTest.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CommandWithHelpTest.java 2009-02-21 20:44:00 UTC (rev 1005)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Christian Hujer.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package test.net.sf.japi.io.args;
+
+import java.util.List;
+import net.sf.japi.io.args.CommandWithHelp;
+import net.sf.japi.io.args.Command;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * TODO:2009-02-21:christianhujer:Documentation.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class CommandWithHelpTest {
+
+ /** Tests that {@link CommandWithHelp#isExiting()} returns <code>false</code>. */
+ @Test
+ public void testExiting() {
+ final Command testling = new CommandWithHelp() {
+ public int run(@NotNull final List<String> args) {
+ return 0;
+ }
+ };
+ Assert.assertFalse("Expecting a command to not be exiting by default.", testling.isExiting());
+ }
+
+ /** Tests that {@link CommandWithHelp#isCheckRequiredOptions()} returns <code>true</code>. */
+ @Test
+ public void testCheckRequiredOptions() {
+ final Command testling = new CommandWithHelp() {
+ public int run(@NotNull final List<String> args) {
+ return 0;
+ }
+ };
+ Assert.assertTrue("Expecting a command to be checking for required optinos by default.", testling.isCheckRequiredOptions());
+ }
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/CommandWithHelpTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.java 2009-02-21 20:44:00 UTC (rev 1005)
@@ -0,0 +1,17 @@
+package test.net.sf.japi.io.args;
+
+import net.sf.japi.io.args.LogCommand;
+import org.jetbrains.annotations.NotNull;
+import java.util.List;
+
+/**
+ * TODO:2009-02-21:christianhujer:Documentation.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+class DummyLogCommand extends LogCommand {
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> args) {
+ return 0;
+ }
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.properties
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.properties (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.properties 2009-02-21 20:44:00 UTC (rev 1005)
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2009 Christian Hujer.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/DummyLogCommand.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/LogCommandTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/LogCommandTest.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/LogCommandTest.java 2009-02-21 20:44:00 UTC (rev 1005)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 Christian Hujer.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package test.net.sf.japi.io.args;
+
+import net.sf.japi.io.args.LogCommand;
+import net.sf.japi.io.args.converter.LogLevelConverter;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link LogCommand}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class LogCommandTest {
+
+ /** Tests that a {@link LogCommand} has Logging.
+ * @throws Exception (unexpected)
+ */
+ @Test
+ public void testLogLevel() throws Exception {
+ final LogCommand testling = new DummyLogCommand();
+ Assert.assertNotNull("Expecting testling to have a log.", testling.getLog());
+ testling.setLevel(new LogLevelConverter().convert("FINEST"));
+ }
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/LogCommandTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|