sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Split the test in a case focusing on vertical extent and in a case for the larger metadata test file.
Date Tue, 10 Sep 2019 18:36:57 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 1f3d2d6  Split the test in a case focusing on vertical extent and in a case for the
larger metadata test file.
1f3d2d6 is described below

commit 1f3d2d6f9dc43390cee2b8139c9c965fe45b398e
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Sep 10 17:47:37 2019 +0200

    Split the test in a case focusing on vertical extent and in a case for the larger metadata
test file.
---
 .../apache/sis/test/integration/MetadataTest.java  | 216 ++++-----------------
 .../sis/test/integration/MetadataVerticalTest.java | 214 ++++++++++++++++++++
 .../sis/test/suite/ReferencingTestSuite.java       |   1 +
 .../org/apache/sis/test/integration/Metadata.xml   |  51 +++--
 4 files changed, 287 insertions(+), 195 deletions(-)

diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
index 27b3458..fb9081a 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
@@ -31,19 +31,8 @@ import org.opengis.metadata.citation.*;
 import org.opengis.metadata.constraint.*;
 import org.opengis.metadata.identification.*;
 import org.opengis.metadata.maintenance.*;
-import org.opengis.metadata.extent.Extent;
-import org.opengis.metadata.extent.GeographicBoundingBox;
-import org.opengis.metadata.extent.VerticalExtent;
 import org.opengis.metadata.spatial.GeometricObjectType;
-import org.opengis.metadata.spatial.SpatialRepresentation;
-import org.opengis.metadata.spatial.VectorSpatialRepresentation;
-import org.opengis.metadata.identification.DataIdentification;
-import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.cs.VerticalCS;
-import org.opengis.referencing.crs.VerticalCRS;
-import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
 
 import org.apache.sis.measure.Units;
@@ -70,7 +59,6 @@ import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
 import org.apache.sis.xml.IdentifierSpace;
-import org.apache.sis.xml.NilObject;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.xml.XML;
 
@@ -78,7 +66,6 @@ import static java.util.Collections.singleton;
 import static java.util.Collections.singletonMap;
 
 // Test dependencies
-
 import org.apache.sis.test.LoggingWatcher;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.xml.DocumentComparator;
@@ -89,7 +76,6 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
 /**
@@ -106,14 +92,13 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
  * @module
  */
 @DependsOn({
-    org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class
+    MetadataVerticalTest.class
 })
-public strictfp class MetadataTest extends TestCase {
+public final strictfp class MetadataTest extends TestCase {
     /**
-     * The resource file which contains an XML representation
-     * of a {@link Metadata} object with a {@link VerticalCRS}.
+     * The resource file which contains an XML representation of a {@link Metadata} object.
      */
-    private static final String VERTICAL_CRS_XML = "Metadata with vertical CRS.xml";
+    private static final String XML_FILE = "Metadata.xml";
 
     /**
      * A JUnit {@link Rule} for listening to log events. This field is public because JUnit
requires us to
@@ -127,6 +112,7 @@ public strictfp class MetadataTest extends TestCase {
      */
     @After
     public void assertNoUnexpectedLog() {
+        loggings.skipNextLogIfContains("sis-temporal");
         loggings.assertNoUnexpectedLog();
     }
 
@@ -148,13 +134,13 @@ public strictfp class MetadataTest extends TestCase {
     /**
      * Programmatically creates the metadata to marshall, or to compare against the unmarshalled
metadata.
      *
-     * @return the hard-coded representation of {@code "Metadata.xml"} content.
+     * @return the hard-coded representation of {@value #XML_FILE} content.
      */
     private DefaultMetadata createHardCoded() {
         final DefaultMetadata metadata = new DefaultMetadata();
-        metadata.setMetadataIdentifier(new DefaultIdentifier("Apache SIS/Metadata test"));
+        metadata.setMetadataIdentifier(new DefaultIdentifier("test/Metadata.xml"));
         metadata.setLocalesAndCharsets(singletonMap(Locale.ENGLISH, StandardCharsets.UTF_8));
-        metadata.setMetadataScopes(singleton(new DefaultMetadataScope(ScopeCode.DATASET,
"Common Data Index record")));
+        metadata.setMetadataScopes(singleton(new DefaultMetadataScope(ScopeCode.DATASET,
"Pseudo Common Data Index record")));
         metadata.setDateInfo(singleton(new DefaultCitationDate(TestUtilities.date("2009-01-01
04:00:00"), DateType.CREATION)));
         /*
          * Contact information for the author. The same party will be used for custodian
and distributor,
@@ -180,15 +166,15 @@ public strictfp class MetadataTest extends TestCase {
             address.setCountry(country);
             address.setElectronicMailAddresses(singleton("xx@xx.fr"));
             contact.setAddresses(singleton(address));
-            author.setParties(singleton(new DefaultOrganisation("Marine institutes", null,
null, contact)));
+            author.setParties(singleton(new DefaultOrganisation("Some marine institute",
null, null, contact)));
             metadata.setContacts(singleton(author));
         }
         /*
          * Data indentification.
          */
         {
-            final DefaultCitation citation = new DefaultCitation("90008411.ctd");
-            citation.setAlternateTitles(singleton(new SimpleInternationalString("42292_5p_19900609195600")));
+            final DefaultCitation citation = new DefaultCitation("Some set of points");
+            citation.setAlternateTitles(singleton(new SimpleInternationalString("Code XYZ")));
             citation.setDates(Arrays.asList(
                     new DefaultCitationDate(TestUtilities.date("1990-06-04 22:00:00"), DateType.REVISION),
                     new DefaultCitationDate(TestUtilities.date("1979-08-02 22:00:00"), DateType.CREATION)));
@@ -212,10 +198,10 @@ public strictfp class MetadataTest extends TestCase {
                 citation.setCitedResponsibleParties(singleton(originator));
             }
             final DefaultDataIdentification identification = new DefaultDataIdentification(
-                    citation,                   // Citation
-                    "CTD NEDIPROD VI 120",      // Abstract
-                    Locale.ENGLISH,             // Language,
-                    TopicCategory.OCEANS);      // Topic category
+                    citation,                                                   // Citation
+                    "Description of pseudo data for testing purpose only.",     // Abstract
+                    Locale.ENGLISH,                                             // Language,
+                    TopicCategory.OCEANS);                                      // Topic
category
             {
                 @SuppressWarnings("deprecation")
                 final DefaultResponsibility custodian = new DefaultResponsibleParty(author);
@@ -259,8 +245,8 @@ public strictfp class MetadataTest extends TestCase {
             {
                 @SuppressWarnings("deprecation")
                 final DefaultAssociatedResource aggregateInfo = new DefaultAggregateInformation();
-                final DefaultCitation name = new DefaultCitation("MEDIPROD VI");
-                name.setAlternateTitles(singleton(new SimpleInternationalString("90008411")));
+                final DefaultCitation name = new DefaultCitation("Some oceanographic campaign");
+                name.setAlternateTitles(singleton(new SimpleInternationalString("Pseudo group
of data")));
                 name.setDates(singleton(new DefaultCitationDate(TestUtilities.date("1990-06-04
22:00:00"), DateType.REVISION)));
                 aggregateInfo.setName(name);
                 aggregateInfo.setInitiativeType(InitiativeType.CAMPAIGN);
@@ -291,8 +277,8 @@ public strictfp class MetadataTest extends TestCase {
                 setTemporalBounds(temporal, "1990-06-05", "1990-07-02");
                 identification.setExtents(singleton(new DefaultExtent(
                         null,
-                        new DefaultGeographicBoundingBox(1.1667, 1.1667, 36.6, 36.6),
-                        new DefaultVerticalExtent(Double.NaN, Double.NaN, vcrs),
+                        new DefaultGeographicBoundingBox(1.1666, 1.1667, 36.4, 36.6),
+                        new DefaultVerticalExtent(10, 25, vcrs),
                         temporal)));
             }
             /*
@@ -317,12 +303,12 @@ public strictfp class MetadataTest extends TestCase {
          * Information about Coordinate Reference System.
          */
         {
-            final DefaultCitation citation = new DefaultCitation("A geographic coordinate
reference frames");
+            final DefaultCitation citation = new DefaultCitation("World Geodetic System 84");
             citation.setAlternateTitles(singleton(new SimpleInternationalString("L101")));
-            citation.setIdentifiers(singleton(new ImmutableIdentifier(null, null, "http://www.seadatanet.org/urnurl/")));
+            citation.setIdentifiers(singleton(new ImmutableIdentifier(null, null, "SDN:L101:2:4326")));
             citation.setEdition(new Anchor(URI.create("SDN:C371:1:2"), "2"));
             metadata.setReferenceSystemInfo(singleton(
-                    new ReferenceSystemMetadata(new ImmutableIdentifier(citation, "L101",
"EPSG:4326"))));
+                    new ReferenceSystemMetadata(new ImmutableIdentifier(citation, "L101",
"4326"))));
         }
         /*
          * Information about content.
@@ -338,13 +324,13 @@ public strictfp class MetadataTest extends TestCase {
         {
             final DefaultMetadataExtensionInformation extensionInfo = new DefaultMetadataExtensionInformation();
             extensionInfo.setExtendedElementInformation(singleton(new DefaultExtendedElementInformation(
-                    "SDN:EDMO::",                           // Name
-                    "http://www.seadatanet.org/urnurl/",    // Definition
-                    null,                                   // Condition
-                    Datatype.CODE_LIST,                     // Data type
-                    "SeaDataNet",                           // Parent entity
-                    null,                                   // Rule
-                    null)));                                // Source
+                    "SDN:EDMO",                                                     // Name
+                    "European Directory of Marine Organisations",                   // Definition
+                    null,                                                           // Condition
+                    Datatype.CODE_LIST,                                             // Data
type
+                    "SeaDataNet",                                                   // Parent
entity
+                    "For testing only",                                             // Rule
+                    NilReason.MISSING.createNilObject(Responsibility.class))));     // Source
             metadata.setMetadataExtensionInfo(singleton(extensionInfo));
         }
         /*
@@ -366,10 +352,10 @@ public strictfp class MetadataTest extends TestCase {
 
             final DefaultDigitalTransferOptions transfer = new DefaultDigitalTransferOptions();
             transfer.setTransferSize(2.431640625);
-            final DefaultOnlineResource onlines = new DefaultOnlineResource(URI.create("http://www.ifremer.fr/data/something"));
-            onlines.setDescription(new SimpleInternationalString("CTDF02"));
+            final DefaultOnlineResource onlines = new DefaultOnlineResource(URI.create("ftp://www.ifremer.fr/data/something"));
+            onlines.setDescription(new SimpleInternationalString("Dummy download link"));
             onlines.setFunction(OnLineFunction.DOWNLOAD);
-            onlines.setProtocol("http");
+            onlines.setProtocol("ftp");
             transfer.setOnLines(singleton(onlines));
             distributionInfo.setTransferOptions(singleton(transfer));
             metadata.setDistributionInfo(singleton(distributionInfo));
@@ -378,12 +364,12 @@ public strictfp class MetadataTest extends TestCase {
     }
 
     /**
-     * Returns the URL to the {@code "Metadata.xml"} file to use for this test.
+     * Returns the URL to the {@value #XML_FILE} file to use for this test.
      *
-     * @return the URL to {@code "Metadata.xml"} test file.
+     * @return the URL to {@value #XML_FILE} test file.
      */
     private URL getResource() {
-        return MetadataTest.class.getResource("Metadata.xml");
+        return MetadataTest.class.getResource(XML_FILE);
     }
 
     /**
@@ -402,14 +388,14 @@ public strictfp class MetadataTest extends TestCase {
         /*
          * Apache SIS can marshal CharSequence as Anchor only if the property type is InternationalString.
          * But the 'Metadata.hierarchyLevelName' and 'Identifier.code' properties are String,
which we can
-         * not subclass. Concequently SIS currently marshals them as plain string. Replace
those strings
+         * not subclass. Consequently SIS currently marshals them as plain string. Replace
those strings
          * by the anchor version so we can compare the XML with the "Metadata.xml" file content.
          */
         final StringBuffer xml = writer.getBuffer();
-        replace(xml, "<gcol:CharacterString>Common Data Index record</gcol:CharacterString>",
-                     "<gmx:Anchor xlink:href=\"SDN:L231:3:CDI\">Common Data Index record</gmx:Anchor>");
-        replace(xml, "<gcol:CharacterString>EPSG:4326</gcol:CharacterString>",
-                     "<gmx:Anchor xlink:href=\"SDN:L101:2:4326\">EPSG:4326</gmx:Anchor>");
+        replace(xml, "<gcol:CharacterString>Pseudo Common Data Index record</gcol:CharacterString>",
+                     "<gmx:Anchor xlink:href=\"SDN:L231:3:CDI\">Pseudo Common Data
Index record</gmx:Anchor>");
+        replace(xml, "<gcol:CharacterString>4326</gcol:CharacterString>",
+                     "<gmx:Anchor xlink:href=\"SDN:L101:2:4326\">4326</gmx:Anchor>");
         /*
          * The <gmd:EX_TemporalExtent> block can not be marshalled yet, since it requires
the sis-temporal module.
          * We need to instruct the XML comparator to ignore this block during the comparison.
We also ignore for
@@ -447,7 +433,7 @@ public strictfp class MetadataTest extends TestCase {
     public void testUnmarshalling() throws JAXBException {
         /*
          * Note: if this MetadataTest class is made final, then all following lines
-         * until pool.recycle(…) can be replaced by a call to unmarshallFile("Metadata.xml").
+         * until pool.recycle(…) can be replaced by a call to unmarshallFile(XML_FILE).
          */
         final MarshallerPool pool = getMarshallerPool();
         final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
@@ -455,125 +441,5 @@ public strictfp class MetadataTest extends TestCase {
         pool.recycle(unmarshaller);
         final DefaultMetadata expected = createHardCoded();
         assertTrue(metadata.equals(expected, ComparisonMode.DEBUG));
-        loggings.skipNextLogIfContains("sis-temporal");
-    }
-
-    /**
-     * Tests the (un)marshalling of a metadata with a vertical CRS.
-     *
-     * @throws JAXBException if the (un)marshalling process fails.
-     */
-    @Test
-    public void testMetadataWithVerticalCRS() throws JAXBException {
-        final Metadata metadata = unmarshalFile(Metadata.class, VERTICAL_CRS_XML);
-        assertEquals("fileIdentifier", "20090901",                     metadata.getMetadataIdentifier().getCode());
-        assertEquals("language",       Locale.ENGLISH,                 getSingleton(metadata.getLocalesAndCharsets().keySet()));
-        assertEquals("characterSet",   StandardCharsets.UTF_8,         getSingleton(metadata.getLocalesAndCharsets().values()));
-        assertEquals("dateStamp",      xmlDate("2014-01-04 00:00:00"), getSingleton(metadata.getDateInfo()).getDate());
-        /*
-         * <gmd:contact>
-         *   <gmd:CI_ResponsibleParty>
-         *     …
-         *   </gmd:CI_ResponsibleParty>
-         * </gmd:contact>
-         */
-        final Responsibility contact        = getSingleton(metadata   .getContacts());
-        final Party          party          = getSingleton(contact    .getParties());
-        final Contact        contactInfo    = getSingleton(party      .getContactInfo());
-        final OnlineResource onlineResource = getSingleton(contactInfo.getOnlineResources());
-        assertInstanceOf("party", Organisation.class, party);
-        assertNotNull("onlineResource", onlineResource);
-        assertEquals("organisationName", "Apache SIS", party.getName().toString());
-        assertEquals("linkage", URI.create("http://sis.apache.org"), onlineResource.getLinkage());
-        assertEquals("function", OnLineFunction.INFORMATION, onlineResource.getFunction());
-        assertEquals("role", Role.PRINCIPAL_INVESTIGATOR, contact.getRole());
-        /*
-         * <gmd:spatialRepresentationInfo>
-         *   <gmd:MD_VectorSpatialRepresentation>
-         *     …
-         *   </gmd:MD_VectorSpatialRepresentation>
-         * </gmd:spatialRepresentationInfo>
-         */
-        final SpatialRepresentation spatial = getSingleton(metadata.getSpatialRepresentationInfo());
-        assertInstanceOf("spatialRepresentationInfo", VectorSpatialRepresentation.class,
spatial);
-        assertEquals("geometricObjectType", GeometricObjectType.POINT, getSingleton(
-                ((VectorSpatialRepresentation) spatial).getGeometricObjects()).getGeometricObjectType());
-        /*
-         * <gmd:referenceSystemInfo>
-         *   <gmd:MD_ReferenceSystem>
-         *     …
-         *   </gmd:MD_ReferenceSystem>
-         * </gmd:referenceSystemInfo>
-         */
-        assertIdentifierEquals("referenceSystemInfo", null, "EPSG", null, "World Geodetic
System 84",
-                getSingleton(metadata.getReferenceSystemInfo()).getName());
-        /*
-         * <gmd:identificationInfo>
-         *   <gmd:MD_DataIdentification>
-         *     …
-         */
-        final DataIdentification identification = (DataIdentification) getSingleton(metadata.getIdentificationInfo());
-        final Citation citation = identification.getCitation();
-        assertInstanceOf("citation", NilObject.class, citation);
-        assertEquals("nilReason", NilReason.MISSING, ((NilObject) citation).getNilReason());
-        assertEquals("abstract", "SIS test", identification.getAbstract().toString());
-        assertEquals("language", Locale.ENGLISH, getSingleton(identification.getLanguages()));
-        /*
-         * <gmd:geographicElement>
-         *   <gmd:EX_GeographicBoundingBox>
-         *     …
-         *   </gmd:EX_GeographicBoundingBox>
-         * </gmd:geographicElement>
-         */
-        final Extent extent = getSingleton(identification.getExtents());
-        final GeographicBoundingBox bbox = (GeographicBoundingBox) getSingleton(extent.getGeographicElements());
-        assertEquals("extentTypeCode", Boolean.TRUE, bbox.getInclusion());
-        assertEquals("westBoundLongitude",  4.55, bbox.getWestBoundLongitude(), STRICT);
-        assertEquals("eastBoundLongitude",  4.55, bbox.getEastBoundLongitude(), STRICT);
-        assertEquals("southBoundLatitude", 44.22, bbox.getSouthBoundLatitude(), STRICT);
-        assertEquals("northBoundLatitude", 44.22, bbox.getNorthBoundLatitude(), STRICT);
-        /*
-         * <gmd:verticalElement>
-         *   <gmd:EX_VerticalExtent>
-         *     …
-         *   </gmd:EX_VerticalExtent>
-         * </gmd:verticalElement>
-         */
-        final VerticalExtent ve = getSingleton(extent.getVerticalElements());
-        assertEquals("minimumValue",   0.1, ve.getMinimumValue(), STRICT);
-        assertEquals("maximumValue", 10000, ve.getMaximumValue(), STRICT);
-        final VerticalCRS crs = ve.getVerticalCRS();
-        verifyIdentifiers("test1", crs);
-        assertEquals("scope", "World", crs.getScope().toString());
-        final VerticalDatum datum = crs.getDatum();
-        verifyIdentifiers("test2", datum);
-        assertEquals("scope", "World", datum.getScope().toString());
-        assertEquals("vertDatumType", VerticalDatumType.DEPTH, datum.getVerticalDatumType());
// Inferred from the name.
-        final VerticalCS cs = crs.getCoordinateSystem();
-        verifyIdentifiers("test3", cs);
-        final CoordinateSystemAxis axis = cs.getAxis(0);
-        verifyIdentifiers("test4", axis);
-        assertEquals("axisAbbrev", "d", axis.getAbbreviation());
-        assertEquals("axisDirection", AxisDirection.DOWN, axis.getDirection());
-        /*
-         *     …
-         *   </gmd:MD_DataIdentification>
-         * </gmd:identificationInfo>
-         *
-         * Now marshal the object and compare with the original file.
-         */
-        assertMarshalEqualsFile(VERTICAL_CRS_XML, metadata, VERSION_2007, "xmlns:*", "xsi:schemaLocation");
-    }
-
-    /**
-     * Verifies the name and identifier for the given object.
-     *
-     * @param  code    the expected identifier code.
-     * @param  object  the object to verify.
-     */
-    private static void verifyIdentifiers(final String code, final IdentifiedObject object)
{
-        assertIdentifierEquals("identifier", "Apache Spatial Information System", "SIS",
-                null, code, getSingleton(object.getIdentifiers()));
-        assertIdentifierEquals("name", null, null, null, "Depth", object.getName());
     }
 }
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataVerticalTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataVerticalTest.java
new file mode 100644
index 0000000..7178e51
--- /dev/null
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataVerticalTest.java
@@ -0,0 +1,214 @@
+/*
+ * 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.test.integration;
+
+import java.net.URI;
+import java.util.Locale;
+import java.nio.charset.StandardCharsets;
+import javax.xml.bind.JAXBException;
+
+import org.opengis.metadata.*;
+import org.opengis.metadata.citation.*;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.metadata.extent.VerticalExtent;
+import org.opengis.metadata.spatial.GeometricObjectType;
+import org.opengis.metadata.spatial.SpatialRepresentation;
+import org.opengis.metadata.spatial.VectorSpatialRepresentation;
+import org.opengis.metadata.identification.DataIdentification;
+import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.cs.VerticalCS;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.datum.VerticalDatum;
+import org.opengis.referencing.datum.VerticalDatumType;
+
+import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.xml.NilObject;
+import org.apache.sis.xml.NilReason;
+
+// Test dependencies
+import org.apache.sis.test.LoggingWatcher;
+import org.apache.sis.test.xml.TestCase;
+import org.apache.sis.test.DependsOn;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.TestUtilities.getSingleton;
+
+
+/**
+ * Tests XML (un)marshalling of a metadata object containing a vertical extent
+ * together with its vertical CRS description.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ *
+ * @see org.apache.sis.metadata.iso.DefaultMetadataTest
+ *
+ * @since 0.5
+ * @module
+ */
+@DependsOn({
+    org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class
+})
+public strictfp class MetadataVerticalTest extends TestCase {
+    /**
+     * The resource file which contains an XML representation
+     * of a {@link Metadata} object with a {@link VerticalCRS}.
+     */
+    private static final String XML_FILE = "Metadata with vertical CRS.xml";
+
+    /**
+     * A JUnit {@link Rule} for listening to log events. This field is public because JUnit
requires us to
+     * do so, but should be considered as an implementation details (it should have been
a private field).
+     */
+    @Rule
+    public final LoggingWatcher loggings = new LoggingWatcher(Loggers.XML);
+
+    /**
+     * Verifies that no unexpected warning has been emitted in any test defined in this class.
+     */
+    @After
+    public void assertNoUnexpectedLog() {
+        loggings.skipNextLogIfContains("sis-temporal");
+        loggings.assertNoUnexpectedLog();
+    }
+
+    /**
+     * Tests the (un)marshalling of a metadata with a vertical CRS.
+     *
+     * @throws JAXBException if the (un)marshalling process fails.
+     */
+    @Test
+    public void testMetadataWithVerticalCRS() throws JAXBException {
+        final Metadata metadata = unmarshalFile(Metadata.class, XML_FILE);
+        assertEquals("fileIdentifier", "20090901",                     metadata.getMetadataIdentifier().getCode());
+        assertEquals("language",       Locale.ENGLISH,                 getSingleton(metadata.getLocalesAndCharsets().keySet()));
+        assertEquals("characterSet",   StandardCharsets.UTF_8,         getSingleton(metadata.getLocalesAndCharsets().values()));
+        assertEquals("dateStamp",      xmlDate("2014-01-04 00:00:00"), getSingleton(metadata.getDateInfo()).getDate());
+        /*
+         * <gmd:contact>
+         *   <gmd:CI_ResponsibleParty>
+         *     …
+         *   </gmd:CI_ResponsibleParty>
+         * </gmd:contact>
+         */
+        final Responsibility contact        = getSingleton(metadata   .getContacts());
+        final Party          party          = getSingleton(contact    .getParties());
+        final Contact        contactInfo    = getSingleton(party      .getContactInfo());
+        final OnlineResource onlineResource = getSingleton(contactInfo.getOnlineResources());
+        assertInstanceOf("party", Organisation.class, party);
+        assertNotNull("onlineResource", onlineResource);
+        assertEquals("organisationName", "Apache SIS", party.getName().toString());
+        assertEquals("linkage", URI.create("http://sis.apache.org"), onlineResource.getLinkage());
+        assertEquals("function", OnLineFunction.INFORMATION, onlineResource.getFunction());
+        assertEquals("role", Role.PRINCIPAL_INVESTIGATOR, contact.getRole());
+        /*
+         * <gmd:spatialRepresentationInfo>
+         *   <gmd:MD_VectorSpatialRepresentation>
+         *     …
+         *   </gmd:MD_VectorSpatialRepresentation>
+         * </gmd:spatialRepresentationInfo>
+         */
+        final SpatialRepresentation spatial = getSingleton(metadata.getSpatialRepresentationInfo());
+        assertInstanceOf("spatialRepresentationInfo", VectorSpatialRepresentation.class,
spatial);
+        assertEquals("geometricObjectType", GeometricObjectType.POINT, getSingleton(
+                ((VectorSpatialRepresentation) spatial).getGeometricObjects()).getGeometricObjectType());
+        /*
+         * <gmd:referenceSystemInfo>
+         *   <gmd:MD_ReferenceSystem>
+         *     …
+         *   </gmd:MD_ReferenceSystem>
+         * </gmd:referenceSystemInfo>
+         */
+        assertIdentifierEquals("referenceSystemInfo", null, "EPSG", null, "World Geodetic
System 84",
+                getSingleton(metadata.getReferenceSystemInfo()).getName());
+        /*
+         * <gmd:identificationInfo>
+         *   <gmd:MD_DataIdentification>
+         *     …
+         */
+        final DataIdentification identification = (DataIdentification) getSingleton(metadata.getIdentificationInfo());
+        final Citation citation = identification.getCitation();
+        assertInstanceOf("citation", NilObject.class, citation);
+        assertEquals("nilReason", NilReason.MISSING, ((NilObject) citation).getNilReason());
+        assertEquals("abstract", "SIS test", identification.getAbstract().toString());
+        assertEquals("language", Locale.ENGLISH, getSingleton(identification.getLanguages()));
+        /*
+         * <gmd:geographicElement>
+         *   <gmd:EX_GeographicBoundingBox>
+         *     …
+         *   </gmd:EX_GeographicBoundingBox>
+         * </gmd:geographicElement>
+         */
+        final Extent extent = getSingleton(identification.getExtents());
+        final GeographicBoundingBox bbox = (GeographicBoundingBox) getSingleton(extent.getGeographicElements());
+        assertEquals("extentTypeCode", Boolean.TRUE, bbox.getInclusion());
+        assertEquals("westBoundLongitude",  4.55, bbox.getWestBoundLongitude(), STRICT);
+        assertEquals("eastBoundLongitude",  4.55, bbox.getEastBoundLongitude(), STRICT);
+        assertEquals("southBoundLatitude", 44.22, bbox.getSouthBoundLatitude(), STRICT);
+        assertEquals("northBoundLatitude", 44.22, bbox.getNorthBoundLatitude(), STRICT);
+        /*
+         * <gmd:verticalElement>
+         *   <gmd:EX_VerticalExtent>
+         *     …
+         *   </gmd:EX_VerticalExtent>
+         * </gmd:verticalElement>
+         */
+        final VerticalExtent ve = getSingleton(extent.getVerticalElements());
+        assertEquals("minimumValue",   0.1, ve.getMinimumValue(), STRICT);
+        assertEquals("maximumValue", 10000, ve.getMaximumValue(), STRICT);
+        final VerticalCRS crs = ve.getVerticalCRS();
+        verifyIdentifiers("test1", crs);
+        assertEquals("scope", "World", crs.getScope().toString());
+        final VerticalDatum datum = crs.getDatum();
+        verifyIdentifiers("test2", datum);
+        assertEquals("scope", "World", datum.getScope().toString());
+        assertEquals("vertDatumType", VerticalDatumType.DEPTH, datum.getVerticalDatumType());
// Inferred from the name.
+        final VerticalCS cs = crs.getCoordinateSystem();
+        verifyIdentifiers("test3", cs);
+        final CoordinateSystemAxis axis = cs.getAxis(0);
+        verifyIdentifiers("test4", axis);
+        assertEquals("axisAbbrev", "d", axis.getAbbreviation());
+        assertEquals("axisDirection", AxisDirection.DOWN, axis.getDirection());
+        /*
+         *     …
+         *   </gmd:MD_DataIdentification>
+         * </gmd:identificationInfo>
+         *
+         * Now marshal the object and compare with the original file.
+         */
+        assertMarshalEqualsFile(XML_FILE, metadata, VERSION_2007, "xmlns:*", "xsi:schemaLocation");
+    }
+
+    /**
+     * Verifies the name and identifier for the given object.
+     *
+     * @param  code    the expected identifier code.
+     * @param  object  the object to verify.
+     */
+    private static void verifyIdentifiers(final String code, final IdentifiedObject object)
{
+        assertIdentifierEquals("identifier", "Apache Spatial Information System", "SIS",
+                null, code, getSingleton(object.getIdentifiers()));
+        assertIdentifierEquals("name", null, null, null, "Depth", object.getName());
+    }
+}
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
b/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
index a5f8691..558a6fe 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
@@ -282,6 +282,7 @@ import org.junit.BeforeClass;
     org.apache.sis.test.integration.CoordinateReferenceSystemTest.class,
     org.apache.sis.test.integration.CoordinateOperationTest.class,
     org.apache.sis.test.integration.DatumShiftTest.class,
+    org.apache.sis.test.integration.MetadataVerticalTest.class,
     org.apache.sis.test.integration.MetadataTest.class,
     org.apache.sis.test.integration.ConsistencyTest.class
 })
diff --git a/core/sis-referencing/src/test/resources/org/apache/sis/test/integration/Metadata.xml
b/core/sis-referencing/src/test/resources/org/apache/sis/test/integration/Metadata.xml
index 0c5527e..566f22a 100644
--- a/core/sis-referencing/src/test/resources/org/apache/sis/test/integration/Metadata.xml
+++ b/core/sis-referencing/src/test/resources/org/apache/sis/test/integration/Metadata.xml
@@ -29,7 +29,7 @@
                           http://www.isotc211.org/2005/gmx http://schemas.opengis.net/iso/19139/20070417/gmx/gmx.xsd">
 
   <gmd:fileIdentifier>
-    <gco:CharacterString>Apache SIS/Metadata test</gco:CharacterString>
+    <gco:CharacterString>test/Metadata.xml</gco:CharacterString>
   </gmd:fileIdentifier>
   <gmd:language>
     <gmd:LanguageCode codeListValue="eng" codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode">English</gmd:LanguageCode>
@@ -41,13 +41,16 @@
     <gmd:MD_ScopeCode codeSpace="eng" codeListValue="dataset" codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_ScopeCode">Dataset</gmd:MD_ScopeCode>
   </gmd:hierarchyLevel>
   <gmd:hierarchyLevelName>
-    <gmx:Anchor xlink:href="SDN:L231:3:CDI">Common Data Index record</gmx:Anchor>
+    <gmx:Anchor xlink:href="SDN:L231:3:CDI">Pseudo Common Data Index record</gmx:Anchor>
   </gmd:hierarchyLevelName>
   <gmd:contact>
     <gmd:CI_ResponsibleParty>
       <gmd:organisationName>
-        <gco:CharacterString>Marine institutes</gco:CharacterString>
+        <gco:CharacterString>Some marine institute</gco:CharacterString>
       </gmd:organisationName>
+
+      <!-- The following contact information is referenced later in this file.
+           We use this for testing SIS capabilities to follow references. -->
       <gmd:contactInfo>
         <gmd:CI_Contact id="IFREMER">
           <gmd:phone>
@@ -91,6 +94,8 @@
           </gmd:onlineResource>
         </gmd:CI_Contact>
       </gmd:contactInfo>
+      <!-- End of section to be referenced later. -->
+
       <gmd:role>
         <gmd:CI_RoleCode codeListValue="author" codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_RoleCode">Author</gmd:CI_RoleCode>
       </gmd:role>
@@ -117,7 +122,7 @@
           <gmd:authority>
             <gmd:CI_Citation>
               <gmd:title>
-                <gco:CharacterString>A geographic coordinate reference frames</gco:CharacterString>
+                <gco:CharacterString>World Geodetic System 84</gco:CharacterString>
               </gmd:title>
               <gmd:alternateTitle>
                 <gco:CharacterString>L101</gco:CharacterString>
@@ -128,14 +133,14 @@
               <gmd:identifier>
                 <gmd:MD_Identifier>
                   <gmd:code>
-                    <gco:CharacterString>http://www.seadatanet.org/urnurl/</gco:CharacterString>
+                    <gco:CharacterString>SDN:L101:2:4326</gco:CharacterString>
                   </gmd:code>
                 </gmd:MD_Identifier>
               </gmd:identifier>
             </gmd:CI_Citation>
           </gmd:authority>
           <gmd:code>
-            <gmx:Anchor xlink:href="SDN:L101:2:4326">EPSG:4326</gmx:Anchor>
+            <gmx:Anchor xlink:href="SDN:L101:2:4326">4326</gmx:Anchor>
           </gmd:code>
           <gmd:codeSpace>
             <gco:CharacterString>L101</gco:CharacterString>
@@ -149,10 +154,10 @@
       <gmd:extendedElementInformation>
         <gmd:MD_ExtendedElementInformation>
           <gmd:name>
-            <gco:CharacterString>SDN:EDMO::</gco:CharacterString>
+            <gco:CharacterString>SDN:EDMO</gco:CharacterString>
           </gmd:name>
           <gmd:definition>
-            <gco:CharacterString>http://www.seadatanet.org/urnurl/</gco:CharacterString>
+            <gco:CharacterString>European Directory of Marine Organisations</gco:CharacterString>
           </gmd:definition>
           <gmd:dataType>
             <gmd:MD_DatatypeCode codeListValue="codelist" codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_DatatypeCode">Codelist</gmd:MD_DatatypeCode>
@@ -160,6 +165,10 @@
           <gmd:parentEntity>
             <gco:CharacterString>SeaDataNet</gco:CharacterString>
           </gmd:parentEntity>
+          <gmd:rule>
+            <gco:CharacterString>For testing only</gco:CharacterString>
+          </gmd:rule>
+          <gmd:source gco:nilReason="missing"/>
         </gmd:MD_ExtendedElementInformation>
       </gmd:extendedElementInformation>
     </gmd:MD_MetadataExtensionInformation>
@@ -169,10 +178,10 @@
       <gmd:citation>
         <gmd:CI_Citation>
           <gmd:title>
-            <gco:CharacterString>90008411.ctd</gco:CharacterString>
+            <gco:CharacterString>Some set of points</gco:CharacterString>
           </gmd:title>
           <gmd:alternateTitle>
-            <gco:CharacterString>42292_5p_19900609195600</gco:CharacterString>
+            <gco:CharacterString>Code XYZ</gco:CharacterString>
           </gmd:alternateTitle>
           <gmd:date>
             <gmd:CI_Date>
@@ -247,12 +256,12 @@
         </gmd:CI_Citation>
       </gmd:citation>
       <gmd:abstract>
-        <gco:CharacterString>CTD NEDIPROD VI 120</gco:CharacterString>
+        <gco:CharacterString>Description of pseudo data for testing purpose only.</gco:CharacterString>
       </gmd:abstract>
       <gmd:pointOfContact>
         <gmd:CI_ResponsibleParty>
           <gmd:organisationName>
-            <gco:CharacterString>Marine institutes</gco:CharacterString>
+            <gco:CharacterString>Some marine institute</gco:CharacterString>
           </gmd:organisationName>
           <gmd:contactInfo xlink:href="#IFREMER"/>
           <gmd:role>
@@ -322,10 +331,10 @@
           <gmd:aggregateDataSetName>
             <gmd:CI_Citation>
               <gmd:title>
-                <gco:CharacterString>MEDIPROD VI</gco:CharacterString>
+                <gco:CharacterString>Some oceanographic campaign</gco:CharacterString>
               </gmd:title>
               <gmd:alternateTitle>
-                <gco:CharacterString>90008411</gco:CharacterString>
+                <gco:CharacterString>Pseudo group of data</gco:CharacterString>
               </gmd:alternateTitle>
               <gmd:date>
                 <gmd:CI_Date>
@@ -364,13 +373,13 @@
                 <gco:Boolean>true</gco:Boolean>
               </gmd:extentTypeCode>
               <gmd:westBoundLongitude>
-                <gco:Decimal>1.1667</gco:Decimal>
+                <gco:Decimal>1.1666</gco:Decimal>
               </gmd:westBoundLongitude>
               <gmd:eastBoundLongitude>
                 <gco:Decimal>1.1667</gco:Decimal>
               </gmd:eastBoundLongitude>
               <gmd:southBoundLatitude>
-                <gco:Decimal>36.6</gco:Decimal>
+                <gco:Decimal>36.4</gco:Decimal>
               </gmd:southBoundLatitude>
               <gmd:northBoundLatitude>
                 <gco:Decimal>36.6</gco:Decimal>
@@ -389,6 +398,8 @@
           </gmd:temporalElement>
           <gmd:verticalElement>
             <gmd:EX_VerticalExtent>
+              <gmd:minimumValue> <gco:Real>10</gco:Real> </gmd:minimumValue>
+              <gmd:maximumValue> <gco:Real>25</gco:Real> </gmd:maximumValue>
               <gmd:verticalCRS>
                 <gml:VerticalCRS gml:id="depth_D28">
                   <gml:name>Depth below D28</gml:name>
@@ -444,7 +455,7 @@
           <gmd:distributorContact>
             <gmd:CI_ResponsibleParty>
               <gmd:organisationName>
-                <gco:CharacterString>Marine institutes</gco:CharacterString>
+                <gco:CharacterString>Some marine institute</gco:CharacterString>
               </gmd:organisationName>
               <gmd:contactInfo xlink:href="#IFREMER"/>
               <gmd:role>
@@ -462,13 +473,13 @@
           <gmd:onLine>
             <gmd:CI_OnlineResource>
               <gmd:linkage>
-                <gmd:URL>http://www.ifremer.fr/data/something</gmd:URL>
+                <gmd:URL>ftp://www.ifremer.fr/data/something</gmd:URL>
               </gmd:linkage>
               <gmd:protocol>
-                <gco:CharacterString>http</gco:CharacterString>
+                <gco:CharacterString>ftp</gco:CharacterString>
               </gmd:protocol>
               <gmd:description>
-                <gco:CharacterString>CTDF02</gco:CharacterString>
+                <gco:CharacterString>Dummy download link</gco:CharacterString>
               </gmd:description>
               <gmd:function>
                 <gmd:CI_OnLineFunctionCode codeSpace="eng" codeListValue="download" codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode">Download</gmd:CI_OnLineFunctionCode>


Mime
View raw message