Author: desruisseaux
Date: Tue Sep 30 17:12:38 2025
New Revision: 1928865

Log:
Add a test case for an example given on the web site which was not working.

Added:
   
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ExamplesTest.java
      - copied, changed from r1928851, 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java
Modified:
   
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java

Modified: 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java
==============================================================================
--- 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java
     Tue Sep 30 13:35:55 2025        (r1928864)
+++ 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java
     Tue Sep 30 17:12:38 2025        (r1928865)
@@ -66,6 +66,7 @@ public class ConnectionTest {
 
     /**
      * Tests fetching a CRS from an EPSG code, formatting to WKT, then parsing 
the WKT.
+     * This method tests both the connection and Apache SIS self-consistency.
      *
      * @throws FactoryException if the CRS can not be obtained.
      */

Copied and modified: 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ExamplesTest.java
 (from r1928851, 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java)
==============================================================================
--- 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ConnectionTest.java
     Mon Sep 29 22:34:27 2025        (r1928851, copy source)
+++ 
sis/release-test/maven/with-epsg-embedded/src/test/java/org/apache/sis/test/ExamplesTest.java
       Tue Sep 30 17:12:38 2025        (r1928865)
@@ -16,63 +16,53 @@
  */
 package org.apache.sis.test;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.SQLException;
-import org.apache.derby.jdbc.EmbeddedDataSource;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.util.FactoryException;
 import org.apache.sis.referencing.CRS;
-import org.apache.sis.util.Utilities;
+import org.apache.sis.referencing.IdentifiedObjects;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 /**
- * Tests the connection to the embedded database.
+ * Tests some of the examples documented on the web site.
+ * The example files are hard-coded rather than downloaded.
  */
-public class ConnectionTest {
+public class ExamplesTest {
     /**
-     * Verifies that the embedded resource is reachable.
-     *
-     * @throws IOException if an error occurred while checking the file 
content.
-     */
-    @Test
-    public void verifyResource() throws IOException {
-        String file = 
"META-INF/SIS_DATA/Databases/spatial-metadata/service.properties";
-        try (InputStream stream = 
ClassLoader.getSystemClassLoader().getResourceAsStream(file)) {
-            assertNotNull(stream, "File not found: " + file);
-            assertEquals('#', stream.read());
-        }
-    }
-
-    /**
-     * Tries a connection to the embedded database.
-     *
-     * @throws SQLException if an error occurred while connecting to the 
database.
-     */
-    @Test
-    public void verifyConnection() throws SQLException {
-        var ds = new EmbeddedDataSource();
-        ds.setDatabaseName("classpath:SIS_DATA/Databases/spatial-metadata");
-        try (Connection c = ds.getConnection()) {
-            c.setSchema("EPSG");
-        }
-    }
-
-    /**
-     * Tests fetching a CRS from an EPSG code, formatting to WKT, then parsing 
the WKT.
+     * Tests the {@code MissingIdentifier.wkt} example.
      *
      * @throws FactoryException if the CRS can not be obtained.
      */
     @Test
-    public void testParseWKT() throws FactoryException {
-        CoordinateReferenceSystem crs = CRS.forCode("EPSG::6676");
-        CoordinateReferenceSystem roundTrip = CRS.fromWKT(crs.toWKT());
-        assertTrue(Utilities.equalsIgnoreMetadata(crs, roundTrip));
+    public void testMissingIdentifier() throws FactoryException {
+        CoordinateReferenceSystem crs = CRS.fromWKT(
+                "PROJCRS[\"NTF (Paris) / zone to be discovered by the 
demo\",\n"
+                + "  BASEGEODCRS[\"Bla (Paris)\",\n"
+                + "    DATUM[\"Nouvelle Triangulation Francaise\",\n"
+                + "      ELLIPSOID[\"Clarke 1880 (IGN)\", 6378249.2, 
293.4660212936269]],\n"
+                + "      PRIMEM[\"Paris\", 2.5969213],\n"
+                + "    UNIT[\"grade\", 0.015707963267948967]],\n"
+                + "  CONVERSION[\"Lambert zone II\",\n"
+                + "    METHOD[\"Lambert Conic Conformal (1SP)\"],\n"
+                + "    PARAMETER[\"Latitude of natural origin\", 52.0, 
UNIT[\"grade\", 0.015707963267948967]],\n"
+                + "    PARAMETER[\"Longitude of natural origin\", 0.0],\n"
+                + "    PARAMETER[\"Scale factor at natural origin\", 
0.99987742],\n"
+                + "    PARAMETER[\"False easting\", 600000.0],\n"
+                + "    PARAMETER[\"False northing\", 2200000.0]],\n"
+                + "  CS[Cartesian, 2],\n"
+                + "    AXIS[\"Easting (E)\", east],\n"
+                + "    AXIS[\"Northing (N)\", north],\n"
+                + "    LENGTHUNIT[\"metre\", 1],\n"
+                + "  SCOPE[\"Large and medium scale topographic mapping and 
engineering survey.\"],\n"
+                + "  AREA[\"France mainland onshore between 50.5 grads and 
53.5 grads North.\"],\n"
+                + "  BBOX[42.33, -4.87, 51.14, 8.23],\n"
+                + "  REMARK[\"In this example, the EPSG:27572 identifier has 
been intentionally omitted.\"]]");
+
+        String identifier = IdentifiedObjects.lookupURN(crs, null);
+        assertNotNull(identifier);
+        assertTrue(identifier.endsWith(":27572"), identifier);
     }
 }

Reply via email to