This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new b8c492eb52 Prepare for the replacement of Derby by H2 or HSQL as the
default database engine. We will test with HSQL first (in a next commit) and H2
after.
b8c492eb52 is described below
commit b8c492eb522e43a92b6b17d0c911ac232a130c7a
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Aug 17 18:41:36 2026 +0200
Prepare for the replacement of Derby by H2 or HSQL as the default database
engine.
We will test with HSQL first (in a next commit) and H2 after.
---
.../sis/metadata/sql/internal/shared/Dialect.java | 8 +++
.../sis/metadata/sql/IdentifierGeneratorTest.java | 1 +
.../sis/metadata/sql/MetadataFallbackVerifier.java | 1 +
.../sis/metadata/sql/MetadataSourceTest.java | 15 ++++-
.../sis/metadata/sql/MetadataWriterTest.java | 55 ++++++++++-------
.../org/apache/sis/metadata/sql/TestDatabase.java | 20 +++++-
.../sql/internal/shared/ScriptRunnerTest.java | 21 ++++++-
.../referencing/factory/sql/EPSGInstallerTest.java | 2 +-
.../apache/sis/storage/sql/SimpleFeatureStore.java | 1 +
.../apache/sis/storage/sql/feature/Analyzer.java | 17 +++++-
.../org/apache/sis/storage/sql/DataAccessTest.java | 17 +++++-
.../apache/sis/storage/sql/TestOnAllDatabases.java | 3 +-
.../sql/feature/SelectionClauseWriterTest.java | 71 +++++++++++++++++-----
13 files changed, 184 insertions(+), 48 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/Dialect.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/Dialect.java
index 3c3c50b804..adbf5d1e63 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/Dialect.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/Dialect.java
@@ -61,6 +61,14 @@ public enum Dialect {
| Supports.CONCURRENCY
| Supports.JAVA_TIME),
+ /**
+ * The database uses H2 syntax. It supports a set of features similar to
{@link #HSQL}.
+ */
+ H2("h2", Supports.ALTER_TABLE_WITH_ADD_CONSTRAINT
+ | Supports.READ_ONLY_UPDATE
+ | Supports.CONCURRENCY
+ | Supports.JAVA_TIME),
+
/**
* The database uses PostgreSQL syntax. This is ANSI, but provided an a
separated
* enumeration value because it allows a few additional commands like
{@code VACUUM}.
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java
index a96de6e515..77d29552ea 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/IdentifierGeneratorTest.java
@@ -32,6 +32,7 @@ import org.apache.sis.test.TestCase;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class IdentifierGeneratorTest extends TestCase {
/**
* The name of the table to be created for testing purpose.
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
index f7ab444833..1c5dceea07 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataFallbackVerifier.java
@@ -42,6 +42,7 @@ import org.opengis.metadata.citation.Responsibility;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class MetadataFallbackVerifier {
/**
* Identifier for which {@link MetadataFallback} does not provide
hard-coded values.
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
index 6fb2e59dbb..f2d9c49fee 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataSourceTest.java
@@ -51,6 +51,19 @@ public final class MetadataSourceTest extends TestCase {
public MetadataSourceTest() {
}
+ /**
+ * Tests {@link MetadataSource} with the default database engine used by
Apache <abbr>SIS</abbr>.
+ * This method delegates its work to all other methods in this class that
expect a {@link MetadataSource} argument.
+ *
+ * @throws Exception if an error occurred while executing the script
runner.
+ */
+ @Test
+ public void testOnDefault() throws Exception {
+ try (TestDatabase db = TestDatabase.create("MetadataSource")) {
+ testAll(db);
+ }
+ }
+
/**
* Tests {@link MetadataSource} with an in-memory Derby database.
* This method delegates its work to all other methods in this class that
expect a {@link MetadataSource} argument.
@@ -59,7 +72,7 @@ public final class MetadataSourceTest extends TestCase {
*/
@Test
public void testOnDerby() throws Exception {
- try (TestDatabase db = TestDatabase.create("MetadataSource")) {
+ try (TestDatabase db = TestDatabase.createOnDerby("MetadataSource")) {
testAll(db);
}
}
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
index baaaf055aa..cba11a4616 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/MetadataWriterTest.java
@@ -60,22 +60,26 @@ public final class MetadataWriterTest extends TestCase {
}
/**
- * Runs all tests on Derby in the required order.
+ * Runs all tests on the default database engine in the required order.
*
* @throws Exception if an error occurred while writing or reading the
database.
*/
@Test
- public void testDerby() throws Exception {
+ public void testOnDefault() throws Exception {
try (final TestDatabase db = TestDatabase.create("MetadataWriter")) {
- source = new MetadataWriter(MetadataStandard.ISO_19115, db.source,
null, null);
- try {
- write();
- search();
- read();
- readWriteDeprecated();
- } finally {
- source.close();
- }
+ run(db, null);
+ }
+ }
+
+ /**
+ * Runs all tests on Derby in the required order.
+ *
+ * @throws Exception if an error occurred while writing or reading the
database.
+ */
+ @Test
+ public void testOnDerby() throws Exception {
+ try (final TestDatabase db =
TestDatabase.createOnDerby("MetadataWriter")) {
+ run(db, null);
}
}
@@ -87,17 +91,26 @@ public final class MetadataWriterTest extends TestCase {
*/
@Test
@ResourceLock(TestDatabase.POSTGRESQL)
- public void testPostgreSQL() throws Exception {
+ public void testOnPostgreSQL() throws Exception {
try (final TestDatabase db =
TestDatabase.createOnPostgreSQL("MetadataWriter", true)) {
- source = new MetadataWriter(MetadataStandard.ISO_19115, db.source,
"MetadataWriter", null);
- try {
- write();
- search();
- read();
- readWriteDeprecated();
- } finally {
- source.close();
- }
+ run(db, "MetadataWriter");
+ }
+ }
+
+ /**
+ * Runs all tests in the required order.
+ *
+ * @throws Exception if an error occurred while writing or reading the
database.
+ */
+ private void run(final TestDatabase db, final String schema) throws
Exception {
+ source = new MetadataWriter(MetadataStandard.ISO_19115, db.source,
schema, null);
+ try {
+ write();
+ search();
+ read();
+ readWriteDeprecated();
+ } finally {
+ source.close();
}
}
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/TestDatabase.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/TestDatabase.java
index bbaeff6718..17a86b73b8 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/TestDatabase.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/TestDatabase.java
@@ -113,6 +113,7 @@ public class TestDatabase implements AutoCloseable {
* The SQL flavor used by the database, or {@code ANSI} if unspecified.
* May be used for identifying the database software.
*/
+ @SuppressWarnings("exports")
public final Dialect dialect;
/**
@@ -124,21 +125,34 @@ public class TestDatabase implements AutoCloseable {
}
/**
- * Creates a temporary database. This method creates a Derby in-memory
database by default,
- * but this default can be changed by setting the {@link #TEST_DATABASE}
hard-coded value.
+ * Creates a temporary database using the default database engine.
+ * This default can be changed by setting the {@link #TEST_DATABASE}
hard-coded value.
* See class javadoc if there is a need to inspect content of that
in-memory database.
*
* <p>The given database name shall be unique, for allowing parallel
execution of tests.
* This is often the name of the test class without the {@code Test}
suffix.</p>
*
* @param name the database name (without {@code "memory:"} prefix).
- * @return connection to the test database (usually on Apache Derby).
+ * @return connection to the test database.
* @throws SQLException if an error occurred while creating the database.
*/
public static TestDatabase create(final String name) throws SQLException {
if (TEST_DATABASE != null) {
return new TestDatabase(TEST_DATABASE, Dialect.ANSI);
}
+ return createOnHSQLDB(name, false);
+ }
+
+ /**
+ * Creates a temporary in-memory database using Derby.
+ * The given database name shall be unique, for allowing parallel
execution of tests.
+ * This is often the name of the test class without the {@code Test}
suffix.
+ *
+ * @param name the database name (without {@code "memory:"} prefix).
+ * @return connection to the test database on Apache Derby.
+ * @throws SQLException if an error occurred while creating the database.
+ */
+ public static TestDatabase createOnDerby(final String name) throws
SQLException {
final var ds = new EmbeddedDataSource();
ds.setDatabaseName("memory:" + name);
ds.setDataSourceName("Apache SIS test database");
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/internal/shared/ScriptRunnerTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/internal/shared/ScriptRunnerTest.java
index c54bd45a21..ecceff1bf7 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/internal/shared/ScriptRunnerTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/sql/internal/shared/ScriptRunnerTest.java
@@ -39,6 +39,23 @@ public final class ScriptRunnerTest extends TestCase {
public ScriptRunnerTest() {
}
+ /**
+ * Tests {@link ScriptRunner} with the default database engine used by
Apache <abbr>SIS</abbr>.
+ * This method delegates its work to all other methods in this class that
expect a {@link ScriptRunner} argument.
+ *
+ * @throws SQLException if an error occurred while executing the script
runner.
+ */
+ @Test
+ public void testOnDefault() throws SQLException {
+ try (TestDatabase db = TestDatabase.create("ScriptRunner");
+ Connection c = db.source.getConnection())
+ {
+ final var sr = new ScriptRunner(c, null, 3);
+ testSupportedFlags(sr);
+ testRegularExpressions(sr);
+ }
+ }
+
/**
* Tests {@link ScriptRunner} with an in-memory Derby database.
* This method delegates its work to all other methods in this class that
expect a {@link ScriptRunner} argument.
@@ -47,10 +64,10 @@ public final class ScriptRunnerTest extends TestCase {
*/
@Test
public void testOnDerby() throws SQLException {
- try (TestDatabase db = TestDatabase.create("ScriptRunner");
+ try (TestDatabase db = TestDatabase.createOnDerby("ScriptRunner");
Connection c = db.source.getConnection())
{
- final ScriptRunner sr = new ScriptRunner(c, null, 3);
+ final var sr = new ScriptRunner(c, null, 3);
testSupportedFlags(sr);
testRegularExpressions(sr);
}
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
index bd4bcc8e48..b0409290f8 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
@@ -103,7 +103,7 @@ public final class EPSGInstallerTest extends
TestCaseWithLogs {
public void testCreationOnDerby() throws Exception {
assumeExtensiveTestsEnabled();
final InstallationScriptProvider scripts = getScripts(); //
Needs to be invoked first.
- try (TestDatabase db = TestDatabase.create("EPSGInstaller")) {
+ try (TestDatabase db = TestDatabase.createOnDerby("EPSGInstaller")) {
createAndTest(db.source, scripts);
verifyParameterValues(db.source);
}
diff --git
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SimpleFeatureStore.java
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SimpleFeatureStore.java
index eb32c98b8e..0cde41b9b2 100644
---
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SimpleFeatureStore.java
+++
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SimpleFeatureStore.java
@@ -26,6 +26,7 @@ import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreProvider;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.FeatureSet;
+import org.apache.sis.storage.IllegalNameException;
import org.apache.sis.util.ArgumentChecks;
diff --git
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Analyzer.java
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Analyzer.java
index d75423fe43..f713e6dc63 100644
---
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Analyzer.java
+++
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Analyzer.java
@@ -17,6 +17,7 @@
package org.apache.sis.storage.sql.feature;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
@@ -104,18 +105,23 @@ public final class Analyzer {
*/
private final String[] tableTypes;
+ /**
+ * Names of schemas to ignore.
+ */
+ private final Set<String> ignoredSchemas;
+
/**
* Names of tables to ignore. This map includes at least the tables
defined by the spatial
* schema standard for storing geometry columns, spatial reference
systems, <i>etc</i>.
* The values tell whether the associated table exists in the database.
*/
- private final Map<String,Boolean> ignoredTables;
+ private final Map<String, Boolean> ignoredTables;
/**
* All tables created by analysis of the database structure. A {@code
null} value means that the table
* is in process of being created. This may happen if there is cyclic
dependencies between tables.
*/
- private final Map<GenericName,Table> featureTables;
+ private final Map<GenericName, Table> featureTables;
/**
* Warnings found while analyzing a database structure. Duplicated
warnings are omitted.
@@ -194,6 +200,10 @@ public final class Analyzer {
case DUCKDB: database = new DuckDB<> (source, metadata,
dialect, g, contentLocale, listeners, locks); break;
default: database = new Database<>(source, metadata,
dialect, g, contentLocale, listeners, locks); break;
}
+ switch (dialect) {
+ case H2: ignoredSchemas =
Collections.singleton("INFORMATION_SCHEMA"); break;
+ default: ignoredSchemas = Collections.emptySet(); break; //
Need an implementation which accepts null.
+ }
ignoredTables = database.detectSpatialSchema(metadata, tableTypes);
}
@@ -233,6 +243,9 @@ public final class Analyzer {
final String[] names = TableReference.splitName(tableName);
try (ResultSet reflect = metadata.getTables(names[2], names[1],
names[0], tableTypes)) {
while (reflect.next()) {
+ if
(ignoredSchemas.contains(reflect.getString(Reflection.TABLE_SCHEM))) {
+ continue;
+ }
final String table = getUniqueString(reflect,
Reflection.TABLE_NAME);
if (ignoredTables.containsKey(table)) {
continue;
diff --git
a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/DataAccessTest.java
b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/DataAccessTest.java
index c7613f18b5..8f5f367224 100644
---
a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/DataAccessTest.java
+++
b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/DataAccessTest.java
@@ -33,6 +33,7 @@ import org.apache.sis.storage.sql.feature.InfoStatementsTest;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class DataAccessTest extends TestCase {
/**
* Creates a new test case.
@@ -40,6 +41,18 @@ public final class DataAccessTest extends TestCase {
public DataAccessTest() {
}
+ /**
+ * Tests on the default database engine used by Apache <abbr>SIS</abbr>.
+ *
+ * @throws Exception if an error occurred while testing the database.
+ */
+ @Test
+ public void testOnDefault() throws Exception {
+ try (TestDatabase database = TestDatabase.create("SQL-DataAccess")) {
+ test(database);
+ }
+ }
+
/**
* Tests on Derby.
*
@@ -47,7 +60,7 @@ public final class DataAccessTest extends TestCase {
*/
@Test
public void testOnDerby() throws Exception {
- try (TestDatabase database = TestDatabase.create("SQL-DataAccess")) {
+ try (TestDatabase database =
TestDatabase.createOnDerby("SQL-DataAccess")) {
test(database);
}
}
@@ -60,7 +73,7 @@ public final class DataAccessTest extends TestCase {
*/
private void test(final TestDatabase database) throws Exception {
database.executeSQL(List.of(InfoStatementsTest.createSpatialRefSys()));
- try (SQLStore store = new SimpleFeatureStore(null, new
StorageConnector(database.source), ResourceDefinition.table("%"));
+ try (var store = new SimpleFeatureStore(null, new
StorageConnector(database.source), ResourceDefinition.table("%"));
DataAccess dao = store.newDataAccess(true))
{
assertEquals(4326, dao.findSRID(HardCodedCRS.WGS84));
diff --git
a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/TestOnAllDatabases.java
b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/TestOnAllDatabases.java
index 88457e760a..5d58f2014f 100644
---
a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/TestOnAllDatabases.java
+++
b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/TestOnAllDatabases.java
@@ -28,6 +28,7 @@ import org.apache.sis.metadata.sql.TestDatabase;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public abstract class TestOnAllDatabases extends TestCase {
/**
* The schema where will be stored the features to test.
@@ -48,7 +49,7 @@ public abstract class TestOnAllDatabases extends TestCase {
@Test
@ResourceLock("SQLStore-Derby")
public void testOnDerby() throws Exception {
- try (TestDatabase database = TestDatabase.create("SQLStore")) {
+ try (TestDatabase database = TestDatabase.createOnDerby("SQLStore")) {
test(database, true);
}
}
diff --git
a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
index 5e58eb45e5..c2228a056e 100644
---
a/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
+++
b/endorsed/src/org.apache.sis.storage.sql/test/org/apache/sis/storage/sql/feature/SelectionClauseWriterTest.java
@@ -19,7 +19,6 @@ package org.apache.sis.storage.sql.feature;
import java.util.List;
import org.apache.sis.geometry.GeneralEnvelope;
import org.apache.sis.storage.StorageConnector;
-import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.sql.SQLStoreProvider;
import org.apache.sis.feature.builder.AttributeTypeBuilder;
import org.apache.sis.feature.builder.FeatureTypeBuilder;
@@ -42,7 +41,7 @@ import org.opengis.filter.SpatialOperator;
/**
- * Tests the formatting of {@link Filter} as a SQL {@code WHERE} statement
body.
+ * Tests the formatting of {@link Filter} as a <abbr>SQL</abbr> {@code WHERE}
statement body.
*
* @author Alexis Manin (Geomatys)
* @author Martin Desruisseaux (Geomatys)
@@ -58,6 +57,11 @@ public final class SelectionClauseWriterTest extends
TestCase implements SchemaM
*/
private Table table;
+ /**
+ * The catalog and schema where the tables are expected to be found.
+ */
+ private String expectedCatalog, expectedSchema;
+
/**
* Creates a new test.
*/
@@ -65,6 +69,34 @@ public final class SelectionClauseWriterTest extends
TestCase implements SchemaM
FF = DefaultFilterFactory.forFeatures();
}
+ /**
+ * Tests on <abbr>H2</abbr> database.
+ *
+ * @throws Exception if an error occurred while testing the database.
+ */
+ @Test
+ public void testOnH2() throws Exception {
+ expectedCatalog = "SELECTIONCLAUSE";
+ expectedSchema = "PUBLIC";
+ try (TestDatabase db = TestDatabase.createOnH2("SelectionClause")) {
+ run(db);
+ }
+ }
+
+ /**
+ * Tests on <abbr>HSQL</abbr> database.
+ *
+ * @throws Exception if an error occurred while testing the database.
+ */
+ @Test
+ public void testOnHSQLDB() throws Exception {
+ expectedCatalog = "PUBLIC";
+ expectedSchema = "PUBLIC";
+ try (TestDatabase db = TestDatabase.createOnHSQLDB("SelectionClause",
false)) {
+ run(db);
+ }
+ }
+
/**
* Tests on Derby.
*
@@ -72,16 +104,25 @@ public final class SelectionClauseWriterTest extends
TestCase implements SchemaM
*/
@Test
public void testOnDerby() throws Exception {
- try (TestDatabase db = TestDatabase.create("SelectionClause")) {
- db.executeSQL(List.of("CREATE TABLE TEST (ALPHA INTEGER, BETA
INTEGER, GAMMA INTEGER, PI FLOAT);"));
- final var connector = new StorageConnector(db.source);
- connector.setOption(SchemaModifier.OPTION_KEY, this);
- try (DataStore store = new SQLStoreProvider().open(connector)) {
- table = (Table) store.findResource("TEST");
- testSimpleFilter();
- testGeometricFilter();
- testGeometricFilterWithTransform();
- }
+ expectedCatalog = "";
+ expectedSchema = "APP";
+ try (TestDatabase db = TestDatabase.createOnDerby("SelectionClause")) {
+ run(db);
+ }
+ }
+
+ /**
+ * Tests the creation of a table.
+ */
+ private void run(final TestDatabase db) throws Exception {
+ db.executeSQL(List.of("CREATE TABLE TEST (ALPHA INTEGER, BETA INTEGER,
GAMMA INTEGER, PI FLOAT);"));
+ final var connector = new StorageConnector(db.source);
+ connector.setOption(SchemaModifier.OPTION_KEY, this);
+ try (var store = new SQLStoreProvider().open(connector)) {
+ table = assertInstanceOf(Table.class, store.findResource("TEST"));
+ testSimpleFilter();
+ testGeometricFilter();
+ testGeometricFilterWithTransform();
}
}
@@ -115,10 +156,10 @@ public final class SelectionClauseWriterTest extends
TestCase implements SchemaM
*/
@Override
public FeatureType editFeatureType(final TableReference table, final
FeatureTypeBuilder feature) {
- assertEquals("", table.catalog);
- assertEquals("APP", table.schema);
+ assertEquals(expectedCatalog, table.catalog);
+ assertEquals(expectedSchema, table.schema);
assertEquals("TEST", table.table);
- ((AttributeTypeBuilder<?>)
feature.getProperty("BETA")).setCRS(HardCodedCRS.WGS84);
+ assertInstanceOf(AttributeTypeBuilder.class,
feature.getProperty("BETA")).setCRS(HardCodedCRS.WGS84);
return feature.build();
}