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
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new afe23b664e More test consolidation: reduce the number of assumptions.
Factorize better where remaining assumptions are done.
afe23b664e is described below
commit afe23b664e957ce46d61a199fcbca210f4ac23fa
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Oct 9 14:07:04 2025 +0200
More test consolidation: reduce the number of assumptions.
Factorize better where remaining assumptions are done.
---
.../org/apache/sis/console/CRSCommandTest.java | 41 +++++++-------
.../sis/metadata/xml/SchemaComplianceTest.java | 10 ++--
.../org/apache/sis/openoffice/TransformerTest.java | 5 +-
.../apache/sis/geometry/AbstractEnvelopeTest.java | 5 +-
.../apache/sis/geometry/CoordinateFormatTest.java | 5 +-
.../org/apache/sis/geometry/EnvelopesTest.java | 11 ----
.../sis/geometry/GeneralDirectPositionTest.java | 11 ++--
.../apache/sis/geometry/GeneralEnvelopeTest.java | 30 +++++------
.../apache/sis/geometry/ImmutableEnvelopeTest.java | 9 ++--
.../org/apache/sis/geometry/TransformTestCase.java | 4 +-
.../test/org/apache/sis/io/wkt/CRSParserTest.java | 26 ++++-----
.../org/apache/sis/io/wkt/ComparisonWithEPSG.java | 5 +-
.../sis/io/wkt/GeodeticObjectParserTest.java | 4 +-
.../org/apache/sis/io/wkt/WKTDictionaryTest.java | 7 +--
.../test/org/apache/sis/io/wkt/WKTFormatTest.java | 7 +--
.../sis/referencing/AuthorityFactoriesTest.java | 11 +---
.../test/org/apache/sis/referencing/CRSTest.java | 11 +---
.../org/apache/sis/referencing/CommonCRSTest.java | 4 +-
.../sis/referencing/EPSGDependentTestCase.java | 52 ------------------
.../sis/referencing/EPSGFactoryFallbackTest.java | 1 +
.../sis/referencing/IdentifiedObjectsTest.java | 1 +
.../sis/referencing/StandardDefinitionsTest.java | 3 +-
.../sis/referencing/factory/TestFactorySource.java | 2 +-
.../operation/provider/DatumShiftTestCase.java | 14 ++---
.../referencing/operation/provider/NTv2Test.java | 5 +-
.../sis/test/integration/DatumShiftTest.java | 7 ++-
.../sis/storage/geotiff/SelfConsistencyTest.java | 21 +-------
.../sis/storage/netcdf/SelfConsistencyTest.java | 21 +-------
.../org/apache/sis/storage/folder/StoreTest.java | 2 -
.../main/org/apache/sis/system/DataDirectory.java | 2 +-
.../main/org/apache/sis/system/Reflect.java | 2 +-
.../apache/sis/util/logging/MonolineFormatter.java | 4 +-
.../apache/sis/converter/PathConverterTest.java | 26 +++------
.../test/org/apache/sis/test/Assumptions.java | 62 ----------------------
.../test/org/apache/sis/test/OptionalTestData.java | 21 +++-----
.../org/apache/sis/test/PlatformDependent.java | 36 -------------
.../test/org/apache/sis/test/TestCase.java | 43 +++++++++++++++
.../sis/storage/geopackage/GpkgStoreTest.java | 1 +
.../resources/embedded/EmbeddedResourcesTest.java | 1 +
39 files changed, 169 insertions(+), 364 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/CRSCommandTest.java
b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/CRSCommandTest.java
index 9ee67c2e12..b76f851090 100644
---
a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/CRSCommandTest.java
+++
b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/CRSCommandTest.java
@@ -29,6 +29,7 @@ import org.apache.sis.test.TestCase;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class CRSCommandTest extends TestCase {
/**
* The Well Known Text for EPSG:4326 as a regular expression.
@@ -67,12 +68,24 @@ public final class CRSCommandTest extends TestCase {
}
/**
- * Interrupts the test if the <abbr>EPSG</abbr> database does not seem
present.
- * We recognize this situation by the fact that the {@code CommonCRS}
fallback
- * defines the datum in the old way.
+ * Tests with the given code. This method formats the output, but check
for a match
+ * only if the <abbr>EPSG</abbr> database is present. We recognize this
situation by
+ * the fact that the {@code CommonCRS} fallback defines the datum in the
old way.
+ *
+ * @param code the code to test.
+ * @throws Exception if an error occurred while creating the command.
*/
- private static void assumeEPSG(final String wkt) {
- assumeConnectionToEPSG(!wkt.contains("Datum[\"World Geodetic System
1984\""));
+ private void test(final String code) throws Exception {
+ var test = new CRSCommand(0, new String[] {CommandRunner.TEST, code});
+ test.run();
+ String wkt = test.outputBuffer.toString();
+ if (wkt.contains("Datum[\"World Geodetic System 1984\"")) {
+ if (REQUIRE_EPSG_DATABASE) {
+ fail("EPSG database is absent or too old.");
+ }
+ } else {
+ assertTrue(wkt.matches(WGS84), wkt);
+ }
}
/**
@@ -82,11 +95,7 @@ public final class CRSCommandTest extends TestCase {
*/
@Test
public void testCode() throws Exception {
- var test = new CRSCommand(0, new String[] {CommandRunner.TEST,
"EPSG:4326"});
- test.run();
- String wkt = test.outputBuffer.toString();
- assumeEPSG(wkt);
- assertTrue(wkt.matches(WGS84), wkt);
+ test("EPSG:4326");
}
/**
@@ -96,11 +105,7 @@ public final class CRSCommandTest extends TestCase {
*/
@Test
public void testURN() throws Exception {
- var test = new CRSCommand(0, new String[] {CommandRunner.TEST,
"urn:ogc:def:crs:epsg::4326"});
- test.run();
- String wkt = test.outputBuffer.toString();
- assumeEPSG(wkt);
- assertTrue(wkt.matches(WGS84), wkt);
+ test("urn:ogc:def:crs:epsg::4326");
}
/**
@@ -110,10 +115,6 @@ public final class CRSCommandTest extends TestCase {
*/
@Test
public void testHTTP() throws Exception {
- var test = new CRSCommand(0, new String[] {CommandRunner.TEST,
"http://www.opengis.net/gml/srs/epsg.xml#4326"});
- test.run();
- String wkt = test.outputBuffer.toString();
- assumeEPSG(wkt);
- assertTrue(wkt.matches(WGS84), wkt);
+ test("http://www.opengis.net/gml/srs/epsg.xml#4326");
}
}
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java
index fd401dc92f..acbba18d7e 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/xml/SchemaComplianceTest.java
@@ -23,7 +23,7 @@ import org.apache.sis.system.DataDirectory;
// Test dependencies
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assumptions.*;
+import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
import org.apache.sis.test.ProjectDirectories;
import org.apache.sis.xml.test.SchemaCompliance;
@@ -46,6 +46,7 @@ public final class SchemaComplianceTest extends TestCase {
/**
* Verifies compliance with metadata schemas.
+ * This test is skipped if the schema are not available in the {@code
SIS_DATA} directory.
*
* @throws Exception if an error occurred while checking the schema.
*
@@ -53,10 +54,9 @@ public final class SchemaComplianceTest extends TestCase {
*/
@Test
public void verifyMetadata() throws Exception {
- Path directory = DataDirectory.SCHEMAS.getDirectory();
- assumeTrue(directory != null, "Schema directory is not specified.");
- directory = directory.resolve("iso");
- assumeTrue(Files.isDirectory(directory.resolve("19115")));
+ final Path directory = assumeDataExists(DataDirectory.SCHEMAS, "iso");
+ final Path subdir = directory.resolve("19115");
+ assertTrue(Files.isDirectory(subdir), () -> "Missing sub-directory: "
+ subdir);
/*
* Locate the root of metadata class directory. In a Maven build:
* "core/sis-metadata/target/classes/org/apache/sis/metadata/iso"
diff --git
a/endorsed/src/org.apache.sis.openoffice/test/org/apache/sis/openoffice/TransformerTest.java
b/endorsed/src/org.apache.sis.openoffice/test/org/apache/sis/openoffice/TransformerTest.java
index 3b66abf9fb..16e5a1c93c 100644
---
a/endorsed/src/org.apache.sis.openoffice/test/org/apache/sis/openoffice/TransformerTest.java
+++
b/endorsed/src/org.apache.sis.openoffice/test/org/apache/sis/openoffice/TransformerTest.java
@@ -25,7 +25,6 @@ import org.apache.sis.storage.DataStoreException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.apache.sis.test.TestCase;
@@ -76,7 +75,7 @@ public final class TransformerTest extends TestCase {
new double[] {32, 23}
};
final var tr = new Transformer(caller, CommonCRS.WGS84.geographic(),
"EPSG:4326", points);
- assumeTrue(tr.hasAreaOfInterest()); // False if there is no EPSG
geodetic dataset installed.
+ assumeConnectionToEPSG(tr.hasAreaOfInterest());
final GeographicBoundingBox bbox = tr.getAreaOfInterest();
assertEquals( 23, bbox.getEastBoundLongitude());
assertEquals(-12, bbox.getWestBoundLongitude());
@@ -106,7 +105,7 @@ public final class TransformerTest extends TestCase {
new double[] {32, 23}
};
final var tr = new Transformer(caller, CommonCRS.WGS84.geographic3D(),
"EPSG:4326", points);
- assumeTrue(tr.hasAreaOfInterest()); // False if there is no EPSG
geodetic dataset installed.
+ assumeConnectionToEPSG(tr.hasAreaOfInterest());
final GeographicBoundingBox bbox = tr.getAreaOfInterest();
assertEquals( 23, bbox.getEastBoundLongitude());
assertEquals(-12, bbox.getWestBoundLongitude());
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
index 5049ee08d5..62bc399cac 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/AbstractEnvelopeTest.java
@@ -23,9 +23,9 @@ import org.opengis.geometry.DirectPosition;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
import static org.opengis.test.Validators.validate;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import static org.apache.sis.referencing.Assertions.assertContains;
import static org.apache.sis.referencing.Assertions.assertDisjoint;
import static org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
@@ -37,7 +37,8 @@ import static
org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
*
* @author Martin Desruisseaux (IRD, Geomatys)
*/
-public final class AbstractEnvelopeTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class AbstractEnvelopeTest extends TestCase {
/**
* Creates a new test case.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
index 373939fa55..8dde2bc6dc 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/CoordinateFormatTest.java
@@ -29,8 +29,8 @@ import org.apache.sis.measure.Units;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import org.apache.sis.test.mock.VerticalCRSMock;
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.referencing.operation.HardCodedConversions;
@@ -44,7 +44,8 @@ import
org.apache.sis.referencing.operation.HardCodedConversions;
*
* @see org.apache.sis.measure.AngleFormatTest
*/
-public final class CoordinateFormatTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class CoordinateFormatTest extends TestCase {
/**
* Creates a new test case.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/EnvelopesTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/EnvelopesTest.java
index 8293d63288..f2c1a20336 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/EnvelopesTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/EnvelopesTest.java
@@ -42,10 +42,8 @@ import
org.apache.sis.referencing.internal.shared.AffineTransform2D;
// Test dependencies
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.*;
import static org.opengis.test.Validators.validate;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import org.apache.sis.referencing.operation.HardCodedConversions;
import org.apache.sis.referencing.crs.HardCodedCRS;
import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals;
@@ -66,15 +64,6 @@ public final class EnvelopesTest extends
TransformTestCase<GeneralEnvelope> {
public EnvelopesTest() {
}
- /**
- * Forces the check of whether of EPSG database exists before to start any
tests.
- * This is done for avoiding race conditions logging the same message many
times.
- */
- @BeforeAll
- public static void forceCheckForEPSG() {
- EPSGDependentTestCase.forceCheckForEPSG();
- }
-
/**
* Creates an envelope for the given CRS and coordinate values.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralDirectPositionTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralDirectPositionTest.java
index 56c07e61fb..a660b0d189 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralDirectPositionTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralDirectPositionTest.java
@@ -20,9 +20,9 @@ import org.apache.sis.io.wkt.Formatter;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
import static org.opengis.test.Validators.validate;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import static org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
@@ -32,7 +32,8 @@ import static
org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
*
* @author Martin Desruisseaux (IRD, Geomatys)
*/
-public final class GeneralDirectPositionTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class GeneralDirectPositionTest extends TestCase {
/**
* Creates a new test case.
*/
@@ -44,7 +45,7 @@ public final class GeneralDirectPositionTest extends
EPSGDependentTestCase {
*/
@Test
public void testNormalize() {
- final GeneralDirectPosition position = new
GeneralDirectPosition(WGS84);
+ final var position = new GeneralDirectPosition(WGS84);
position.setCoordinates(300, -100);
assertTrue(position.normalize());
assertEquals(-90.0, position.getCoordinate(1));
@@ -57,7 +58,7 @@ public final class GeneralDirectPositionTest extends
EPSGDependentTestCase {
*/
@Test
public void testFormatWKT() {
- final GeneralDirectPosition position = new GeneralDirectPosition(6,
10);
+ final var position = new GeneralDirectPosition(6, 10);
assertEquals("POINT[6 10]", position.toWKT());
position.setCoordinateReferenceSystem(WGS84);
assertEquals("POINT[6.00000000 10.00000000]", position.toWKT());
// 1 cm precision on Earth.
@@ -69,7 +70,7 @@ public final class GeneralDirectPositionTest extends
EPSGDependentTestCase {
*/
@Test
public void testToString() {
- final GeneralDirectPosition position = new GeneralDirectPosition(6,
10, 2);
+ final var position = new GeneralDirectPosition(6, 10, 2);
assertEquals("POINT(6 10 2)", position.toString());
validate(position);
}
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
index 979ab33296..5e65663add 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
@@ -27,12 +27,10 @@ import org.apache.sis.io.wkt.Convention;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
import static org.opengis.test.Validators.validate;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import org.apache.sis.referencing.crs.HardCodedCRS;
-import static org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
-import static org.apache.sis.referencing.crs.HardCodedCRS.WGS84_LATITUDE_FIRST;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.referencing.Assertions.assertWktEquals;
@@ -48,7 +46,7 @@ import static
org.apache.sis.referencing.Assertions.assertWktEquals;
* @author Johann Sorel (Geomatys)
*/
@SuppressWarnings("exports")
-public class GeneralEnvelopeTest extends EPSGDependentTestCase {
+public class GeneralEnvelopeTest extends TestCase {
/**
* Tolerance threshold for floating point comparisons.
*/
@@ -73,8 +71,8 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
* This method is overridden by {@link SubEnvelopeTest}.
*/
GeneralEnvelope create(final double xmin, final double ymin, final double
xmax, final double ymax) {
- final GeneralEnvelope envelope = new GeneralEnvelope(2);
- envelope.setCoordinateReferenceSystem(WGS84);
+ final var envelope = new GeneralEnvelope(2);
+ envelope.setCoordinateReferenceSystem(HardCodedCRS.WGS84);
envelope.setEnvelope(xmin, ymin, xmax, ymax);
if (!skipValidation) {
validate(envelope);
@@ -87,7 +85,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
* This method is overridden by {@link SubEnvelopeTest}.
*/
void verifyInvariants(final GeneralEnvelope envelope) {
- assertSame(WGS84, envelope.getCoordinateReferenceSystem());
+ assertSame(HardCodedCRS.WGS84,
envelope.getCoordinateReferenceSystem());
}
/**
@@ -594,7 +592,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
*/
e.setRange(1, -10, -20);
var ex = assertThrows(IllegalStateException.class,
- () -> e.setCoordinateReferenceSystem(WGS84),
+ () -> e.setCoordinateReferenceSystem(HardCodedCRS.WGS84),
"Invalid range shall not be allowed.");
assertMessageContains(ex, AxisNames.GEODETIC_LATITUDE);
/*
@@ -606,7 +604,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
assertEquals( 3, e.getUpper(0));
assertEquals(-20, e.getUpper(1));
e.setRange(1, -20, -10);
- e.setCoordinateReferenceSystem(WGS84);
+ e.setCoordinateReferenceSystem(HardCodedCRS.WGS84);
assertEnvelopeEquals(e, 2, -20, 3, -10);
verifyInvariants(e);
}
@@ -631,7 +629,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
*/
@Test
public void testTranslate() {
- final GeneralEnvelope envelope = new GeneralEnvelope(new double[] {4,
5}, new double[] {8, 7});
+ final var envelope = new GeneralEnvelope(new double[] {4, 5}, new
double[] {8, 7});
envelope.translate(2, -4);
assertEnvelopeEquals(envelope, 6, 1, 10, 3);
}
@@ -645,7 +643,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
envelope.setCoordinateReferenceSystem(HardCodedCRS.GEOID_4D_MIXED_ORDER);
envelope = envelope.horizontal();
assertEnvelopeEquals(envelope, 5, -8, 7, -3);
- assertSame(WGS84_LATITUDE_FIRST,
envelope.getCoordinateReferenceSystem());
+ assertSame(HardCodedCRS.WGS84_LATITUDE_FIRST,
envelope.getCoordinateReferenceSystem());
}
/**
@@ -654,7 +652,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
*/
@Test
public void testTimeRange() {
- final GeneralEnvelope envelope = new
GeneralEnvelope(HardCodedCRS.WGS84_WITH_TIME);
+ final var envelope = new GeneralEnvelope(HardCodedCRS.WGS84_WITH_TIME);
envelope.setRange(0, -20, 25);
envelope.setRange(1, -30, 12);
envelope.setRange(2, 58840, 59000.75);
@@ -743,7 +741,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
*/
@Test
public void testWktFormatting() {
- final GeneralEnvelope envelope = new GeneralEnvelope(3);
+ final var envelope = new GeneralEnvelope(3);
envelope.setRange(0, 6, 10);
envelope.setRange(1, 16, 20);
envelope.setRange(2, 23, 50);
@@ -762,7 +760,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
* Initializes an empty envelope. The new envelope is empty
* but not null because initialized to 0, not NaN.
*/
- final GeneralEnvelope e1 = new GeneralEnvelope(4);
+ final var e1 = new GeneralEnvelope(4);
assertTrue (e1.isEmpty());
assertFalse (e1.isAllNaN());
assertEquals(e1.getLowerCorner(), e1.getUpperCorner());
@@ -780,7 +778,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
* Creates a new envelope initialized with the same
* coordinate values. The two envelope shall be equal.
*/
- final GeneralEnvelope e2 = new GeneralEnvelope(e1);
+ final var e2 = new GeneralEnvelope(e1);
assertPositionEquals(e1.getLowerCorner(), e2.getLowerCorner());
assertPositionEquals(e1.getUpperCorner(), e2.getUpperCorner());
assertTrue (e1.contains(e2, true ));
@@ -828,7 +826,7 @@ public class GeneralEnvelopeTest extends
EPSGDependentTestCase {
*/
@Test
public void testClone() {
- final GeneralEnvelope e1 = new GeneralEnvelope(2);
+ final var e1 = new GeneralEnvelope(2);
e1.setRange(0, -40, +60);
e1.setRange(1, -20, +30);
final GeneralEnvelope e2 = e1.clone();
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ImmutableEnvelopeTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ImmutableEnvelopeTest.java
index 194a5ac40f..bde26057c2 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ImmutableEnvelopeTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/ImmutableEnvelopeTest.java
@@ -18,11 +18,11 @@ package org.apache.sis.geometry;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
import static org.opengis.test.Validators.validate;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
-import static org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
+import org.apache.sis.referencing.crs.HardCodedCRS;
/**
@@ -32,7 +32,8 @@ import static
org.apache.sis.referencing.crs.HardCodedCRS.WGS84;
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class ImmutableEnvelopeTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class ImmutableEnvelopeTest extends TestCase {
/**
* Creates a new test case.
*/
@@ -46,7 +47,7 @@ public final class ImmutableEnvelopeTest extends
EPSGDependentTestCase {
public void testSerialization() {
final var e1 = new ImmutableEnvelope(
new double[] {-20, -10},
- new double[] { 20, 10}, WGS84);
+ new double[] { 20, 10}, HardCodedCRS.WGS84);
final ImmutableEnvelope e2 = assertSerializedEquals(e1);
assertNotSame(e1, e2);
validate(e2);
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/TransformTestCase.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/TransformTestCase.java
index 2727e6393f..ce28be5317 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/TransformTestCase.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/TransformTestCase.java
@@ -36,8 +36,8 @@ import static
org.apache.sis.referencing.internal.shared.Formulas.LINEAR_TOLERAN
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.referencing.operation.HardCodedConversions;
@@ -52,7 +52,7 @@ import
org.apache.sis.referencing.operation.HardCodedConversions;
* @param <G> the type of geometric objects, either {@link GeneralEnvelope}
or {@link java.awt.geom.Rectangle2D}.
*/
@SuppressWarnings("exports")
-public abstract class TransformTestCase<G> extends EPSGDependentTestCase {
+public abstract class TransformTestCase<G> extends TestCase {
/**
* Creates an envelope or rectangle for the given CRS and coordinate
values.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
index 82bdbef548..5da7217039 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/CRSParserTest.java
@@ -26,7 +26,6 @@ import org.apache.sis.system.Loggers;
// Test dependencies
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -34,7 +33,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import org.opengis.test.referencing.WKTParserTest;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.FailureDetailsReporter;
-import org.apache.sis.referencing.EPSGDependentTestCase;
+import org.apache.sis.test.TestCase;
/**
@@ -43,8 +42,18 @@ import org.apache.sis.referencing.EPSGDependentTestCase;
*
* @author Martin Desruisseaux (IRD, Geomatys)
*/
+@SuppressWarnings("exports")
@ExtendWith(FailureDetailsReporter.class)
public final class CRSParserTest extends WKTParserTest {
+ /**
+ * Forces the check of whether the EPSG database exists before to start
any test.
+ * This is done for avoiding race conditions logging the same message many
times.
+ */
+ static {
+ // Will do nothing, the intend is only to force class initialization.
+ TestCase.out.flush();
+ }
+
/**
* A JUnit extension for listening to log events.
*/
@@ -67,17 +76,8 @@ public final class CRSParserTest extends WKTParserTest {
}
/**
- * Forces the check of whether of EPSG database exists before to start any
tests.
- * This is done for avoiding race conditions logging the same message many
times.
- */
- @BeforeAll
- public static void forceCheckForEPSG() {
- EPSGDependentTestCase.forceCheckForEPSG();
- }
-
- /**
- * Pre-process the WKT string before parsing. This method may replace
curly quotation marks
- * ({@code “} and {@code ”}) by straight quotation marks ({@code "}).
+ * Pre-processes the <abbr>WKT</abbr> string before parsing. This method
may replace
+ * curly quotation marks ({@code “} and {@code ”}) by straight quotation
marks ({@code "}).
* The Apache SIS parser should understand both forms transparently.
*
* @param wkt the Well-Known Text to pre-process.
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/ComparisonWithEPSG.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/ComparisonWithEPSG.java
index f1c42945ae..b69f189c07 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/ComparisonWithEPSG.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/ComparisonWithEPSG.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.apache.sis.referencing.EPSGDependentTestCase;
+import org.apache.sis.test.TestCase;
import org.apache.sis.referencing.factory.TestFactorySource;
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
@@ -39,9 +39,10 @@ import static
org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
@Execution(ExecutionMode.CONCURRENT)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public final class ComparisonWithEPSG extends EPSGDependentTestCase {
+public final class ComparisonWithEPSG extends TestCase {
/**
* The source of the EPSG factory.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
index c93c01e8fa..afd7ebe58c 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
@@ -52,8 +52,8 @@ import static
org.apache.sis.util.internal.shared.Constants.SECONDS_PER_DAY;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import static org.apache.sis.test.Assertions.assertMessageContains;
import static org.apache.sis.test.Assertions.assertMultilinesEquals;
import static org.apache.sis.referencing.Assertions.assertAxisEquals;
@@ -67,7 +67,7 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
* @author Martin Desruisseaux (IRD, Geomatys)
*/
@SuppressWarnings("exports")
-public final class GeodeticObjectParserTest extends EPSGDependentTestCase {
+public final class GeodeticObjectParserTest extends TestCase {
/**
* The parser to use for the test.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
index 8d7e4eb39d..81f1ae4121 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTDictionaryTest.java
@@ -41,8 +41,8 @@ import org.apache.sis.util.collection.BackingStoreException;
// 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.TestUtilities;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import static org.apache.sis.test.Assertions.assertSetEquals;
import static org.apache.sis.test.Assertions.assertMessageContains;
@@ -56,7 +56,8 @@ import static
org.opengis.test.Assertions.assertAxisDirectionsEqual;
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class WKTDictionaryTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class WKTDictionaryTest extends TestCase {
/**
* Creates a new test case.
*/
@@ -71,7 +72,7 @@ public final class WKTDictionaryTest extends
EPSGDependentTestCase {
*/
@Test
public void testAddDefinitions() throws FactoryException {
- final WKTDictionary factory = new WKTDictionary(null);
+ final var factory = new WKTDictionary(null);
factory.addDefinitions(List.of(
"GeodCRS[\"Anguilla 1957\",\n" +
" Datum[\"Anguilla 1957\",\n" +
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
index 45c21869bf..a39656690c 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTFormatTest.java
@@ -33,8 +33,8 @@ import org.apache.sis.parameter.Parameterized;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.referencing.EPSGDependentTestCase;
import org.apache.sis.referencing.operation.transform.MathTransformFactoryMock;
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
import static org.apache.sis.test.Assertions.assertMessageContains;
@@ -46,7 +46,8 @@ import static
org.apache.sis.test.Assertions.assertMultilinesEquals;
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class WKTFormatTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class WKTFormatTest extends TestCase {
/**
* The instance to use for the test, or {@code null} if none.
*/
@@ -76,7 +77,7 @@ public final class WKTFormatTest extends
EPSGDependentTestCase {
@Test
public void testParse() throws ParseException {
format = new WKTFormat();
- final VerticalCRS crs = (VerticalCRS) format.parseObject(
+ final var crs = (VerticalCRS) format.parseObject(
"VERT_CS[“Gravity-related height”,\n" +
" VERT_DATUM[“Mean Sea Level”, 2005],\n" +
" UNIT[“metre”, 1],\n" +
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AuthorityFactoriesTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AuthorityFactoriesTest.java
index 9f172a1dda..e8e9e662d3 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AuthorityFactoriesTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/AuthorityFactoriesTest.java
@@ -35,7 +35,6 @@ import
org.apache.sis.referencing.factory.GeodeticAuthorityFactory;
// Test dependencies
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCaseWithLogs;
import org.apache.sis.referencing.crs.HardCodedCRS;
@@ -48,6 +47,7 @@ import static
org.apache.sis.test.Assertions.assertNotDeepEquals;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class AuthorityFactoriesTest extends TestCaseWithLogs {
/**
* Creates a new test case.
@@ -56,15 +56,6 @@ public final class AuthorityFactoriesTest extends
TestCaseWithLogs {
super(Loggers.CRS_FACTORY);
}
- /**
- * Forces the check of whether of EPSG database exists before to start any
tests.
- * This is done for avoiding race conditions logging the same message many
times.
- */
- @BeforeAll
- public static void forceCheckForEPSG() {
- EPSGDependentTestCase.forceCheckForEPSG();
- }
-
/**
* Ensures that {@link EPSGFactoryProxy} is declared before {@link
CommonAuthorityFactory}.
* This is preferable (but not mandatory) because of the way we
implemented {@link AuthorityFactories}.
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
index 94dcc1f456..7f2bdb6302 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/CRSTest.java
@@ -39,7 +39,6 @@ import org.apache.sis.util.Utilities;
// Test dependencies
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCaseWithLogs;
import org.apache.sis.referencing.cs.HardCodedCS;
@@ -58,6 +57,7 @@ import org.opengis.referencing.ObjectDomain;
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
*/
+@SuppressWarnings("exports")
public final class CRSTest extends TestCaseWithLogs {
/**
* Creates a new test case.
@@ -66,15 +66,6 @@ public final class CRSTest extends TestCaseWithLogs {
super(Loggers.CRS_FACTORY);
}
- /**
- * Forces the check of whether of EPSG database exists before to start any
tests.
- * This is done for avoiding race conditions logging the same message many
times.
- */
- @BeforeAll
- public static void forceCheckForEPSG() {
- EPSGDependentTestCase.forceCheckForEPSG();
- }
-
/**
* Asserts that the result of {@link CRS#forCode(String)} is the given CRS.
*/
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 dd5a0b4f74..5c9f1024a2 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
@@ -44,6 +44,7 @@ import static
org.apache.sis.util.internal.shared.Constants.UTC;
// Test dependencies
import org.junit.jupiter.api.Test;
+import org.apache.sis.test.TestCase;
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
import static org.apache.sis.test.Assertions.assertMessageContains;
@@ -60,7 +61,8 @@ import static
org.opengis.test.Assertions.assertAxisDirectionsEqual;
*
* @author Martin Desruisseaux (IRD, Geomatys)
*/
-public final class CommonCRSTest extends EPSGDependentTestCase {
+@SuppressWarnings("exports")
+public final class CommonCRSTest extends TestCase {
/**
* Creates a new test case.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGDependentTestCase.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGDependentTestCase.java
deleted file mode 100644
index fba8b60bd1..0000000000
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGDependentTestCase.java
+++ /dev/null
@@ -1,52 +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;
-
-// Test dependencies
-import org.junit.jupiter.api.BeforeAll;
-import org.apache.sis.test.TestCase;
-
-
-/**
- * Base class of Apache SIS tests that may depend on the EPSG database (except
GeoAPI tests).
- * This base class is used for checking in a single place whether the EPSG
database exists on
- * the local machine. Note that this is not necessarily for tests that
<em>require</em> EPSG.
- * This base class is also for tests that <em>may</em> use EPSG if present,
sometime indirectly.
- * For example, even when the test is using {@link
org.apache.sis.referencing.crs.HardCodedCRS}
- * constants, SIS may still look for EPSG data for validation or for searching
coordinate operations.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public class EPSGDependentTestCase extends TestCase {
- /**
- * Creates a new test case.
- */
- protected EPSGDependentTestCase() {
- }
-
- /**
- * Performs an arbitrary operation which will force Apache SIS to check
whether the EPSG database exists.
- * This is done before any test is started in order to avoid race
conditions causing the same message to
- * be logged many times when tests are run in parallel. Note that those
race conditions do not break the
- * tests (results are still correct). It only pollutes the logs, and may
cause random test failures when
- * the test verifies the logs.
- */
- @BeforeAll
- public static void forceCheckForEPSG() {
- CommonCRS.defaultGeographic();
- }
-}
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
index 191bb02450..93baa75ab3 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
@@ -56,6 +56,7 @@ import static org.apache.sis.test.Assertions.assertSetEquals;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
@Isolated("Temporarily modifies the system-wide EPSG factory.")
public final class EPSGFactoryFallbackTest extends TestCaseWithLogs {
/**
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/IdentifiedObjectsTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/IdentifiedObjectsTest.java
index 0020019b12..ab2324b141 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/IdentifiedObjectsTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/IdentifiedObjectsTest.java
@@ -42,6 +42,7 @@ import org.apache.sis.referencing.crs.HardCodedCRS;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class IdentifiedObjectsTest extends TestCase {
/**
* Creates a new test case.
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/StandardDefinitionsTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/StandardDefinitionsTest.java
index 14a650459d..e913f60711 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/StandardDefinitionsTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/StandardDefinitionsTest.java
@@ -42,6 +42,7 @@ import org.apache.sis.referencing.datum.HardCodedDatum;
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.referencing.cs.HardCodedAxes;
import org.apache.sis.referencing.cs.HardCodedCS;
+import org.apache.sis.test.TestCase;
/**
@@ -50,7 +51,7 @@ import org.apache.sis.referencing.cs.HardCodedCS;
* @author Martin Desruisseaux (Geomatys)
*/
@SuppressWarnings("exports")
-public final class StandardDefinitionsTest extends EPSGDependentTestCase {
+public final class StandardDefinitionsTest extends TestCase {
/**
* Creates a new test case.
*/
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
index 55a7d11f4c..bae2ecf671 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
@@ -76,7 +76,7 @@ public final class TestFactorySource {
private static final boolean TEST_ON_POSTGRESQL = false;
static {
if (TEST_ON_POSTGRESQL) {
- final PGSimpleDataSource ds = new PGSimpleDataSource();
+ final var ds = new PGSimpleDataSource();
// Server default to "localhost".
ds.setDatabaseName(Initializer.DATABASE);
Initializer.setDefault(() -> ds);
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
index f26f57f173..71c006484c 100644
---
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
@@ -22,7 +22,6 @@ import java.net.URISyntaxException;
import org.apache.sis.referencing.operation.gridded.GridFile;
// Test dependencies
-import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assertions.*;
import org.apache.sis.test.TestCase;
@@ -50,11 +49,8 @@ public abstract class DatumShiftTestCase extends TestCase {
*/
public static URL getResourceAsConvertibleURL(final String name) {
final URL file = DatumShiftTestCase.class.getResource(name);
- if (file == null) {
- fail("Test file \"" + name + "\" not found.");
- } else {
- assumeFalse("jar".equals(file.getProtocol()), "Cannot read grid
data in a JAR file.");
- }
+ assertNotNull(file, () -> "Test file \"" + name + "\" not found.");
+ assertFalse("jar".equals(file.getProtocol()), "Cannot read grid data
in a JAR file.");
return file;
}
@@ -66,10 +62,6 @@ public abstract class DatumShiftTestCase extends TestCase {
* @return the requested resources.
*/
static GridFile getResource(final String name) throws URISyntaxException {
- final URL file = getResourceAsConvertibleURL(name);
- if (file == null) {
- assumeFalse("jar".equals(file.getProtocol()), "Cannot read grid
data in a JAR file.");
- }
- return new GridFile(file.toURI());
+ return new GridFile(getResourceAsConvertibleURL(name).toURI());
}
}
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 c1b27d692f..368fae9223 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
@@ -42,7 +42,6 @@ import org.apache.sis.system.DataDirectory;
// Test dependencies
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.junit.jupiter.api.Assertions.*;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
@@ -184,12 +183,10 @@ public final class NTv2Test extends DatumShiftTestCase {
*/
@Test
public void testMultiGrids() throws Exception {
- assumeExtensiveTestsEnabled();
- assumeTrue(DataDirectory.getenv() != null);
+ assumeDataExists(DataDirectory.DATUM_CHANGES, MULTIGRID_TEST_FILE);
final Parameters pg = Parameters.castOrWrap(new
NTv2().getParameters().createValue());
pg.getOrCreate(NTv2.FILE).setValue(new URI(MULTIGRID_TEST_FILE));
final GridFile file = new GridFile(pg, NTv2.FILE);
- assumeTrue(Files.exists(file.path().orElseThrow()));
final LoadedGrid<Angle,Angle> grid = NTv2.getOrLoad(NTv2.class, file,
2);
assertInstanceOf(GridGroup.class, grid, "Should contain many grids.");
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 5dff7e902b..fadcdebda7 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
@@ -26,7 +26,6 @@ import org.apache.sis.referencing.operation.provider.NTv2Test;
import org.apache.sis.referencing.operation.provider.NADCONTest;
import
org.apache.sis.referencing.operation.provider.FranceGeocentricInterpolationTest;
import org.apache.sis.test.TestCase;
-import static org.apache.sis.test.Assumptions.assumeDataExists;
/**
@@ -51,7 +50,7 @@ public final class DatumShiftTest extends TestCase {
*/
@Test
public void testRGF93() throws Exception {
- final URI file = assumeDataExists(DataDirectory.DATUM_CHANGES,
"ntf_r93.gsb");
+ final URI file = assumeDataExists(DataDirectory.DATUM_CHANGES,
"ntf_r93.gsb").toUri();
NTv2Test.testRGF93(new GridFile(file));
}
@@ -63,8 +62,8 @@ public final class DatumShiftTest extends TestCase {
*/
@Test
public void testNADCON() throws Exception {
- final URI latitudeShifts =
assumeDataExists(DataDirectory.DATUM_CHANGES, "conus.las");
- final URI longitudeShifts =
assumeDataExists(DataDirectory.DATUM_CHANGES, "conus.los");
+ 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));
}
}
diff --git
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
index 8cf7796f26..4c53c1e0ee 100644
---
a/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
+++
b/endorsed/src/org.apache.sis.storage.geotiff/test/org/apache/sis/storage/geotiff/SelfConsistencyTest.java
@@ -17,10 +17,7 @@
package org.apache.sis.storage.geotiff;
import java.util.List;
-import java.util.Optional;
-import java.nio.file.Path;
import org.opengis.util.GenericName;
-import org.apache.sis.util.Workaround;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.GridCoverageResource;
import org.apache.sis.storage.IllegalNameException;
@@ -29,7 +26,6 @@ import org.apache.sis.storage.StorageConnector;
// Test dependencies
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assumptions.abort;
import static org.apache.sis.test.Assertions.assertMessageContains;
import org.apache.sis.test.OptionalTestData;
import org.apache.sis.storage.test.CoverageReadConsistency;
@@ -45,6 +41,7 @@ import org.apache.sis.storage.test.CoverageReadConsistency;
* @author Martin Desruisseaux (Geomatys)
* @author Alexis Manin (Geomatys)
*/
+@SuppressWarnings("exports")
public final class SelfConsistencyTest extends
CoverageReadConsistency<GeoTiffStore> {
/**
* Opens the test file to be used for all tests.
@@ -52,21 +49,7 @@ public final class SelfConsistencyTest extends
CoverageReadConsistency<GeoTiffSt
* @throws DataStoreException if an error occurred while opening the file.
*/
public SelfConsistencyTest() throws DataStoreException {
- super(openFile());
- }
-
- /**
- * Work around for RFE #4093999 in Sun's bug database
- * ("Relax constraint on placement of this()/super() call in
constructors").
- */
- @Workaround(library="JDK", version="1.7")
- private static GeoTiffStore openFile() throws DataStoreException {
- final Optional<Path> path = OptionalTestData.GEOTIFF.path();
- if (path.isPresent()) {
- return new GeoTiffStore(null, new StorageConnector(path.get()));
- }
- abort("Test file not found.");
- return null;
+ super(new GeoTiffStore(null, new
StorageConnector(OptionalTestData.GEOTIFF.path())));
}
/**
diff --git
a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/SelfConsistencyTest.java
b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/SelfConsistencyTest.java
index 9c6ad1d2b5..152a263954 100644
---
a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/SelfConsistencyTest.java
+++
b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/SelfConsistencyTest.java
@@ -16,16 +16,12 @@
*/
package org.apache.sis.storage.netcdf;
-import java.util.Optional;
-import java.nio.file.Path;
-import org.apache.sis.util.Workaround;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.GridCoverageResource;
import org.apache.sis.storage.StorageConnector;
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assumptions.abort;
import org.apache.sis.test.OptionalTestData;
import org.apache.sis.storage.test.CoverageReadConsistency;
@@ -39,6 +35,7 @@ import org.apache.sis.storage.test.CoverageReadConsistency;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
public final class SelfConsistencyTest extends
CoverageReadConsistency<NetcdfStore> {
/**
* Opens the test file to be used for all tests.
@@ -46,21 +43,7 @@ public final class SelfConsistencyTest extends
CoverageReadConsistency<NetcdfSto
* @throws DataStoreException if an error occurred while opening the file.
*/
public SelfConsistencyTest() throws DataStoreException {
- super(openFile());
- }
-
- /**
- * Work around for RFE #4093999 in Sun's bug database
- * ("Relax constraint on placement of this()/super() call in
constructors").
- */
- @Workaround(library="JDK", version="1.7")
- private static NetcdfStore openFile() throws DataStoreException {
- final Optional<Path> path = OptionalTestData.NETCDF.path();
- if (path.isPresent()) {
- return new NetcdfStore(null, new StorageConnector(path.get()));
- }
- abort("Test file not found.");
- return null;
+ super(new NetcdfStore(null, new
StorageConnector(OptionalTestData.NETCDF.path())));
}
/**
diff --git
a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
index efe8f74a50..33b1d9041b 100644
---
a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
+++
b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
@@ -34,7 +34,6 @@ import org.apache.sis.storage.StorageConnector;
// Test dependencies
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.apache.sis.test.TestCaseWithLogs;
@@ -60,7 +59,6 @@ public final class StoreTest extends TestCaseWithLogs {
private static Path testDirectory() throws URISyntaxException {
final URL sample = StoreTest.class.getResource("test-data/README.txt");
assertNotNull(sample, "Test data not found");
- assumeTrue(sample.getProtocol().equals("file"));
return Path.of(sample.toURI()).getParent();
}
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/DataDirectory.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/DataDirectory.java
index f041678426..203df7a185 100644
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/DataDirectory.java
+++
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/DataDirectory.java
@@ -142,7 +142,7 @@ public enum DataDirectory {
*
* @see System#getenv(String)
*/
- public static String getenv() throws SecurityException {
+ public static String getenv() {
return System.getenv(ENV);
}
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Reflect.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Reflect.java
index a871ad9f58..7d46a3d0ea 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Reflect.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Reflect.java
@@ -49,7 +49,7 @@ public final class Reflect implements
Consumer<StackWalker.StackFrame> {
* @throws SecurityException if this method is not allowed to get the
current thread
* context class loader or one of its parent.
*/
- public static ClassLoader getContextClassLoader() throws SecurityException
{
+ public static ClassLoader getContextClassLoader() {
final Reflect walker = new Reflect();
return
StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk((stream)
-> {
stream.forEach(walker);
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/MonolineFormatter.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/MonolineFormatter.java
index 2a5881b8b3..72f51579d9 100644
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/MonolineFormatter.java
+++
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/logging/MonolineFormatter.java
@@ -1020,7 +1020,7 @@ loop: for (int i=0; ; i++) {
* @throws SecurityException if this method does not have the permission
to install the formatter.
*/
@Configuration(writeAccess = Configuration.Access.STATIC)
- public static MonolineFormatter install() throws SecurityException {
+ public static MonolineFormatter install() {
return install(Logger.getLogger(""), null);
}
@@ -1065,7 +1065,7 @@ loop: for (int i=0; ; i++) {
*/
@Debug
@Configuration(writeAccess = Configuration.Access.STATIC)
- public static MonolineFormatter install(final Logger logger, final Level
level) throws SecurityException {
+ public static MonolineFormatter install(final Logger logger, final Level
level) {
MonolineFormatter monoline = null;
for (final Handler handler : logger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/converter/PathConverterTest.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/converter/PathConverterTest.java
index 78ec6c3681..99ef7b00c2 100644
---
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/converter/PathConverterTest.java
+++
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/converter/PathConverterTest.java
@@ -22,15 +22,14 @@ import java.net.URL;
import java.net.URISyntaxException;
import java.net.MalformedURLException;
import org.apache.sis.math.FunctionProperty;
-import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.ObjectConverter;
import org.apache.sis.util.UnconvertibleObjectException;
// Test dependencies
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.condition.DisabledOnOs;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.PlatformDependent;
import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
@@ -47,15 +46,6 @@ public final class PathConverterTest extends TestCase {
public PathConverterTest() {
}
- /**
- * Assumes that the platform file system has a Unix-style root.
- * Windows platform has driver letters instead, like "C:\\",
- * which are not correctly tested by this class.
- */
- private static void assumeUnixRoot() {
- assumeTrue(ArraysExt.contains(File.listRoots(), new File("/")));
- }
-
/**
* Asserts that conversion of the given {@code source} value produces
* the given {@code target} value, and tests the inverse conversion.
@@ -86,9 +76,8 @@ public final class PathConverterTest extends TestCase {
* @throws URISyntaxException if this test uses a malformed URI.
*/
@Test
- @PlatformDependent
+ @DisabledOnOs(OS.WINDOWS)
public void testFile_URI() throws URISyntaxException {
- assumeUnixRoot();
final ObjectConverter<File,URI> c = PathConverter.FileURI.INSTANCE;
runInvertibleConversion(c, new File("/home/user/index.txt"), new
URI("file:/home/user/index.txt"));
assertSerializedEquals(c);
@@ -100,9 +89,8 @@ public final class PathConverterTest extends TestCase {
* @throws MalformedURLException if this test uses a malformed URL.
*/
@Test
- @PlatformDependent
+ @DisabledOnOs(OS.WINDOWS)
public void testFile_URL() throws MalformedURLException {
- assumeUnixRoot();
final ObjectConverter<File,URL> c = PathConverter.FileURL.INSTANCE;
runInvertibleConversion(c, new File("/home/user/index.txt"),
URI.create("file:/home/user/index.txt").toURL());
assertSerializedEquals(c);
@@ -139,9 +127,8 @@ public final class PathConverterTest extends TestCase {
* @throws URISyntaxException if this test uses a malformed URI.
*/
@Test
- @PlatformDependent
+ @DisabledOnOs(OS.WINDOWS)
public void testURI_File() throws URISyntaxException {
- assumeUnixRoot();
final ObjectConverter<URI,File> c = PathConverter.URIFile.INSTANCE;
runInvertibleConversion(c, new URI("file:/home/user/index.txt"), new
File("/home/user/index.txt"));
assertSerializedEquals(c);
@@ -179,9 +166,8 @@ public final class PathConverterTest extends TestCase {
* @throws MalformedURLException if this test uses a malformed URL.
*/
@Test
- @PlatformDependent
+ @DisabledOnOs(OS.WINDOWS)
public void testURL_File() throws MalformedURLException {
- assumeUnixRoot();
final ObjectConverter<URL,File> c = PathConverter.URLFile.INSTANCE;
runInvertibleConversion(c,
URI.create("file:/home/user/index.txt").toURL(), new
File("/home/user/index.txt"));
assertSerializedEquals(c);
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assumptions.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assumptions.java
deleted file mode 100644
index 5ee7b45779..0000000000
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/Assumptions.java
+++ /dev/null
@@ -1,62 +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.test;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.nio.file.Files;
-import org.apache.sis.system.DataDirectory;
-
-// Test dependencies
-import static org.junit.jupiter.api.Assumptions.*;
-
-
-/**
- * Assumption methods used by the SIS project in addition of the JUnit ones.
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-public final class Assumptions {
- /**
- * Do not allow instantiation.
- */
- private Assumptions() {
- }
-
- /**
- * Assumes that the {@code SIS_DATA} environment variable is defined, that
the directory
- * exists and contains the given file. If this condition fails, then the
test is skipped.
- *
- * <p>This is used for tests that require data not distributed with SIS.
- * Examples of data not distributed with SIS are datum shift grids.
- * If desired, those grids need to be downloaded by the user and stored in
the directory
- * identified by the {@code SIS_DATA} environment variable.</p>
- *
- * @param type the directory where to search for the given file.
- * @param file the file that needs to exist.
- * @return the path to the given file.
- */
- public static URI assumeDataExists(final DataDirectory type, final String
file) {
- assumeTrue(System.getenv(DataDirectory.ENV) != null, "$SIS_DATA
environment variable not set.");
- Path path = type.getDirectory();
- assumeTrue(path != null, () -> "$SIS_DATA/" + type + " directory not
found.");
- path = path.resolve(file);
- assumeTrue(Files.exists(path), "Specified file or directory not
found.");
- assumeTrue(Files.isReadable(path), "Specified directory not
readable.");
- return path.toUri();
- }
-}
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
index 1acbc67967..b3e9838fc8 100644
---
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
+++
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/OptionalTestData.java
@@ -16,7 +16,6 @@
*/
package org.apache.sis.test;
-import java.util.Optional;
import java.io.LineNumberReader;
import java.io.IOException;
import java.io.InputStream;
@@ -26,7 +25,6 @@ import java.nio.file.Path;
import org.apache.sis.system.DataDirectory;
// Test dependencies
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
@@ -121,18 +119,13 @@ public enum OptionalTestData {
/**
* Returns the path to the test file if {@code $SIS_DATA} is defined an
the file exists.
+ * If the file does not exist, throws {@link
org.junit.AssumptionViolatedException} as
+ * by {@link org.junit.jupiter.api.Assumptions} methods.
*
- * @return path to the test file, or an empty optional if none.
+ * @return path to the test file.
*/
- public Optional<Path> path() {
- Path path = DataDirectory.TESTS.getDirectory();
- if (path != null) {
- path = path.resolve(filename);
- if (Files.isRegularFile(path)) {
- return Optional.of(path);
- }
- }
- return Optional.empty();
+ public Path path() {
+ return TestCase.assumeDataExists(DataDirectory.TESTS, filename);
}
/**
@@ -144,9 +137,7 @@ public enum OptionalTestData {
* @throws IOException if an error occurred while opening the test file.
*/
private InputStream open() throws IOException {
- final Optional<Path> path = path();
- assumeTrue(path.isPresent(), () -> "File “$SIS_DATA/Tests/" + filename
+ "” has not been found.");
- return Files.newInputStream(path.get());
+ return Files.newInputStream(path());
}
/**
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/PlatformDependent.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/PlatformDependent.java
deleted file mode 100644
index 3fbdfbb885..0000000000
---
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/PlatformDependent.java
+++ /dev/null
@@ -1,36 +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.test;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-
-
-/**
- * A marker annotation for platform-dependent tests. The platform-dependent
part may
- * be the Operating System, or whether some dependencies are present or not.
- *
- * <p>This annotation is used in order to remember which part of the SIS
library
- * (or its test suite) need to be revisited for better portability.</p>
- *
- * @author Martin Desruisseaux (Geomatys)
- */
-@Documented
-@Target(ElementType.METHOD)
-public @interface PlatformDependent {
-}
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestCase.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestCase.java
index 6b9d226d97..488c5f4cca 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestCase.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/TestCase.java
@@ -17,6 +17,10 @@
package org.apache.sis.test;
import java.util.Set;
+import java.nio.file.Path;
+import java.nio.file.Files;
+import org.apache.sis.system.DataDirectory;
+import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.logging.MonolineFormatter;
// Test dependencies
@@ -59,6 +63,22 @@ public abstract class TestCase {
f.setSourceFormat("class.method");
}
+ /**
+ * Performs an arbitrary operation which will force Apache SIS to check
whether the EPSG database exists.
+ * This is done before any test is started in order to avoid race
conditions causing the same message to
+ * be logged many times when tests are run in parallel. Note that those
race conditions do not break the
+ * tests (results are still correct). It only pollutes the logs, and may
cause random test failures when
+ * the test verifies the logs.
+ */
+ static {
+ try {
+
Class.forName("org.apache.sis.referencing.CommonCRS").getMethod("defaultGeographic").invoke(null);
+ } catch (ReflectiveOperationException | RuntimeException e) {
+ // It does not prevent the tests to work, but this is abnormal.
+ Logging.severeException(null, TestCase.class, "<clinit>", e);
+ }
+ }
+
/**
* Whether to run more extensive tests.
* If {@code true}, then the test suite will include some tests that were
normally skipped because they are slow.
@@ -163,4 +183,27 @@ public abstract class TestCase {
assumeTrue(available, "No connection to EPSG geodetic dataset.");
}
}
+
+ /**
+ * Assumes that the {@code SIS_DATA} environment variable is defined, that
the directory
+ * exists and contains the given file. If this condition fails, then the
test is skipped.
+ *
+ * <p>This is used for tests that require data not distributed with
<abbr>SIS</abbr>.
+ * Examples of data not distributed with <abbr>SIS</abbr> are datum shift
grids.
+ * If desired, those grids need to be downloaded by the user and stored in
the directory
+ * identified by the {@code SIS_DATA} environment variable.</p>
+ *
+ * @param type the directory where to search for the given file.
+ * @param file the file or directory that needs to exist.
+ * @return the path to the given file or directory.
+ */
+ protected static Path assumeDataExists(final DataDirectory type, final
String file) {
+ assumeTrue(DataDirectory.getenv() != null, DataDirectory.ENV + "
environment variable not set.");
+ Path path = type.getDirectory();
+ assumeTrue(path != null, () -> '$' + DataDirectory.ENV + '/' + type +
" directory not found.");
+ path = path.resolve(file);
+ assumeTrue(Files.exists(path), "File not found.");
+ assumeTrue(Files.isReadable(path), "File or directory not readable.");
+ return path;
+ }
}
diff --git
a/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
b/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
index 6ed52ec5ed..6a8cceb6c9 100644
---
a/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
+++
b/incubator/src/org.apache.sis.storage.geopackage/test/org/apache/sis/storage/geopackage/GpkgStoreTest.java
@@ -57,6 +57,7 @@ import org.opengis.feature.PropertyType;
*
* @author Johann Sorel (Geomatys)
*/
+@SuppressWarnings("exports")
@Execution(ExecutionMode.SAME_THREAD)
public final class GpkgStoreTest {
/**
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 18b541db15..0fa03223c4 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
@@ -45,6 +45,7 @@ import org.apache.sis.test.TestUtilities;
*
* @author Martin Desruisseaux (Geomatys)
*/
+@SuppressWarnings("exports")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public final class EmbeddedResourcesTest {
/**