You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2024/08/12 15:58:50 UTC

(sis) branch geoapi-4.0 updated (3b047f32e1 -> 0046340d13)

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


    from 3b047f32e1 Add tests for the Geopackage module (work by Johann Sorel).
     new efce779d6d Document better the alternative way to enable tests on PostgreSQL, because setting properties on the Gradle command-line is not easy.
     new 0046340d13 Uncomment tests in optional modules, replaced by an `assumeDataPresent()`.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/sis/test/TestConfiguration.java     | 18 +++++++++++++++-
 optional/build.gradle.kts                          |  4 +++-
 .../resources/embedded/EmbeddedResourcesTest.java  | 25 +++++++++++++++++-----
 .../sis/referencing/factory/sql/epsg/README.md     |  3 ++-
 .../factory/sql/epsg/ScriptProviderTest.java       |  9 +++++++-
 5 files changed, 50 insertions(+), 9 deletions(-)


(sis) 02/02: Uncomment tests in optional modules, replaced by an `assumeDataPresent()`.

Posted by de...@apache.org.
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 <ma...@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.
      */


(sis) 01/02: Document better the alternative way to enable tests on PostgreSQL, because setting properties on the Gradle command-line is not easy.

Posted by de...@apache.org.
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 efce779d6dbf708dc7c9354b1bcb4a457082774b
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Aug 9 10:36:35 2024 +0200

    Document better the alternative way to enable tests on PostgreSQL,
    because setting properties on the Gradle command-line is not easy.
---
 .../test/org/apache/sis/test/TestConfiguration.java    | 18 +++++++++++++++++-
 .../apache/sis/referencing/factory/sql/epsg/README.md  |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestConfiguration.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestConfiguration.java
index fa56ccf190..941666aa51 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestConfiguration.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestConfiguration.java
@@ -28,7 +28,7 @@ public final class TestConfiguration extends Static {
     /**
      * Environment variable to use as a fallback if a system property is not set.
      * This is a comma-separated list of the following keywords, without spaces:
-     * {@code extensive}, {@code verbose}.
+     * {@code extensive}, {@code postgresql}, {@code widget}, {@code verbose}.
      *
      * @see TestCase#RUN_EXTENSIVE_TESTS
      * @see TestCase#VERBOSE
@@ -41,6 +41,10 @@ public final class TestConfiguration extends Static {
      * If this {@linkplain System#getProperties() system property} is set to {@code true},
      * then Apache SIS will run some tests which were normally skipped because they are slow.
      *
+     * <p>Alternatively, the extensive tests can also be enabled by setting the
+     * {@value #SIS_TEST_OPTIONS} environment variable to {@code "extensive"}.</p>
+     *
+     * @see #SIS_TEST_OPTIONS
      * @see TestCase#RUN_EXTENSIVE_TESTS
      */
     public static final String EXTENSIVE_TESTS_KEY = "org.apache.sis.test.extensive";
@@ -50,6 +54,10 @@ public final class TestConfiguration extends Static {
      * on the PostgreSQL database. If this {@linkplain System#getProperties() system property}
      * is set to {@code true}, then the {@code "SpatialMetadataTest"} database will be used.
      *
+     * <p>Alternatively, the tests on PostgreSQL can also be enabled by setting the
+     * {@value #SIS_TEST_OPTIONS} environment variable to {@code "postgresql"}.</p>
+     *
+     * @see #SIS_TEST_OPTIONS
      * @see TestCase#USE_POSTGRESQL
      * @see org.apache.sis.metadata.sql.TestDatabase
      */
@@ -60,6 +68,10 @@ public final class TestConfiguration extends Static {
      * If this {@linkplain System#getProperties() system property} is set to {@code true},
      * then the content sent to the {@link TestCase#out} field will be printed after each test.
      *
+     * <p>Alternatively, the verbose outputs can also be enabled by setting the
+     * {@value #SIS_TEST_OPTIONS} environment variable to {@code "verbose"}.</p>
+     *
+     * @see #SIS_TEST_OPTIONS
      * @see TestCase#VERBOSE
      */
     public static final String VERBOSE_OUTPUT_KEY = "org.apache.sis.test.verbose";
@@ -68,6 +80,10 @@ public final class TestConfiguration extends Static {
      * The {@systemProperty org.apache.sis.test.gui.show} system property
      * for enabling display of test images or widgets.
      *
+     * <p>Alternatively, the widgets display can also be enabled by setting the
+     * {@value #SIS_TEST_OPTIONS} environment variable to {@code "widget"}.</p>
+     *
+     * @see #SIS_TEST_OPTIONS
      * @see TestCase#SHOW_WIDGET
      */
     public static final String SHOW_WIDGET_KEY = "org.apache.sis.test.gui.show";
diff --git a/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md b/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md
index 42f030d594..017ec271ba 100644
--- a/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md
+++ b/optional/src/org.apache.sis.referencing.epsg/test/org/apache/sis/referencing/factory/sql/epsg/README.md
@@ -112,7 +112,8 @@ Then the whole Apache SIS project should be [tested extensively](https://sis.apa
 preferably with a PostgreSQL server ready to accept local connections to `SpatialMetadataTest` database:
 
 ```
-mvn install -Dorg.apache.sis.test.extensive=true
+EXPORT SIS_TEST_OPTIONS=extensive,postgresql
+gradle test
 ```
 
 Regenerate the HTML pages listing available CRS and coordinate operation methods.