use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class EPSGInstallerTest method testCreationOnHSQLDB.
/**
* Tests the creation of an EPSG database on HSQLDB.
* This test is skipped if the SQL scripts are not found.
*
* @throws Exception if an error occurred while creating the database.
*/
@Test
public void testCreationOnHSQLDB() throws Exception {
// Needs to be invoked first.
final InstallationScriptProvider scripts = getScripts();
try (TestDatabase db = TestDatabase.createOnHSQLDB("EPSGInstaller", false)) {
createAndTest(db.source, scripts);
verifyParameterValues(db.source);
}
loggings.assertNextLogContains("EPSG", "jdbc:hsqldb:mem:EPSGInstaller");
loggings.assertNoUnexpectedLog();
}
use of org.apache.sis.test.sql.TestDatabase in project sis by apache.
the class SelectionClauseWriterTest method testOnDerby.
/**
* Tests on Derby.
*
* @throws Exception if an error occurred while testing the database.
*/
@Test
public void testOnDerby() throws Exception {
try (TestDatabase db = TestDatabase.create("SQLStore")) {
db.executeSQL(SelectionClauseWriterTest.class, "CREATE TABLE TEST (ALPHA INTEGER, BETA INTEGER, GAMMA INTEGER, PI FLOAT);");
final StorageConnector connector = new StorageConnector(db.source);
connector.setOption(SchemaModifier.OPTION, this);
try (DataStore store = new SQLStoreProvider().open(connector)) {
table = (Table) store.findResource("TEST");
testSimpleFilter();
testGeometricFilter();
testGeometricFilterWithTransform();
}
}
}
use of org.apache.sis.test.sql.TestDatabase 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