Revision: 9323
http://languagetool.svn.sourceforge.net/languagetool/?rev=9323&view=rev
Author: dnaber
Date: 2013-02-07 22:12:49 +0000 (Thu, 07 Feb 2013)
Log Message:
-----------
adding test (from old source trunk)
Modified Paths:
--------------
trunk/languagetool/languagetool-commandline/pom.xml
Added Paths:
-----------
trunk/languagetool/languagetool-commandline/src/test/
trunk/languagetool/languagetool-commandline/src/test/java/
trunk/languagetool/languagetool-commandline/src/test/java/org/
trunk/languagetool/languagetool-commandline/src/test/java/org/languagetool/
trunk/languagetool/languagetool-commandline/src/test/java/org/languagetool/commandline/
trunk/languagetool/languagetool-commandline/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
Modified: trunk/languagetool/languagetool-commandline/pom.xml
===================================================================
--- trunk/languagetool/languagetool-commandline/pom.xml 2013-02-07 21:44:20 UTC
(rev 9322)
+++ trunk/languagetool/languagetool-commandline/pom.xml 2013-02-07 22:12:49 UTC
(rev 9323)
@@ -74,6 +74,13 @@
<artifactId>language-all</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Copied:
trunk/languagetool/languagetool-commandline/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
(from rev 9047,
trunk/JLanguageTool/src/test/java/org/languagetool/commandline/CommandLineParserTest.java)
===================================================================
---
trunk/languagetool/languagetool-commandline/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
(rev 0)
+++
trunk/languagetool/languagetool-commandline/src/test/java/org/languagetool/commandline/CommandLineParserTest.java
2013-02-07 22:12:49 UTC (rev 9323)
@@ -0,0 +1,75 @@
+/* LanguageTool, a natural language style checker
+ * Copyright (C) 2012 Daniel Naber (http://www.danielnaber.de)
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+package org.languagetool.commandline;
+
+import junit.framework.TestCase;
+
+public class CommandLineParserTest extends TestCase {
+
+ public void testUsage() throws Exception {
+ final CommandLineParser parser = new CommandLineParser();
+ try {
+ parser.parseOptions(new String[]{});
+ fail();
+ } catch (WrongParameterNumberException expected) {}
+
+ final CommandLineOptions commandLineOptions = parser.parseOptions(new
String[]{"--help"});
+ assertTrue(commandLineOptions.isPrintUsage());
+ }
+
+ public void testErrors() throws Exception {
+ final CommandLineParser parser = new CommandLineParser();
+ try {
+ parser.parseOptions(new String[]{"--apply", "--taggeronly"});
+ fail();
+ } catch (IllegalArgumentException expected) {}
+ }
+
+ public void testSimple() throws Exception {
+ final CommandLineParser parser = new CommandLineParser();
+ CommandLineOptions options;
+
+ options = parser.parseOptions(new String[]{"filename.txt"});
+ assertNull(options.getLanguage());
+ assertEquals("filename.txt", options.getFilename());
+ assertFalse(options.isVerbose());
+
+ options = parser.parseOptions(new String[]{"--language", "de",
"filename.txt"});
+ assertEquals("de", options.getLanguage().getShortName());
+ assertEquals("filename.txt", options.getFilename());
+ assertFalse(options.isVerbose());
+
+ options = parser.parseOptions(new String[]{"-l", "de", "filename.txt"});
+ assertEquals("de", options.getLanguage().getShortName());
+ assertEquals("filename.txt", options.getFilename());
+ assertFalse(options.isVerbose());
+
+ options = parser.parseOptions(new String[]{"-v", "-l", "de",
"filename.txt"});
+ assertEquals("de", options.getLanguage().getShortName());
+ assertEquals("filename.txt", options.getFilename());
+ assertTrue(options.isVerbose());
+
+ options = parser.parseOptions(new String[]{"--version"});
+ assertTrue(options.isPrintVersion());
+
+ options = parser.parseOptions(new String[]{"--list"});
+ assertTrue(options.isPrintLanguages());
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits