Class ParameterizedTransformTest

Object
TestCase
TransformTestCase
ParameterizedTransformTest

Tests parameterized math transforms from the org.opengis.referencing.operation package. Math transform instances are created using the factory given at construction time.

Skipping tests for unsupported operations

If the tested factory throws a NoSuchIdentifierException during the invocation of one of the following methods: then the tests is skipped. If any other kind of exception is thrown, or if NoSuchIdentifierException is thrown under other circumstances than the invocation of above methods, then the test fails.

Tests and accuracy

By default, every tests expect an accuracy of 1 centimetre. This accuracy matches the precision of most example points given in the EPSG guidance notice. Implementers can modify the kind of tests being executed and the tolerance threshold in different ways:

Usage example

in order to specify their factories and run the tests in a JUnit framework, implementers can define a subclass in their own test suite as in the example below. That example shows also how implementers can alter some tests (here the tolerance value for the Lambert Azimuthal Equal Area projection) and add more checks to be executed after every tests (here ensuring that the transform implements the MathTransform2D interface):
import org.junit.jupiter.api.Test;
import org.opengis.test.referencing.ParameterizedTransformTest;
import static org.junit.jupiter.api.Assertions.*;

public class MyTest extends ParameterizedTransformTest {
    public MyTest() {
        super(new MyMathTransformFactory());
    }

    @Test
    @Override
    public void testLambertAzimuthalEqualArea() throws FactoryException, TransformException {
        tolerance = 0.1;                              // Increase the tolerance value to 10 cm.
        super.testLambertAzimuthalEqualArea();
        // If more tests specific to this projection are wanted, do them here.
        // In this example, we replace the ellipsoid by a sphere and test again.
        // Note that spherical formulas can have an error up to 30 km compared
        // to ellipsoidal formulas, so we have to relax again the tolerance threshold.
        parameters.parameter("semi_minor").setValue(parameters.parameter("semi_major").doubleValue());
        tolerance = 30000;                            // Increase the tolerance value to 30 km.
        super.testLambertAzimuthalEqualArea();
    }

    @After
    public void ensureAllTransformAreMath2D() {
        assertTrue(transform instanceof MathTransform2D);
    }
}
Since:
3.1
See Also: