org.unitils.database.sqlassert
Class SqlAssert

java.lang.Object
  extended by org.unitils.database.sqlassert.SqlAssert

public abstract class SqlAssert
extends Object

Assertion class to verify content in the database, by specifying your own SQL and checking the result. todo td refactor

Author:
Jeroen Horemans

Constructor Summary
SqlAssert()
           
 
Method Summary
static void assertCountSqlResult(String sql, DataSource dataSource, Long countResult)
          The SQL given should only return one row with one column, this column should be a number (preferred a count(*)).
static void assertCountSqlResult(String sql, Long countResult)
          The SQL given should only return one row with one column, this column should be a number (preferred a count(*)).
static void assertMultipleRowSqlResult(String sql, DataSource dataSource, String[]... rows)
          To be successful the result of the SQL should return as many rows as the two dimensional array has, each row should be identical to the given parameter.
static void assertMultipleRowSqlResult(String sql, String[]... rows)
          To be succesfull the result of the SQL should return as many rows as the two dimensional arrey has, each row should be identical to the given parameter.
static void assertSingleRowSqlResult(String sql, DataSource dataSource, String[] row)
          To be successful the result of the SQL should only return one row, this row should be identical to the given parameter.
static void assertSingleRowSqlResult(String sql, String[] row)
          To be succesfull the result of the SQL should only return one row, this row should be identical to the given parameter.
protected static String[][] getItemAsString(String sql, DataSource dataSource, Integer columnCount)
          Returns the value extracted from the result of the given query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlAssert

public SqlAssert()
Method Detail

assertSingleRowSqlResult

public static void assertSingleRowSqlResult(String sql,
                                            String[] row)
To be succesfull the result of the SQL should only return one row, this row should be identical to the given parameter. The sequence of the values is not important. The datasource will be fetched from the database module of unitils (DatabaseModule).

Parameters:
sql -
row -

assertMultipleRowSqlResult

public static void assertMultipleRowSqlResult(String sql,
                                              String[]... rows)
To be succesfull the result of the SQL should return as many rows as the two dimensional arrey has, each row should be identical to the given parameter. The sequence of the values is not important nor is the order of the rows. The datasource will be fetched from the database module of unitils (DatabaseModule).

Parameters:
sql -
rows -

assertCountSqlResult

public static void assertCountSqlResult(String sql,
                                        Long countResult)
The SQL given should only return one row with one column, this column should be a number (preferred a count(*)). The result is asserted with the countResult parameter. The datasource will be fetched from the database module of unitils (DatabaseModule).

Parameters:
sql -
countResult -

assertSingleRowSqlResult

public static void assertSingleRowSqlResult(String sql,
                                            DataSource dataSource,
                                            String[] row)
To be successful the result of the SQL should only return one row, this row should be identical to the given parameter. The sequence of the values is not important.

Parameters:
sql -
dataSource -
row -

assertMultipleRowSqlResult

public static void assertMultipleRowSqlResult(String sql,
                                              DataSource dataSource,
                                              String[]... rows)
To be successful the result of the SQL should return as many rows as the two dimensional array has, each row should be identical to the given parameter. The sequence of the values is not important nor the order of the rows.

Parameters:
sql -
dataSource -
rows -

assertCountSqlResult

public static void assertCountSqlResult(String sql,
                                        DataSource dataSource,
                                        Long countResult)
The SQL given should only return one row with one column, this column should be a number (preferred a count(*)). The result is asserted with the countResult parameter.

Parameters:
sql -
dataSource -
countResult -

getItemAsString

protected static String[][] getItemAsString(String sql,
                                            DataSource dataSource,
                                            Integer columnCount)
Returns the value extracted from the result of the given query. If no value is found, a UnitilsException is thrown.

Parameters:
sql - The sql string for retrieving the items
dataSource - The data source, not null
Returns:
The string item value


Copyright © 2011. All Rights Reserved.