This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/sis.git
commit 0af06aeeb2335011af92e60ff75cc089e4074f99 Merge: 878da1aaa3 5909d8a9de Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sat Feb 17 17:42:17 2024 +0100 Merge branch 'geoapi-3.1': Change of argument order in `Assertions` classes for consistency with JUnit 5 convention. .../sis/coverage/grid/DimensionAppenderTest.java | 2 +- .../coverage/grid/DimensionalityReductionTest.java | 4 +- .../sis/coverage/grid/GridDerivationTest.java | 62 +++++---- .../apache/sis/coverage/grid/GridExtentTest.java | 32 ++--- .../apache/sis/coverage/grid/GridGeometryTest.java | 115 ++++++++-------- .../sis/coverage/grid/PixelTranslationTest.java | 28 ++-- .../coverage/grid/ResampledGridCoverageTest.java | 6 +- .../test/org/apache/sis/metadata/Assertions.java | 9 +- .../apache/sis/metadata/PropertyAccessorTest.java | 10 +- .../sis/metadata/PropertyInformationTest.java | 2 +- .../test/org/apache/sis/metadata/TreeNodeTest.java | 2 +- .../sis/metadata/iso/DefaultIdentifierTest.java | 4 +- .../sis/metadata/iso/DefaultMetadataTest.java | 28 ++-- .../sis/metadata/iso/citation/CitationsTest.java | 32 ++--- .../metadata/iso/citation/DefaultCitationTest.java | 15 +- .../DefaultDataIdentificationTest.java | 3 +- .../DefaultServiceIdentificationTest.java | 9 +- .../apache/sis/xml/NilReasonMarshallingTest.java | 11 +- .../org/apache/sis/xml/UUIDMarshallingTest.java | 12 +- .../sis/xml/bind/fra/DataIdentificationTest.java | 4 +- .../apache/sis/io/wkt/MathTransformParserTest.java | 28 ++-- .../org/apache/sis/io/wkt/WKTDictionaryTest.java | 8 +- .../org/apache/sis/referencing/Assertions.java | 4 +- .../org/apache/sis/referencing/CommonCRSTest.java | 7 +- .../sis/referencing/GeodeticCalculatorTest.java | 9 +- .../sis/referencing/ImmutableIdentifierTest.java | 18 +-- .../referencing/crs/DefaultCompoundCRSTest.java | 6 +- .../sis/referencing/crs/DefaultDerivedCRSTest.java | 12 +- .../referencing/crs/DefaultEngineeringCRSTest.java | 4 +- .../sis/referencing/crs/DefaultImageCRSTest.java | 2 +- .../referencing/crs/DefaultProjectedCRSTest.java | 4 +- .../sis/referencing/cs/CoordinateSystemsTest.java | 50 +++---- .../referencing/cs/DefaultCylindricalCSTest.java | 6 +- .../sis/referencing/cs/DefaultPolarCSTest.java | 6 +- .../sis/referencing/cs/DefaultSphericalCSTest.java | 4 +- .../referencing/datum/BursaWolfParametersTest.java | 18 +-- .../datum/DefaultGeodeticDatumTest.java | 10 +- .../datum/DefaultTemporalDatumTest.java | 4 +- .../referencing/datum/TimeDependentBWPTest.java | 4 +- .../factory/CommonAuthorityFactoryTest.java | 18 +-- .../sis/referencing/factory/TestFactorySource.java | 4 +- .../referencing/factory/sql/EPSGFactoryTest.java | 30 ++-- .../operation/CoordinateOperationFinderTest.java | 31 ++--- .../DefaultConcatenatedOperationTest.java | 10 +- .../operation/DefaultConversionTest.java | 47 ++++--- .../operation/DefaultOperationMethodTest.java | 4 +- .../operation/DefaultPassThroughOperationTest.java | 8 +- .../operation/SingleOperationMarshallingTest.java | 10 +- .../builder/LinearTransformBuilderTest.java | 37 ++--- .../operation/builder/LinearizerTest.java | 15 +- .../builder/LocalizationGridBuilderTest.java | 6 +- .../operation/builder/ResidualGridTest.java | 2 +- .../referencing/operation/matrix/MatricesTest.java | 40 +++--- .../referencing/operation/matrix/Matrix4Test.java | 14 +- .../operation/matrix/MatrixTestCase.java | 2 +- .../operation/matrix/NonSquareMatrixTest.java | 24 ++-- .../operation/projection/MercatorTest.java | 6 +- .../projection/ObliqueStereographicTest.java | 2 +- .../operation/provider/Geographic3Dto2DTest.java | 22 +-- .../operation/provider/LongitudeRotationTest.java | 11 +- .../referencing/operation/provider/NADCONTest.java | 9 +- .../referencing/operation/provider/NTv2Test.java | 9 +- .../transform/ConcatenatedTransformTest.java | 28 ++-- .../transform/ContextualParametersTest.java | 24 ++-- .../transform/DefaultMathTransformFactoryTest.java | 19 +-- .../operation/transform/MathTransformsTest.java | 22 +-- .../transform/PassThroughTransformTest.java | 8 +- .../transform/ProjectiveTransformTest.java | 10 +- .../operation/transform/ScaleTransformTest.java | 5 +- .../operation/transform/TransferFunctionTest.java | 10 +- .../transform/TransformResultComparator.java | 2 +- .../transform/TransformSeparatorTest.java | 36 ++--- .../transform/TranslationTransformTest.java | 5 +- .../transform/WraparoundTransformTest.java | 40 +++--- .../util/EllipsoidalHeightCombinerTest.java | 20 +-- .../util/GeodeticObjectBuilderTest.java | 3 +- .../sis/test/integration/MetadataVerticalTest.java | 11 +- .../sis/storage/base/MetadataBuilderTest.java | 10 +- .../test/org/apache/sis/storage/wkt/StoreTest.java | 2 +- .../sis/converter/ConverterRegistryTest.java | 152 ++++++++++----------- .../test/org/apache/sis/io/AppenderTestCase.java | 2 +- .../test/org/apache/sis/test/Assertions.java | 6 +- .../test/org/apache/sis/test/GeoapiAssert.java | 131 ++++++++++++------ .../test/org/apache/sis/test/TestCase.java | 2 +- 84 files changed, 785 insertions(+), 718 deletions(-) diff --cc endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java index 6b40f4e8f7,6b33cb7346..9ca6aa7eb1 --- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java +++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/coverage/grid/GridDerivationTest.java @@@ -44,7 -44,7 +44,6 @@@ import static org.apache.sis.coverage.g // Test dependencies import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; - import static org.opengis.test.Assert.assertBetween; -import static org.opengis.test.Assertions.assertBetween; import org.apache.sis.test.TestCase; import org.apache.sis.test.DependsOn; import org.apache.sis.test.DependsOnMethod; @@@ -52,8 -52,8 +51,9 @@@ import org.apache.sis.referencing.crs.H import org.apache.sis.referencing.operation.HardCodedConversions; import static org.apache.sis.referencing.Assertions.assertEnvelopeEquals; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import static org.opengis.test.Assertions.assertMatrixEquals; +// Specific to the main branch: ++import static org.apache.sis.test.GeoapiAssert.assertBetween; +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; /** diff --cc endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java index 2367c2a972,63fd863c48..2b0ec2147f --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/Assertions.java @@@ -76,13 -72,13 +75,13 @@@ public final class Assertions extends S * Asserts that the given citation has only one responsible party, * and its English name is equal to the expected string. * - * @param message the message to report in case of test failure. * @param expected the expected English responsibly party name. * @param citation the citation to test. + * @param message the message to report in case of test failure. */ - public static void assertPartyNameEquals(final String message, final String expected, final Citation citation) { + public static void assertPartyNameEquals(final String expected, final Citation citation, final String message) { assertNotNull(citation, message); - final Responsibility r = getSingleton(citation.getCitedResponsibleParties()); + final DefaultResponsibility r = (DefaultResponsibility) getSingleton(citation.getCitedResponsibleParties()); final InternationalString name = getSingleton(r.getParties()).getName(); assertNotNull(name, message); assertEquals(expected, name.toString(Locale.US), message); diff --cc endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java index 427b2f675d,1f08f347a6..a2d21994c2 --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/DefaultMetadataTest.java @@@ -230,8 -233,8 +230,8 @@@ public final class DefaultMetadataTest * Verifies that the deprecated method get its value from the CitationDate objects. */ Date creation = date("2014-10-07 00:00:00"); - final DefaultCitationDate[] dates = new DefaultCitationDate[] { + final var dates = new DefaultCitationDate[] { - new DefaultCitationDate(date("2014-10-09 00:00:00"), DateType.LAST_UPDATE), + new DefaultCitationDate(date("2014-10-09 00:00:00"), DateType.valueOf("LAST_UPDATE")), new DefaultCitationDate(creation, DateType.CREATION) }; metadata.setDateInfo(Arrays.asList(dates)); @@@ -277,8 -280,10 +277,8 @@@ @Test @SuppressWarnings("deprecation") public void testDataSetUri() throws URISyntaxException { - final DefaultMetadata metadata = new DefaultMetadata(); + final var metadata = new DefaultMetadata(); metadata.setDataSetUri("file:/tmp/myfile.txt"); assertEquals("file:/tmp/myfile.txt", metadata.getDataSetUri()); - assertEquals("file:/tmp/myfile.txt", getSingleton(getSingleton(metadata.getIdentificationInfo()) - .getCitation().getOnlineResources()).getLinkage().toString()); } } diff --cc endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java index db4b94321d,638f2abd01..ff2da6b01c --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/citation/CitationsTest.java @@@ -291,9 -287,9 +291,9 @@@ public final class CitationsTest extend */ @Test public void testIdentifierMatches() { - final Identifier ogc = new Id("OGC", "06-042"); - final Identifier iso = new Id("ISO", "19128"); - final DefaultCitation citation = new DefaultCitation("Web Map Server"); - final var ogc = new DefaultIdentifier("OGC", "06-042", null); - final var iso = new DefaultIdentifier("ISO", "19128", null); ++ final var ogc = new Id("OGC", "06-042"); ++ final var iso = new Id("ISO", "19128"); + final var citation = new DefaultCitation("Web Map Server"); citation.setIdentifiers(List.of(ogc, iso, new DefaultIdentifier("Foo", "06-042", null))); assertTrue (/* With full identifier */ Citations.identifierMatches(citation, ogc, ogc.getCode())); assertTrue (/* With full identifier */ Citations.identifierMatches(citation, iso, iso.getCode())); diff --cc endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java index 7ea1069485,072bd2e931..db634ae99a --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java @@@ -117,10 -122,10 +116,10 @@@ public final class DefaultServiceIdenti */ @Test public void testUnmarshal() throws JAXBException { - final ServiceIdentification id = unmarshalFile(ServiceIdentification.class, openTestFile(Format.XML2016)); + final DefaultServiceIdentification id = unmarshalFile(DefaultServiceIdentification.class, openTestFile(Format.XML2016)); verify(id); - final CoupledResource resource = getSingleton(id.getCoupledResources()); + final DefaultCoupledResource resource = getSingleton(id.getCoupledResources()); - assertTitleEquals("resourceReference", "WMS specification", getSingleton(resource.getResourceReferences())); + assertTitleEquals("WMS specification", getSingleton(resource.getResourceReferences()), "resourceReference"); } /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java index 06091f9b8e,81a6e15c69..7d959e30e1 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java @@@ -29,6 -29,6 +29,7 @@@ import static java.lang.StrictMath.* import net.sf.geographiclib.Geodesic; import net.sf.geographiclib.GeodesicData; import org.opengis.geometry.DirectPosition; ++import org.opengis.referencing.cs.AxisDirection; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.TransformException; import org.apache.sis.referencing.util.Formulas; @@@ -43,7 -43,7 +44,6 @@@ import static org.apache.sis.metadata.i // Test dependencies import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; - import static org.opengis.test.Assert.assertBetween; -import static org.opengis.test.Assertions.assertBetween; import org.apache.sis.test.OptionalTestData; import org.apache.sis.test.DependsOnMethod; import org.apache.sis.test.TestUtilities; @@@ -51,6 -51,10 +51,9 @@@ import org.apache.sis.test.TestCase import org.apache.sis.test.widget.VisualCheck; import org.apache.sis.referencing.crs.HardCodedCRS; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.referencing.cs.AxisDirection; -import static org.opengis.test.Assertions.assertAxisDirectionsEqual; ++import static org.apache.sis.test.GeoapiAssert.assertBetween; ++import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual; + /** * Tests {@link GeodeticCalculator}. Test values come from the following sources: diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java index fa6d39a987,52620a2019..8978d2d2e7 --- 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 @@@ -29,7 -29,7 +29,7 @@@ import org.apache.sis.referencing.facto // Test dependencies import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assumptions.*; - import static org.opengis.test.Assert.assertBetween; -import static org.opengis.test.Assertions.assertBetween; ++import static org.apache.sis.test.GeoapiAssert.assertBetween; /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java index 4dc567c418,91583ffe8f..0f6cbb3000 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java @@@ -70,9 -70,10 +70,10 @@@ import org.apache.sis.referencing.cs.Ha import org.apache.sis.referencing.crs.HardCodedCRS; import static org.apache.sis.test.Assertions.assertMessageContains; import static org.apache.sis.test.Assertions.assertSetEquals; + import static org.apache.sis.test.TestCase.STRICT; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.test.Assertions; +// Specific to the main branch: +import org.apache.sis.test.GeoapiAssert; /** @@@ -170,8 -166,9 +166,9 @@@ public final class CoordinateOperationF * Verifies that the current transform is a linear transform with a matrix equals to the given one. */ private void assertMatrixEquals(final Matrix expected) { - GeoapiAssert.assertMatrixEquals("transform.matrix", expected, - assertInstanceOf(LinearTransform.class, transform).getMatrix(), STRICT); - Assertions.assertMatrixEquals(expected, ++ GeoapiAssert.assertMatrixEquals(expected, + assertInstanceOf(LinearTransform.class, transform).getMatrix(), + STRICT, "transform.matrix"); } /** @@@ -971,16 -967,16 +968,16 @@@ assertEquals("CompoundCRS[“Test3D”] ⟶ CompoundCRS[“Test4D”]", operation.getName().getCode()); transform = operation.getMathTransform(); - assertInstanceOf(LinearTransform.class, transform); - assertEquals(3, transform.getSourceDimensions()); - assertEquals(4, transform.getTargetDimensions()); - GeoapiAssert.assertMatrixEquals("transform.matrix", Matrices.create(5, 4, new double[] { - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 0, 0, - 0, 0, 1./(24*60*60), 40587, - 0, 0, 0, 1 - }), ((LinearTransform) transform).getMatrix(), 1E-12); + final var linear = assertInstanceOf(LinearTransform.class, transform); + assertEquals(3, linear.getSourceDimensions()); + assertEquals(4, linear.getTargetDimensions()); - Assertions.assertMatrixEquals(Matrices.create(5, 4, new double[] { ++ GeoapiAssert.assertMatrixEquals(Matrices.create(5, 4, new double[] { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 1./(24*60*60), 40587, + 0, 0, 0, 1 + }), linear.getMatrix(), 1E-12, "transform.matrix"); tolerance = 2E-12; verifyTransform(new double[] { diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java index a0861e0b6e,c0bbd2bf6f..f594a21d5a --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/builder/LinearizerTest.java @@@ -69,12 -67,11 +69,11 @@@ public final class LinearizerTest exten assertFalse(transform instanceof LinearTransform); // Linear approximation by Least Square Root method. - final LinearTransform linear = LinearTransformBuilder.approximate(transform, new Envelope2D(null, 0, 0, 3, 5)); - assertMatrixEquals("linear", - new Matrix3(111319, 0, 0, - 0, 110662, -62, - 0, 0, 1), linear.getMatrix(), 0.5); - + LinearTransform linear = LinearTransformBuilder.approximate(transform, new Envelope2D(null, 0, 0, 3, 5)); + var expected = new Matrix3(111319, 0, 0, + 0, 110662, -62, + 0, 0, 1); - Assertions.assertMatrixEquals(expected, linear.getMatrix(), 0.5, "linear"); ++ assertMatrixEquals(expected, linear.getMatrix(), 0.5, "linear"); assertSame(points.create(null), linear, "Should have extracted the existing instance instead of computing a new one."); } } diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java index eb24db5d46,698baddfd7..8946798018 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MercatorTest.java @@@ -36,13 -36,13 +36,13 @@@ import static org.apache.sis.referencin // Test dependencies import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; - import static org.opengis.test.Assert.assertBetween; -import static org.opengis.test.Assertions.assertBetween; import org.apache.sis.test.DependsOnMethod; import org.apache.sis.test.DependsOn; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.apache.sis.referencing.operation.provider.MercatorSpherical; -import org.apache.sis.referencing.operation.provider.RegionalMercator; +// Specific to the main branch: +import static org.junit.jupiter.api.Assumptions.assumeTrue; ++import static org.apache.sis.test.GeoapiAssert.assertBetween; +import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE; /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java index f3bf6b4bd4,7fda3f1253..350b52ed62 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/ObliqueStereographicTest.java @@@ -360,7 -375,9 +360,7 @@@ public final class ObliqueStereographic final Matrix derivative = spherical.transform(srcPts, 0, null, 0, true); tolerance = 1E-12; - assertMatrixEquals("Spherical derivative", reference, derivative, tolerance); - assertMatrixEquals("Spherical derivative", reference, derivative, - new Matrix2(tolerance, tolerance, - tolerance, tolerance)); ++ assertMatrixEquals(reference, derivative, tolerance, "Spherical derivative"); } /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java index 600769d889,99dab2407b..d764e3dc45 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ConcatenatedTransformTest.java @@@ -29,10 -29,11 +29,11 @@@ import org.apache.sis.referencing.opera // Test dependencies import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; + import static org.apache.sis.test.TestCase.STRICT; import org.apache.sis.test.DependsOn; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.test.Assertions; +// Specific to the main branch: +import static org.apache.sis.test.GeoapiAssert.assertMatrixEquals; /** @@@ -185,10 -181,11 +181,11 @@@ public final class ConcatenatedTransfor * Dropping a dimension is not a problem. */ final MathTransform c = MathTransforms.concatenate(tr1, tr2.inverse()); - assertMatrixEquals("Forward", Matrices.create(3, 4, new double[] { - 4, 0, 0, 0, // scale = 8/2 - 0, 2, 0, 0, // scale = 6/3 - 0, 0, 0, 1}), MathTransforms.getMatrix(c), STRICT); - Assertions.assertMatrixEquals(Matrices.create(3, 4, new double[] { ++ assertMatrixEquals(Matrices.create(3, 4, new double[] { + 4, 0, 0, 0, // scale = 8/2 + 0, 2, 0, 0, // scale = 6/3 + 0, 0, 0, 1 + }), MathTransforms.getMatrix(c), STRICT, "Forward"); /* * Following test is the interesting part. By inverting the transform, we ask for a conversion * from 2D points to 3D points. Without contextual information we would not know which value to @@@ -196,11 -193,12 +193,12 @@@ * this concatenation was built from a transform which was putting value 5 in third dimension, * we can complete the matrix as below with value 10 in third dimension. */ - assertMatrixEquals("Inverse", Matrices.create(4, 3, new double[] { - 0.25, 0, 0, - 0, 0.5, 0, - 0, 0, 10, // Having value 10 instead of NaN is the main purpose of this test. - 0, 0, 1}), MathTransforms.getMatrix(c.inverse()), STRICT); - Assertions.assertMatrixEquals(Matrices.create(4, 3, new double[] { ++ assertMatrixEquals(Matrices.create(4, 3, new double[] { + 0.25, 0, 0, + 0, 0.5, 0, + 0, 0, 10, // Having value 10 instead of NaN is the main purpose of this test. + 0, 0, 1 + }), MathTransforms.getMatrix(c.inverse()), STRICT, "Inverse"); } /** @@@ -218,6 -216,6 +216,6 @@@ final MathTransform tr2 = MathTransforms.linear(new Matrix2(-1, 0, 0, 1)); final MathTransform c = MathTransforms.concatenate(tr1, tr2); final Matrix m = ((LinearTransform) c).getMatrix(); - assertMatrixEquals("Concatenate", new Matrix2(-4.9E-324, 5387, 0, 1), m, STRICT); - Assertions.assertMatrixEquals(new Matrix2(-4.9E-324, 5387, 0, 1), m, STRICT, "Concatenate"); ++ assertMatrixEquals(new Matrix2(-4.9E-324, 5387, 0, 1), m, STRICT, "Concatenate"); } } diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java index 1292d77340,bebb69e751..e030710198 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/PassThroughTransformTest.java @@@ -276,8 -289,8 +276,8 @@@ public final class PassThroughTransform 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}); -- assertMatrixEquals("Expected removal of dimensions 0 and 4 before pass-through", - m, MathTransforms.getMatrix(steps.get(0)), 0); - m, MathTransforms.getMatrix(steps.get(0)), null); ++ assertMatrixEquals(m, MathTransforms.getMatrix(steps.get(0)), 0, ++ "Expected removal of dimensions 0 and 4 before pass-through"); /* * The number of pass-through dimensions have decreased from 2 to 1 on both sides of the sub-transform. */ @@@ -294,8 -307,8 +294,8 @@@ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1}); -- assertMatrixEquals("Expected removal of dimensions 1 and 2 after pass-through", - m, MathTransforms.getMatrix(steps.get(2)), 0); - m, MathTransforms.getMatrix(steps.get(2)), null); ++ assertMatrixEquals(m, MathTransforms.getMatrix(steps.get(2)), 0, ++ "Expected removal of dimensions 1 and 2 after pass-through"); } /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java index 288efae560,8cad25b902..fd3e72026d --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java @@@ -39,11 -38,11 +39,12 @@@ import org.junit.jupiter.api.Test import org.opengis.test.Validators; import org.apache.sis.test.DependsOn; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: +// Specific to the main branch: +import org.junit.jupiter.api.Disabled; import static org.junit.jupiter.api.Assertions.*; + import static org.apache.sis.test.TestCase.STRICT; -import org.opengis.test.Assertions; -import org.opengis.test.referencing.AffineTransformTest; +import org.opengis.test.referencing.TransformTestCase; +import org.apache.sis.test.GeoapiAssert; /** @@@ -54,24 -53,8 +55,19 @@@ * * @author Martin Desruisseaux (Geomatys) */ +@SuppressWarnings("doclint:missing") @DependsOn({AbstractMathTransformTest.class, ScaleTransformTest.class}) -public class ProjectiveTransformTest extends AffineTransformTest { +public class ProjectiveTransformTest extends TransformTestCase { + /** + * The factory to use for creating linear transforms. + */ + private final MathTransformFactory mtFactory; + + /** + * The matrix for the tested transform. + */ + private Matrix matrix; + - /** - * Tolerance factor for strict comparisons. - */ - private static final double STRICT = 0; - /** * A math transform factory which delegates instantiations to the enclosing test class. * This is a workaround for RFE #4093999 ("Relax constraint on placement of this()/super() @@@ -246,8 -169,9 +242,8 @@@ public void testOptimizeConstant() throws FactoryException, TransformException { matrix = new Matrix2(0, 10, 0, 1); transform = mtFactory.createAffineTransform(matrix); - GeoapiAssert.assertMatrixEquals("Transform shall use the given matrix unmodified.", - matrix, assertInstanceOf(LinearTransform.class, transform).getMatrix(), STRICT); - Assertions.assertMatrixEquals(matrix, assertInstanceOf(LinearTransform.class, transform).getMatrix(), STRICT, ++ GeoapiAssert.assertMatrixEquals(matrix, assertInstanceOf(LinearTransform.class, transform).getMatrix(), STRICT, + "Transform shall use the given matrix unmodified."); - verifyConsistency(1, 2, 3, -3, -2, -1); } /** diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java index e59917ef7b,8f9057b329..5284c18775 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ScaleTransformTest.java @@@ -57,7 -58,7 +58,7 @@@ public final class ScaleTransformTest e final ScaleTransform tr = new ScaleTransform(matrix.getNumRow(), matrix.getNumCol(), elements); assertEquals(sourceDimensions, tr.getSourceDimensions()); assertEquals(targetDimensions, tr.getTargetDimensions()); - GeoapiAssert.assertMatrixEquals("matrix", matrix, tr.getMatrix(), 0.0); - Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); ++ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); assertArrayEquals(elements, TranslationTransformTest.getElementAsNumbers(tr)); transform = tr; validate(); @@@ -140,7 -141,7 +141,7 @@@ final ScaleTransform tr = new ScaleTransform(4, 4, elements); assertEquals(3, tr.getSourceDimensions()); assertEquals(3, tr.getTargetDimensions()); - GeoapiAssert.assertMatrixEquals("matrix", matrix, tr.getMatrix(), 0.0); - Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); ++ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); TranslationTransformTest.replaceZeroByNull(elements, O); assertArrayEquals(elements, tr.getElementAsNumbers(false)); diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java index 35914d0817,b1e1774845..5ad569505e --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/TranslationTransformTest.java @@@ -57,7 -58,7 +58,7 @@@ public final class TranslationTransform final TranslationTransform tr = new TranslationTransform(matrix.getNumRow(), elements); assertEquals(dimensions, tr.getSourceDimensions()); assertEquals(dimensions, tr.getTargetDimensions()); - GeoapiAssert.assertMatrixEquals("matrix", matrix, tr.getMatrix(), 0.0); - Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); ++ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); assertArrayEquals(elements, getElementAsNumbers(tr)); transform = tr; validate(); @@@ -99,7 -100,7 +100,7 @@@ final TranslationTransform tr = new TranslationTransform(4, elements); assertEquals(3, tr.getSourceDimensions()); assertEquals(3, tr.getTargetDimensions()); - GeoapiAssert.assertMatrixEquals("matrix", matrix, tr.getMatrix(), 0.0); - Assertions.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); ++ GeoapiAssert.assertMatrixEquals(matrix, tr.getMatrix(), STRICT, "matrix"); replaceZeroByNull(elements, O); assertArrayEquals(elements, tr.getElementAsNumbers(false)); diff --cc endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java index c029ff57fd,a3d8f44178..6ef1ccf9b5 --- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java +++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java @@@ -86,10 -86,10 +86,10 @@@ public final class MetadataBuilderTest * @param notice the copyright statement to parse. */ private static void verifyCopyrightParsing(final String notice) { - final MetadataBuilder builder = new MetadataBuilder(); + final var builder = new MetadataBuilder(); builder.parseLegalNotice(notice); - final DefaultLegalConstraints constraints = (DefaultLegalConstraints) getSingleton(getSingleton( - builder.build().getIdentificationInfo()).getResourceConstraints()); - final var constraints = assertInstanceOf(LegalConstraints.class, - getSingleton(getSingleton(builder.build().getIdentificationInfo()).getResourceConstraints())); ++ final var constraints = assertInstanceOf(DefaultLegalConstraints.class, getSingleton(getSingleton( ++ builder.build().getIdentificationInfo()).getResourceConstraints())); assertEquals(Restriction.COPYRIGHT, getSingleton(constraints.getUseConstraints())); final Citation ref = getSingleton(constraints.getReferences()); diff --cc endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java index 383176d3b3,0000000000..a89e46e757 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java +++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java @@@ -1,194 -1,0 +1,247 @@@ +/* + * 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.util.Collection; +import org.opengis.metadata.citation.Citation; +import org.opengis.referencing.ReferenceIdentifier; +import org.opengis.referencing.cs.AxisDirection; +import org.opengis.referencing.cs.CoordinateSystem; +import org.opengis.referencing.operation.Matrix; +import org.opengis.util.InternationalString; +import org.apache.sis.util.Static; ++import org.opengis.test.Assert; + - // Test dependencies - import static org.junit.jupiter.api.Assertions.assertEquals; - import static org.junit.jupiter.api.Assertions.fail; ++import static org.junit.jupiter.api.Assertions.*; + + +/** + * Temporary class for test methods that are expected to be provided in next GeoAPI release. + * Those methods are defined in a separated class in order to make easier for us to identify + * which methods may be removed from SIS (actually moved to GeoAPI) in a future GeoAPI release. + * - * <p>This class is needed for Apache SIS trunk, since the later is linked to GeoAPI official release. ++ * <p>This class is needed for Apache SIS main branch, since the later is linked to GeoAPI official release. + * But this class can be removed on Apache SIS branches which are linked to a GeoAPI development branch.</p> + * + * @author Martin Desruisseaux (Geomatys) + */ +public final class GeoapiAssert extends Static { + /** + * A flag for code that are pending next GeoAPI release before to be enabled. + * This flag is always set to {@code false}, except occasionally just before + * a GeoAPI release for testing purpose. It shall be used as below: + * + * {@snippet lang="java" : + * if (PENDING_NEXT_GEOAPI_RELEASE) { + * // Do some stuff here. + * } + * } + * + * The intend is to make easier to identify test cases that fail with the current version + * of the {@code geoapi-conformance} module, but should pass with the development snapshot. + */ + public static final boolean PENDING_NEXT_GEOAPI_RELEASE = false; + + /** + * The keyword for unrestricted value in {@link String} arguments. + */ + private static final String UNRESTRICTED = "##unrestricted"; + + /** + * Do not allow instantiation of this class. + */ + private GeoapiAssert() { + } + ++ private static String nonNull(final String message) { ++ return (message != null) ? message.trim().concat(" ") : ""; ++ } ++ + /** + * Returns the concatenation of the given message with the given extension. + * This method returns the given extension if the message is null or empty. + * + * <p>Invoking this method is equivalent to invoking {@code nonNull(message) + ext}, + * but avoid the creation of temporary objects in the common case where the message + * is null.</p> + * - * @param message The message, or {@code null}. - * @param ext The extension to append after the message. - * @return The concatenated string. ++ * @param message the message, or {@code null}. ++ * @param ext the extension to append after the message. ++ * @return the concatenated string. + */ + private static String concat(String message, final String ext) { + if (message == null || (message = message.trim()).isEmpty()) { + return ext; + } + return message + ' ' + ext; + } + + /** + * Verifies if we expected a null value, then returns {@code true} if the value is null as expected. + */ - private static boolean isNull(final String message, final Object expected, final Object actual) { ++ private static boolean isNull(final Object expected, final Object actual, final String message) { + final boolean isNull = (actual == null); + if (isNull != (expected == null)) { + fail(concat(message, isNull ? "Value is null." : "Expected null.")); + } + return isNull; + } + ++ public static void assertPositive(final int value, final String message) { ++ Assert.assertPositive(message, value); ++ } ++ ++ public static void assertStrictlyPositive(final int value, final String message) { ++ Assert.assertStrictlyPositive(message, value); ++ } ++ ++ public static <T> void assertValidRange(final Comparable<T> minimum, final Comparable<T> maximum, final String message) { ++ Assert.assertValidRange(message, minimum, maximum); ++ } ++ ++ public static void assertValidRange(final int minimum, final int maximum, final String message) { ++ Assert.assertValidRange(message, minimum, maximum); ++ } ++ ++ public static void assertValidRange(final double minimum, final double maximum, final String message) { ++ Assert.assertValidRange(message, minimum, maximum); ++ } ++ ++ public static <T> void assertBetween(final Comparable<T> minimum, final Comparable<T> maximum, T value, final String message) { ++ Assert.assertBetween(message, minimum, maximum, value); ++ } ++ ++ public static void assertBetween(final int minimum, final int maximum, final int value, final String message) { ++ Assert.assertBetween(message, minimum, maximum, value); ++ } ++ ++ public static void assertBetween(final double minimum, final double maximum, final double value, final String message) { ++ Assert.assertBetween(message, minimum, maximum, value); ++ } ++ ++ public static void assertContains(final Collection<?> collection, final Object value, final String message) { ++ Assert.assertContains(message, collection, value); ++ } ++ + /** + * Asserts that the title or an alternate title of the given citation is equal to the given string. + * This method is typically used for testing if a citation stands for the OGC, OGP or EPSG authority + * for instance. Such abbreviations are often declared as {@linkplain Citation#getAlternateTitles() + * alternate titles} rather than the main {@linkplain Citation#getTitle() title}, but this method + * tests both for safety. + * - * @param message Header of the exception message in case of failure, or {@code null} if none. - * @param expected The expected title or alternate title. - * @param actual The citation to test. ++ * @param expected the expected title or alternate title. ++ * @param actual the citation to test. ++ * @param message header of the exception message in case of failure, or {@code null} if none. + */ - public static void assertAnyTitleEquals(final String message, final String expected, final Citation actual) { - if (isNull(message, expected, actual)) { ++ public static void assertAnyTitleEquals(final String expected, final Citation actual, final String message) { ++ if (isNull(expected, actual, message)) { + return; + } + InternationalString title = actual.getTitle(); + if (title != null && expected.equals(title.toString())) { + return; + } + for (final InternationalString t : actual.getAlternateTitles()) { + if (expected.equals(t.toString())) { + return; + } + } + fail(concat(message, '"' + expected + "\" not found in title or alternate titles.")); + } + + /** - * Asserts that the given identifier is equals to the given authority, code space, version and code. ++ * Asserts that the given identifier is equal to the given authority, code space, version and code. + * If any of the above-cited properties is {@code ""##unrestricted"}, then it will not be verified. + * This flexibility is useful in the common case where a test accepts any {@code version} value. + * - * @param message Header of the exception message in case of failure, or {@code null} if none. - * @param authority The expected authority title or alternate title (may be {@code null}), or {@code "##unrestricted"}. - * @param codeSpace The expected code space (may be {@code null}), or {@code "##unrestricted"}. - * @param version The expected version (may be {@code null}), or {@code "##unrestricted"}. - * @param code The expected code value (may be {@code null}), or {@code "##unrestricted"}. - * @param actual The identifier to test. ++ * @param authority the expected authority title or alternate title (may be {@code null}), or {@code "##unrestricted"}. ++ * @param codeSpace the expected code space (may be {@code null}), or {@code "##unrestricted"}. ++ * @param version the expected version (may be {@code null}), or {@code "##unrestricted"}. ++ * @param code the expected code value (may be {@code null}), or {@code "##unrestricted"}. ++ * @param actual the identifier to test. ++ * @param message header of the exception message in case of failure, or {@code null} if none. + */ - public static void assertIdentifierEquals(final String message, final String authority, final String codeSpace, - final String version, final String code, final ReferenceIdentifier actual) ++ public static void assertIdentifierEquals(final String authority, final String codeSpace, final String version, ++ final String code, final ReferenceIdentifier actual, final String message) + { + if (actual == null) { + fail(concat(message, "Identifier is null")); + } else { - if (!UNRESTRICTED.equals(authority)) assertAnyTitleEquals(message, authority, actual.getAuthority()); ++ if (!UNRESTRICTED.equals(authority)) assertAnyTitleEquals(authority, actual.getAuthority(), message); + if (!UNRESTRICTED.equals(codeSpace)) assertEquals(codeSpace, actual.getCodeSpace(), () -> concat(message, "Wrong code space")); + if (!UNRESTRICTED.equals(version)) assertEquals(version, actual.getVersion(), () -> concat(message, "Wrong version")); - if (!UNRESTRICTED.equals(code)) assertEquals(code, actual.getCode(), () -> concat(message, "Wrong code")); ++ if (!UNRESTRICTED.equals(code)) assertEquals(code, actual.getCode(), () -> concat(message, "Wrong code")); + } + } + + /** + * Asserts that all axes in the given coordinate system are pointing toward the given directions, in the same order. + * - * @param message Header of the exception message in case of failure, or {@code null} if none. - * @param cs The coordinate system to test. - * @param expected The expected axis directions. ++ * @param cs the coordinate system to test. ++ * @param expected the expected axis directions. + */ - public static void assertAxisDirectionsEqual(String message, - final CoordinateSystem cs, final AxisDirection... expected) - { ++ public static void assertAxisDirectionsEqual(final CoordinateSystem cs, final AxisDirection... expected) { ++ assertAxisDirectionsEqual(cs, expected, null); ++ } ++ ++ /** ++ * Asserts that all axes in the given coordinate system are pointing toward the given directions, ++ * in the same order. ++ * ++ * @param cs the coordinate system to test. ++ * @param expected the expected axis directions. ++ * @param message header of the exception message in case of failure, or {@code null} if none. ++ */ ++ public static void assertAxisDirectionsEqual(final CoordinateSystem cs, final AxisDirection[] expected, final String message) { + assertEquals(expected.length, cs.getDimension(), () -> concat(message, "Wrong coordinate system dimension.")); + for (int i=0; i<expected.length; i++) { - assertEquals(expected[i], cs.getAxis(i).getDirection(), () -> concat(message, "Wrong axis direction.")); ++ final int ci = i; // Because lambda expressions require final values. ++ assertEquals(expected[i], cs.getAxis(i).getDirection(), ++ () -> concat(message, "Wrong axis direction at index" + ci + '.')); + } + } + + /** - * Asserts that the given matrix is equals to the expected one, up to the given tolerance value. ++ * Asserts that the given matrix is equal to the expected one, up to the given tolerance value. ++ * ++ * @param expected the expected matrix, which may be {@code null}. ++ * @param actual the matrix to compare, or {@code null}. ++ * @param tolerance the tolerance threshold. ++ * @param message header of the exception message in case of failure, or {@code null} if none. + * - * @param message Header of the exception message in case of failure, or {@code null} if none. - * @param expected The expected matrix, which may be {@code null}. - * @param actual The matrix to compare, or {@code null}. - * @param tolerance The tolerance threshold. ++ * @see org.opengis.test.referencing.TransformTestCase#assertMatrixEquals(String, Matrix, Matrix, Matrix) + */ - public static void assertMatrixEquals(final String message, final Matrix expected, final Matrix actual, final double tolerance) { - if (isNull(message, expected, actual)) { ++ public static void assertMatrixEquals(final Matrix expected, final Matrix actual, final double tolerance, final String message) { ++ if (isNull(expected, actual, message)) { + return; + } + final int numRow = actual.getNumRow(); + final int numCol = actual.getNumCol(); + assertEquals(expected.getNumRow(), numRow, "numRow"); + assertEquals(expected.getNumCol(), numCol, "numCol"); + for (int j=0; j<numRow; j++) { + for (int i=0; i<numCol; i++) { + final double e = expected.getElement(j,i); + final double a = actual.getElement(j,i); + if (!(StrictMath.abs(e - a) <= tolerance) && Double.doubleToLongBits(a) != Double.doubleToLongBits(e)) { - fail("Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a); ++ fail(nonNull(message) + "Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a); + } + } + } + } +}