Author: desruisseaux
Date: Fri Jun 6 15:00:19 2014
New Revision: 1600904
URL: http://svn.apache.org/r1600904
Log:
Ported LinearTransformTest.
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
(with props)
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/AbstractMathTransformTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/IterationStrategyTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/AbstractMathTransformTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/AbstractMathTransformTest.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/AbstractMathTransformTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/AbstractMathTransformTest.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -19,10 +19,12 @@ package org.apache.sis.referencing.opera
import java.util.Arrays;
import java.util.Random;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.test.DependsOnMethod;
-import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.TestCase;
+
+// Test imports
import org.junit.Test;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
import static org.junit.Assert.*;
import static java.lang.StrictMath.*;
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -19,6 +19,8 @@ package org.apache.sis.referencing.opera
import java.util.Random;
import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Longitude;
+
+// Test imports
import org.apache.sis.test.mock.GeodeticDatumMock;
import static java.lang.StrictMath.*;
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CopyTransformTest.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -18,8 +18,10 @@ package org.apache.sis.referencing.opera
import org.opengis.referencing.operation.TransformException;
import org.apache.sis.referencing.operation.provider.Affine;
-import org.apache.sis.test.DependsOn;
+
+// Test imports
import org.junit.Test;
+import org.apache.sis.test.DependsOn;
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/IterationStrategyTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/IterationStrategyTest.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/IterationStrategyTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/IterationStrategyTest.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -19,9 +19,11 @@ package org.apache.sis.referencing.opera
import java.util.Arrays;
import java.util.Random;
import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.test.DependsOnMethod;
-import org.apache.sis.test.TestCase;
+
+// Test imports
import org.junit.Test;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOnMethod;
import static org.junit.Assert.*;
import static java.lang.StrictMath.*;
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java?rev=1600904&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
(added)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation.transform;
+
+import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.TransformException;
+
+// Test imports
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.apache.sis.test.DependsOn;
+
+import static org.opengis.test.Assert.*;
+
+
+/**
+ * Tests various implementation of the {@link LinearTransform} interface by
inheriting the tests defined
+ * in GeoAPI conformance module. The transforms are created by {@link
MathTransforms#linear(Matrix)}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.5 (derived from geotk-3.19)
+ * @version 0.5
+ * @module
+ */
+@RunWith(JUnit4.class)
+@DependsOn(ProjectiveTransformTest.class)
+public final strictfp class LinearTransformTest extends
ProjectiveTransformTest {
+ /**
+ * Creates a new test suite.
+ */
+ public LinearTransformTest() {
+ super(new MathTransformFactoryBase() {
+ @Override
+ public LinearTransform createAffineTransform(final Matrix matrix) {
+ return MathTransforms.linear(matrix);
+ }
+ });
+ }
+
+ /**
+ * Do not skip any interface check - all of them shall be correct in this
test case.
+ */
+ @Override
+ boolean skipInterfaceCheckForDimension(final int dimension) {
+ return false;
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testIdentity1D() throws FactoryException, TransformException {
+ super.testIdentity1D();
+ assertInstanceOf("Unexpected implementation.",
IdentityTransform1D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testIdentity2D() throws FactoryException, TransformException {
+ super.testIdentity2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testIdentity3D() throws FactoryException, TransformException {
+ super.testIdentity3D();
+ assertInstanceOf("Unexpected implementation.",
IdentityTransform.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testAxisSwapping2D() throws FactoryException,
TransformException {
+ super.testAxisSwapping2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testSouthOrientated2D() throws FactoryException,
TransformException {
+ super.testSouthOrientated2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testTranslatation2D() throws FactoryException,
TransformException {
+ super.testTranslatation2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testUniformScale2D() throws FactoryException,
TransformException {
+ super.testUniformScale2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testGenericScale2D() throws FactoryException,
TransformException {
+ super.testGenericScale2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testRotation2D() throws FactoryException, TransformException {
+ super.testRotation2D();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testGeneral() throws FactoryException, TransformException {
+ super.testGeneral();
+ assertInstanceOf("Unexpected implementation.",
AffineTransform2D.class, transform);
+ }
+
+ /**
+ * Runs the GeoAPI tests, then perform implementation-specific checks.
+ *
+ * @throws FactoryException should never happen.
+ * @throws TransformException should never happen.
+ */
+ @Test
+ @Override
+ public void testDimensionReduction() throws FactoryException,
TransformException {
+ super.testDimensionReduction();
+ assertInstanceOf("Unexpected implementation.",
ProjectiveTransform.class, transform);
+ }
+}
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/LinearTransformTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -28,21 +28,23 @@ import org.opengis.parameter.ParameterDe
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.geometry.DirectPosition;
import org.opengis.metadata.Identifier;
-import org.opengis.test.Validators;
-import org.opengis.test.CalculationType;
-import org.opengis.test.ToleranceModifier;
-import org.opengis.test.referencing.TransformTestCase;
import org.apache.sis.parameter.Parameterized;
import org.apache.sis.util.Debug;
import org.apache.sis.util.Classes;
+import org.apache.sis.math.Statistics;
+import org.apache.sis.math.StatisticsFormat;
import org.apache.sis.io.TableAppender;
import org.apache.sis.io.wkt.Convention;
import org.apache.sis.io.wkt.FormattableObject;
import org.apache.sis.internal.util.Numerics;
-import org.apache.sis.math.Statistics;
-import org.apache.sis.math.StatisticsFormat;
-import org.apache.sis.test.TestUtilities;
+
+// Test imports
+import org.opengis.test.Validators;
+import org.opengis.test.CalculationType;
+import org.opengis.test.ToleranceModifier;
+import org.opengis.test.referencing.TransformTestCase;
import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestUtilities;
import static java.lang.StrictMath.*;
import static org.apache.sis.test.ReferencingAssert.*;
@@ -191,7 +193,8 @@ public abstract strictfp class MathTrans
/**
* Validates the current {@linkplain #transform transform}. This method
verifies that
* the transform implements {@link MathTransform1D} or {@link
MathTransform2D} if the
- * transform dimension suggests that it should.
+ * transform dimension suggests that it should. In addition, all Apache
SIS transforms
+ * shall implement {@link Parameterized}.
*
* @see Validators#validate(MathTransform)
*/
@@ -206,6 +209,7 @@ public abstract strictfp class MathTrans
assertFalse(completeMessage("MathTransform1D"), transform
instanceof MathTransform1D);
assertFalse(completeMessage("MathTransform2D"), transform
instanceof MathTransform2D);
}
+ assertInstanceOf(completeMessage("Parameterized"),
Parameterized.class, transform);
}
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ProjectiveTransformTest.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -17,10 +17,22 @@
package org.apache.sis.referencing.operation.transform;
import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform1D;
+import org.opengis.referencing.operation.MathTransform2D;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.apache.sis.referencing.operation.matrix.Matrices;
+import org.apache.sis.referencing.operation.provider.Affine;
+import org.apache.sis.parameter.Parameterized;
+
+// Test imports
import org.opengis.test.referencing.AffineTransformTest;
+import org.opengis.test.Validators;
import org.apache.sis.test.DependsOn;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import org.junit.After;
+
+import static org.opengis.test.Assert.*;
/**
@@ -36,7 +48,14 @@ import org.junit.runners.JUnit4;
*/
@RunWith(JUnit4.class)
@DependsOn(AbstractMathTransformTest.class)
-public final strictfp class ProjectiveTransformTest extends
AffineTransformTest {
+public strictfp class ProjectiveTransformTest extends AffineTransformTest {
+ /**
+ * For {@link LinearTransformTest} constructor only.
+ */
+ ProjectiveTransformTest(final MathTransformFactory factory) {
+ super(factory);
+ }
+
/**
* Creates a new test suite.
*/
@@ -54,6 +73,61 @@ public final strictfp class ProjectiveTr
}
/*
- * Inherit all the tests from GeoAPI.
+ * Inherit all the tests from GeoAPI:
+ * - testIdentity1D()
+ * - testIdentity2D()
+ * - testIdentity3D()
+ * - testAxisSwapping2D()
+ * - testSouthOrientated2D()
+ * - testTranslatation2D()
+ * - testUniformScale2D()
+ * - testGenericScale2D()
+ * - testRotation2D()
+ * - testGeneral()
+ * - testDimensionReduction()
*/
+
+ /**
+ * {@code true} if {@link #ensureImplementRightInterface()} should skip
its check for a transform
+ * of the given dimension. {@code ProjectiveTransformTest} needs to skip
the case for dimension 1
+ * because there is no {@code ProjectiveTransform1D} class. However {@link
LinearTransformTest}
+ * can check for all dimensions.
+ */
+ boolean skipInterfaceCheckForDimension(final int dimension) {
+ return dimension == 1;
+ }
+
+ /**
+ * Executed after every test in order to ensure that the {@linkplain
#transform transform}
+ * implements the {@link MathTransform1D} or {@link MathTransform2D}
interface as needed.
+ * In addition, all Apache SIS classes for linear transforms shall
implement
+ * {@link LinearTransform} and {@link Parameterized} interfaces.
+ */
+ @After
+ public final void ensureImplementRightInterface() {
+ /*
+ * Below is a copy of MathTransformTestCase.validate(), with minor
modifications
+ * due to the fact that this class does not extend
MathTransformTestCase.
+ */
+ assertNotNull("The 'transform' field shall be assigned a value.",
transform);
+ Validators.validate(transform);
+ final int dimension = transform.getSourceDimensions();
+ if (transform.getTargetDimensions() == dimension &&
!skipInterfaceCheckForDimension(dimension)) {
+ assertEquals("MathTransform1D", dimension == 1, (transform
instanceof MathTransform1D));
+ assertEquals("MathTransform2D", dimension == 2, (transform
instanceof MathTransform2D));
+ } else {
+ assertFalse("MathTransform1D", transform instanceof
MathTransform1D);
+ assertFalse("MathTransform2D", transform instanceof
MathTransform2D);
+ }
+ assertInstanceOf("Parameterized", Parameterized.class, transform);
+ /*
+ * End of MathTransformTestCase.validate(). Remaining is specific to
LinearTransform implementations.
+ */
+ assertInstanceOf("Not a LinearTransform.", LinearTransform.class,
transform);
+ final Matrix tm = ((LinearTransform) transform).getMatrix();
+ assertTrue("The matrix declared by the MathTransform is not equal to
the one given at creation time.",
+ Matrices.equals(matrix, tm, tolerance, false));
+
+ assertSame("ParameterDescriptor", Affine.PARAMETERS, ((Parameterized)
transform).getParameterDescriptors());
+ }
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1600904&r1=1600903&r2=1600904&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Jun 6 15:00:19 2014
@@ -43,6 +43,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.operation.transform.IterationStrategyTest.class,
org.apache.sis.referencing.operation.transform.AbstractMathTransformTest.class,
org.apache.sis.referencing.operation.transform.ProjectiveTransformTest.class,
+ org.apache.sis.referencing.operation.transform.LinearTransformTest.class,
org.apache.sis.referencing.operation.transform.CopyTransformTest.class,
org.apache.sis.internal.referencing.FormulasTest.class,