Author: desruisseaux
Date: Tue Dec 18 02:05:42 2012
New Revision: 1423250
URL: http://svn.apache.org/viewvc?rev=1423250&view=rev
Log:
Tests the envelope using validators.
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition1DTest.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition2DTest.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
Tue Dec 18 02:05:42 2012
@@ -26,6 +26,7 @@ import org.junit.Ignore;
import org.junit.Test;
import static java.lang.Double.NaN;
+import static org.opengis.test.Validators.*;
import static org.apache.sis.referencing.Assert.*;
@@ -66,22 +67,30 @@ public final strictfp class AbstractEnve
final double xmin, final double xmax,
final double ymin, final double ymax)
{
+ final Envelope envelope;
switch (type) {
case GENERAL: {
- final GeneralEnvelope envelope = new GeneralEnvelope(2);
- envelope.setCoordinateReferenceSystem(WGS84);
- envelope.setRange(0, xmin, xmax);
- envelope.setRange(1, ymin, ymax);
- return envelope;
+ final GeneralEnvelope ge = new GeneralEnvelope(2);
+ ge.setCoordinateReferenceSystem(WGS84);
+ ge.setRange(0, xmin, xmax);
+ ge.setRange(1, ymin, ymax);
+ envelope = ge;
+ break;
}
case IMMUTABLE: {
- return new ImmutableEnvelope(new double[] {xmin, ymin}, new
double[] {xmax, ymax}, WGS84);
+ envelope = new ImmutableEnvelope(new double[] {xmin, ymin},
new double[] {xmax, ymax}, WGS84);
+ break;
}
case RECTANGLE: {
- return new Envelope2D(xmin, ymin, xmax - xmin, ymax - ymin,
WGS84);
+ envelope = new Envelope2D(xmin, ymin, xmax - xmin, ymax -
ymin, WGS84);
+ break;
}
default: throw new IllegalArgumentException(String.valueOf(type));
}
+ if (PENDING_NEXT_GEOAPI_RELEASE) {
+ validate(envelope);
+ }
+ return envelope;
}
/**
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition1DTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition1DTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition1DTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition1DTest.java
Tue Dec 18 02:05:42 2012
@@ -22,6 +22,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
+import static org.opengis.test.Validators.*;
/**
@@ -39,7 +40,9 @@ public final strictfp class DirectPositi
*/
@Test
public void testWktFormatting() {
- assertEquals("POINT(8.5)", new DirectPosition1D(8.5).toString());
+ final DirectPosition1D position = new DirectPosition1D(8.5);
+ assertEquals("POINT(8.5)", position.toString());
+ validate(position);
}
/**
@@ -47,7 +50,9 @@ public final strictfp class DirectPositi
*/
@Test
public void testWktParsing() {
- assertEquals("POINT(8)", new DirectPosition1D("POINT(8)").toString());
+ final DirectPosition1D position = new DirectPosition1D("POINT(8)");
+ assertEquals("POINT(8)", position.toString());
+ validate(position);
}
/**
@@ -80,6 +85,7 @@ public final strictfp class DirectPositi
final DirectPosition1D p2 = p1.clone();
assertEquals("Expected the same CRS and ordinates.", p1, p2);
assertEquals("Expected the same ordinates.", 20.0, p2.ordinate, 0.0);
+ validate(p2);
}
/**
@@ -87,7 +93,9 @@ public final strictfp class DirectPositi
*/
@Test
public void testSerialize() {
- final GeneralDirectPosition p = new GeneralDirectPosition(12, -20, 4,
9);
- assertNotSame(p, assertSerializedEquals(p));
+ final DirectPosition1D p1 = new DirectPosition1D(12);
+ final DirectPosition1D p2 = assertSerializedEquals(p1);
+ assertNotSame(p1, p2);
+ validate(p2);
}
}
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition2DTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition2DTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition2DTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/DirectPosition2DTest.java
Tue Dec 18 02:05:42 2012
@@ -22,6 +22,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
+import static org.opengis.test.Validators.*;
/**
@@ -39,7 +40,9 @@ public final strictfp class DirectPositi
*/
@Test
public void testWktFormatting() {
- assertEquals("POINT(6.5 10)", new DirectPosition2D(6.5,
10).toString());
+ final DirectPosition2D position = new DirectPosition2D(6.5, 10);
+ assertEquals("POINT(6.5 10)", position.toString());
+ validate(position);
}
/**
@@ -47,7 +50,9 @@ public final strictfp class DirectPositi
*/
@Test
public void testWktParsing() {
- assertEquals("POINT(6 10)", new DirectPosition2D("POINT(6
10)").toString());
+ final DirectPosition2D position = new DirectPosition2D("POINT(6 10)");
+ assertEquals("POINT(6 10)", position.toString());
+ validate(position);
}
/**
@@ -81,6 +86,7 @@ public final strictfp class DirectPositi
assertEquals("Expected the same CRS and ordinates.", p1, p2);
assertEquals("Expected the same ordinates.", 10.0, p2.x, 0.0);
assertEquals("Expected the same ordinates.", 30.0, p2.y, 0.0);
+ validate(p2);
}
/**
@@ -88,7 +94,9 @@ public final strictfp class DirectPositi
*/
@Test
public void testSerialize() {
- final GeneralDirectPosition p = new GeneralDirectPosition(12, -20, 4,
9);
- assertNotSame(p, assertSerializedEquals(p));
+ final DirectPosition2D p1 = new DirectPosition2D(12, -20);
+ final DirectPosition2D p2 = assertSerializedEquals(p1);
+ assertNotSame(p1, p2);
+ validate(p2);
}
}
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
Tue Dec 18 02:05:42 2012
@@ -20,6 +20,7 @@ import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import static org.opengis.test.Validators.*;
import static org.apache.sis.referencing.Assert.*;
import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
@@ -42,7 +43,9 @@ public final strictfp class Envelope2DTe
*/
@Test
public void testSerialization() {
- final Envelope2D envelope = new Envelope2D(-20, -10, 40, 20, WGS84);
- assertNotSame(envelope, assertSerializedEquals(envelope));
+ final Envelope2D e1 = new Envelope2D(-20, -10, 40, 20, WGS84);
+ final Envelope2D e2 = assertSerializedEquals(e1);
+ assertNotSame(e1, e2);
+ validate(e2);
}
}
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
Tue Dec 18 02:05:42 2012
@@ -21,6 +21,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
+import static org.opengis.test.Validators.*;
/**
@@ -37,7 +38,9 @@ public final strictfp class GeneralDirec
*/
@Test
public void testWktFormatting() {
- assertEquals("POINT(6 10 2)", new GeneralDirectPosition(6, 10,
2).toString());
+ final GeneralDirectPosition position = new GeneralDirectPosition(6,
10, 2);
+ assertEquals("POINT(6 10 2)", position.toString());
+ validate(position);
}
/**
@@ -94,6 +97,7 @@ public final strictfp class GeneralDirec
assertEquals ("Expected the same CRS and ordinates.", p1, p2);
assertTrue ("Expected the same ordinates.",
Arrays.equals(p1.ordinates, p2.ordinates));
assertNotSame("the ordinates array should have been cloned.",
p1.ordinates, p2.ordinates);
+ validate(p2);
}
/**
@@ -101,7 +105,9 @@ public final strictfp class GeneralDirec
*/
@Test
public void testSerialize() {
- final GeneralDirectPosition p = new GeneralDirectPosition(12, -20, 4,
9);
- assertNotSame(p, assertSerializedEquals(p));
+ final GeneralDirectPosition p1 = new GeneralDirectPosition(12, -20, 4,
9);
+ final GeneralDirectPosition p2 = assertSerializedEquals(p1);
+ assertNotSame(p1, p2);
+ validate(p2);
}
}
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
Tue Dec 18 02:05:42 2012
@@ -24,6 +24,7 @@ import org.junit.Ignore;
import org.junit.Test;
import static java.lang.Double.NaN;
+import static org.opengis.test.Validators.*;
import static org.apache.sis.referencing.Assert.*;
import static org.apache.sis.math.MathFunctions.isNegative;
import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
@@ -60,6 +61,9 @@ public final strictfp class GeneralEnvel
final GeneralEnvelope envelope = new GeneralEnvelope(2);
envelope.setCoordinateReferenceSystem(WGS84);
envelope.setEnvelope(xmin, ymin, xmax, ymax);
+ if (PENDING_NEXT_GEOAPI_RELEASE) {
+ validate(envelope);
+ }
return envelope;
}
@@ -362,6 +366,7 @@ public final strictfp class GeneralEnvel
assertEquals( 180, envelope.getUpper(0), STRICT);
assertEquals( -90, envelope.getLower(1), STRICT);
assertEquals( 90, envelope.getUpper(1), STRICT);
+ validate(envelope);
envelope = new GeneralEnvelope("BOX3D(-180 -90 10, 180 90 30)");
assertEquals(3, envelope.getDimension());
@@ -371,12 +376,14 @@ public final strictfp class GeneralEnvel
assertEquals( 90, envelope.getUpper(1), STRICT);
assertEquals( 10, envelope.getLower(2), STRICT);
assertEquals( 30, envelope.getUpper(2), STRICT);
+ validate(envelope);
envelope = new GeneralEnvelope("POLYGON((-80 -30,-100 40,80 40,100
-40,-80 -30))");
assertEquals(-100, envelope.getLower(0), STRICT);
assertEquals( 100, envelope.getUpper(0), STRICT);
assertEquals( -40, envelope.getLower(1), STRICT);
assertEquals( 40, envelope.getUpper(1), STRICT);
+ validate(envelope);
assertEquals("BOX2D(6 10, 6 10)", new GeneralEnvelope("POINT(6
10)").toString());
assertEquals("BOX3D(6 10 3, 6 10 3)", new GeneralEnvelope("POINT M [ 6
10 3 ] ").toString());
@@ -481,6 +488,7 @@ public final strictfp class GeneralEnvel
e1.setRange(0, -40, +60);
e1.setRange(1, -20, +30);
final GeneralEnvelope e2 = e1.clone();
+ validate(e2);
assertNotSame("Expected a new instance.", e1, e2);
assertEquals ("The two instances should be equal.", e1, e2);
e1.setRange(0, -40, +61);
@@ -494,9 +502,11 @@ public final strictfp class GeneralEnvel
*/
@Test
public void testSerialization() {
- final GeneralEnvelope envelope = new GeneralEnvelope(
+ final GeneralEnvelope e1 = new GeneralEnvelope(
new double[] {-20, -10},
new double[] { 20, 10});
- assertNotSame(envelope, assertSerializedEquals(envelope));
+ final GeneralEnvelope e2 = assertSerializedEquals(e1);
+ assertNotSame(e1, e2);
+ validate(e2);
}
}
Modified:
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java
(original)
+++
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java
Tue Dec 18 02:05:42 2012
@@ -20,6 +20,7 @@ import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import static org.opengis.test.Validators.*;
import static org.apache.sis.referencing.Assert.*;
import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
@@ -41,9 +42,11 @@ public final strictfp class ImmutableEnv
*/
@Test
public void testSerialization() {
- final ImmutableEnvelope envelope = new ImmutableEnvelope(
+ final ImmutableEnvelope e1 = new ImmutableEnvelope(
new double[] {-20, -10},
new double[] { 20, 10}, WGS84);
- assertNotSame(envelope, assertSerializedEquals(envelope));
+ final ImmutableEnvelope e2 = assertSerializedEquals(e1);
+ assertNotSame(e1, e2);
+ validate(e2);
}
}
Modified:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestCase.java?rev=1423250&r1=1423249&r2=1423250&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
(original)
+++
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
Tue Dec 18 02:05:42 2012
@@ -66,6 +66,22 @@ import static org.apache.sis.test.TestCo
@RunWith(TestRunner.class)
public abstract strictfp class TestCase {
/**
+ * 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:
+ *
+ * {@preformat 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;
+
+ /**
* If non-null, the output writer where to print debugging information.
* This field is non-null if the {@value
org.apache.sis.test.TestConfiguration#VERBOSE_OUTPUT_KEY}
* system property is set to {@code true}. This writer will use the system
default encoding, unless