You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2024/02/21 16:00:28 UTC
(sis) 01/01: Merge branch 'geoapi-3.1': post-merge organization of imports.
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 6eba4a5b2dca2712dc3402706aeefa2604d240fd
Merge: 15c3081113 445620db52
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Feb 21 16:58:44 2024 +0100
Merge branch 'geoapi-3.1':
post-merge organization of imports.
.../org/apache/sis/coverage/grid/j2d/ScaledColorSpaceTest.java | 2 +-
.../test/org/apache/sis/feature/Assertions.java | 2 +-
.../test/org/apache/sis/feature/FeatureTestCase.java | 2 +-
.../apache/sis/feature/builder/CharacteristicTypeBuilderTest.java | 2 +-
.../test/org/apache/sis/geometry/wrapper/esri/FactoryTest.java | 2 +-
.../test/org/apache/sis/geometry/wrapper/j2d/FactoryTest.java | 2 +-
.../test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java | 2 ++
.../test/org/apache/sis/geometry/wrapper/jts/FactoryTest.java | 2 +-
.../org/apache/sis/metadata/iso/citation/DefaultCitationTest.java | 2 +-
.../org/apache/sis/metadata/iso/extent/DefaultExtentTest.java | 2 +-
.../iso/identification/DefaultServiceIdentificationTest.java | 2 +-
.../apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java | 2 +-
.../sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java | 2 +-
.../test/org/apache/sis/util/iso/DefaultNameFactoryTest.java | 2 +-
.../test/org/apache/sis/util/iso/SerializableRecordSchema.java | 2 ++
.../test/org/apache/sis/xml/ReferenceResolverTest.java | 2 +-
.../test/org/apache/sis/xml/bind/gco/MultiplicityTest.java | 2 +-
.../test/org/apache/sis/xml/bind/lan/PT_LocaleTest.java | 2 +-
.../test/org/apache/sis/xml/test/AnnotationConsistencyCheck.java | 4 ++--
.../test/org/apache/sis/xml/test/TestCase.java | 2 +-
.../test/org/apache/sis/geometry/GeneralEnvelopeTest.java | 2 +-
.../test/org/apache/sis/io/wkt/ComparisonWithEPSG.java | 2 +-
.../test/org/apache/sis/referencing/GeodeticCalculatorTest.java | 1 +
.../org/apache/sis/referencing/factory/TestFactorySource.java | 2 ++
.../sis/referencing/operation/CoordinateOperationFinderTest.java | 2 +-
.../referencing/operation/CoordinateOperationRegistryTest.java | 2 +-
.../operation/DefaultCoordinateOperationFactoryTest.java | 2 +-
.../operation/builder/LocalizationGridBuilderTest.java | 2 +-
.../referencing/operation/projection/ConformalProjectionTest.java | 2 +-
.../referencing/operation/projection/MapProjectionTestCase.java | 2 +-
.../operation/provider/CoordinateFrameRotationTest.java | 2 +-
.../referencing/operation/provider/GeocentricTranslationTest.java | 2 +-
.../sis/referencing/operation/provider/GeographicOffsetsTest.java | 2 +-
.../referencing/operation/provider/PositionVector7ParamTest.java | 2 +-
.../operation/transform/CoordinateSystemTransformTest.java | 2 +-
.../referencing/operation/transform/MathTransformTestCase.java | 6 +++---
.../referencing/operation/transform/ProjectiveTransformTest.java | 8 ++++----
.../org/apache/sis/test/integration/CoordinateOperationTest.java | 2 +-
.../test/org/apache/sis/storage/netcdf/MetadataReaderTest.java | 2 +-
.../org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java | 2 +-
.../apache/sis/storage/sql/feature/TemporalValueGetterTest.java | 2 +-
.../main/org/apache/sis/storage/base/LegalSymbols.java | 2 +-
.../test/org/apache/sis/storage/image/WorldFileStoreTest.java | 2 +-
.../test/org/apache/sis/storage/xml/MimeTypeDetectorTest.java | 2 +-
.../test/org/apache/sis/test/FailureDetailsReporter.java | 2 ++
.../test/org/apache/sis/test/GeoapiAssert.java | 3 ++-
.../test/org/apache/sis/test/TestCaseWithLogs.java | 2 ++
.../test/org/apache/sis/util/collection/CacheTest.java | 2 +-
.../test/org/apache/sis/util/collection/RangeSetTest.java | 2 +-
49 files changed, 61 insertions(+), 49 deletions(-)
diff --cc endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java
index 96ef2de9af,20545eff26..12a634a035
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/Assertions.java
@@@ -27,8 -26,8 +26,9 @@@ import org.apache.sis.util.Static
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.coverage.grid.SequenceType;
+// Specific to the main branch:
++import java.awt.geom.PathIterator;
+import org.apache.sis.image.SequenceType;
/**
diff --cc endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java
index 08a3d95899,9cba286bda..081fee01c8
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/feature/FeatureTestCase.java
@@@ -31,10 -31,15 +31,10 @@@ import org.apache.sis.util.SimpleIntern
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.Assertions.assertMessageContains;
+ import static org.apache.sis.test.Assertions.assertSerializedEquals;
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
- import static org.apache.sis.test.Assertions.assertSerializedEquals;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.feature.Attribute;
-import org.opengis.feature.AttributeType;
-import org.opengis.feature.Property;
-
/**
* Tests common to {@link DenseFeatureTest} and {@link SparseFeatureTest}.
diff --cc endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java
index a85ee63b00,4eb9c4ef79..568f008677
--- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java
+++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/geometry/wrapper/j2d/FlatShapeTest.java
@@@ -22,7 -22,9 +22,9 @@@ import org.opengis.referencing.operatio
// Test dependencies
import org.junit.jupiter.api.Test;
import org.apache.sis.test.TestCase;
+
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertPathEquals;
++// Specific to the main branch:
+import static org.apache.sis.feature.Assertions.assertPathEquals;
/**
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/geometry/GeneralEnvelopeTest.java
index b534ec3154,22fbae2d82..8fdd97e6d0
--- 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
@@@ -33,12 -33,9 +33,12 @@@ import org.apache.sis.referencing.crs.H
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.referencing.Assertions.assertWktEquals;
import static org.apache.sis.test.Assertions.assertMessageContains;
+ import static org.apache.sis.referencing.Assertions.assertWktEquals;
+// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.PENDING_NEXT_GEOAPI_RELEASE;
+
/**
* Tests the {@link GeneralEnvelope} class. The {@link Envelope2D} class will also be tested as a
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/GeodeticCalculatorTest.java
index 4692afc97b,d61c0203aa..38d749342e
--- 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
@@@ -50,8 -50,9 +50,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 static org.opengis.test.Assertions.assertBetween;
-import static org.opengis.test.Assertions.assertAxisDirectionsEqual;
++// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
+import static org.apache.sis.test.GeoapiAssert.assertAxisDirectionsEqual;
/**
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/TestFactorySource.java
index 363511562b,6643b163e8..b4fde14907
--- 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
@@@ -28,7 -28,9 +28,9 @@@ import org.apache.sis.referencing.facto
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;
+
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import static org.opengis.test.Assertions.assertBetween;
++// Specific to the main branch:
+import static org.apache.sis.test.GeoapiAssert.assertBetween;
/**
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
index f36391004c,d0a02b4035..45bd612672
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/CoordinateOperationRegistryTest.java
@@@ -44,10 -43,11 +43,11 @@@ import static org.junit.jupiter.api.Ass
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
+ import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
import static org.apache.sis.referencing.Assertions.assertEpsgNameAndIdentifierEqual;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.metadata.Identifier;
+// Specific to the main branch:
+import org.opengis.referencing.ReferenceIdentifier;
/**
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
index c452f21b76,d6f10f15e9..486a9acd8a
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/projection/MapProjectionTestCase.java
@@@ -35,8 -34,12 +34,9 @@@ import org.apache.sis.referencing.datum
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
+ import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
import org.apache.sis.test.TestUtilities;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.referencing.ParameterizedTransformTest;
-
/**
* Base class of map projection tests.
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java
index 7195df59db,f647c473a6..9291fe4812
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/provider/GeocentricTranslationTest.java
@@@ -37,7 -36,13 +36,8 @@@ import org.apache.sis.referencing.opera
// Test dependencies
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
+ import org.apache.sis.referencing.operation.transform.MathTransformTestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import java.util.Arrays;
-import org.opengis.test.ToleranceModifier;
-import org.apache.sis.referencing.datum.HardCodedDatum;
-
/**
* Tests {@link GeocentricTranslation} and {@link GeocentricTranslation3D}.
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
index 9c5b165bf2,4c5fec2831..58c17b47df
--- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
+++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
@@@ -39,11 -38,18 +38,12 @@@ import org.apache.sis.io.wkt.Formattabl
// Test dependencies
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.extension.ExtendWith;
+ import org.opengis.test.Validators;
+ import org.apache.sis.referencing.Assertions;
+ import org.apache.sis.referencing.operation.matrix.MatrixTestCase;
import org.apache.sis.test.FailureDetailsReporter;
import org.apache.sis.test.TestUtilities;
- import org.apache.sis.referencing.Assertions;
- import org.opengis.test.Validators;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.geometry.DirectPosition;
-import org.apache.sis.measure.Longitude;
-import org.opengis.test.CalculationType;
-import org.opengis.test.referencing.TransformTestCase;
-
/**
* Base class for tests of {@link AbstractMathTransform} implementations.
diff --cc endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
index d8638c2788,c2c8bc7596..eb36ad5ef7
--- 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
@@@ -37,15 -36,14 +36,16 @@@ import org.apache.sis.math.Fraction
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
- import org.apache.sis.test.FailureDetailsReporter;
+ import static org.junit.jupiter.api.Assertions.*;
import org.opengis.test.Validators;
+ import org.apache.sis.test.FailureDetailsReporter;
+ import static org.apache.sis.test.TestCase.STRICT;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.Assertions;
-import org.opengis.test.referencing.AffineTransformTest;
+// Specific to the main branch:
++import org.opengis.referencing.operation.MathTransformFactory;
+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.referencing.TransformTestCase;
+import org.apache.sis.test.GeoapiAssert;
/**
diff --cc endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
index dc5d086ee1,5bf3b2ffa8..8152b8e88c
--- a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
+++ b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
@@@ -31,9 -30,10 +30,10 @@@ import org.apache.sis.util.Version
// Test dependencies
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
+ import org.apache.sis.storage.netcdf.base.TestCase;
-// Specific to the geoapi-3.1 and geoapi-4.0 branches:
-import org.opengis.test.dataset.TestData;
+// Specific to the main branch:
+import org.apache.sis.storage.netcdf.base.TestData;
/**
diff --cc endorsed/src/org.apache.sis.util/test/org/apache/sis/test/GeoapiAssert.java
index a89e46e757,0000000000..e39b5f3b8d
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,247 -1,0 +1,248 @@@
+/*
+ * 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.*;
++import org.opengis.test.Assert;
+
+
+/**
+ * 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 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.
+ */
+ 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 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 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 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 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 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 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(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"));
+ }
+ }
+
+ /**
+ * 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.
+ */
+ 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++) {
+ 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 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.
+ *
+ * @see org.opengis.test.referencing.TransformTestCase#assertMatrixEquals(String, Matrix, Matrix, Matrix)
+ */
+ 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(nonNull(message) + "Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a);
+ }
+ }
+ }
+ }
+}