first unit-test v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 15 Dec 2013 22:54:29 +0100
branchv_0
changeset 6 c79a5b030e99
parent 5 26223eb63851
child 7 a7555ec6eea9
first unit-test
java/sql-dk/nbproject/project.properties
java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java
--- a/java/sql-dk/nbproject/project.properties	Sun Dec 15 22:44:11 2013 +0100
+++ b/java/sql-dk/nbproject/project.properties	Sun Dec 15 22:54:29 2013 +0100
@@ -37,7 +37,8 @@
 javac.target=1.7
 javac.test.classpath=\
     ${javac.classpath}:\
-    ${build.classes.dir}
+    ${build.classes.dir}:\
+    ${libs.testng.classpath}
 javac.test.processorpath=\
     ${javac.test.classpath}
 javadoc.additionalparam=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java	Sun Dec 15 22:54:29 2013 +0100
@@ -0,0 +1,32 @@
+package info.globalcode.sql.dk;
+
+import info.globalcode.sql.dk.CLIParser.Tokens;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Ing. František Kučera (frantovo.cz)
+ */
+public class CLIParserTest {
+
+	public static final String DATABASE_NAME_1 = "some database 1";
+	public static final String SQL_1 = "SELECT * FROM table1";
+	private CLIParser parser;
+
+	@BeforeMethod
+	public void setUpMethod() throws Exception {
+		parser = new CLIParser();
+	}
+
+	@Test
+	public void testParseOptions() throws InvalidOptionsException {
+		String[] args = new String[]{Tokens.DB, DATABASE_NAME_1, Tokens.SQL, SQL_1};
+		CLIOptions options = parser.parseOptions(args);
+		options.validate();
+
+		assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
+		assertEquals(options.getSql(), SQL_1);
+	}
+}
\ No newline at end of file