more unit-tests v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 15 Dec 2013 23:54:37 +0100
branchv_0
changeset 7a7555ec6eea9
parent 6 c79a5b030e99
child 8 4507cb9a0cf1
more unit-tests
java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java
     1.1 --- a/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java	Sun Dec 15 22:54:29 2013 +0100
     1.2 +++ b/java/sql-dk/test/info/globalcode/sql/dk/CLIParserTest.java	Sun Dec 15 23:54:37 2013 +0100
     1.3 @@ -11,8 +11,11 @@
     1.4   */
     1.5  public class CLIParserTest {
     1.6  
     1.7 -	public static final String DATABASE_NAME_1 = "some database 1";
     1.8 -	public static final String SQL_1 = "SELECT * FROM table1";
     1.9 +	private static final String DATABASE_NAME_1 = "some database 1";
    1.10 +	private static final String SQL_1 = "SELECT * FROM table1";
    1.11 +	private static final String DATA_1 = "aaa";
    1.12 +	private static final String DATA_2 = "bbb";
    1.13 +	private static final String DATA_3 = "ccc";
    1.14  	private CLIParser parser;
    1.15  
    1.16  	@BeforeMethod
    1.17 @@ -21,12 +24,51 @@
    1.18  	}
    1.19  
    1.20  	@Test
    1.21 -	public void testParseOptions() throws InvalidOptionsException {
    1.22 -		String[] args = new String[]{Tokens.DB, DATABASE_NAME_1, Tokens.SQL, SQL_1};
    1.23 +	public void testParseOptions_QueryNow_Numbered() throws InvalidOptionsException {
    1.24 +		String[] args = new String[]{Tokens.DB, DATABASE_NAME_1, Tokens.SQL, SQL_1, Tokens.DATA, DATA_1, DATA_2, DATA_3};
    1.25  		CLIOptions options = parser.parseOptions(args);
    1.26  		options.validate();
    1.27  
    1.28  		assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
    1.29  		assertEquals(options.getSql(), SQL_1);
    1.30 +		assertEquals(options.getMode(), CLIOptions.MODE.QUERY_NOW);
    1.31 +		assertEquals(options.getNumberedParameters().size(), 3);
    1.32 +		assertEquals(options.getNumberedParameters().get(0).getValue(), DATA_1);
    1.33 +		assertEquals(options.getNumberedParameters().get(1).getValue(), DATA_2);
    1.34 +		assertEquals(options.getNumberedParameters().get(2).getValue(), DATA_3);
    1.35 +		assertEquals(options.getNumberedParameters().get(0).getType(), Parameter.DEFAULT_TYPE);
    1.36 +		assertEquals(options.getNumberedParameters().get(1).getType(), Parameter.DEFAULT_TYPE);
    1.37 +		assertEquals(options.getNumberedParameters().get(2).getType(), Parameter.DEFAULT_TYPE);
    1.38 +	}
    1.39 +
    1.40 +	@Test
    1.41 +	public void testParseOptions_QueryNow_Named() throws InvalidOptionsException {
    1.42 +		String[] args = new String[]{Tokens.DB, DATABASE_NAME_1, Tokens.SQL, SQL_1, Tokens.TYPES};
    1.43 +		CLIOptions options = parser.parseOptions(args);
    1.44 +		options.validate();
    1.45 +
    1.46 +		assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
    1.47 +		assertEquals(options.getSql(), SQL_1);
    1.48 +		assertEquals(options.getMode(), CLIOptions.MODE.QUERY_NOW);
    1.49 +	}
    1.50 +
    1.51 +	@Test
    1.52 +	public void testParseOptions_PrepareBatch() throws InvalidOptionsException {
    1.53 +		String[] args = new String[]{Tokens.BATCH, Tokens.SQL, SQL_1};
    1.54 +		CLIOptions options = parser.parseOptions(args);
    1.55 +		options.validate();
    1.56 +
    1.57 +		assertEquals(options.getSql(), SQL_1);
    1.58 +		assertEquals(options.getMode(), CLIOptions.MODE.PREPARE_BATCH);
    1.59 +	}
    1.60 +
    1.61 +	@Test
    1.62 +	public void testParseOptions_ExecuteBatch() throws InvalidOptionsException {
    1.63 +		String[] args = new String[]{Tokens.BATCH, Tokens.DB, DATABASE_NAME_1};
    1.64 +		CLIOptions options = parser.parseOptions(args);
    1.65 +		options.validate();
    1.66 +
    1.67 +		assertEquals(options.getDatabaseName(), DATABASE_NAME_1);
    1.68 +		assertEquals(options.getMode(), CLIOptions.MODE.EXECUTE_BATCH);
    1.69  	}
    1.70  }
    1.71 \ No newline at end of file