sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1553624 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/ sis-referencing/src/main/java/org/apache/sis/referencing/datum/ sis-referencing/src/test/java/org/apache/sis/referencing/ sis-ref...
Date Fri, 27 Dec 2013 04:20:04 GMT
Author: desruisseaux
Date: Fri Dec 27 04:20:04 2013
New Revision: 1553624

URL: http://svn.apache.org/r1553624
Log:
Added tests for DefaultGeodeticDatum XML (un)marshalling, and fixed some bugs discovered in
this process.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
      - copied, changed from r1553455, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS
84.xml   (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_PrimeMeridian.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Clarke
1880.xml   (contents, props changed)
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Paris.xml
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_PrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_PrimeMeridian.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_PrimeMeridian.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CD_PrimeMeridian.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -77,7 +77,7 @@ public final class CD_PrimeMeridian exte
      *
      * @return The element to be marshalled.
      */
-    @XmlElement(name = "Ellipsoid")
+    @XmlElement(name = "PrimeMeridian")
     public DefaultPrimeMeridian getElement() {
         return DefaultPrimeMeridian.castOrCopy(metadata);
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -87,7 +87,7 @@ public class AbstractDatum extends Abstr
      * Description, possibly including coordinates, of the point or points used to anchor
the datum
      * to the Earth. Also known as the "origin", especially for Engineering and Image Datums.
      */
-    @XmlElement
+    @XmlElement(name = "anchorDefinition")
     private final InternationalString anchorPoint;
 
     /**
@@ -102,7 +102,7 @@ public class AbstractDatum extends Abstr
     /**
      * Area or region in which this datum object is valid.
      */
-    @XmlElement(name = "validArea")
+    @XmlElement
     private final Extent domainOfValidity;
 
     /**

Copied: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
(from r1553455, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java?p2=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java&r1=1553455&r2=1553624&rev=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -14,90 +14,186 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.referencing.datum;
+package org.apache.sis.referencing;
 
-import java.net.URL;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.JAXBException;
+import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.GeographicExtent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.datum.PrimeMeridian;
-import org.apache.sis.xml.MarshallerPool;
-import org.apache.sis.test.XMLTestCase;
+import org.opengis.referencing.datum.GeodeticDatum;
 
 import static org.apache.sis.test.Assert.*;
 
 
 /**
- * Base class of test in the datum package that need XML (un)marshalling.
+ * Verifies the values of some geodetic objects. Methods in this class ignore most textual
properties like remarks,
+ * because OGP allows implementations to modify non-essential properties.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
  * @version 0.4
  * @module
+ *
+ * @todo Move this class to GeoAPI.
  */
-abstract strictfp class DatumTestCase extends XMLTestCase {
+public final strictfp class GeodeticObjectVerifier {
+    /**
+     * The tolerance factor for strict comparisons of floating point values.
+     */
+    private static final double STRICT = 0.0;
+
     /**
      * Creates a new test case.
      */
-    DatumTestCase() {
+    private GeodeticObjectVerifier() {
     }
 
     /**
-     * Asserts the the given prime meridian is the Greenwich one.
+     * Asserts that all {@link GeographicBoundingBox}, if any,
+     * {@linkplain #assertIsWorld(GeographicBoundingBox) encompasses the world}.
+     *
+     * <p><b>Note:</b> a future version of this method may accept other
kinds of extent,
+     * for example a polygon encompassing the world.</p>
+     *
+     * @param extent The extent to verify, or {@code null} if none.
      */
-    static void assertIsGreenwichMeridian(final PrimeMeridian meridian) {
-        assertEquals("name", "Greenwich", meridian.getName().getCode());
-        assertEquals("greenwichLongitude", 0, meridian.getGreenwichLongitude(), 0);
-        assertEquals("angularUnit", NonSI.DEGREE_ANGLE, meridian.getAngularUnit());
+    private static void assertIsWorld(final Extent extent) {
+        if (extent != null) {
+            for (final GeographicExtent element : extent.getGeographicElements()) {
+                if (element instanceof GeographicBoundingBox) {
+                    assertIsWorld((GeographicBoundingBox) element);
+                }
+            }
+        }
     }
 
     /**
-     * Asserts the the given prime meridian is the Paris one.
+     * Asserts that the given geographic bounding box encompasses the world.
+     * This method verifies the following properties:
+     *
+     * <table class="sis">
+     * <tr><th>Property</th> <th>Expected value</th></tr>
+     * <tr><td>{@linkplain GeographicBoundingBox#getInclusion() Inclusion}</td><td>Absent
or {@link Boolean#TRUE}</td></tr>
+     * <tr><td>{@linkplain GeographicBoundingBox#getWestBoundLongitude() West
bound longitude}</td><td>-180</td></tr>
+     * <tr><td>{@linkplain GeographicBoundingBox#getEastBoundLongitude() East
bound longitude}</td><td>+180</td></tr>
+     * <tr><td>{@linkplain GeographicBoundingBox#getSouthBoundLatitude() South
bound latitude}</td><td> -90</td></tr>
+     * <tr><td>{@linkplain GeographicBoundingBox#getNorthBoundLatitude() North
bound latitude}</td><td> +90</td></tr>
+     * </table>
+     *
+     * @param box The geographic bounding box to verify.
      */
-    static void assertIsParisMeridian(final PrimeMeridian meridian) {
-        assertEquals("name", "Paris", meridian.getName().getCode());
-        assertEquals("greenwichLongitude", 2.5969213, meridian.getGreenwichLongitude(), 0);
-        assertEquals("angularUnit", NonSI.GRADE, meridian.getAngularUnit());
+    public static void assertIsWorld(final GeographicBoundingBox box) {
+        final Boolean inclusion = box.getInclusion();
+        if (inclusion != null) {
+            assertEquals("inclusion", Boolean.TRUE, inclusion);
+        }
+        assertEquals("westBoundLongitude", -180, box.getWestBoundLongitude(), STRICT);
+        assertEquals("eastBoundLongitude", +180, box.getEastBoundLongitude(), STRICT);
+        assertEquals("southBoundLatitude",  -90, box.getSouthBoundLatitude(), STRICT);
+        assertEquals("northBoundLatitude",  +90, box.getNorthBoundLatitude(), STRICT);
     }
 
     /**
-     * Marshals the given object and ensure that the result is equals to the content of the
given file,
-     * ignoring namespace declarations.
+     * Asserts that the given prime meridian is the Greenwich one.
+     * This method verifies the following properties:
+     *
+     * <table class="sis">
+     * <tr><th>Property</th> <th>Expected value</th></tr>
+     * <tr><td>{@linkplain ReferenceIdentifier#getCode() Code} of the {@linkplain
PrimeMeridian#getName() name}</td>
+     *     <td>{@code "Greenwich"}</td></tr>
+     * <tr><td>{@linkplain PrimeMeridian#getGreenwichLongitude() Greenwich longitude}</td>
+     *     <td>0</td></tr>
+     * <tr><td>{@linkplain PrimeMeridian#getAngularUnit() Angular unit}</td>
+     *     <td>{@link NonSI#DEGREE_ANGLE}</td></tr>
+     * </table>
      *
-     * @param  filename The name of the XML file.
-     * @param  object The object to marshal.
-     * @throws JAXBException If an error occurred during marshalling.
+     * @param meridian The prime meridian to verify.
      */
-    final void assertMarshalEqualsFile(final String filename, final Object object) throws
JAXBException {
-        assertXmlEquals(getResource(filename), marshal(object), "xlmns:*", "xsi:schemaLocation");
+    public static void assertIsGreenwich(final PrimeMeridian meridian) {
+        assertEquals("name",               "Greenwich",        meridian.getName().getCode());
+        assertEquals("greenwichLongitude", 0,                  meridian.getGreenwichLongitude(),
STRICT);
+        assertEquals("angularUnit",        NonSI.DEGREE_ANGLE, meridian.getAngularUnit());
     }
 
     /**
-     * Unmarshalls the given test file.
+     * Asserts that the given prime meridian is the Paris one.
+     * This method verifies the following properties:
      *
-     * @param  type The expected object type.
-     * @param  filename The name of the XML file.
-     * @return The object unmarshalled from the given file.
-     * @throws JAXBException If an error occurred during unmarshalling.
+     * <table class="sis">
+     * <tr><th>Property</th> <th>Expected value</th></tr>
+     * <tr><td>{@linkplain ReferenceIdentifier#getCode() Code} of the {@linkplain
PrimeMeridian#getName() name}</td>
+     *     <td>{@code "Paris"}</td></tr>
+     * <tr><td>{@linkplain PrimeMeridian#getGreenwichLongitude() Greenwich longitude}</td>
+     *     <td>2.5969213</td></tr>
+     * <tr><td>{@linkplain PrimeMeridian#getAngularUnit() Angular unit}</td>
+     *     <td>{@link NonSI#GRADE}</td></tr>
+     * </table>
+     *
+     * @param meridian The prime meridian to verify.
+     */
+    public static void assertIsParis(final PrimeMeridian meridian) {
+        assertEquals("name",               "Paris",     meridian.getName().getCode());
+        assertEquals("greenwichLongitude", 2.5969213,   meridian.getGreenwichLongitude(),
STRICT);
+        assertEquals("angularUnit",        NonSI.GRADE, meridian.getAngularUnit());
+    }
+
+    /**
+     * Asserts that the given ellipsoid is the WGS 84 one.
+     * This method verifies the following properties:
+     *
+     * <table class="sis">
+     * <tr><th>Property</th> <th>Expected value</th></tr>
+     * <tr><td>{@linkplain ReferenceIdentifier#getCode() Code} of the {@linkplain
Ellipsoid#getName() name}</td>
+     *     <td>{@code "WGS 84"}</td></tr>
+     * <tr><td>{@linkplain Ellipsoid#getAxisUnit() Axis unit}</td>
+     *     <td>{@link SI#METRE}</td></tr>
+     * <tr><td>{@linkplain Ellipsoid#getSemiMajorAxis() Semi-major axis}</td>
+     *     <td>6378137</td></tr>
+     * <tr><td>{@linkplain Ellipsoid#getSemiMinorAxis() Semi-minor axis}</td>
+     *     <td>6356752.314245179 ± 0.001</td></tr>
+     * <tr><td>{@linkplain Ellipsoid#getInverseFlattening() Inverse flattening}</td>
+     *     <td>298.257223563</td></tr>
+     * <tr><td>{@linkplain Ellipsoid#isIvfDefinitive() is IVF definitive}</td>
+     *     <td>{@code true}</td></tr>
+     * </table>
+     *
+     * @param ellipsoid The ellipsoid to verify.
      */
-    static <T> T unmarshall(final Class<T> type, final String filename) throws
JAXBException {
-        final MarshallerPool pool = getMarshallerPool();
-        final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
-        final Object object = unmarshaller.unmarshal(getResource(filename));
-        pool.recycle(unmarshaller);
-        assertInstanceOf(filename, type, object);
-        return type.cast(object);
+    public static void assertIsWGS84(final Ellipsoid ellipsoid) {
+        assertEquals("name",              "WGS 84",          ellipsoid.getName().getCode());
+        assertEquals("axisUnit",          SI.METRE,          ellipsoid.getAxisUnit());
+        assertEquals("semiMajorAxis",     6378137,           ellipsoid.getSemiMajorAxis(),
    STRICT);
+        assertEquals("semiMinorAxis",     6356752.314245179, ellipsoid.getSemiMinorAxis(),
    0.001);
+        assertEquals("inverseFlattening", 298.257223563,     ellipsoid.getInverseFlattening(),
STRICT);
+        assertTrue  ("isIvfDefinitive",                      ellipsoid.isIvfDefinitive());
     }
 
     /**
-     * Returns the URL to the XML file of the given name.
+     * Asserts that the given datum is the WGS 84 one.
+     * This method verifies the following properties:
+     *
+     * <table class="sis">
+     * <tr><th>Property</th> <th>Expected value</th></tr>
+     * <tr><td>{@linkplain ReferenceIdentifier#getCode() Code} of the {@linkplain
GeodeticDatum#getName() name}</td>
+     *     <td>{@code "World Geodetic System 1984"}</td></tr>
+     * <tr><td>{@linkplain GeodeticDatum#getDomainOfValidity() Domain of validity}</td>
+     *     <td>{@linkplain #assertIsWorld(GeographicBoundingBox) Is world}</td></tr>
+     * <tr><td>{@linkplain GeodeticDatum#getPrimeMeridian() Prime meridian}</td>
+     *     <td>{@linkplain #assertIsGreenwich(PrimeMeridian) Is Greenwich}</td></tr>
+     * <tr><td>{@linkplain GeodeticDatum#getEllipsoid() Ellipsoid}</td>
+     *     <td>{@linkplain #assertIsWGS84(Ellipsoid) Is WGS84}</td></tr>
+     * </table>
      *
-     * @param  filename The name of the XML file.
-     * @return The URL to the given XML file.
+     * @param datum The datum to verify.
      */
-    private static URL getResource(final String filename) {
-        final URL resource = DatumTestCase.class.getResource(filename);
-        assertNotNull(filename, resource);
-        return resource;
+    public static void assertIsWGS84(final GeodeticDatum datum) {
+        assertEquals("name", "World Geodetic System 1984", datum.getName().getCode());
+        assertIsWorld    (datum.getDomainOfValidity());
+        assertIsGreenwich(datum.getPrimeMeridian());
+        assertIsWGS84    (datum.getEllipsoid());
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -19,8 +19,6 @@ package org.apache.sis.referencing.datum
 import java.net.URL;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBException;
-import javax.measure.unit.NonSI;
-import org.opengis.referencing.datum.PrimeMeridian;
 import org.apache.sis.xml.MarshallerPool;
 import org.apache.sis.test.XMLTestCase;
 
@@ -43,24 +41,6 @@ abstract strictfp class DatumTestCase ex
     }
 
     /**
-     * Asserts the the given prime meridian is the Greenwich one.
-     */
-    static void assertIsGreenwichMeridian(final PrimeMeridian meridian) {
-        assertEquals("name", "Greenwich", meridian.getName().getCode());
-        assertEquals("greenwichLongitude", 0, meridian.getGreenwichLongitude(), 0);
-        assertEquals("angularUnit", NonSI.DEGREE_ANGLE, meridian.getAngularUnit());
-    }
-
-    /**
-     * Asserts the the given prime meridian is the Paris one.
-     */
-    static void assertIsParisMeridian(final PrimeMeridian meridian) {
-        assertEquals("name", "Paris", meridian.getName().getCode());
-        assertEquals("greenwichLongitude", 2.5969213, meridian.getGreenwichLongitude(), 0);
-        assertEquals("angularUnit", NonSI.GRADE, meridian.getAngularUnit());
-    }
-
-    /**
      * Marshals the given object and ensure that the result is equals to the content of the
given file,
      * ignoring namespace declarations.
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -21,10 +21,13 @@ import java.util.HashMap;
 import java.util.Locale;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
+import javax.xml.bind.JAXBException;
 import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.test.Validators;
+import org.apache.sis.xml.Namespaces;
 import org.apache.sis.metadata.iso.extent.DefaultExtent;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.test.DependsOnMethod;
@@ -32,7 +35,9 @@ import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
 import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.TestUtilities.*;
 import static org.apache.sis.test.mock.GeodeticDatumMock.*;
+import static org.apache.sis.referencing.GeodeticObjectVerifier.*;
 
 
 /**
@@ -176,4 +181,61 @@ public final strictfp class DefaultGeode
                 "DATUM[“WGS84”,\n" +
                 "  SPHEROID[“WGS84”, 6378137.0, 298.257223563]]");
     }
+
+    /**
+     * Tests marshalling.
+     *
+     * @throws JAXBException If an error occurred during marshalling.
+     */
+    @Test
+    public void testMarshalling() throws JAXBException {
+        assertXmlEquals(
+                "<gml:GeodeticDatum xmlns:gml=\"" + Namespaces.GML + "\">\n" +
+                "  <gml:name codeSpace=\"test\">WGS84</gml:name>\n" +
+                "  <gml:primeMeridian>\n" +
+                "    <gml:PrimeMeridian>\n" +
+                "      <gml:name codeSpace=\"test\">Greenwich</gml:name>\n" +
+                "      <gml:greenwichLongitude uom=\"urn:ogc:def:uom:EPSG::9102\">0.0</gml:greenwichLongitude>\n"
+
+                "    </gml:PrimeMeridian>\n" +
+                "  </gml:primeMeridian>\n" +
+                "  <gml:ellipsoid>\n" +
+                "    <gml:Ellipsoid>\n" +
+                "      <gml:name codeSpace=\"test\">WGS84</gml:name>\n" +
+                "      <gml:semiMajorAxis uom=\"urn:ogc:def:uom:EPSG::9001\">6378137.0</gml:semiMajorAxis>\n"
+
+                "      <gml:secondDefiningParameter>\n" +
+                "        <gml:SecondDefiningParameter>\n" +
+                "          <gml:inverseFlattening uom=\"urn:ogc:def:uom:EPSG::9201\">298.257223563</gml:inverseFlattening>\n"
+
+                "        </gml:SecondDefiningParameter>\n" +
+                "      </gml:secondDefiningParameter>\n" +
+                "    </gml:Ellipsoid>\n" +
+                "  </gml:ellipsoid>\n" +
+                "</gml:GeodeticDatum>",
+                marshal(new DefaultGeodeticDatum(WGS84)), "xmlns:*");
+    }
+
+    /**
+     * Tests unmarshalling.
+     *
+     * @throws JAXBException If an error occurred during unmarshalling.
+     */
+    @Test
+    public void testUnmarshalling() throws JAXBException {
+        final DefaultGeodeticDatum datum = unmarshall(DefaultGeodeticDatum.class, "WGS 84.xml");
+        assertIsWGS84(datum);
+        assertIsWorld((GeographicBoundingBox) getSingleton(datum.getDomainOfValidity().getGeographicElements()));
+        /*
+         * Values in the following tests are specific to our XML file.
+         * The actual texts in the EPSG database are more descriptive.
+         */
+        assertEquals("remarks", "No distinction between the original and subsequent WGS 84
frames.",
+                datum.getRemarks().toString());
+        assertEquals("scope", "Satellite navigation.",
+                datum.getScope().toString());
+        assertEquals("anchorDefinition", "Station coordinates changed by a few centimetres
in 1994, 1997, 2002 and 2012.",
+                datum.getAnchorPoint().toString());
+//      assertEquals("realizationEpoch", date("1984-01-01 00:00:00"),
+//              datum.getRealizationEpoch());
+        assertEquals("remarks", "Defining parameters cited in EPSG database.",
+                datum.getEllipsoid().getRemarks().toString());
+    }
 }

Modified: 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=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -30,6 +30,7 @@ import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
 import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.referencing.GeodeticObjectVerifier.*;
 import static org.apache.sis.test.mock.PrimeMeridianMock.GREENWICH;
 
 
@@ -49,7 +50,7 @@ public final strictfp class DefaultPrime
     @Test
     public void testToWKT() {
         final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
-        assertIsGreenwichMeridian(pm);
+        assertIsGreenwich(pm);
         assertWktEquals(pm, "PRIMEM[“Greenwich”, 0.0]");
     }
 
@@ -106,7 +107,7 @@ public final strictfp class DefaultPrime
     @Test
     public void testUnmarshall() throws JAXBException {
         final DefaultPrimeMeridian pm = unmarshall(DefaultPrimeMeridian.class, "Greenwich.xml");
-        assertIsGreenwichMeridian(pm);
+        assertIsGreenwich(pm);
     }
 
     /**
@@ -123,7 +124,7 @@ public final strictfp class DefaultPrime
         final DefaultPrimeMeridian pm = (DefaultPrimeMeridian)
                 unmarshal(unmarshaller, getGreenwichXml(LegacyNamespaces.GML));
         pool.recycle(unmarshaller);
-        assertIsGreenwichMeridian(pm);
+        assertIsGreenwich(pm);
     }
 
     /**
@@ -135,7 +136,7 @@ public final strictfp class DefaultPrime
     @DependsOnMethod({"testUnmarshall", "testMarshall"})
     public void testParisMeridian() throws JAXBException {
         final DefaultPrimeMeridian pm = unmarshall(DefaultPrimeMeridian.class, "Paris.xml");
-        assertIsParisMeridian(pm);
+        assertIsParis(pm);
         assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(NonSI.DEGREE_ANGLE),
1E-12);
         assertEquals("Equivalent to 2°20′14.025″.", pm.getRemarks().toString());
         assertNull("name.codeSpace", pm.getName().getCodeSpace());

Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Clarke
1880.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Clarke%201880.xml?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Clarke
1880.xml [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Clarke
1880.xml [iso-8859-1] Fri Dec 27 04:20:04 2013
@@ -18,11 +18,10 @@
   under the License.
 -->
 
-<gml:Ellipsoid
-    xmlns:gml = "http://www.opengis.net/gml/3.2"
-    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
-    gml:id = "epsg-ellipsoid-7055">
+<gml:Ellipsoid xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
+               xmlns:gml          = "http://www.opengis.net/gml/3.2"
+               xmlns:xsi          = "http://www.w3.org/2001/XMLSchema-instance"
+               gml:id             = "epsg-ellipsoid-7055">
 
   <gml:identifier codeSpace="OGP">urn:ogc:def:ellipsoid:EPSG::7055</gml:identifier>
   <gml:name>Clarke 1880 (international foot)</gml:name>

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Clarke
1880.xml
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Fri Dec 27 04:20:04 2013
@@ -1 +1 @@
-text/plain;charset=UTF-8
+text/xml

Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
(original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
Fri Dec 27 04:20:04 2013
@@ -18,11 +18,10 @@
   under the License.
 -->
 
-<gml:PrimeMeridian
-    xmlns:gml = "http://www.opengis.net/gml/3.2"
-    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
-    gml:id = "epsg-meridian-8901">
+<gml:PrimeMeridian xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
+                   xmlns:gml          = "http://www.opengis.net/gml/3.2"
+                   xmlns:xsi          = "http://www.w3.org/2001/XMLSchema-instance"
+                   gml:id             = "epsg-meridian-8901">
 
   <gml:identifier codeSpace="OGP">urn:ogc:def:meridian:EPSG::8901</gml:identifier>
   <gml:name>Greenwich</gml:name>

Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Paris.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Paris.xml?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Paris.xml
(original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Paris.xml
Fri Dec 27 04:20:04 2013
@@ -18,11 +18,10 @@
   under the License.
 -->
 
-<gml:PrimeMeridian
-    xmlns:gml = "http://www.opengis.net/gml/3.2"
-    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
-    gml:id = "epsg-meridian-8903">
+<gml:PrimeMeridian xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
+                   xmlns:gml          = "http://www.opengis.net/gml/3.2"
+                   xmlns:xsi          = "http://www.w3.org/2001/XMLSchema-instance"
+                   gml:id             = "epsg-meridian-8903">
 
   <gml:identifier codeSpace="OGP">urn:ogc:def:meridian:EPSG::8903</gml:identifier>
   <gml:name>Paris</gml:name>

Added: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS
84.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS%2084.xml?rev=1553624&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS
84.xml (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS
84.xml Fri Dec 27 04:20:04 2013
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<gml:GeodeticDatum xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd"
+                   xmlns:gml          = "http://www.opengis.net/gml/3.2"
+                   xmlns:gmd          = "http://www.isotc211.org/2005/gmd"
+                   xmlns:gco          = "http://www.isotc211.org/2005/gco"
+                   xmlns:xsi          = "http://www.w3.org/2001/XMLSchema-instance"
+                   xmlns:xlink        = "http://www.w3.org/1999/xlink"
+                   gml:id             = "epsg-datum-6326">
+
+  <gml:identifier codeSpace="OGP">urn:ogc:def:datum:EPSG::6326</gml:identifier>
+  <gml:name>World Geodetic System 1984</gml:name>
+  <gml:remarks>No distinction between the original and subsequent WGS 84 frames.</gml:remarks>
+  <gml:domainOfValidity>
+    <gmd:EX_Extent>
+      <gmd:description>
+        <gco:CharacterString>World.</gco:CharacterString>
+      </gmd:description>
+      <gmd:geographicElement>
+        <gmd:EX_GeographicBoundingBox>
+          <gmd:westBoundLongitude><gco:Decimal>-180</gco:Decimal></gmd:westBoundLongitude>
+          <gmd:eastBoundLongitude><gco:Decimal>+180</gco:Decimal></gmd:eastBoundLongitude>
+          <gmd:southBoundLatitude><gco:Decimal> -90</gco:Decimal></gmd:southBoundLatitude>
+          <gmd:northBoundLatitude><gco:Decimal> +90</gco:Decimal></gmd:northBoundLatitude>
+        </gmd:EX_GeographicBoundingBox>
+      </gmd:geographicElement>
+    </gmd:EX_Extent>
+  </gml:domainOfValidity>
+  <gml:scope>Satellite navigation.</gml:scope>
+  <gml:anchorDefinition>Station coordinates changed by a few centimetres in 1994, 1997,
2002 and 2012.</gml:anchorDefinition>
+  <gml:realizationEpoch>1984-01-01</gml:realizationEpoch>
+  <gml:primeMeridian>
+    <gml:PrimeMeridian gml:id = "epsg-meridian-8901">
+      <gml:identifier codeSpace="OGP">urn:ogc:def:meridian:EPSG::8901</gml:identifier>
+      <gml:name>Greenwich</gml:name>
+      <gml:greenwichLongitude uom="urn:ogc:def:uom:EPSG::9102">0</gml:greenwichLongitude>
+    </gml:PrimeMeridian>
+  </gml:primeMeridian>
+  <gml:ellipsoid>
+    <gml:Ellipsoid gml:id = "epsg-ellipsoid-7030">
+      <gml:identifier codeSpace="OGP">urn:ogc:def:ellipsoid:EPSG::7030</gml:identifier>
+      <gml:name>WGS 84</gml:name>
+      <gml:remarks>Defining parameters cited in EPSG database.</gml:remarks>
+      <gml:semiMajorAxis uom="urn:ogc:def:uom:EPSG::9001">6378137</gml:semiMajorAxis>
+      <gml:secondDefiningParameter>
+        <gml:SecondDefiningParameter>
+          <gml:inverseFlattening uom="urn:ogc:def:uom:EPSG::9201">298.257223563</gml:inverseFlattening>
+        </gml:SecondDefiningParameter>
+      </gml:secondDefiningParameter>
+    </gml:Ellipsoid>
+  </gml:ellipsoid>
+</gml:GeodeticDatum>

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS
84.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/WGS
84.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/DateAsLongAdapter.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -73,6 +73,6 @@ public final class DateAsLongAdapter ext
                 return new GO_DateTime(new Date(time), false);
             }
         }
-        return new GO_DateTime();
+        return null;
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -53,7 +53,7 @@ public final class GO_DateTime extends X
     private XMLGregorianCalendar date;
 
     /**
-     * Empty constructor for JAXB, and also for empty wrapper for formating only an empty
element.
+     * Empty constructor for JAXB.
      */
     public GO_DateTime() {
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -125,18 +125,18 @@ public final class Measure {
     @XmlAttribute(required = true)
     public String getUOM() {
         final Unit<?> unit = this.unit;
-        if (unit == null || unit.equals(Unit.ONE)) {
-            return "";
-        }
-        if (unit.equals(NonSI.PIXEL)) {
-            return "pixel"; // TODO: maybe not the most appropriate unit.
-        }
         if (!asXPointer) {
             final Integer code = Units.getEpsgCode(unit);
             if (code != null) {
                 return "urn:ogc:def:uom:EPSG::" + code;
             }
         }
+        if (unit == null || unit.equals(Unit.ONE)) {
+            return "";
+        }
+        if (unit.equals(NonSI.PIXEL)) {
+            return "pixel"; // TODO: maybe not the most appropriate unit.
+        }
         return Context.schema(Context.current(), "gmd", Schemas.METADATA_ROOT).append(Schemas.UOM_PATH)
                 .append("#xpointer(//*[@gml:id='").append(unit).append("'])").toString();
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -113,9 +113,8 @@ public class ReferenceResolver {
      *
      * @param  <T>     The compile-time type of the {@code type} argument.
      * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling
process.
-     * @param  type    The type of object to be unmarshalled as an <strong>interface</strong>.
-     *                 This is usually a <a href="http://www.geoapi.org">GeoAPI</a>
interface.
-     * @param  link The {@code xlink} attributes.
+     * @param  type    The type of object to be unmarshalled, often as an interface.
+     * @param  link    The {@code xlink} attributes.
      * @return An object of the given type for the given {@code xlink} attribute, or {@code
null} if none.
      */
     public <T> T resolve(final MarshalContext context, final Class<T> type, final
XLink link) {
@@ -141,8 +140,7 @@ public class ReferenceResolver {
      *
      * @param  <T>     The compile-time type of the {@code type} argument.
      * @param  context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling
process.
-     * @param  type    The type of object to be marshalled as an <strong>interface</strong>.
-     *                 This is usually a <a href="http://www.geoapi.org">GeoAPI</a>
interface.
+     * @param  type    The type of object to be unmarshalled, often as an interface.
      * @param  object  The object to be marshalled.
      * @param  uuid    The unique identifier of the object to be marshalled.
      * @return {@code true} if the marshaller can use the {@code uuidref} attribute

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java?rev=1553624&r1=1553623&r2=1553624&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/MeasureTest.java
[UTF-8] Fri Dec 27 04:20:04 2013
@@ -17,9 +17,11 @@
 package org.apache.sis.internal.jaxb.gco;
 
 import java.net.URISyntaxException;
+import javax.measure.unit.Unit;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import org.apache.sis.internal.jaxb.Schemas;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -31,16 +33,30 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.10)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final strictfp class MeasureTest extends TestCase {
     /**
+     * Tests the {@link Measure#getUOM()}.
+     */
+    @Test
+    public void testGetUOM() {
+        final Measure measure = new Measure(10, SI.METRE);
+        assertEquals("urn:ogc:def:uom:EPSG::9001", measure.getUOM());
+        measure.unit = NonSI.DEGREE_ANGLE;
+        assertEquals("urn:ogc:def:uom:EPSG::9102", measure.getUOM());
+        measure.unit = Unit.ONE;
+        assertEquals("urn:ogc:def:uom:EPSG::9201", measure.getUOM());
+    }
+
+    /**
      * Tests the {@link Measure#setUOM(String)}.
      *
      * @throws URISyntaxException Should not happen.
      */
     @Test
+    @DependsOnMethod("testGetUOM")
     public void testSetUOM() throws URISyntaxException {
         final Measure measure = new Measure();
         measure.setUOM("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#m");



Mime
View raw message