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 b3bd3bc4af Reduce the number of constructors of `GridFile` to one. The 
intend is to have a single place where to validate URIs.
b3bd3bc4af is described below

commit b3bd3bc4af7f756779893f169d4fd292580002c1
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Sep 19 12:01:16 2026 +0900

    Reduce the number of constructors of `GridFile` to one.
    The intend is to have a single place where to validate URIs.
---
 .../referencing/operation/gridded/GridFile.java    | 60 ++++-------------
 .../provider/FranceGeocentricInterpolation.java    | 10 +--
 .../sis/referencing/operation/provider/NADCON.java |  6 +-
 .../sis/referencing/operation/provider/NTv2.java   |  2 +-
 .../transform/InterpolatedGeocentricTransform.java |  4 +-
 .../InterpolatedGeocentricTransform2D.java         |  2 +-
 .../operation/provider/DatumShiftTestCase.java     | 67 -------------------
 .../FranceGeocentricInterpolationTest.java         | 75 ++++++++++++++++++----
 .../referencing/operation/provider/NADCONTest.java | 45 ++++++++++++-
 .../referencing/operation/provider/NTv2Test.java   | 44 +++++++++++--
 .../InterpolatedGeocentricTransformTest.java       |  5 +-
 .../transform/InterpolatedTransformTest.java       |  7 +-
 .../sis/test/integration/DatumShiftTest.java       |  8 ++-
 13 files changed, 180 insertions(+), 155 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/gridded/GridFile.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/gridded/GridFile.java
index f3d2e53c4b..f8bd80929a 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/gridded/GridFile.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/gridded/GridFile.java
@@ -61,9 +61,11 @@ public final class GridFile {
     private static final AtomicBoolean datumDirectoryLogged = new 
AtomicBoolean();
 
     /**
-     * The directory where to search for a local copy of the data, or {@code 
null} if none.
+     * Returns the directory where to search for a local copy of the data.
      */
-    private final DataDirectory localDirectory;
+    private static DataDirectory localDirectory() {
+        return DataDirectory.DATUM_CHANGES;
+    }
 
     /**
      * The URI specified in the parameter. This URI is usually relative to an 
unspecified directory.
@@ -87,18 +89,6 @@ public final class GridFile {
      */
     private Path asPath;
 
-    /**
-     * Creates a file for the given URI, assumed already resolved.
-     * This constructor is for testing purposes.
-     *
-     * @param  resolved  the resolved URI.
-     */
-    public GridFile(final URI resolved) {
-        parameter = resolved;
-        this.resolved = resolved;
-        localDirectory = DataDirectory.DATUM_CHANGES;
-    }
-
     /**
      * Resolves the given parameter as an absolute URI, resolved in the {@code 
"$SIS_DATA/DatumChanges"} directory
      * if the URI is relative. If the URI cannot be resolved, a {@link 
MissingFactoryResourceException} is thrown.
@@ -112,27 +102,7 @@ public final class GridFile {
      * @throws MissingFactoryResourceException if the path cannot be resolved.
      */
     public GridFile(final Parameters group, final ParameterDescriptor<URI> 
param) throws MissingFactoryResourceException {
-        this(group, param, DataDirectory.DATUM_CHANGES);
-    }
-
-    /**
-     * Resolves the given parameter as an absolute URI, resolved with the 
specified {@code DataDirectory}
-     * if the URI is relative. If the URI cannot be resolved, a {@link 
MissingFactoryResourceException} is thrown.
-     * That exception type is necessary for letting the caller know that a 
coordinate operation is probably valid
-     * but cannot be constructed because an optional configuration is missing.
-     * It is typically because the {@code SIS_DATA} environment variable has 
not been set.
-     *
-     * @param  group           the group of parameters from which to get the 
URI.
-     * @param  param           identification of the parameter to fetch.
-     * @param  localDirectory  the directory where to search for a local copy 
of the data, or {@code null} if none.
-     * @throws ParameterNotFoundException if the specified parameter is not 
found in the given group.
-     * @throws MissingFactoryResourceException if the path cannot be resolved.
-     */
-    public GridFile(final Parameters group, final ParameterDescriptor<URI> 
param, final DataDirectory localDirectory)
-            throws MissingFactoryResourceException
-    {
         RuntimeException error = null;
-        this.localDirectory = localDirectory;
         parameter = group.getMandatoryValue(param);
         if (parameter.isAbsolute()) {
             resolved = parameter.normalize();
@@ -142,17 +112,15 @@ public final class GridFile {
              * That directory can be seen as a cache to be tried before to 
download data that may be
              * on the network.
              */
-            if (localDirectory != null) {
-                base = localDirectory.getDirectoryAsURI();
-                if (base != null) try {
-                    resolved = base.resolve(parameter).normalize();
-                    asPath = Path.of(resolved);
-                    if (Files.exists(asPath)) {
-                        return;
-                    }
-                } catch (IllegalArgumentException | 
FileSystemNotFoundException e) {
-                    error = e;
+            base = localDirectory().getDirectoryAsURI();
+            if (base != null) try {
+                resolved = base.resolve(parameter).normalize();
+                asPath = Path.of(resolved);
+                if (Files.exists(asPath)) {
+                    return;
                 }
+            } catch (IllegalArgumentException | FileSystemNotFoundException e) 
{
+                error = e;
             }
             /*
              * If the "$SIS_DATA/DatumChanges" directory cannot be used, check 
if we
@@ -276,8 +244,8 @@ public final class GridFile {
      * @param  cause   the cause of the failure to load the grid file.
      */
     public FactoryException canNotLoad(final Class<?> caller, final String 
format, final Exception cause) {
-        if (localDirectory != null && !datumDirectoryLogged.get()) {
-            final Path directory = localDirectory.getDirectory();
+        if (!datumDirectoryLogged.get()) {
+            final Path directory = localDirectory().getDirectory();
             if (directory != null && !datumDirectoryLogged.getAndSet(true)) {
                 GridLoader.log(caller, 
Resources.forLocale(null).createLogRecord(Level.INFO,
                                        Resources.Keys.DatumChangesDirectory_1, 
directory));
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java
index b5f2f11a8a..5f32bd89c9 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolation.java
@@ -281,7 +281,7 @@ public final class FranceGeocentricInterpolation extends 
AbstractProvider {
         final Parameters pg = 
Parameters.castOrWrap(context.getCompletedParameters());
         final int dim = pg.getValue(Molodensky.DIMENSION);
         final GridFile file = new GridFile(pg, FILE);
-        final LoadedGrid<Angle,Length> grid;
+        final LoadedGrid<Angle, Length> grid;
         try {
             grid = getOrLoad(file, isRecognized(file) ? new double[] {TX, TY, 
TZ} : null, PRECISION);
         } catch (FactoryException e) {
@@ -321,7 +321,7 @@ public final class FranceGeocentricInterpolation extends 
AbstractProvider {
      *
      * @see GridLoader#canNotLoad(Class, String, URI, Exception)
      */
-    static LoadedGrid<Angle,Length> getOrLoad(final GridFile file, final 
double[] averages, final double scale)
+    static LoadedGrid<Angle, Length> getOrLoad(final GridFile file, final 
double[] averages, final double scale)
             throws Exception
     {
         return LoadedGrid.getOrLoad(file, null, new Loader(file, averages, 
scale))
@@ -363,7 +363,7 @@ public final class FranceGeocentricInterpolation extends 
AbstractProvider {
             final LoadedGrid<?,?> grid;
             try (BufferedReader in = file.newBufferedReader()) {
                 file.startLoading(FranceGeocentricInterpolation.class);
-                final LoadedGrid.Float<Angle,Length> g = load(in, file);
+                final LoadedGrid.Float<Angle, Length> g = load(in, file);
                 grid = CompressedGrid.compress(g, averages, scale);
             }
             return grid.useSharedData();
@@ -380,10 +380,10 @@ public final class FranceGeocentricInterpolation extends 
AbstractProvider {
          * @throws FactoryException if an problem is found with the file 
content.
          * @throws ArithmeticException if the width or the height exceed the 
integer capacity.
          */
-        static LoadedGrid.Float<Angle,Length> load(final BufferedReader in, 
final GridFile file)
+        static LoadedGrid.Float<Angle, Length> load(final BufferedReader in, 
final GridFile file)
                 throws IOException, FactoryException, 
NoninvertibleTransformException
         {
-            LoadedGrid.Float<Angle,Length> grid = null;
+            LoadedGrid.Float<Angle, Length> grid = null;
             double x0 = 0;
             double xf = 0;
             double y0 = 0;
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java
index 646c8ff8d8..39abed6781 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NADCON.java
@@ -79,7 +79,7 @@ public final class NADCON extends AbstractProvider {
      *   <li>Default value: {@code conus.las}</li>
      * </ul>
      */
-    private static final ParameterDescriptor<URI> LATITUDE;
+    public static final ParameterDescriptor<URI> LATITUDE;
 
     /**
      * The operation parameter descriptor for the <q>Longitude difference 
file</q> parameter value.
@@ -95,12 +95,12 @@ public final class NADCON extends AbstractProvider {
      *   <li>Default value: {@code conus.los}</li>
      * </ul>
      */
-    private static final ParameterDescriptor<URI> LONGITUDE;
+    public static final ParameterDescriptor<URI> LONGITUDE;
 
     /**
      * The group of all parameters expected by this coordinate operation.
      */
-    private static final ParameterDescriptorGroup PARAMETERS;
+    static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
         LATITUDE = builder
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java
index 7d6cb44ef2..9a15b6f4b5 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/NTv2.java
@@ -90,7 +90,7 @@ public final class NTv2 extends AbstractProvider {
     /**
      * The group of all parameters expected by this coordinate operation.
      */
-    private static final ParameterDescriptorGroup PARAMETERS;
+    static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
         FILE = builder
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
index 249c127ac8..64103f2586 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform.java
@@ -203,7 +203,7 @@ public class InterpolatedGeocentricTransform extends 
DatumShiftTransform {
      */
     protected InterpolatedGeocentricTransform(final Ellipsoid source, final 
boolean isSource3D,
                                               final Ellipsoid target, final 
boolean isTarget3D,
-                                              final 
DatumShiftGrid<Angle,Length> grid)
+                                              final DatumShiftGrid<Angle, 
Length> grid)
     {
         this(source, isSource3D, target, isTarget3D, grid, null);
     }
@@ -341,7 +341,7 @@ public class InterpolatedGeocentricTransform extends 
DatumShiftTransform {
     public static MathTransform createGeodeticTransformation(final 
MathTransformFactory factory,
             final Ellipsoid source, final boolean isSource3D,
             final Ellipsoid target, final boolean isTarget3D,
-            final DatumShiftGrid<Angle,Length> grid) throws FactoryException
+            final DatumShiftGrid<Angle, Length> grid) throws FactoryException
     {
         final InterpolatedGeocentricTransform tr;
         if (isSource3D || isTarget3D) {
diff --git 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java
 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java
index ac4f52a918..e27513c563 100644
--- 
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java
+++ 
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java
@@ -41,7 +41,7 @@ final class InterpolatedGeocentricTransform2D extends 
InterpolatedGeocentricTran
     /**
      * Constructs a 2D transform.
      */
-    InterpolatedGeocentricTransform2D(final Ellipsoid source, final Ellipsoid 
target, final DatumShiftGrid<Angle,Length> grid) {
+    InterpolatedGeocentricTransform2D(final Ellipsoid source, final Ellipsoid 
target, final DatumShiftGrid<Angle, Length> grid) {
         super(source, false, target, false, grid);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/DatumShiftTestCase.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/DatumShiftTestCase.java
deleted file mode 100644
index 71c006484c..0000000000
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/DatumShiftTestCase.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sis.referencing.operation.provider;
-
-import java.net.URI;
-import java.net.URL;
-import java.net.URISyntaxException;
-import org.apache.sis.referencing.operation.gridded.GridFile;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.TestCase;
-
-
-/**
- * Base class of tests that need to load a datum shift grid. This base class 
provides a
- * {@link #getResourceAsConvertibleURL(String)} method for fetching the data 
in a form
- * convertible to {@link URI}.
- *
- * @author  Martin Desruisseaux (Geomatys)
- */
-public abstract class DatumShiftTestCase extends TestCase {
-    /**
-     * For subclass constructors only.
-     */
-    DatumShiftTestCase() {
-    }
-
-    /**
-     * Finds resource of the given name as a URL convertible to a {@link URI}.
-     * If the URL is not convertible, then this method declares the test as 
ignored.
-     *
-     * @param  name  name of the resource to get.
-     * @return the requested resources.
-     */
-    public static URL getResourceAsConvertibleURL(final String name) {
-        final URL file = DatumShiftTestCase.class.getResource(name);
-        assertNotNull(file, () -> "Test file \"" + name + "\" not found.");
-        assertFalse("jar".equals(file.getProtocol()), "Cannot read grid data 
in a JAR file.");
-        return file;
-    }
-
-    /**
-     * Finds resource of the given name as an URI. If the resource cannot be 
obtained because
-     * the grid file is inside a JAR file, declares the test as ignored 
instead of failed.
-     *
-     * @param  name  name of the resource to get.
-     * @return the requested resources.
-     */
-    static GridFile getResource(final String name) throws URISyntaxException {
-        return new GridFile(getResourceAsConvertibleURL(name).toURI());
-    }
-}
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
index 70c569b1c7..889d460104 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/FranceGeocentricInterpolationTest.java
@@ -16,8 +16,9 @@
  */
 package org.apache.sis.referencing.operation.provider;
 
-import java.net.URISyntaxException;
+import java.net.URL;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.io.BufferedReader;
 import java.io.IOException;
 import javax.measure.quantity.Angle;
@@ -28,10 +29,13 @@ import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.referencing.operation.gridded.GridFile;
 import org.apache.sis.referencing.operation.gridded.LoadedGrid;
 import org.apache.sis.referencing.operation.gridded.CompressedGrid;
+import org.apache.sis.referencing.factory.MissingFactoryResourceException;
+import org.apache.sis.parameter.Parameters;
 
 // Test dependencies
 import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.*;
+import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestStep;
 
 
@@ -43,7 +47,7 @@ import org.apache.sis.test.TestStep;
  * @see GeocentricTranslationTest#testFranceGeocentricInterpolationPoint()
  * @see 
org.apache.sis.referencing.operation.transform.MolodenskyTransformTest#testFranceGeocentricInterpolationPoint()
  */
-public final class FranceGeocentricInterpolationTest extends 
DatumShiftTestCase {
+public final class FranceGeocentricInterpolationTest extends TestCase {
     /**
      * Name of the file containing a small extract of the "{@code 
GR3DF97A.txt}" file.
      * The amount of data in this test file is less than 0.14% of the original 
file.
@@ -93,17 +97,62 @@ public final class FranceGeocentricInterpolationTest 
extends DatumShiftTestCase
     public FranceGeocentricInterpolationTest() {
     }
 
+    /**
+     * Creates a grid file for the given <abbr>URI</abbr>.
+     *
+     * @param  file  the grid file <abbr>URI</abbr>.
+     * @return an object representing the grid file at the given URI.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     */
+    private static GridFile newGridFile(final URI file) throws 
MissingFactoryResourceException {
+        Parameters pg = 
Parameters.castOrWrap(FranceGeocentricInterpolation.PARAMETERS.createValue());
+        pg.getOrCreate(FranceGeocentricInterpolation.FILE).setValue(file);
+        return new GridFile(pg, FranceGeocentricInterpolation.FILE);
+    }
+
+    /**
+     * Creates a file for the resource of the given name.
+     *
+     * @param  filename  filename of the grid to load.
+     * @return an object representing the grid file for the specified resource.
+     * @throws URISyntaxException if the URL to the test file is not valid.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     */
+    private static GridFile getResource(final String filename)
+            throws URISyntaxException, MissingFactoryResourceException
+    {
+        URL file = 
FranceGeocentricInterpolationTest.class.getResource(filename);
+        assertNotNull(file, filename);
+        return newGridFile(file.toURI());
+    }
+
+    /**
+     * Returns the value of {@code 
FranceGeocentricInterpolation.isRecognized(…)}
+     * for a grid using the given <abbr>URI</abbr>.
+     *
+     * @param  resolved  the <abbr>URI</abbr> to test.
+     * @throws URISyntaxException if the URL to the test file is not valid.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     * @return result of {@code FranceGeocentricInterpolation.isRecognized(…)}.
+     */
+    private static boolean isRecognized(final String resolved)
+            throws URISyntaxException, MissingFactoryResourceException
+    {
+        return FranceGeocentricInterpolation.isRecognized(newGridFile(new 
URI(resolved)));
+    }
+
     /**
      * Tests {@link FranceGeocentricInterpolation#isRecognized(URI)}.
      *
      * @throws URISyntaxException if the URL to the test file is not valid.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
      */
     @Test
-    public void testIsRecognized() throws URISyntaxException {
-        assertTrue (FranceGeocentricInterpolation.isRecognized(new 
GridFile(new URI("GR3DF97A.txt"))));
-        assertTrue (FranceGeocentricInterpolation.isRecognized(new 
GridFile(new URI("gr3df"))));
-        assertFalse(FranceGeocentricInterpolation.isRecognized(new 
GridFile(new URI("gr3d"))));
-        assertTrue (FranceGeocentricInterpolation.isRecognized(new 
GridFile(new URI(TEST_FILE))));
+    public void testIsRecognized() throws URISyntaxException, 
MissingFactoryResourceException {
+        assertTrue (isRecognized("GR3DF97A.txt"));
+        assertTrue (isRecognized("gr3df"));
+        assertFalse(isRecognized("gr3d"));
+        assertTrue (isRecognized(TEST_FILE));
     }
 
     /**
@@ -132,11 +181,11 @@ public final class FranceGeocentricInterpolationTest 
extends DatumShiftTestCase
      * @throws TransformException if an error occurred while computing the 
envelope.
      */
     @TestStep
-    private static LoadedGrid<Angle,Length> testGridAsFloats()
+    private static LoadedGrid<Angle, Length> testGridAsFloats()
             throws URISyntaxException, IOException, FactoryException, 
TransformException
     {
         final GridFile file = getResource(TEST_FILE);
-        final LoadedGrid.Float<Angle,Length> grid;
+        final LoadedGrid.Float<Angle, Length> grid;
         try (BufferedReader in = file.newBufferedReader()) {
             grid = FranceGeocentricInterpolation.Loader.load(in, file);
         }
@@ -159,10 +208,10 @@ public final class FranceGeocentricInterpolationTest 
extends DatumShiftTestCase
      * @throws TransformException if an error occurred while computing the 
envelope.
      */
     @TestStep
-    private static LoadedGrid<Angle,Length> 
testGridAsShorts(LoadedGrid<Angle,Length> grid)
+    private static LoadedGrid<Angle, Length> 
testGridAsShorts(LoadedGrid<Angle, Length> grid)
             throws TransformException
     {
-        grid = CompressedGrid.compress((LoadedGrid.Float<Angle,Length>) grid, 
new double[] {
+        grid = CompressedGrid.compress((LoadedGrid.Float<Angle, Length>) grid, 
new double[] {
                 FranceGeocentricInterpolation.TX,           //  168 metres
                 FranceGeocentricInterpolation.TY,           //   60 metres
                 FranceGeocentricInterpolation.TZ},          // -320 metres
@@ -181,7 +230,7 @@ public final class FranceGeocentricInterpolationTest 
extends DatumShiftTestCase
      *
      * @throws TransformException if an error occurred while computing the 
envelope.
      */
-    private static void verifyGrid(final LoadedGrid<Angle,Length> grid) throws 
TransformException {
+    private static void verifyGrid(final LoadedGrid<Angle, Length> grid) 
throws TransformException {
         final Envelope envelope = grid.getDomainOfValidity();
         assertEquals( 2.2, envelope.getMinimum(0), 1E-12, "xmin");
         assertEquals( 2.5, envelope.getMaximum(0), 1E-12, "xmax");
@@ -223,7 +272,7 @@ public final class FranceGeocentricInterpolationTest 
extends DatumShiftTestCase
      */
     @Test
     public void testGetOrLoad() throws Exception {
-        final LoadedGrid<Angle,Length> grid = 
FranceGeocentricInterpolation.getOrLoad(
+        final LoadedGrid<Angle, Length> grid = 
FranceGeocentricInterpolation.getOrLoad(
                 getResource(TEST_FILE), new double[] {
                         FranceGeocentricInterpolation.TX,
                         FranceGeocentricInterpolation.TY,
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
index 361711d59a..5747469378 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NADCONTest.java
@@ -19,23 +19,29 @@ package org.apache.sis.referencing.operation.provider;
 import java.util.Locale;
 import java.io.BufferedWriter;
 import java.io.IOException;
+import java.net.URL;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.nio.file.Files;
 import javax.measure.quantity.Angle;
 import org.opengis.geometry.Envelope;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.referencing.operation.gridded.GridFile;
 import org.apache.sis.referencing.operation.gridded.GridLoader;
 import org.apache.sis.referencing.operation.gridded.LoadedGrid;
 import org.apache.sis.referencing.operation.matrix.Matrix3;
+import org.apache.sis.referencing.factory.MissingFactoryResourceException;
 import org.apache.sis.geometry.Envelope2D;
 import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.measure.Units;
+import org.apache.sis.parameter.Parameters;
 
 // Test dependencies
 import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.*;
+import org.apache.sis.test.TestCase;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
 import static org.opengis.test.Assertions.assertMatrixEquals;
@@ -47,7 +53,7 @@ import static org.opengis.test.Assertions.assertMatrixEquals;
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Simon Reynard (Geomatys)
  */
-public final class NADCONTest extends DatumShiftTestCase {
+public final class NADCONTest extends TestCase {
     /**
      * Creates a new test case.
      */
@@ -97,6 +103,39 @@ public final class NADCONTest extends DatumShiftTestCase {
      */
     public static final String TEST_FILE = "conus-extract";
 
+    /**
+     * Creates a grid file for the given <abbr>URI</abbr>.
+     *
+     * @param  file       the grid file <abbr>URI</abbr>.
+     * @param  parameter  {@link NADCON#LONGITUDE} or {@link NADCON#LATITUDE}.
+     * @return an object representing the grid file at the given URI.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     */
+    public static GridFile newGridFile(final URI file, final 
ParameterDescriptor<URI> parameter)
+            throws MissingFactoryResourceException
+    {
+        Parameters pg = Parameters.castOrWrap(NADCON.PARAMETERS.createValue());
+        pg.getOrCreate(parameter).setValue(file);
+        return new GridFile(pg, parameter);
+    }
+
+    /**
+     * Creates a file for the resource of the given name.
+     *
+     * @param  filename   filename of the grid to load.
+     * @param  parameter  {@link NADCON#LONGITUDE} or {@link NADCON#LATITUDE}.
+     * @return an object representing the grid file for the specified resource.
+     * @throws URISyntaxException if the URL to the test file is not valid.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     */
+    private static GridFile getResource(final String filename, final 
ParameterDescriptor<URI> parameter)
+            throws URISyntaxException, MissingFactoryResourceException
+    {
+        URL file = NADCONTest.class.getResource(filename);
+        assertNotNull(file, filename);
+        return newGridFile(file.toURI(), parameter);
+    }
+
     /**
      * Tests loading a grid file and interpolating a sample point.
      * The point used for this test is given by {@link #samplePoint(int)}.
@@ -105,8 +144,8 @@ public final class NADCONTest extends DatumShiftTestCase {
      */
     @Test
     public void testLoader() throws Exception {
-        testNADCON(getResource(TEST_FILE + ".laa"),     // Latitude shifts
-                   getResource(TEST_FILE + ".loa"),     // Longitude shifts
+        testNADCON(getResource(TEST_FILE + ".laa", NADCON.LATITUDE),
+                   getResource(TEST_FILE + ".loa", NADCON.LONGITUDE),
                    -99.75, -98.0, 37.5, 39.75);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
index 368fae9223..e07e471260 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/NTv2Test.java
@@ -16,7 +16,9 @@
  */
 package org.apache.sis.referencing.operation.provider;
 
+import java.net.URL;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -33,6 +35,7 @@ import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.referencing.operation.gridded.GridFile;
 import org.apache.sis.referencing.operation.gridded.GridGroup;
 import org.apache.sis.referencing.operation.gridded.LoadedGrid;
+import org.apache.sis.referencing.factory.MissingFactoryResourceException;
 import static 
org.apache.sis.referencing.operation.gridded.GridLoader.DEGREES_TO_SECONDS;
 import org.apache.sis.geometry.Envelope2D;
 import org.apache.sis.geometry.Envelopes;
@@ -43,6 +46,7 @@ import org.apache.sis.system.DataDirectory;
 // Test dependencies
 import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.*;
+import org.apache.sis.test.TestCase;
 
 // Specific to the geoapi-3.1 and geoapi-4.0 branches:
 import static org.opengis.test.Assertions.assertMatrixEquals;
@@ -57,7 +61,7 @@ import static org.opengis.test.Assertions.assertMatrixEquals;
  * @see GeocentricTranslationTest#testFranceGeocentricInterpolationPoint()
  * @see 
org.apache.sis.referencing.operation.transform.MolodenskyTransformTest#testFranceGeocentricInterpolationPoint()
  */
-public final class NTv2Test extends DatumShiftTestCase {
+public final class NTv2Test extends TestCase {
     /**
      * Name of the file containing a small extract of the "{@code 
NTF_R93.gsb}" file.
      * The amount of data in this test file is less than 0.14% of the original 
file.
@@ -83,8 +87,36 @@ public final class NTv2Test extends DatumShiftTestCase {
     }
 
     /**
-     * Tests loading a grid file and interpolating a sample point. The point 
used for
-     * this test is given by {@link 
FranceGeocentricInterpolationTest#samplePoint(int)}.
+     * Creates a grid file for the given <abbr>URI</abbr>.
+     *
+     * @param  file  the grid file <abbr>URI</abbr>.
+     * @return an object representing the grid file at the given URI.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     */
+    public static GridFile newGridFile(final URI file) throws 
MissingFactoryResourceException {
+        Parameters pg = Parameters.castOrWrap(NTv2.PARAMETERS.createValue());
+        pg.getOrCreate(NTv2.FILE).setValue(file);
+        return new GridFile(pg, NTv2.FILE);
+    }
+
+    /**
+     * Creates a file for the resource of the given name.
+     *
+     * @param  filename  filename of the grid to load.
+     * @return an object representing the grid file for the specified resource.
+     * @throws URISyntaxException if the URL to the test file is not valid.
+     * @throws MissingFactoryResourceException if the path cannot be resolved.
+     */
+    private static GridFile getResource(final String filename)
+            throws URISyntaxException, MissingFactoryResourceException
+    {
+        URL file = NTv2Test.class.getResource(filename);
+        assertNotNull(file, filename);
+        return newGridFile(file.toURI());
+    }
+
+    /**
+     * Tests loading a grid file and interpolating a sample point.
      *
      * @throws Exception if an error occurred while loading or computing the 
grid, or while testing transformations.
      */
@@ -122,7 +154,7 @@ public final class NTv2Test extends DatumShiftTestCase {
             final double ymin, final double ymax) throws Exception
     {
         final double cellSize = 360;
-        final LoadedGrid<Angle,Angle> grid = NTv2.getOrLoad(NTv2.class, file, 
2);
+        final LoadedGrid<Angle, Angle> grid = NTv2.getOrLoad(NTv2.class, file, 
2);
         assertInstanceOf(LoadedGrid.Float.class, grid, "Should not be 
compressed.");
         assertEquals(Units.ARC_SECOND, grid.getCoordinateUnit());
         assertEquals(Units.ARC_SECOND, grid.getTranslationUnit());
@@ -184,11 +216,11 @@ public final class NTv2Test extends DatumShiftTestCase {
     @Test
     public void testMultiGrids() throws Exception {
         assumeDataExists(DataDirectory.DATUM_CHANGES, MULTIGRID_TEST_FILE);
-        final Parameters pg = Parameters.castOrWrap(new 
NTv2().getParameters().createValue());
+        final Parameters pg = 
Parameters.castOrWrap(NTv2.PARAMETERS.createValue());
         pg.getOrCreate(NTv2.FILE).setValue(new URI(MULTIGRID_TEST_FILE));
         final GridFile file = new GridFile(pg, NTv2.FILE);
 
-        final LoadedGrid<Angle,Angle> grid = NTv2.getOrLoad(NTv2.class, file, 
2);
+        final LoadedGrid<Angle, Angle> grid = NTv2.getOrLoad(NTv2.class, file, 
2);
         assertInstanceOf(GridGroup.class, grid, "Should contain many grids.");
         assertEquals(Units.ARC_SECOND, grid.getCoordinateUnit());
         assertEquals(Units.ARC_SECOND, grid.getTranslationUnit());
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
index 8bad45b6bb..20efd27cf5 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransformTest.java
@@ -35,7 +35,8 @@ import org.apache.sis.referencing.datum.HardCodedDatum;
  *
  * @author  Martin Desruisseaux (Geomatys)
  */
-public class InterpolatedGeocentricTransformTest extends MathTransformTestCase 
{
+@SuppressWarnings("exports")
+public final class InterpolatedGeocentricTransformTest extends 
MathTransformTestCase {
     /**
      * Creates a new test case.
      */
@@ -56,7 +57,7 @@ public class InterpolatedGeocentricTransformTest extends 
MathTransformTestCase {
      * Creates the transform using the given provider.
      */
     final void createGeodeticTransformation(final 
FranceGeocentricInterpolation provider) throws FactoryException {
-        final URL file = 
FranceGeocentricInterpolationTest.getResourceAsConvertibleURL(FranceGeocentricInterpolationTest.TEST_FILE);
+        final URL file = 
FranceGeocentricInterpolationTest.class.getResource(FranceGeocentricInterpolationTest.TEST_FILE);
         final Ellipsoid source = HardCodedDatum.NTF.getEllipsoid();     // 
Clarke 1880 (IGN)
         final Ellipsoid target = CommonCRS.ETRS89.ellipsoid();          // GRS 
1980 ellipsoid
         final ParameterValueGroup values = 
provider.getParameters().createValue();
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
index 142c832b98..98061ba8c0 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/InterpolatedTransformTest.java
@@ -44,6 +44,7 @@ import org.apache.sis.referencing.operation.provider.NTv2Test;
  *
  * @author  Martin Desruisseaux (Geomatys)
  */
+@SuppressWarnings("exports")
 public final class InterpolatedTransformTest extends MathTransformTestCase {
     /**
      * Creates a new test case.
@@ -73,7 +74,7 @@ public final class InterpolatedTransformTest extends 
MathTransformTestCase {
      * @throws FactoryException if an error occurred while loading the grid.
      */
     private void createRGF93() throws FactoryException {
-        final URL file = 
NTv2Test.getResourceAsConvertibleURL(NTv2Test.TEST_FILE);
+        final URL file = NTv2Test.class.getResource(NTv2Test.TEST_FILE);
         final NTv2 provider = new NTv2();
         final ParameterValueGroup values = 
provider.getParameters().createValue();
         values.parameter("Latitude and longitude difference 
file").setValue(file);    // Automatic conversion from URL to Path.
@@ -88,8 +89,8 @@ public final class InterpolatedTransformTest extends 
MathTransformTestCase {
      * @throws FactoryException if an error occurred while loading the grid.
      */
     private void createNADCON() throws FactoryException {
-        final URL latitudeShifts  = 
NADCONTest.getResourceAsConvertibleURL(NADCONTest.TEST_FILE + ".laa");
-        final URL longitudeShifts = 
NADCONTest.getResourceAsConvertibleURL(NADCONTest.TEST_FILE + ".loa");
+        final URL latitudeShifts  = 
NADCONTest.class.getResource(NADCONTest.TEST_FILE + ".laa");
+        final URL longitudeShifts = 
NADCONTest.class.getResource(NADCONTest.TEST_FILE + ".loa");
         final NADCON provider = new NADCON();
         final ParameterValueGroup values = 
provider.getParameters().createValue();
         values.parameter("Latitude difference file").setValue(latitudeShifts);
diff --git 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/DatumShiftTest.java
 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/DatumShiftTest.java
index fadcdebda7..81f0ab69e7 100644
--- 
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/DatumShiftTest.java
+++ 
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/test/integration/DatumShiftTest.java
@@ -18,7 +18,7 @@ package org.apache.sis.test.integration;
 
 import java.net.URI;
 import org.apache.sis.system.DataDirectory;
-import org.apache.sis.referencing.operation.gridded.GridFile;
+import org.apache.sis.referencing.operation.provider.NADCON;
 
 // Test dependencies
 import org.junit.jupiter.api.Test;
@@ -51,7 +51,7 @@ public final class DatumShiftTest extends TestCase {
     @Test
     public void testRGF93() throws Exception {
         final URI file = assumeDataExists(DataDirectory.DATUM_CHANGES, 
"ntf_r93.gsb").toUri();
-        NTv2Test.testRGF93(new GridFile(file));
+        NTv2Test.testRGF93(NTv2Test.newGridFile(file));
     }
 
     /**
@@ -64,6 +64,8 @@ public final class DatumShiftTest extends TestCase {
     public void testNADCON() throws Exception {
         final URI latitudeShifts  = 
assumeDataExists(DataDirectory.DATUM_CHANGES, "conus.las").toUri();
         final URI longitudeShifts = 
assumeDataExists(DataDirectory.DATUM_CHANGES, "conus.los").toUri();
-        NADCONTest.testNADCON(new GridFile(latitudeShifts), new 
GridFile(longitudeShifts));
+        NADCONTest.testNADCON(
+                NADCONTest.newGridFile(latitudeShifts,  NADCON.LATITUDE),
+                NADCONTest.newGridFile(longitudeShifts, NADCON.LONGITUDE));
     }
 }

Reply via email to