use of org.apache.sis.internal.sql.feature.TableReference in project sis by apache.
the class SQLStoreTest method test.
/**
* Runs all tests on a single database software. A temporary schema is created at the beginning of this method
* and deleted after all tests finished. The schema is created and populated by the {@code Features.sql} script.
*
* @param inMemory whether the test database is in memory. If {@code true}, then the schema will be created
* and will be the only schema to exist (ignoring system schema); i.e. we assume that there
* is no ambiguity if we do not specify the schema in {@link SQLStore} constructor.
*/
private void test(final TestDatabase database, final boolean inMemory) throws Exception {
final String[] scripts = { "CREATE SCHEMA " + SCHEMA + ';', "file:Features.sql" };
if (!inMemory) {
// Omit the "CREATE SCHEMA" statement if the schema already exists.
scripts[0] = null;
}
try (TestDatabase tmp = database) {
// TODO: omit `tmp` with JDK16.
database.executeSQL(SQLStoreTest.class, scripts);
final StorageConnector connector = new StorageConnector(database.source);
final ResourceDefinition table = ResourceDefinition.table(null, inMemory ? null : SCHEMA, "Cities");
testTableQuery(connector, table);
/*
* Verify using SQL statements instead of tables.
*/
verifyFetchCityTableAsQuery(connector);
verifyNestedSQLQuery(connector);
verifyLimitOffsetAndColumnSelectionFromQuery(connector);
verifyDistinctQuery(connector);
/*
* Test on the table again, but with cyclic associations enabled.
*/
connector.setOption(SchemaModifier.OPTION, new SchemaModifier() {
@Override
public boolean isCyclicAssociationAllowed(TableReference dependency) {
return true;
}
});
isCyclicAssociationAllowed = true;
testTableQuery(connector, table);
}
}
Aggregations