1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sun Dec 15 23:58:58 2013 +0100
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Mon Dec 16 00:05:30 2013 +0100
1.3 @@ -39,7 +39,7 @@
1.4 case Tokens.TYPES:
1.5 String typesString = fetchNext(args, ++i);
1.6
1.7 - for (String oneType : typesString.split("\\s*,\\s*")) {
1.8 + for (String oneType : typesString.split(",")) {
1.9 int sepatratorIndex = oneType.indexOf(TYPE_NAME_SEPARATOR);
1.10 if (sepatratorIndex == -1) {
1.11 numberedTypes.add(getType(oneType));
1.12 @@ -127,7 +127,7 @@
1.13 }
1.14
1.15 private int getType(String typeString) throws CLIParserException {
1.16 - Integer type = types.get(typeString);
1.17 + Integer type = types.get(typeString.trim());
1.18 if (type == null) {
1.19 throw new CLIParserException("Unsupported type: " + typeString);
1.20 } else {
2.1 --- a/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java Sun Dec 15 23:58:58 2013 +0100
2.2 +++ b/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java Mon Dec 16 00:05:30 2013 +0100
2.3 @@ -1,6 +1,7 @@
2.4 package info.globalcode.sql.dk;
2.5
2.6 import info.globalcode.sql.dk.CLIParser.Tokens;
2.7 +import java.sql.Types;
2.8 import static org.testng.Assert.*;
2.9 import org.testng.annotations.BeforeMethod;
2.10 import org.testng.annotations.Test;
2.11 @@ -42,6 +43,28 @@
2.12 }
2.13
2.14 @Test
2.15 + public void testParseOptions_QueryNow_Numbered_withTypes() throws InvalidOptionsException, CLIParserException {
2.16 + String[] args = new String[]{
2.17 + Tokens.DB, DATABASE_NAME_1,
2.18 + Tokens.SQL, SQL_1,
2.19 + Tokens.TYPES, " int,string, boolean",
2.20 + Tokens.DATA, DATA_1, DATA_2, DATA_3};
2.21 + CLIOptions options = parser.parseOptions(args);
2.22 + options.validate();
2.23 +
2.24 + assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
2.25 + assertEquals(options.getSql(), SQL_1);
2.26 + assertEquals(options.getMode(), CLIOptions.MODE.QUERY_NOW);
2.27 + assertEquals(options.getNumberedParameters().size(), 3);
2.28 + assertEquals(options.getNumberedParameters().get(0).getValue(), DATA_1);
2.29 + assertEquals(options.getNumberedParameters().get(1).getValue(), DATA_2);
2.30 + assertEquals(options.getNumberedParameters().get(2).getValue(), DATA_3);
2.31 + assertEquals(options.getNumberedParameters().get(0).getType(), Types.INTEGER);
2.32 + assertEquals(options.getNumberedParameters().get(1).getType(), Types.VARCHAR);
2.33 + assertEquals(options.getNumberedParameters().get(2).getType(), Types.BOOLEAN);
2.34 + }
2.35 +
2.36 + @Test
2.37 public void testParseOptions_QueryNow_Named() throws InvalidOptionsException, CLIParserException {
2.38 String[] args = new String[]{Tokens.DB, DATABASE_NAME_1, Tokens.SQL, SQL_1};
2.39 CLIOptions options = parser.parseOptions(args);