sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1776312 - in /sis/branches/JDK8: core/sis-utility/src/test/java/org/apache/sis/test/ storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ storage/sis-storage/s...
Date Wed, 28 Dec 2016 18:02:13 GMT
Author: desruisseaux
Date: Wed Dec 28 18:02:13 2016
New Revision: 1776312

URL: http://svn.apache.org/viewvc?rev=1776312&view=rev
Log:
Complete ISO 19115 to GPX metadata conversion.
Improve error message if a FeatureType is not valid for the data store.

Added:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalFeatureTypeException.java
      - copied, changed from r1776234, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreContentException.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/MetadataTest.java
      - copied, changed from r1776249, sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java
Modified:
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Bounds.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Writer.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/test/suite/GPXTestSuite.java

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -18,6 +18,7 @@ package org.apache.sis.test;
 
 import java.util.Set;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.LinkedHashSet;
@@ -36,9 +37,6 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.Classes;
 
-// Branch-dependent imports
-import java.util.Objects;
-
 
 /**
  * Assertion methods used by the SIS project in addition of the JUnit and GeoAPI assertions.

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -33,6 +33,7 @@ import org.apache.sis.storage.Unsupporte
 import org.apache.sis.internal.storage.ChannelDataInput;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.metadata.sql.MetadataStoreException;
+import org.apache.sis.storage.DataStoreClosedException;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.Classes;
 
@@ -54,7 +55,7 @@ public class GeoTiffStore extends DataSt
     final Charset encoding;
 
     /**
-     * The GeoTIFF reader implementation, or {@code null} if none.
+     * The GeoTIFF reader implementation, or {@code null} if the store has been closed.
      */
     private Reader reader;
 
@@ -102,6 +103,7 @@ public class GeoTiffStore extends DataSt
     @Override
     public synchronized Metadata getMetadata() throws DataStoreException {
         if (metadata == null) {
+            final Reader reader = reader();
             final MetadataBuilder builder = reader.metadata;
             try {
                 builder.setFormat("GeoTIFF");
@@ -128,6 +130,17 @@ public class GeoTiffStore extends DataSt
     }
 
     /**
+     * Returns the reader if it is not closed, or thrown an exception otherwise.
+     */
+    private Reader reader() throws DataStoreException {
+        final Reader r = reader;
+        if (r == null) {
+            throw new DataStoreClosedException(errors().getString(Errors.Keys.ClosedReader_1, "GeoTIFF"));
+        }
+        return r;
+    }
+
+    /**
      * Closes this GeoTIFF store and releases any underlying resources.
      *
      * @throws DataStoreException if an error occurred while closing the GeoTIFF file.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -67,6 +67,11 @@ public final class Resources extends Ind
         public static final short ExcessiveStringSize_3 = 0;
 
         /**
+         * The “{0}” data store does not accept features of type “{1}”.
+         */
+        public static final short IllegalFeatureType_2 = 6;
+
+        /**
          * Components of the “{0}” name are inconsistent with those of the name that was added.
          */
         public static final short InconsistentNameComponents_1 = 4;

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] Wed Dec 28 18:02:13 2016
@@ -20,6 +20,7 @@
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package.
 #
 ExcessiveStringSize_3             = Character string in the \u201c{0}\u201d file is too long. The string has {2} characters while the limit is {1}.
+IllegalFeatureType_2              = The \u201c{0}\u201d data store does not accept features of type \u201c{1}\u201d.
 InconsistentNameComponents_1      = Components of the \u201c{0}\u201d name are inconsistent with those of the name that was added.
 MissingSchemeInURI_1              = Missing scheme in \u201c{0}\u201d URI.
 ProcessingExecutedOn_1            = Processing executed on {0}.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] Wed Dec 28 18:02:13 2016
@@ -25,6 +25,7 @@
 #   U+00A0 NO-BREAK SPACE         before  :
 #
 ExcessiveStringSize_3             = La cha\u00eene de caract\u00e8res dans le fichier \u00ab\u202f{0}\u202f\u00bb est trop longue. La cha\u00eene fait {2} caract\u00e8res alors que la limite est {1}.
+IllegalFeatureType_2              = Le format \u00ab\u202f{0}\u202f\u00bb ne stocke pas de donn\u00e9es de type \u00ab\u202f{1}\u202f\u00bb.
 InconsistentNameComponents_1      = Les \u00e9l\u00e9ments qui composent le nom \u00ab\u202f{0}\u202f\u00bb ne sont pas coh\u00e9rents avec ceux du nom qui avait \u00e9t\u00e9 ajout\u00e9.
 MissingSchemeInURI_1              = Il manque le sch\u00e9ma dans l\u2019URI \u00ab\u202f{0}\u202f\u00bb.
 ProcessingExecutedOn_1            = Traitement ex\u00e9cut\u00e9 sur {0}.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -110,8 +110,16 @@ public abstract class DataStore implemen
 
     /**
      * Sets the locale to use for formatting warnings and other messages.
+     * In a client-server architecture, it should be the locale on the <em>client</em> side.
+     *
+     * <p>This locale is used on a <cite>best-effort</cite> basis; whether messages will honor this locale or not
+     * depends on the code that logged warnings or threw exceptions. In Apache SIS implementation, this locale has
+     * better chances to be honored by the {@link DataStoreException#getLocalizedMessage()} method rather than
+     * {@code getMessage()}. See {@code getLocalizedMessage()} javadoc for more information.</p>
      *
      * @param locale  the new locale to use.
+     *
+     * @see DataStoreException#getLocalizedMessage()
      */
     public synchronized void setLocale(final Locale locale) {
         ArgumentChecks.ensureNonNull("locale", locale);

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -16,13 +16,17 @@
  */
 package org.apache.sis.storage;
 
+import java.util.Locale;
+import org.apache.sis.internal.storage.Resources;
+
 
 /**
  * Thrown when a {@link DataStore} can not complete a read or write operation.
  *
  * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 public class DataStoreException extends Exception {
@@ -32,10 +36,28 @@ public class DataStoreException extends
     private static final long serialVersionUID = -1778987176103191950L;
 
     /**
+     * The locale to use for formatting the localized error message, or {@code null} for the default.
+     */
+    private final Locale locale;
+
+    /**
+     * The resources key as one of the {@code Resources.Keys} constant, or 0 if none.
+     */
+    private final short key;
+
+    /**
+     * The arguments for the localization message, or {@code null} if none.
+     */
+    private final Object[] arguments;
+
+    /**
      * Creates an exception with no cause and no details message.
      */
     public DataStoreException() {
         super();
+        locale    = null;
+        key       = 0;
+        arguments = null;
     }
 
     /**
@@ -45,6 +67,9 @@ public class DataStoreException extends
      */
     public DataStoreException(final String message) {
         super(message);
+        locale    = null;
+        key       = 0;
+        arguments = null;
     }
 
     /**
@@ -54,6 +79,9 @@ public class DataStoreException extends
      */
     public DataStoreException(final Throwable cause) {
         super(cause);
+        locale    = null;
+        key       = 0;
+        arguments = null;
     }
 
     /**
@@ -64,5 +92,54 @@ public class DataStoreException extends
      */
     public DataStoreException(final String message, final Throwable cause) {
         super(message, cause);
+        locale    = null;
+        key       = 0;
+        arguments = null;
+    }
+
+    /**
+     * Creates a new exception which will format a localized message in the given locale.
+     *
+     * @param locale     the locale for the message to be returned by {@link #getLocalizedMessage()}.
+     * @param key        one of {@link Resources.Keys} constants.
+     * @param arguments  arguments to use for formatting the messages.
+     */
+    DataStoreException(final Locale locale, final short key, final Object... arguments) {
+        super(Resources.format(key, arguments));
+        this.locale    = locale;
+        this.key       = key;
+        this.arguments = arguments;
+    }
+
+    /**
+     * Returns a localized version of the exception message, typically for final user.
+     * This is often the same message than the one returned by {@link #getMessage()},
+     * but may in some occasions be different if {@link DataStore#setLocale(Locale)}
+     * has been invoked with a different locale.
+     *
+     * <div class="section">{@code getMessage()} versus {@code getLocalizedMessage()}</div>
+     * When {@code getMessage()} and {@code getLocalizedMessage()} are not equivalent, the Apache SIS policy
+     * is that {@code getMessage()} returns the message in the {@linkplain Locale#getDefault() default locale}
+     * while {@code getLocalizedMessage()} returns the message in a locale that depends on the context in which
+     * the exception has been thrown.
+     *
+     * In a client-server architecture, the former is often the locale on the <em>server</em> side while the later
+     * is the locale on the <em>client</em> side if that information has been provided to the {@link DataStore}.
+     * {@code getMessage()} is targeted to the developer would will analyze the stack trace while
+     * {@code getLocalizedMessage()} is targeted to the final user would may receive the error message
+     * without stack trace.
+     *
+     * @return the localized message of this exception.
+     *
+     * @see DataStore#setLocale(Locale)
+     *
+     * @since 0.8
+     */
+    @Override
+    public String getLocalizedMessage() {
+        if (key != 0) {
+            return Resources.forLocale(locale).getString(key, arguments);
+        }
+        return super.getLocalizedMessage();
     }
 }

Copied: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalFeatureTypeException.java (from r1776234, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreContentException.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalFeatureTypeException.java?p2=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalFeatureTypeException.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreContentException.java&r1=1776234&r2=1776312&rev=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreContentException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalFeatureTypeException.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -16,35 +16,31 @@
  */
 package org.apache.sis.storage;
 
+import java.util.Locale;
+import org.apache.sis.internal.storage.Resources;
+import org.opengis.util.GenericName;
+
 
 /**
- * Thrown when a store can not be read because the stream contains invalid data.
- * It may be for example a logical inconsistency, or a reference not found,
- * or an unsupported file format version, <i>etc.</i>
- *
- * <div class="note"><b>Note:</b>
- * exceptions that are caused by {@link java.io.IOException} or {@link java.sql.SQLException}
- * should generally be wrapped by another type of {@link DataStoreException}, unless the data
- * store can determine that the error was caused by a problem with the stream content rather
- * than some I/O problems.</div>
+ * Thrown when a store can not write the given feature because its type is not one of the supported types.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
-public class DataStoreContentException extends DataStoreException {
+public class IllegalFeatureTypeException extends DataStoreException {
     /**
      * For cross-version compatibility.
      */
-    private static final long serialVersionUID = 3469934460013440211L;
+    private static final long serialVersionUID = 1426887859737756607L;
 
     /**
      * Creates an exception with the specified details message.
      *
      * @param message  the detail message.
      */
-    public DataStoreContentException(String message) {
+    public IllegalFeatureTypeException(String message) {
         super(message);
     }
 
@@ -53,7 +49,7 @@ public class DataStoreContentException e
      *
      * @param cause  the cause for this exception.
      */
-    public DataStoreContentException(Throwable cause) {
+    public IllegalFeatureTypeException(Throwable cause) {
         super(cause);
     }
 
@@ -63,7 +59,18 @@ public class DataStoreContentException e
      * @param message  the detail message.
      * @param cause    the cause for this exception.
      */
-    public DataStoreContentException(String message, Throwable cause) {
+    public IllegalFeatureTypeException(String message, Throwable cause) {
         super(message, cause);
     }
+
+    /**
+     * Creates an exception with a default message in the given locale.
+     *
+     * @param locale     the message locale.
+     * @param format     short name of the format that do not accept the given feature type.
+     * @param dataType   name of the feature type that can not be accepted by the data store.
+     */
+    public IllegalFeatureTypeException(final Locale locale, final String format, final GenericName dataType) {
+        super(locale, Resources.Keys.IllegalFeatureType_2, format, dataType);
+    }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Bounds.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Bounds.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Bounds.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Bounds.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -18,6 +18,7 @@ package org.apache.sis.internal.gpx;
 
 import javax.xml.bind.annotation.XmlAttribute;
 import org.apache.sis.internal.xml.GeographicEnvelope;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 
 
 /**
@@ -65,6 +66,27 @@ public final class Bounds extends Geogra
     }
 
     /**
+     * Copies properties from the given ISO 19115 metadata.
+     */
+    private Bounds(final GeographicBoundingBox box) {
+        westBoundLongitude = box.getWestBoundLongitude();
+        eastBoundLongitude = box.getEastBoundLongitude();
+        northBoundLatitude = box.getNorthBoundLatitude();
+        southBoundLatitude = box.getSouthBoundLatitude();
+    }
+
+    /**
+     * Returns the given ISO 19115 metadata as a {@code Bounds} instance.
+     * This method copies the data only if needed.
+     *
+     * @param  box  the ISO 19115 metadata, or {@code null}.
+     * @return the GPX metadata, or {@code null}.
+     */
+    public static Bounds castOrCopy(final GeographicBoundingBox box) {
+        return (box == null || box instanceof Bounds) ? (Bounds) box : new Bounds(box);
+    }
+
+    /**
      * Returns the western-most coordinate of the limit of the dataset extent.
      * The value is expressed in longitude in decimal degrees (positive east).
      *

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -46,6 +46,7 @@ import org.apache.sis.internal.util.Unmo
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.metadata.iso.citation.DefaultCitationDate;
 import org.apache.sis.metadata.iso.identification.DefaultKeywords;
+import org.apache.sis.metadata.iso.extent.Extents;
 
 
 /**
@@ -72,6 +73,7 @@ import org.apache.sis.metadata.iso.ident
  * the ISO 19115 metadata model and can be ignored if the user only wants to manipulate the GPX model.
  *
  * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
@@ -161,33 +163,40 @@ public final class Metadata extends Simp
 
     /**
      * Copies properties from the given ISO 19115 metadata.
+     * If a property has more than one value, only the first one will be retained
+     * (except for links and keywords where multi-values are allowed).
      */
-    private Metadata(final org.opengis.metadata.Metadata md, final Locale locale) {
+    Metadata(final org.opengis.metadata.Metadata md, final Locale locale) {
         for (final Identification id : md.getIdentificationInfo()) {
-            final Citation c = id.getCitation();
-            if (c != null) {
+            /*
+             * identificationInfo.citation.title                    →   name
+             * identificationInfo.citation.date.date                →   time
+             * identificationInfo.citation.onlineResource.name      →   link.text
+             * identificationInfo.citation.onlineResource.linkage   →   link.uri
+             * identificationInfo.abstract                          →   description
+             */
+            final Citation ci = id.getCitation();
+            if (ci != null) {
                 if (name == null) {
-                    name = Types.toString(c.getTitle(), locale);
+                    name = Types.toString(ci.getTitle(), locale);
                 }
                 if (time == null) {
-                    for (final CitationDate d : c.getDates()) {
+                    for (final CitationDate d : ci.getDates()) {
                         time = d.getDate();
                         if (time != null) break;
                     }
                 }
-                for (final OnlineResource r : c.getOnlineResources()) {
-                    final Link link = Link.castOrCopy(r, locale);
-                    if (link != null) {
-                        if (links == null) {
-                            links = new ArrayList<>();
-                        }
-                        links.add(link);
-                    }
+                for (final OnlineResource r : ci.getOnlineResources()) {
+                    links = addIfNonNull(links, Link.castOrCopy(r, locale));
                 }
             }
             if (description == null) {
                 description = Types.toString(id.getAbstract(), locale);
             }
+            /*
+             * identificationInfo.pointOfContact.party.name   →   creator        if role is ORIGINATOR
+             * identificationInfo.pointOfContact.party.name   →   author.name    if role is AUTHOR
+             */
             for (final Responsibility r : id.getPointOfContacts()) {
                 final Person p = Person.castOrCopy(r, locale);
                 if (p != null) {
@@ -200,23 +209,34 @@ public final class Metadata extends Simp
                     }
                 }
             }
+            /*
+             * identificationInfo.resourceConstraints.responsibleParty.party.name        →   copyright.author
+             * identificationInfo.resourceConstraints.reference.date.date                →   copyright.year
+             * identificationInfo.resourceConstraints.reference.onlineResource.linkage   →   copyright.license
+             */
             if (copyright == null) {
-                for (final Constraints cr : id.getResourceConstraints()) {
-                    if (cr instanceof LegalConstraints) {
-                        copyright = Copyright.castOrCopy((LegalConstraints) cr, locale);
+                for (final Constraints c : id.getResourceConstraints()) {
+                    if (c instanceof LegalConstraints) {
+                        copyright = Copyright.castOrCopy((LegalConstraints) c, locale);
                         if (copyright != null) break;
                     }
                 }
             }
+            /*
+             * identificationInfo.descriptiveKeywords.keyword   →   keywords
+             */
             for (final Keywords k : id.getDescriptiveKeywords()) {
-                for (final InternationalString kw : k.getKeywords()) {
-                    final String s = Types.toString(kw, locale);
-                    if (s != null) {
-                        if (keywords == null) {
-                            keywords = new ArrayList<>();
-                        }
-                        keywords.add(s);
-                    }
+                for (final InternationalString word : k.getKeywords()) {
+                    keywords = addIfNonNull(keywords, Types.toString(word, locale));
+                }
+            }
+            /*
+             * identificationInfo.extent.geographicElement   →   bounds
+             */
+            if (bounds == null) {
+                for (final Extent e : id.getExtents()) {
+                    bounds = Bounds.castOrCopy(Extents.getGeographicBoundingBox(e));
+                    if (bounds != null) break;
                 }
             }
         }
@@ -432,4 +452,23 @@ public final class Metadata extends Simp
             table.nextLine();
         }
     }
+
+    /**
+     * Adds the given element to the given list if non null, or do nothing otherwise.
+     * This is a convenience method for storing {@code <link>} elements in way points,
+     * routes or tracks among others.
+     *
+     * @param  list     the list where to add the element, or {@code null} if not yet created.
+     * @param  element  the element to add, or {@code null} if none.
+     * @return the list where the element has been added.
+     */
+    static <T> List<T> addIfNonNull(List<T> list, final T element) {
+        if (element != null) {
+            if (list == null) {
+                list = new ArrayList<>(4);         // Small capacity since there is usually few elements.
+            }
+            list.add(element);
+        }
+        return list;
+    }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Reader.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -299,25 +299,6 @@ parse:  while (reader.hasNext()) {
     }
 
     /**
-     * Adds the given element to the given list if non null, or do nothing otherwise.
-     * This is a convenience method for storing {@code <link>} elements in way points,
-     * routes or tracks (not in metadata).
-     *
-     * @param  links    the list where to add the element, or {@code null} if not yet created.
-     * @param  element  the element to add, or {@code null} if none.
-     * @return the list where the element has been added.
-     */
-    private static List<Link> addIfNonNull(List<Link> links, final Link element) {
-        if (element != null) {
-            if (links == null) {
-                links = new ArrayList<>(3);         // Small capacity since there is usually only one link.
-            }
-            links.add(element);
-        }
-        return links;
-    }
-
-    /**
      * Returns the metadata (ISO 19115 compatible), or {@code null} if none.
      * This method can return a non-null value only if {@code initialize(true)}
      * has been invoked before this method.
@@ -460,8 +441,8 @@ parse:  while (reader.hasNext()) {
                         case Tags.SATELITTES:       // Fallthrough to getElementAsInteger()
                         case Tags.DGPS_ID:          value = getElementAsInteger(); break;
                         case Tags.FIX:              value = Fix.fromGPX(getElementText()); break;
-                        case Tags.LINK:             links = addIfNonNull(links, unmarshal(Link.class)); continue;
-                        case Tags.URL:              links = addIfNonNull(links, Link.valueOf(getElementAsURI())); continue;
+                        case Tags.LINK:             links = Metadata.addIfNonNull(links, unmarshal(Link.class)); continue;
+                        case Tags.URL:              links = Metadata.addIfNonNull(links, Link.valueOf(getElementAsURI())); continue;
                         default: {
                             if (name.equals(tagName)) {
                                 throw new DataStoreContentException(nestedElement(name));
@@ -515,8 +496,8 @@ parse:  while (reader.hasNext()) {
                         case Tags.SOURCE:      // ︙
                         case Tags.TYPE:        value = getElementText(); break;
                         case Tags.NUMBER:      value = getElementAsInteger(); break;
-                        case Tags.LINK:        links = addIfNonNull(links, unmarshal(Link.class)); continue;
-                        case Tags.URL:         links = addIfNonNull(links, Link.valueOf(getElementAsURI())); continue;
+                        case Tags.LINK:        links = Metadata.addIfNonNull(links, unmarshal(Link.class)); continue;
+                        case Tags.URL:         links = Metadata.addIfNonNull(links, Link.valueOf(getElementAsURI())); continue;
                         case Tags.ROUTES:      throw new DataStoreContentException(nestedElement(name));
                         case Tags.ROUTE_POINTS: {
                             if (wayPoints == null) wayPoints = new ArrayList<>(8);
@@ -614,8 +595,8 @@ parse:  while (reader.hasNext()) {
                         case Tags.SOURCE:       // ︙
                         case Tags.TYPE:         value = getElementText(); break;
                         case Tags.NUMBER:       value = getElementAsInteger(); break;
-                        case Tags.LINK:         links = addIfNonNull(links, unmarshal(Link.class)); continue;
-                        case Tags.URL:          links = addIfNonNull(links, Link.valueOf(getElementAsURI())); continue;
+                        case Tags.LINK:         links = Metadata.addIfNonNull(links, unmarshal(Link.class)); continue;
+                        case Tags.URL:          links = Metadata.addIfNonNull(links, Link.valueOf(getElementAsURI())); continue;
                         case Tags.TRACKS:       throw new DataStoreContentException(nestedElement(name));
                         case Tags.TRACK_SEGMENTS: {
                             if (segments == null) segments = new ArrayList<>(8);

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Writer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Writer.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Writer.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Writer.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -23,6 +23,7 @@ import javax.xml.bind.JAXBException;
 import com.esri.core.geometry.Point;
 import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.IllegalFeatureTypeException;
 import org.apache.sis.internal.xml.StaxStreamWriter;
 import org.apache.sis.util.Version;
 
@@ -155,7 +156,7 @@ final class Writer extends StaxStreamWri
             } else {
                 final boolean isRoute = types.route.isAssignableFrom(type);
                 if (!isRoute && !types.track.isAssignableFrom(type)) {
-                    throw new DataStoreException();     // TODO: provide message.
+                    throw new IllegalFeatureTypeException(owner.getLocale(), owner.getFormatName(), type.getName());
                 }
                 writer.writeStartElement(isRoute ? Tags.ROUTES : Tags.TRACKS);
                 writeSingleValue(Tags.NAME,        feature.getPropertyValue(Tags.NAME));

Copied: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/MetadataTest.java (from r1776249, sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/MetadataTest.java?p2=sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/MetadataTest.java&p1=sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java&r1=1776249&r2=1776312&rev=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/MetadataTest.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -16,36 +16,19 @@
  */
 package org.apache.sis.internal.gpx;
 
-import java.util.List;
 import java.util.Arrays;
 import java.net.URI;
-import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
-import com.esri.core.geometry.Point;
-import org.apache.sis.storage.gps.Fix;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.StorageConnector;
-import org.apache.sis.util.Version;
-import org.apache.sis.util.Debug;
-import org.apache.sis.test.DependsOn;
+import java.net.URISyntaxException;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
+import static org.junit.Assert.*;
 import static org.apache.sis.test.TestUtilities.date;
 
-// Branch-dependent imports
-import java.time.Instant;
-import org.apache.sis.test.DependsOnMethod;
-import org.opengis.feature.Feature;
-
 
 /**
- * Tests (indirectly) the {@link Writer} class.
- * This class creates a {@link Store} instance and uses it in write mode.
- * The {@link Reader} is used for verifying the content.
+ * Tests the {@link Metadata} class.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -53,86 +36,41 @@ import org.opengis.feature.Feature;
  * @version 0.8
  * @module
  */
-@DependsOn(ReaderTest.class)
-public final strictfp class WriterTest extends TestCase {
-    /**
-     * The provider shared by all data stores created in this test class.
-     */
-    private static StoreProvider provider;
-
-    /**
-     * Creates the provider to be shared by all data stores created in this test class.
-     */
-    @BeforeClass
-    public static void createProvider() {
-        provider = new StoreProvider();
-    }
-
-    /**
-     * Disposes the data store provider after all tests have been completed.
-     */
-    @AfterClass
-    public static void disposeProvider() {
-        provider = null;
-    }
-
-    /**
-     * Where to write the GPX file.
-     */
-    private final ByteArrayOutputStream output = new ByteArrayOutputStream();
-
-    /**
-     * Creates a new GPX data store which will read and write in memory.
-     */
-    private Store create() throws DataStoreException {
-        return new Store(provider, new StorageConnector(output));
-    }
-
-    /**
-     * Returns a string representation of the XML data written by the test case.
-     * This is a helper method for debugging purpose only.
-     *
-     * @return the XML document written by the test case.
-     */
-    @Debug
-    @Override
-    public String toString() {
-        try {
-            return output.toString("UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new AssertionError(e);
-        }
-    }
-
+public final strictfp class MetadataTest extends TestCase {
     /**
-     * Test writing GPX 1.0 metadata. This test creates programmatically the same metadata than the ones
-     * found in {@code 1.0/metadata.xml} file, then compare the written XML file with the expected file.
+     * Tests the {@link Metadata#equals(Object)} and {@link Metadata#hashCode()}.
      *
-     * @throws Exception if an error occurred while writing the XML data.
+     * @throws URISyntaxException if a {@link Link} element is constructed with an invalid URI.
      */
     @Test
-    public void testMetadata100() throws Exception {
-        testMetadata(Store.V1_0, "1.0/metadata.xml");
+    public void testEqualsAndHashCode() throws URISyntaxException {
+        final Metadata md1 = create();
+        final Metadata md2 = create();
+        assertEquals("equals", md1, md2);
+        assertEquals("hashCode", md1.hashCode(), md2.hashCode());
+        md2.author.name = "someone else";
+        assertNotEquals("equals", md1, md2);
+        assertNotEquals("hashCode", md1.hashCode(), md2.hashCode());
     }
 
     /**
-     * Test writing GPX 1.1 metadata. This test creates programmatically the same metadata than the ones
-     * found in {@code 1.1/metadata.xml} file, then compare the written XML file with the expected file.
+     * Tests the copy constructor used for converting ISO 19115 metadata to GPX metadata.
      *
-     * @throws Exception if an error occurred while writing the XML data.
+     * @throws URISyntaxException if a {@link Link} element is constructed with an invalid URI.
      */
     @Test
-    public void testMetadata110() throws Exception {
-        testMetadata(Store.V1_1, "1.1/metadata.xml");
+    @DependsOnMethod("testEqualsAndHashCode")
+    public void testCopyConstructor() throws URISyntaxException {
+        final Metadata md1 = create();
+        final Metadata md2 = new Metadata(md1, null);
+        assertEquals("equals", md1, md2);
+        assertEquals("hashCode", md1.hashCode(), md2.hashCode());
     }
 
     /**
-     * Implementations of {@link #testMetadata100()} and {@link #testMetadata110()}.
-     *
-     * @param version   either {@link Store#V1_0} or {@link Store#V1_1}.
-     * @param expected  name of a test file containing the expected XML result.
+     * Creates a metadata instance with the same data than the one in the {@code "1.1/metadata.xml"} test file.
      */
-    private void testMetadata(final Version version, final String expected) throws Exception {
+    static Metadata create() throws URISyntaxException {
         final Person person = new Person();
         person.name  = "Jean-Pierre";
         person.email = "jean.pierre@test.com";
@@ -163,214 +101,6 @@ public final strictfp class WriterTest e
                                              new Link(new URI("http://third-address.org")));
         metadata.links.get(2).type = "website";
         metadata.links.get(0).text = "first";
-
-        try (Store store = create()) {
-            store.setVersion(version);
-            store.write(metadata, null);
-        }
-        assertXmlEquals(WriterTest.class.getResourceAsStream(expected), toString(), STRICT,
-                        new String[] {Tags.NAMESPACE_V11 + ":extensions"},
-                        new String[] {"xmlns:xsi", "xsi:schemaLocation", "xsi:type"});
-    }
-
-    /**
-     * Tests writing various GPX 1.0 way points. This test creates programmatically the same features than
-     * the ones found in {@code 1.0/waypoint.xml}, then compare the written XML file with the expected file.
-     *
-     * @throws Exception if an error occurred while writing the XML data.
-     */
-    @Test
-    @DependsOnMethod("testMetadata100")
-    public void testWayPoints100() throws Exception {
-        testFeatures(Store.V1_0, Type.WAY_POINT, "1.0/waypoint.xml");
-    }
-
-    /**
-     * Tests writing various GPX 1.1 way points. This test creates programmatically the same features than
-     * the ones found in {@code 1.1/waypoint.xml}, then compare the written XML file with the expected file.
-     *
-     * @throws Exception if an error occurred while writing the XML data.
-     */
-    @Test
-    @DependsOnMethod("testMetadata110")
-    public void testWayPoints110() throws Exception {
-        testFeatures(Store.V1_1, Type.WAY_POINT, "1.1/waypoint.xml");
-    }
-
-    /**
-     * Tests writing various GPX 1.0 routes. This test creates programmatically the same features than
-     * the ones found in {@code 1.0/route.xml}, then compare the written XML file with the expected file.
-     *
-     * @throws Exception if an error occurred while writing the XML data.
-     */
-    @Test
-    @DependsOnMethod("testWayPoints100")
-    public void testRoutes100() throws Exception {
-        testFeatures(Store.V1_0, Type.ROUTE, "1.0/route.xml");
-    }
-
-    /**
-     * Tests writing various GPX 1.1 routes. This test creates programmatically the same features than
-     * the ones found in {@code 1.1/route.xml}, then compare the written XML file with the expected file.
-     *
-     * @throws Exception if an error occurred while writing the XML data.
-     */
-    @Test
-    @DependsOnMethod("testWayPoints110")
-    public void testRoutes110() throws Exception {
-        testFeatures(Store.V1_1, Type.ROUTE, "1.1/route.xml");
-    }
-
-    /**
-     * Tests writing various GPX 1.0 tracks. This test creates programmatically the same features than
-     * the ones found in {@code 1.0/track.xml}, then compare the written XML file with the expected file.
-     *
-     * @throws Exception if an error occurred while writing the XML data.
-     */
-    @Test
-    @DependsOnMethod("testRoutes100")
-    public void testTracks100() throws Exception {
-        testFeatures(Store.V1_0, Type.TRACK, "1.0/track.xml");
-    }
-
-    /**
-     * Tests writing various GPX 1.1 tracks. This test creates programmatically the same features than
-     * the ones found in {@code 1.1/track.xml}, then compare the written XML file with the expected file.
-     *
-     * @throws Exception if an error occurred while writing the XML data.
-     */
-    @Test
-    @DependsOnMethod("testRoutes110")
-    public void testTracks110() throws Exception {
-        testFeatures(Store.V1_1, Type.TRACK, "1.1/track.xml");
-    }
-
-    /**
-     * The kind of feature to write.
-     */
-    private enum Type {
-        WAY_POINT, ROUTE, TRACK
-    }
-
-    /**
-     * Implementation of way points, routes and tracks test methods.
-     *
-     * @param version   either {@link Store#V1_0} or {@link Store#V1_1}.
-     * @param type      the kind of feature to test: way point, route or track.
-     * @param expected  name of a test file containing the expected XML result.
-     */
-    private void testFeatures(final Version version, final Type type, final String expected) throws Exception {
-        final Types types = Types.DEFAULT;
-        /*
-         * Way Points as defined in "waypoint.xml" test file.
-         * Appear also in "route.xml" and "track.xml" files.
-         */
-        final Feature point1 = types.wayPoint.newInstance();
-        point1.setPropertyValue("@geometry",     new Point(15, 10));
-        point1.setPropertyValue("time",          Instant.parse("2010-01-10T00:00:00Z"));
-        point1.setPropertyValue("name",          "first point");
-        point1.setPropertyValue("cmt",           "first comment");
-        point1.setPropertyValue("desc",          "first description");
-        point1.setPropertyValue("src",           "first source");
-        point1.setPropertyValue("sym",           "first symbol");
-        point1.setPropertyValue("type",          "first type");
-        point1.setPropertyValue("ele",           140.0);
-        point1.setPropertyValue("magvar",        35.0);
-        point1.setPropertyValue("geoidheight",   112.32);
-        point1.setPropertyValue("sat",           11);
-        point1.setPropertyValue("hdop",          15.15);
-        point1.setPropertyValue("vdop",          14.14);
-        point1.setPropertyValue("pdop",          13.13);
-        point1.setPropertyValue("ageofdgpsdata", 55.55);
-        point1.setPropertyValue("dgpsid",        256);
-        point1.setPropertyValue("fix",           Fix.NONE);
-        point1.setPropertyValue("link",          Arrays.asList(new Link(new URI("http://first-address1.org")),
-                                                               new Link(new URI("http://first-address2.org")),
-                                                               new Link(new URI("http://first-address3.org"))));
-        final Feature point3 = types.wayPoint.newInstance();
-        point3.setPropertyValue("@geometry",     new Point(35, 30));
-        point3.setPropertyValue("time",          Instant.parse("2010-01-30T00:00:00Z"));
-        point3.setPropertyValue("name",          "third point");
-        point3.setPropertyValue("cmt",           "third comment");
-        point3.setPropertyValue("desc",          "third description");
-        point3.setPropertyValue("src",           "third source");
-        point3.setPropertyValue("sym",           "third symbol");
-        point3.setPropertyValue("type",          "third type");
-        point3.setPropertyValue("ele",           150.0);
-        point3.setPropertyValue("magvar",        25.0);
-        point3.setPropertyValue("geoidheight",   142.32);
-        point3.setPropertyValue("sat",           35);
-        point3.setPropertyValue("hdop",          35.15);
-        point3.setPropertyValue("vdop",          34.14);
-        point3.setPropertyValue("pdop",          33.13);
-        point3.setPropertyValue("ageofdgpsdata", 85.55);
-        point3.setPropertyValue("dgpsid",        456);
-        point3.setPropertyValue("fix",           Fix.THREE_DIMENSIONAL);
-        point3.setPropertyValue("link",          Arrays.asList(new Link(new URI("http://third-address1.org")),
-                                                               new Link(new URI("http://third-address2.org"))));
-        final Feature point2 = types.wayPoint.newInstance();
-        point2.setPropertyValue("@geometry", new Point(25, 20));
-        final List<Feature> wayPoints = Arrays.asList(point1, point2, point3);
-        final List<Feature> features;
-        switch (type) {
-            case WAY_POINT: {
-                features = wayPoints;
-                break;
-            }
-            case ROUTE: {
-                final Feature route1 = types.route.newInstance();
-                route1.setPropertyValue("name",   "Route name");
-                route1.setPropertyValue("cmt",    "Route comment");
-                route1.setPropertyValue("desc",   "Route description");
-                route1.setPropertyValue("src",    "Route source");
-                route1.setPropertyValue("type",   "Route type");
-                route1.setPropertyValue("number", 7);
-                route1.setPropertyValue("rtept",  wayPoints);
-                route1.setPropertyValue("link",   Arrays.asList(new Link(new URI("http://route-address1.org")),
-                                                                new Link(new URI("http://route-address2.org")),
-                                                                new Link(new URI("http://route-address3.org"))));
-                final Feature route2 = types.route.newInstance();
-                features = Arrays.asList(route1, route2);
-                break;
-            }
-            case TRACK: {
-                final Feature seg1 = types.trackSegment.newInstance();
-                final Feature seg2 = types.trackSegment.newInstance();
-                seg1.setPropertyValue("trkpt", wayPoints);
-
-                final Feature track1 = types.track.newInstance();
-                track1.setPropertyValue("name",   "Track name");
-                track1.setPropertyValue("cmt",    "Track comment");
-                track1.setPropertyValue("desc",   "Track description");
-                track1.setPropertyValue("src",    "Track source");
-                track1.setPropertyValue("type",   "Track type");
-                track1.setPropertyValue("number", 7);
-                track1.setPropertyValue("trkseg", Arrays.asList(seg1, seg2));
-                track1.setPropertyValue("link",   Arrays.asList(new Link(new URI("http://track-address1.org")),
-                                                                new Link(new URI("http://track-address2.org")),
-                                                                new Link(new URI("http://track-address3.org"))));
-                final Feature track2 = types.track.newInstance();
-                features = Arrays.asList(track1, track2);
-                break;
-            }
-            default: throw new AssertionError(type);
-        }
-        /*
-         * Add minimalist metadata and marshal.
-         */
-        final Bounds bounds = new Bounds();
-        bounds.westBoundLongitude = -20;
-        bounds.eastBoundLongitude =  30;
-        bounds.southBoundLatitude =  10;
-        bounds.northBoundLatitude =  40;
-        final Metadata metadata = new Metadata();
-        metadata.bounds = bounds;
-        metadata.creator = "DataProducer";
-        try (final Store store = create()) {
-            store.version = version;
-            store.write(metadata, features.stream());
-        }
-        assertXmlEquals(WriterTest.class.getResourceAsStream(expected), toString(),
-                        "xmlns:xsi", "xsi:schemaLocation", "xsi:type");
+        return metadata;
     }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/ReaderTest.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -26,6 +26,7 @@ import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
@@ -48,6 +49,7 @@ import org.opengis.feature.Feature;
  * @version 0.8
  * @module
  */
+@DependsOn(MetadataTest.class)
 public final strictfp class ReaderTest extends TestCase {
     /**
      * The provider shared by all data stores created in this test class.

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/WriterTest.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -28,17 +28,16 @@ import org.apache.sis.storage.StorageCon
 import org.apache.sis.util.Version;
 import org.apache.sis.util.Debug;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.test.TestUtilities.date;
 
 // Branch-dependent imports
 import java.time.Instant;
-import org.apache.sis.test.DependsOnMethod;
 import org.opengis.feature.Feature;
 
 
@@ -53,7 +52,7 @@ import org.opengis.feature.Feature;
  * @version 0.8
  * @module
  */
-@DependsOn(ReaderTest.class)
+@DependsOn({MetadataTest.class, ReaderTest.class})
 public final strictfp class WriterTest extends TestCase {
     /**
      * The provider shared by all data stores created in this test class.
@@ -133,37 +132,7 @@ public final strictfp class WriterTest e
      * @param expected  name of a test file containing the expected XML result.
      */
     private void testMetadata(final Version version, final String expected) throws Exception {
-        final Person person = new Person();
-        person.name  = "Jean-Pierre";
-        person.email = "jean.pierre@test.com";
-        person.link  = new Link(new URI("http://someone-site.org"));
-
-        final Copyright copyright = new Copyright();
-        copyright.author  = "Apache";
-        copyright.year    = 2004;
-        copyright.license = new URI("http://www.apache.org/licenses/LICENSE-2.0");
-
-        final Bounds bounds = new Bounds();
-        bounds.westBoundLongitude = -20;
-        bounds.eastBoundLongitude =  30;
-        bounds.southBoundLatitude =  10;
-        bounds.northBoundLatitude =  40;
-
-        final Metadata metadata = new Metadata();
-        metadata.name        = "Sample";
-        metadata.description = "GPX test file";
-        metadata.author      = person;
-        metadata.creator     = "DataProducer";
-        metadata.copyright   = copyright;
-        metadata.keywords    = Arrays.asList("sample", "metadata");
-        metadata.bounds      = bounds;
-        metadata.time        = date("2010-03-01 00:00:00");
-        metadata.links       = Arrays.asList(new Link(new URI("http://first-address.org")),
-                                             new Link(new URI("http://second-address.org")),
-                                             new Link(new URI("http://third-address.org")));
-        metadata.links.get(2).type = "website";
-        metadata.links.get(0).text = "first";
-
+        final Metadata metadata = MetadataTest.create();
         try (Store store = create()) {
             store.setVersion(version);
             store.write(metadata, null);

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/test/suite/GPXTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/test/suite/GPXTestSuite.java?rev=1776312&r1=1776311&r2=1776312&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/test/suite/GPXTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/test/suite/GPXTestSuite.java [UTF-8] Wed Dec 28 18:02:13 2016
@@ -25,6 +25,7 @@ import org.junit.BeforeClass;
  * All tests from the {@code sis-xmlstore} module, in approximative dependency order.
  */
 @Suite.SuiteClasses({
+    org.apache.sis.internal.gpx.MetadataTest.class,
     org.apache.sis.internal.gpx.ReaderTest.class,
     org.apache.sis.internal.gpx.WriterTest.class
 })



Mime
View raw message