[Japi-cvs] SF.net SVN: japi:[1005] libs/argparser/trunk/src/tst/test/net/sf/japi/io/ args
Status: Beta
Brought to you by:
christianhujer
|
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.
|