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 2016/04/22 18:44:05 UTC
svn commit: r1740562 - in
/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing:
CRSTest.java IdentifiedObjectsTest.java
factory/GeodeticObjectFactoryTest.java
Author: desruisseaux
Date: Fri Apr 22 16:44:05 2016
New Revision: 1740562
URL: http://svn.apache.org/viewvc?rev=1740562&view=rev
Log:
Add tests.
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1740562&r1=1740561&r2=1740562&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Fri Apr 22 16:44:05 2016
@@ -21,6 +21,7 @@ import org.opengis.referencing.crs.Geode
import org.opengis.referencing.crs.SingleCRS;
import org.opengis.util.FactoryException;
import org.apache.sis.referencing.crs.DefaultCompoundCRS;
+import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
@@ -105,6 +106,23 @@ public final strictfp class CRSTest exte
}
/**
+ * Tests simple WKT parsing. It is not the purpose of this class to test extensively the WKT parser;
+ * those tests are rather done by {@link org.apache.sis.io.wkt.GeodeticObjectParserTest}.
+ * Here we merely test that {@link CRS#fromWKT(String)} is connected to the parser.
+ *
+ * @throws FactoryException if an error occurred while parsing the WKT.
+ */
+ @Test
+ public void testFromWKT() throws FactoryException {
+ final CoordinateReferenceSystem crs = CRS.fromWKT(
+ "GEOGCS[\"GCS WGS 1984\","
+ + "DATUM[\"WGS 1984\",SPHEROID[\"WGS 1984\",6378137,298.257223563]],"
+ + "PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]");
+ assertInstanceOf("GEOGCS", DefaultGeographicCRS.class, crs);
+ assertEquals("GCS WGS 1984", crs.getName().getCode());
+ }
+
+ /**
* Tests {@link CRS#isHorizontalCRS(CoordinateReferenceSystem)}.
*/
@Test
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java?rev=1740562&r1=1740561&r2=1740562&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java [UTF-8] Fri Apr 22 16:44:05 2016
@@ -33,9 +33,10 @@ import static org.apache.sis.referencing
/**
* Tests the {@link IdentifiedObjects} static methods.
- * This test class intentionally declares {@code testLookup()} method without {@link Test} annotation
- * because those tests should not be executed only after the EPSG tests. Those tests will be executed
- * by {@link CRSTest} instead.
+ *
+ * <p><b>Note:</b> this test class intentionally declares {@link #testLookupEPSG()} and {@link #testLookupWMS()}
+ * methods without {@link Test} annotation because those tests should be executed only after the EPSG tests in
+ * {@link org.apache.sis.test.suite.ReferencingTestSuite}. Those tests will be executed by {@link CRSTest} instead.</p>
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java?rev=1740562&r1=1740561&r2=1740562&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java [UTF-8] Fri Apr 22 16:44:05 2016
@@ -91,7 +91,7 @@ public final strictfp class GeodeticObje
}
/**
- * Test {@link GeodeticObjectFactory#createFromWKT(String)}. We test only a very small WKT here because
+ * Tests {@link GeodeticObjectFactory#createFromWKT(String)}. We test only a very small WKT here because
* it is not the purpose of this class to test the parser. The main purpose of this test is to verify
* that {@link GeodeticObjectFactory} has been able to instantiate the parser.
*
@@ -111,6 +111,35 @@ public final strictfp class GeodeticObje
}
/**
+ * Tests {@link GeodeticObjectFactory#createFromWKT(String)} with an erroneous projection parameter name.
+ * The intend is to verify that the expected exception is thrown.
+ *
+ * @throws FactoryException if the parsing failed for another reason than the expected one.
+ */
+ @Test
+ public void testInvalidParameterInWKT() throws FactoryException {
+ try {
+ crsFactory.createFromWKT(
+ "PROJCRS[“Custom”,\n" +
+ " BASEGEODCRS[“North American 1983”,\n" +
+ " DATUM[“North American 1983”,\n" +
+ " ELLIPSOID[“GRS 1980”, 6378137, 298.257222101]]],\n" +
+ " CONVERSION[“Custom”,\n" +
+ " METHOD[“Lambert Conformal Conic”],\n" +
+ " PARAMETER[“Standard parallel 1”, 43.0],\n" +
+ " PARAMETER[“Standard parallel 2”, 45.5],\n" +
+ " PARAMETER[“Central parallel”, 41.75]],\n" + // Wrong parameter.
+ " CS[Cartesian, 2],\n" +
+ " AXIS[“(Y)”, north],\n" +
+ " AXIS[“(X)”, east]]");
+ fail("Should not have parsed a WKT with wrong projection parameter.");
+ } catch (InvalidGeodeticParameterException e) {
+ final String message = e.getMessage();
+ assertTrue(message, message.contains("Central parallel"));
+ }
+ }
+
+ /**
* Convenience method creating a map with only the "{@code name"} property.
* This is the only mandatory property for object creation.
*/