sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1542790 - in /sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis: referencing/ referencing/datum/ test/suite/
Date Sun, 17 Nov 2013 18:35:26 GMT
Author: desruisseaux
Date: Sun Nov 17 18:35:26 2013
New Revision: 1542790

URL: http://svn.apache.org/r1542790
Log:
Added some WKT formatting tests.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java?rev=1542790&r1=1542789&r2=1542790&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
[UTF-8] Sun Nov 17 18:35:26 2013
@@ -25,6 +25,7 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.geometry.AbstractEnvelope;
 import org.apache.sis.geometry.GeneralDirectPosition;
@@ -38,7 +39,7 @@ import static java.lang.StrictMath.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public strictfp class Assert extends org.apache.sis.test.Assert {
@@ -282,4 +283,22 @@ public strictfp class Assert extends org
             assertFalse("e1.contains(" + pos + ')', e1.contains(pos));
         }
     }
+
+    /**
+     * Asserts that the WKT of the given object is equal to the expected one. If the given
string contains
+     * {@code '“'} and {@code '”'} characters (for easier reading), then those characters
will be replaced
+     * by "ordinary" quote characters ({@code '"'}).
+     *
+     * @param object The object to format in <cite>Well Known Text</cite> format.
+     * @param expected The expected text, or {@code null} if {@code object} is expected to
be null.
+     */
+    public static void assertWktEquals(final IdentifiedObject object, String expected) {
+        if (expected == null) {
+            assertNull(object);
+        } else {
+            assertNotNull(object);
+            expected = expected.replace('“', '"').replace('”', '"');
+            assertMultilinesEquals(object.getName().getCode(), expected, object.toWKT());
+        }
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java?rev=1542790&r1=1542789&r2=1542790&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] Sun Nov 17 18:35:26 2013
@@ -28,7 +28,7 @@ import org.apache.sis.test.DependsOnMeth
 import org.junit.Test;
 
 import static java.lang.StrictMath.*;
-import static org.opengis.test.Assert.*;
+import static org.apache.sis.referencing.Assert.*;
 
 
 /**
@@ -149,4 +149,13 @@ public final strictfp class DefaultEllip
         assertEquals("SPHERE", 6371007, sphere.getAuthalicRadius(), 0.0);
         assertEquals("GRS80",  6371007, GRS80 .getAuthalicRadius(), 0.2);
     }
+
+    /**
+     * Tests {@link DefaultEllipsoid#toWKT()}.
+     */
+    @Test
+    public void testToWKT() {
+        final DefaultEllipsoid e = new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid());
+        assertWktEquals(e, "SPHEROID[“WGS84”, 6378137.0, 298.257223563]");
+    }
 }

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java?rev=1542790&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] Sun Nov 17 18:35:26 2013
@@ -0,0 +1,43 @@
+/*
+ * 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.datum;
+
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.mock.PrimeMeridianMock.GREENWICH;
+
+
+/**
+ * Tests the {@link DefaultPrimeMeridian} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final strictfp class DefaultPrimeMeridianTest extends TestCase {
+    /**
+     * Tests {@link DefaultPrimeMeridian#toWKT()}.
+     */
+    @Test
+    public void testToWKT() {
+        final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
+        assertWktEquals(pm, "PRIMEM[“Greenwich”, 0.0]");
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java?rev=1542790&r1=1542789&r2=1542790&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] Sun Nov 17 18:35:26 2013
@@ -23,7 +23,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.referencing.Assert.*;
 import static java.util.Collections.singletonMap;
 
 
@@ -63,4 +63,17 @@ public final strictfp class DefaultVerti
         typeField.set(datum, null);
         return datum.getVerticalDatumType();
     }
+
+    /**
+     * Tests {@link DefaultVerticalDatum#toWKT()}.
+     */
+    @Test
+    public void testToWKT() {
+        DefaultVerticalDatum datum;
+        datum = new DefaultVerticalDatum(singletonMap(DefaultVerticalDatum.NAME_KEY, "Geoidal"),
VerticalDatumType.GEOIDAL);
+        assertWktEquals(datum, "VERT_DATUM[“Geoidal”, 2005]");
+
+        datum = new DefaultVerticalDatum(singletonMap(DefaultVerticalDatum.NAME_KEY, "Ellipsoidal"),
VerticalDatumTypes.ELLIPSOIDAL);
+        assertWktEquals(datum, "VERT_DATUM[“Ellipsoidal”, 2002]");
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1542790&r1=1542789&r2=1542790&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Sun Nov 17 18:35:26 2013
@@ -52,6 +52,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
     org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
     org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
+    org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class,
     org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
     org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
     org.apache.sis.referencing.StandardDefinitionsTest.class,



Mime
View raw message