}
return;
}
IDatabaseConnection connection = testContext.getConnection();
for (int i = annotations.size() - 1; i >= 0; i--) {
ExpectedDatabase annotation = annotations.get(i);
String query = annotation.query();
String table = annotation.table();
IDataSet expectedDataSet = loadDataset(testContext, annotation.value());
if (expectedDataSet != null) {
if (logger.isDebugEnabled()) {
logger.debug("Veriftying @DatabaseTest expectation using " + annotation.value());
}
DatabaseAssertion assertion = annotation.assertionMode().getDatabaseAssertion();
if (StringUtils.hasLength(query)) {
Assert.hasLength(table, "The table name must be specified when using a SQL query");
ITable expectedTable = expectedDataSet.getTable(table);
ITable actualTable = connection.createQueryTable(table, query);
assertion.assertEquals(expectedTable, actualTable);
} else if (StringUtils.hasLength(table)) {
ITable actualTable = connection.createTable(table);
ITable expectedTable = expectedDataSet.getTable(table);
assertion.assertEquals(expectedTable, actualTable);
} else {
IDataSet actualDataSet = connection.createDataSet();
assertion.assertEquals(expectedDataSet, actualDataSet);
}
}
if (annotation.override()) {
// No need to test any more
return;
}
}