[Japi-cvs] SF.net SVN: japi:[1004] libs/argparser/trunk/src/tst/test/net/sf/japi/io/ args/converter
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2009-02-21 18:25:25
|
Revision: 1004
http://japi.svn.sourceforge.net/japi/?rev=1004&view=rev
Author: christianhujer
Date: 2009-02-21 18:25:15 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Added unit tests to bring unit test coverage for ArgParser to 100% class, method and line coverage.
Added Paths:
-----------
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/InputStreamConverterTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/LogLevelConverterTest.java
libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/OutputStreamConverterTest.java
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/InputStreamConverterTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/InputStreamConverterTest.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/InputStreamConverterTest.java 2009-02-21 18:25:15 UTC (rev 1004)
@@ -0,0 +1,65 @@
+/*
+ * 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.converter;
+
+import java.io.InputStream;
+import junit.framework.Assert;
+import net.sf.japi.io.args.converter.InputStreamConverter;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link InputStreamConverter}.
+ *
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>.
+ */
+public class InputStreamConverterTest {
+
+ /** Tests that {@link InputStreamConverter#convert(String)} works with "-".
+ * @throws Exception (unexpected).
+ */
+ @Test
+ public void testStdin() throws Exception {
+ final InputStreamConverter testling = new InputStreamConverter();
+ Assert.assertEquals("Conversion of \"-\" must return System.in.", System.in, testling.convert("-"));
+ }
+
+ /** Tests that {@link InputStreamConverter#convert(String)} works with a URL.
+ * @throws Exception (unexpected).
+ */
+ @Test
+ public void testUrl() throws Exception {
+ final InputStreamConverter testling = new InputStreamConverter();
+ // TODO:2009-02-21:christianhujer:Choose a better resource.
+ final InputStream in = testling.convert("http://www.w3.org/");
+ Assert.assertNotNull("Expecting InputStream.", in);
+ // TODO:2009-02-21:christianhujer:Verify resource contents.
+ }
+
+ /** Tests that {@link InputStreamConverter#convert(String)} works with a filename.
+ * @throws Exception (unexpected).
+ */
+ @Test
+ public void testFile() throws Exception {
+ final InputStreamConverter testling = new InputStreamConverter();
+ // TODO:2009-02-21:christianhujer:Choose a better file.
+ final InputStream in = testling.convert(".svn/entries");
+ Assert.assertNotNull("Expecting InputStream.", in);
+ // TODO:2009-02-21:christianhujer:Verify file contents.
+ }
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/InputStreamConverterTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/LogLevelConverterTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/LogLevelConverterTest.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/LogLevelConverterTest.java 2009-02-21 18:25:15 UTC (rev 1004)
@@ -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.converter;
+
+import java.util.logging.Level;
+import junit.framework.Assert;
+import net.sf.japi.io.args.converter.LogLevelConverter;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link LogLevelConverter}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class LogLevelConverterTest {
+
+ /** Tests that {@link LogLevelConverter#convert(String)} works.
+ * @throws Exception (unexpected).
+ */
+ @Test
+ public void testConvert() throws Exception {
+ final LogLevelConverter testling = new LogLevelConverter();
+ final Level logLevel = testling.convert("FINEST");
+ Assert.assertEquals("Expecting \"FINEST\"", Level.FINEST, logLevel);
+ }
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/LogLevelConverterTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/OutputStreamConverterTest.java
===================================================================
--- libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/OutputStreamConverterTest.java (rev 0)
+++ libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/OutputStreamConverterTest.java 2009-02-21 18:25:15 UTC (rev 1004)
@@ -0,0 +1,53 @@
+/*
+ * 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.converter;
+
+import java.io.OutputStream;
+import junit.framework.Assert;
+import net.sf.japi.io.args.converter.OutputStreamConverter;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link OutputStreamConverter}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class OutputStreamConverterTest {
+
+ /** Tests that {@link OutputStreamConverter#convert(String)} works with "-".
+ * @throws Exception (unexpected).
+ */
+ @Test
+ public void testStdin() throws Exception {
+ final OutputStreamConverter testling = new OutputStreamConverter();
+ Assert.assertEquals("Conversion of \"-\" must return System.out.", System.out, testling.convert("-"));
+ }
+
+ /** Tests that {@link OutputStreamConverter#convert(String)} works with a filename.
+ * @throws Exception (unexpected).
+ */
+ @Test
+ public void testFile() throws Exception {
+ final OutputStreamConverter testling = new OutputStreamConverter();
+ // TODO:2009-02-21:christianhujer:Choose a better file.
+ final OutputStream in = testling.convert("foo.txt");
+ Assert.assertNotNull("Expecting OutputStream.", in);
+ // TODO:2009-02-21:christianhujer:Write to file then verify file contents.
+ }
+
+}
Property changes on: libs/argparser/trunk/src/tst/test/net/sf/japi/io/args/converter/OutputStreamConverterTest.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.
|