1.1 --- a/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java Sun Jan 19 18:30:21 2014 +0100
1.2 +++ b/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java Mon Jan 20 00:05:23 2014 +0100
1.3 @@ -20,6 +20,7 @@
1.4 import info.globalcode.sql.dk.CLIParser.Tokens;
1.5 import static info.globalcode.sql.dk.CLIParser.TYPE_NAME_SEPARATOR;
1.6 import info.globalcode.sql.dk.InfoLister.InfoType;
1.7 +import java.io.ByteArrayInputStream;
1.8 import java.util.Collection;
1.9 import static org.testng.Assert.*;
1.10 import org.testng.annotations.BeforeMethod;
1.11 @@ -46,12 +47,16 @@
1.12 parser = new CLIParser();
1.13 }
1.14
1.15 + private CLIOptions parseOptions(String[] args) throws CLIParserException {
1.16 + return parser.parseOptions(args, new ByteArrayInputStream("".getBytes()));
1.17 + }
1.18 +
1.19 @Test
1.20 public void testParseOptions_QueryNow_NoParams() throws InvalidOptionsException, CLIParserException {
1.21 String[] args = new String[]{
1.22 Tokens.DB, DATABASE_NAME_1,
1.23 Tokens.SQL, SQL_1};
1.24 - CLIOptions options = parser.parseOptions(args);
1.25 + CLIOptions options = parseOptions(args);
1.26 options.validate();
1.27
1.28 assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
1.29 @@ -67,7 +72,7 @@
1.30 Tokens.DB, DATABASE_NAME_1,
1.31 Tokens.SQL, SQL_1,
1.32 Tokens.DATA, DATA_1, DATA_2, DATA_3};
1.33 - CLIOptions options = parser.parseOptions(args);
1.34 + CLIOptions options = parseOptions(args);
1.35 options.validate();
1.36
1.37 assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
1.38 @@ -89,7 +94,7 @@
1.39 Tokens.SQL, SQL_1,
1.40 Tokens.TYPES, " INTEGER,VARCHAR, BOOLEAN",
1.41 Tokens.DATA, DATA_1, DATA_2, DATA_3};
1.42 - CLIOptions options = parser.parseOptions(args);
1.43 + CLIOptions options = parseOptions(args);
1.44 options.validate();
1.45
1.46 assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
1.47 @@ -110,7 +115,7 @@
1.48 Tokens.DB, DATABASE_NAME_1,
1.49 Tokens.SQL, SQL_1,
1.50 Tokens.DATA_NAMED, NAME_1, DATA_1, NAME_2, DATA_2, NAME_3, DATA_3};
1.51 - CLIOptions options = parser.parseOptions(args);
1.52 + CLIOptions options = parseOptions(args);
1.53 options.validate();
1.54
1.55 assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
1.56 @@ -130,7 +135,7 @@
1.57 Tokens.NAME_PREFIX, "$",
1.58 Tokens.TYPES, " " + NAME_1 + TYPE_NAME_SEPARATOR + "INTEGER" + "," + NAME_3 + TYPE_NAME_SEPARATOR + "BOOLEAN",
1.59 Tokens.DATA_NAMED, NAME_1, DATA_1, NAME_2, DATA_2, NAME_3, DATA_3};
1.60 - CLIOptions options = parser.parseOptions(args);
1.61 + CLIOptions options = parseOptions(args);
1.62 options.validate();
1.63
1.64 assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
1.65 @@ -158,7 +163,7 @@
1.66 String[] args = new String[]{
1.67 Tokens.BATCH,
1.68 Tokens.SQL, SQL_1};
1.69 - CLIOptions options = parser.parseOptions(args);
1.70 + CLIOptions options = parseOptions(args);
1.71 options.validate();
1.72
1.73 assertEquals(options.getSql(), SQL_1);
1.74 @@ -170,7 +175,7 @@
1.75 String[] args = new String[]{
1.76 Tokens.BATCH,
1.77 Tokens.DB, DATABASE_NAME_1};
1.78 - CLIOptions options = parser.parseOptions(args);
1.79 + CLIOptions options = parseOptions(args);
1.80 options.validate();
1.81
1.82 assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
1.83 @@ -180,7 +185,7 @@
1.84 @Test
1.85 public void testParseOptions_ShowInfo_Help() throws InvalidOptionsException, CLIParserException {
1.86 String[] args = new String[]{Tokens.INFO_HELP};
1.87 - CLIOptions options = parser.parseOptions(args);
1.88 + CLIOptions options = parseOptions(args);
1.89 options.validate();
1.90
1.91 assertEquals(options.getMode(), CLIOptions.MODE.JUST_SHOW_INFO);