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
commit cf438ac229efe41f6e70779ab1cacb1caf1ecebe Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed Aug 19 13:07:12 2026 +0200 Avoid a test failure when the EPSG database is absent. Document the fact that the `DROP SCHEMA` statement is a workaround for HSQLDB. --- .../main/org/apache/sis/metadata/sql/MetadataSource.java | 1 + .../org/apache/sis/metadata/sql/internal/shared/ScriptRunner.java | 7 +++++++ .../test/org/apache/sis/referencing/CommonCRSTest.java | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java index d2dbe20537..968ba8b332 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/MetadataSource.java @@ -450,6 +450,7 @@ public class MetadataSource implements AutoCloseable { * * Maintenance note: this method is invoked by reflection in the {@code org.apache.sis.referencing.database} module. * If we make this method public in a future Apache SIS version, then we can remove the reflection code. + * For a public method, {@code installIfAbsent()} would be a better name. * * @throws SQLException if an error occurred while inserting the metadata. */ diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/ScriptRunner.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/ScriptRunner.java index 589d17723a..ba890fcdc3 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/ScriptRunner.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/internal/shared/ScriptRunner.java @@ -36,6 +36,7 @@ import java.sql.SQLException; import java.sql.DatabaseMetaData; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.CharSequences; +import org.apache.sis.util.Workaround; import org.apache.sis.util.internal.shared.Strings; import org.apache.sis.util.resources.Errors; @@ -176,7 +177,13 @@ public class ScriptRunner implements AutoCloseable { * Used for rolling back in case of failure. This is set to {@code null} after successful completion. * In principle, {@link Connection#rollback()} should be sufficient, but it appears to not be the case * with all databases. + * + * <p>This is a workaround for what seems to be a bug in <abbr>HSQLDB</abbr>, where + * {@link Connection#rollback()} does drop the schema created before the rollback.</p> + * + * @see <a href="https://sourceforge.net/p/hsqldb/bugs/1754/">Connection.rollback() does not remove schemas</a> */ + @Workaround(library = "HSQLDB", version = "2.7.4") private String schemaToDelete; /** diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java index c8fc3ba2fc..ee5e84f46f 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CommonCRSTest.java @@ -355,12 +355,14 @@ public final class CommonCRSTest extends TestCase { final ProjectedCRS crs = CommonCRS.WGS84.universal(45, 3); // UTM zone 31N. final IdentifiedObjectFinder finder = IdentifiedObjects.newFinder(Constants.EPSG); finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION); - assertSame(crs, finder.findSingleton(crs)); assertEquals(32631, IdentifiedObjects.lookupEPSG(crs)); + assertSame(crs, finder.findSingleton(crs)); final Conversion fromBase = crs.getConversionFromBase(); + final Integer code = IdentifiedObjects.lookupEPSG(fromBase); + assumeConnectionToEPSG(code != null); + assertEquals(16031, code); assertEqualsIgnoreMetadata(fromBase, finder.findSingleton(fromBase)); - assertEquals(16031, IdentifiedObjects.lookupEPSG(fromBase)); } /**
