This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 0046340d138b96d3a739bbe297550e72d23d17dd Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Aug 5 16:25:22 2024 +0200 Uncomment tests in optional modules, replaced by an `assumeDataPresent()`. --- optional/build.gradle.kts | 4 +++- .../resources/embedded/EmbeddedResourcesTest.java | 25 +++++++++++++++++----- .../factory/sql/epsg/ScriptProviderTest.java | 9 +++++++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/optional/build.gradle.kts b/optional/build.gradle.kts index 3c820e1655..156e99e056 100644 --- a/optional/build.gradle.kts +++ b/optional/build.gradle.kts @@ -92,7 +92,6 @@ tasks.compileTestJava { srcDir.list().forEach { addRead(options.compilerArgs, it, "org.apache.sis.test.optional,org.junit.jupiter.api") } - addRead(options.compilerArgs, "org.apache.sis.referencing.database", "org.apache.sis.referencing.epsg"); } /* @@ -130,6 +129,9 @@ fun patchForTests(args : MutableList<String>) { patchModuleWithTests(args, "org.apache.sis.util") patchModuleWithTests(args, "org.apache.sis.metadata") patchModuleWithTests(args, "org.apache.sis.feature") + + addRead(args, "org.apache.sis.referencing.database", "org.apache.sis.referencing.epsg"); + // ――――――――――――― Module name ――――――――――――――――――――――― Package to export ――――――――――――――― addExport(args, "org.apache.sis.util", "org.apache.sis.test", "org.apache.sis.gui," + diff --git a/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java b/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java index 4809fbd9e9..80e2813ab1 100644 --- a/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java +++ b/optional/src/org.apache.sis.referencing.database/test/org/apache/sis/resources/embedded/EmbeddedResourcesTest.java @@ -49,13 +49,25 @@ public final strictfp class EmbeddedResourcesTest { private static boolean databaseCreated; /** - * Returns the {@link EmbeddedResources} instance declared in the {@code META-INF/services/} directory. - * The provider may coexist with providers defined in other modules, so we need to filter them. + * Creates a new test case. */ - private static synchronized InstallationResources getInstance() { + public EmbeddedResourcesTest() { + } + + /** + * Skips the test if the EPSG scripts are not present. + * This method uses {@code LICENSE.txt} as a sentinel file. + */ + private static void assumeDataPresent() { assumeTrue(ScriptProvider.class.getResource("LICENSE.txt") != null, "EPSG resources not found. See `README.md` for manual installation."); + } + /** + * Returns the {@link EmbeddedResources} instance declared in the {@code META-INF/services/} directory. + * The provider may coexist with providers defined in other modules, so we need to filter them. + */ + private static synchronized InstallationResources getInstance() { if (!databaseCreated) try { new Generator().run(); databaseCreated = true; @@ -79,8 +91,9 @@ public final strictfp class EmbeddedResourcesTest { * * @throws IOException if an error occurred while reading a license. */ -// @Test + @Test public void testLicences() throws IOException { + assumeDataPresent(); final InstallationResources provider = getInstance(); assertTrue(provider.getLicense("Embedded", null, "text/plain").contains("IOGP")); assertTrue(provider.getLicense("Embedded", null, "text/html" ).contains("IOGP")); @@ -91,8 +104,9 @@ public final strictfp class EmbeddedResourcesTest { * * @throws Exception if an error occurred while fetching the data source, or connecting to the database. */ -// @Test + @Test public void testConnection() throws Exception { + assumeDataPresent(); final String dir = DataDirectory.getenv(); assertTrue((dir == null) || dir.isEmpty(), "The SIS_DATA environment variable must be unset for enabling this test."); final DataSource ds = Initializer.getDataSource(); @@ -118,6 +132,7 @@ public final strictfp class EmbeddedResourcesTest { */ @Test public void testCrsforCode() throws FactoryException { + assumeDataPresent(); CoordinateReferenceSystem crs = CRS.forCode("EPSG:6676"); String area = TestUtilities.getSingleton(crs.getDomains()).getDomainOfValidity().getDescription().toString(); assertTrue(area.contains("Japan"), area); diff --git a/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/ScriptProviderTest.java b/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/ScriptProviderTest.java index 111bdd6474..0758110649 100644 --- a/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/ScriptProviderTest.java +++ b/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/ScriptProviderTest.java @@ -33,6 +33,12 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; * @author Martin Desruisseaux (Geomatys) */ public final strictfp class ScriptProviderTest { + /** + * Creates a new test case. + */ + public ScriptProviderTest() { + } + /** * Returns the {@link ScriptProvider} instance declared in the {@code META-INF/services/} directory. * The provider may coexist with providers defined in other modules, so we need to filter them. @@ -65,7 +71,8 @@ public final strictfp class ScriptProviderTest { } /** - * Tests fetching the resources. + * Tests fetching the resources. This test does not execute the scripts. + * It only verifies that if the sentinel file exists, then all resources exist and are non-empty. * * @throws IOException if an error occurred while reading a resource. */