sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1776228 - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/ core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/ core/sis-utilit...
Date Wed, 28 Dec 2016 05:32:15 GMT
Author: desruisseaux
Date: Wed Dec 28 05:32:15 2016
New Revision: 1776228

URL: http://svn.apache.org/viewvc?rev=1776228&view=rev
Log:
Enable tests of GPX metadata writer.

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/DateAdapter.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/UniversalTimeAdapter.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Writer.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamWriter.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/resources/org/apache/sis/internal/gpx/1.1/metadata.xml

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/XmlUtilities.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -71,8 +71,8 @@ public final class XmlUtilities extends
     /**
      * Returns the factory for creating {@link javax.xml.datatype} objects.
      *
-     * @return The factory (never {@code null}).
-     * @throws DatatypeConfigurationException If the factory can not be created.
+     * @return the factory (never {@code null}).
+     * @throws DatatypeConfigurationException if the factory can not be created.
      */
     public static DatatypeFactory getDatatypeFactory() throws DatatypeConfigurationException
{
         DatatypeFactory f = factory;
@@ -112,8 +112,8 @@ public final class XmlUtilities extends
      *
      * <p>This method will be deprecated after we implemented ISO 19108 in SIS.</p>
      *
-     * @param  gc The date to modify in-place.
-     * @param  force {@code true} for forcing the temporal components to be removed without
any check.
+     * @param  gc     the date to modify in-place.
+     * @param  force  {@code true} for forcing the temporal components to be removed without
any check.
      * @return {@code true} if the time part has been completely removed, {@code false} otherwise.
      */
     public static boolean trimTime(final XMLGregorianCalendar gc, final boolean force) {
@@ -134,10 +134,10 @@ public final class XmlUtilities extends
      * Converts the given date to a XML Gregorian calendar using the locale and timezone
      * from the current {@linkplain Context marshalling context}.
      *
-     * @param  context The current (un)marshalling context, or {@code null} if none.
-     * @param  date The date to convert to a XML calendar, or {@code null}.
-     * @return The XML calendar, or {@code null} if {@code date} was null.
-     * @throws DatatypeConfigurationException If the factory can not be created.
+     * @param  context  the current (un)marshalling context, or {@code null} if none.
+     * @param  date     the date to convert to a XML calendar, or {@code null}.
+     * @return the XML calendar, or {@code null} if {@code date} was null.
+     * @throws DatatypeConfigurationException if the factory can not be created.
      */
     public static XMLGregorianCalendar toXML(final Context context, final Date date) throws
DatatypeConfigurationException {
         if (date != null) {
@@ -153,7 +153,7 @@ public final class XmlUtilities extends
      * timezone were explicitely set, then the default ones are used as documented in the
      * {@link org.apache.sis.xml.XML#TIMEZONE} constant.
      *
-     * @return A Gregorian calendar initialized with the current timezone and locale.
+     * @return a Gregorian calendar initialized with the current timezone and locale.
      */
     private static GregorianCalendar createGregorianCalendar(final Context context) {
         if (context != null) {
@@ -177,9 +177,9 @@ public final class XmlUtilities extends
     /**
      * Converts the given XML Gregorian calendar to a date.
      *
-     * @param  context The current (un)marshalling context, or {@code null} if none.
-     * @param  xml The XML calendar to convert to a date, or {@code null}.
-     * @return The date, or {@code null} if {@code xml} was null.
+     * @param  context  the current (un)marshalling context, or {@code null} if none.
+     * @param  xml      the XML calendar to convert to a date, or {@code null}.
+     * @return the date, or {@code null} if {@code xml} was null.
      */
     public static Date toDate(final Context context, final XMLGregorianCalendar xml) {
         if (xml != null) {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_DateTime.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -38,6 +38,9 @@ import org.apache.sis.internal.jaxb.XmlU
  * @since   0.3
  * @version 0.4
  * @module
+ *
+ * @see org.apache.sis.internal.jaxb.gml.DateAdapter
+ * @see org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter
  */
 @XmlType(name = "Date_PropertyType")
 public final class GO_DateTime extends XmlAdapter<GO_DateTime, Date> {
@@ -66,7 +69,7 @@ public final class GO_DateTime extends X
     /**
      * Builds a wrapper for the given {@link Date}.
      *
-     * @param date The date to marshal. Can not be {@code null}.
+     * @param date  the date to marshal. Can not be {@code null}.
      */
     private GO_DateTime(final Date date) {
         final Context context = Context.current();
@@ -94,8 +97,8 @@ public final class GO_DateTime extends X
      * Converts a date read from a XML stream to the object which will contains
      * the value. JAXB calls automatically this method at unmarshalling time.
      *
-     * @param value The adapter for this metadata value.
-     * @return A {@linkplain Date date} which represents the metadata value.
+     * @param  value  the adapter for this metadata value.
+     * @return a {@linkplain Date date} which represents the metadata value.
      */
     @Override
     public Date unmarshal(final GO_DateTime value) {
@@ -107,8 +110,8 @@ public final class GO_DateTime extends X
      * file or stream. JAXB calls automatically this method at marshalling time.
      * The use of {@code <gco:Date>} or {@code <gco:DateTime>} is determined
automatically.
      *
-     * @param value The date value.
-     * @return The adapter for this date.
+     * @param  value  the date value.
+     * @return the adapter for this date.
      */
     @Override
     public GO_DateTime marshal(final Date value) {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/DateAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/DateAdapter.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/DateAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/DateAdapter.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -46,6 +46,7 @@ import org.apache.sis.internal.jaxb.XmlU
  * @module
  *
  * @see UniversalTimeAdapter
+ * @see org.apache.sis.internal.jaxb.gco.GO_DateTime
  */
 public final class DateAdapter extends XmlAdapter<XMLGregorianCalendar, Date> {
     /**
@@ -58,8 +59,8 @@ public final class DateAdapter extends X
      * Converts a date read from a XML stream to the object which will contains
      * the value. JAXB calls automatically this method at unmarshalling time.
      *
-     * @param  value The XML date, or {@code null}.
-     * @return The {@code java.util} date, or {@code null}.
+     * @param  value  the XML date, or {@code null}.
+     * @return the {@code java.util} date, or {@code null}.
      */
     @Override
     public Date unmarshal(final XMLGregorianCalendar value) {
@@ -70,8 +71,8 @@ public final class DateAdapter extends X
      * Converts the date to the object to be marshalled in a XML file or stream.
      * JAXB calls automatically this method at marshalling time.
      *
-     * @param  value The {@code java.util} date value, or {@code null}.
-     * @return The XML date, or {@code null}.
+     * @param  value  the {@code java.util} date value, or {@code null}.
+     * @return the XML date, or {@code null}.
      */
     @Override
     public XMLGregorianCalendar marshal(final Date value) {
@@ -79,7 +80,7 @@ public final class DateAdapter extends X
             final Context context = Context.current();
             try {
                 final XMLGregorianCalendar gc = XmlUtilities.toXML(context, value);
-                XmlUtilities.trimTime(gc, true); // Type is xsd:date without time.
+                XmlUtilities.trimTime(gc, true);        // Type is xsd:date without time.
                 return gc;
             } catch (DatatypeConfigurationException e) {
                 Context.warningOccured(context, XmlAdapter.class, "marshal", e, true);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/UniversalTimeAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/UniversalTimeAdapter.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/UniversalTimeAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/UniversalTimeAdapter.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -41,6 +41,7 @@ import static org.apache.sis.internal.ja
  * @module
  *
  * @see DateAdapter
+ * @see org.apache.sis.internal.jaxb.gco.GO_DateTime
  */
 public final class UniversalTimeAdapter extends XmlAdapter<XMLGregorianCalendar, Date>
{
     /**
@@ -58,8 +59,8 @@ public final class UniversalTimeAdapter
      * Converts a date read from a XML stream to the object which will contains
      * the value. JAXB calls automatically this method at unmarshalling time.
      *
-     * @param  value The XML date, or {@code null}.
-     * @return The {@code java.util} date, or {@code null}.
+     * @param  value  the XML date, or {@code null}.
+     * @return the {@code java.util} date, or {@code null}.
      */
     @Override
     public Date unmarshal(final XMLGregorianCalendar value) {
@@ -70,8 +71,8 @@ public final class UniversalTimeAdapter
      * Converts the date to the object to be marshalled in a XML file or stream.
      * JAXB calls automatically this method at marshalling time.
      *
-     * @param  value The {@code java.util} date value, or {@code null}.
-     * @return The XML date, or {@code null}.
+     * @param  value  the {@code java.util} date value, or {@code null}.
+     * @return the XML date, or {@code null}.
      */
     @Override
     public XMLGregorianCalendar marshal(final Date value) {

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=1776228&r1=1776227&r2=1776228&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 05:32:15 2016
@@ -59,8 +59,8 @@ public strictfp class Assert extends org
      * Asserts that the two given objects are not equal.
      * This method tests all {@link ComparisonMode} except {@code DEBUG}.
      *
-     * @param o1  The first object.
-     * @param o2  The second object.
+     * @param  o1  the first object.
+     * @param  o2  the second object.
      */
     public static void assertNotDeepEquals(final Object o1, final Object o2) {
         assertNotSame("same", o1, o2);
@@ -78,8 +78,8 @@ public strictfp class Assert extends org
      * {@link ComparisonMode#APPROXIMATIVE} criterion, but not equal according the
      * {@link ComparisonMode#IGNORE_METADATA} criterion.
      *
-     * @param expected  The expected object.
-     * @param actual    The actual object.
+     * @param  expected  the expected object.
+     * @param  actual    the actual object.
      */
     public static void assertAlmostEquals(final Object expected, final Object actual) {
         assertFalse("Shall not be strictly equals",          Utilities.deepEquals(expected,
actual, ComparisonMode.STRICT));
@@ -92,8 +92,8 @@ public strictfp class Assert extends org
      * Asserts that the two given objects are equal ignoring metadata.
      * See {@link ComparisonMode#IGNORE_METADATA} for more information.
      *
-     * @param expected  The expected object.
-     * @param actual    The actual object.
+     * @param  expected  the expected object.
+     * @param  actual    the actual object.
      */
     public static void assertEqualsIgnoreMetadata(final Object expected, final Object actual)
{
         assertTrue("Shall be approximatively equals",       Utilities.deepEquals(expected,
actual, ComparisonMode.DEBUG));
@@ -105,8 +105,8 @@ public strictfp class Assert extends org
      * Asserts that the two given arrays contains objects that are equal ignoring metadata.
      * See {@link ComparisonMode#IGNORE_METADATA} for more information.
      *
-     * @param expected  The expected objects (array can be {@code null}).
-     * @param actual    The actual objects (array can be {@code null}).
+     * @param  expected  the expected objects (array can be {@code null}).
+     * @param  actual    the actual objects (array can be {@code null}).
      *
      * @since 0.7
      */
@@ -133,8 +133,8 @@ public strictfp class Assert extends org
      * The comparisons is performed one a line-by-line basis. For each line, trailing
      * spaces (but not leading spaces) are ignored.
      *
-     * @param expected The expected string.
-     * @param actual   The actual string.
+     * @param  expected  the expected string.
+     * @param  actual    the actual string.
      */
     public static void assertMultilinesEquals(final CharSequence expected, final CharSequence
actual) {
         assertMultilinesEquals(null, expected, actual);
@@ -145,9 +145,9 @@ public strictfp class Assert extends org
      * The comparisons is performed one a line-by-line basis. For each line, trailing
      * spaces (but not leading spaces) are ignored.
      *
-     * @param message  The message to print in case of failure, or {@code null} if none.
-     * @param expected The expected string.
-     * @param actual   The actual string.
+     * @param  message   the message to print in case of failure, or {@code null} if none.
+     * @param  expected  the expected string.
+     * @param  actual    the actual string.
      */
     public static void assertMultilinesEquals(final String message, final CharSequence expected,
final CharSequence actual) {
         final CharSequence[] expectedLines = CharSequences.splitOnEOL(expected);
@@ -177,8 +177,8 @@ public strictfp class Assert extends org
      *
      * <p>The given collections are typically instances of {@link Set}, but this is
not mandatory.</p>
      *
-     * @param expected The expected set, or {@code null}.
-     * @param actual   The actual set, or {@code null}.
+     * @param  expected  the expected set, or {@code null}.
+     * @param  actual    the actual set, or {@code null}.
      */
     public static void assertSetEquals(final Collection<?> expected, final Collection<?>
actual) {
         if (expected != null && actual != null && !expected.isEmpty()) {
@@ -198,8 +198,8 @@ public strictfp class Assert extends org
      * Asserts that the given map contains the same entries.
      * In case of failure, this method lists the missing or unexpected entries.
      *
-     * @param expected The expected map, or {@code null}.
-     * @param actual   The actual map, or {@code null}.
+     * @param  expected  the expected map, or {@code null}.
+     * @param  actual    the actual map, or {@code null}.
      */
     public static void assertMapEquals(final Map<?,?> expected, final Map<?,?>
actual) {
         if (expected != null && actual != null && !expected.isEmpty()) {
@@ -241,9 +241,9 @@ public strictfp class Assert extends org
      * Ensures that a tree is equals to an other tree.
      * This method invokes itself recursively for every child nodes.
      *
-     * @param  expected The expected tree, or {@code null}.
-     * @param  actual   The tree to compare with the expected one, or {@code null}.
-     * @return The number of nodes.
+     * @param  expected  the expected tree, or {@code null}.
+     * @param  actual    the tree to compare with the expected one, or {@code null}.
+     * @return the number of nodes.
      */
     public static int assertTreeEquals(final TreeNode expected, final TreeNode actual) {
         if (expected == null) {
@@ -319,10 +319,10 @@ public strictfp class Assert extends org
      *   "xmlns:*", "xsi:schemaLocation", "xsi:type"
      * }
      *
-     * @param  expected The expected XML document.
-     * @param  actual   The XML document to compare.
-     * @param  ignoredAttributes The fully-qualified names of attributes to ignore
-     *         (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}).
+     * @param  expected           the expected XML document.
+     * @param  actual             the XML document to compare.
+     * @param  ignoredAttributes  the fully-qualified names of attributes to ignore
+     *                            (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}).
      *
      * @see XMLComparator
      */
@@ -337,12 +337,12 @@ public strictfp class Assert extends org
      * will ignore comments and the optional attributes given in arguments as documented
in the
      * above method.
      *
-     * @param  expected  The expected XML document.
-     * @param  actual    The XML document to compare.
-     * @param  tolerance The tolerance threshold for comparison of numerical values.
-     * @param  ignoredNodes The fully-qualified names of the nodes to ignore, or {@code null}
if none.
-     * @param  ignoredAttributes The fully-qualified names of attributes to ignore
-     *         (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}).
+     * @param  expected           the expected XML document.
+     * @param  actual             the XML document to compare.
+     * @param  tolerance          the tolerance threshold for comparison of numerical values.
+     * @param  ignoredNodes       the fully-qualified names of the nodes to ignore, or {@code
null} if none.
+     * @param  ignoredAttributes  the fully-qualified names of attributes to ignore
+     *                            (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}).
      *
      * @see XMLComparator
      */
@@ -381,9 +381,9 @@ public strictfp class Assert extends org
      * <p>If the serialization fails, then this method throws an {@link AssertionError}
      * as do the other JUnit assertion methods.</p>
      *
-     * @param  <T> The type of the object to serialize.
-     * @param  object The object to serialize.
-     * @return The deserialized object.
+     * @param  <T>     the type of the object to serialize.
+     * @param  object  the object to serialize.
+     * @return the deserialized object.
      */
     public static <T> T assertSerializedEquals(final T object) {
         final Object deserialized;

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -390,7 +390,7 @@ public final strictfp class TestUtilitie
      * @throws InterruptedException if this thread has been interrupted while waiting.
      */
     public static void waitForBlockedState(final Thread thread) throws IllegalThreadStateException,
InterruptedException {
-        int retry = MAXIMAL_WAIT_TIME / 5; // 5 shall be the same number than in the call
to Thread.sleep.
+        int retry = MAXIMAL_WAIT_TIME / 5;              // 5 shall be the same number than
in the call to Thread.sleep.
         do {
             Thread.sleep(5);
             switch (thread.getState()) {
@@ -419,7 +419,7 @@ public final strictfp class TestUtilitie
      */
     public static boolean waitForGarbageCollection(final Callable<Boolean> stopCondition)
throws InterruptedException {
         assertTrue("GC-dependent tests not allowed in this run.", TestConfiguration.allowGarbageCollectorDependentTests());
-        int retry = MAXIMAL_WAIT_TIME / 50; // 50 shall be the same number than in the call
to Thread.sleep.
+        int retry = MAXIMAL_WAIT_TIME / 50;             // 50 shall be the same number than
in the call to Thread.sleep.
         boolean stop;
         do {
             if (--retry == 0) {

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=1776228&r1=1776227&r2=1776228&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 05:32:15 2016
@@ -54,11 +54,6 @@ final class Writer extends StaxStreamWri
     private final int version;
 
     /**
-     * The namespace, which is either {@link Tags#NAMESPACE_V10} or {@link Tags#NAMESPACE_V11}.
-     */
-    private final String namespace;
-
-    /**
      * The metadata to write, or {@code null} if none.
      */
     private final Metadata metadata;
@@ -80,13 +75,10 @@ final class Writer extends StaxStreamWri
         this.metadata = metadata;
         final Version ver = owner.version;
         if (ver != null && ver.compareTo(Store.V1_0, 2) <= 0) {
-            version   = 0;
-            namespace = Tags.NAMESPACE_V10;
+            version = 0;
         } else {
-            version   = 1;
-            namespace = Tags.NAMESPACE_V11;
+            version = 1;
         }
-        writer.setDefaultNamespace(namespace);
     }
 
     /**
@@ -97,14 +89,17 @@ final class Writer extends StaxStreamWri
      */
     @Override
     public void writeStartDocument() throws Exception {
-        super.writeStartDocument();
-        writer.writeStartElement(Tags.GPX);
+        final String namespace;
         final Version ver;
         switch (version) {
             default:
-            case 1: ver = Store.V1_1; break;
-            case 0: ver = Store.V1_0; break;
+            case 1: ver = Store.V1_1; namespace = Tags.NAMESPACE_V11; break;
+            case 0: ver = Store.V1_0; namespace = Tags.NAMESPACE_V10; break;
         }
+        super.writeStartDocument();
+        writer.setDefaultNamespace(namespace);
+        writer.writeStartElement(Tags.GPX);
+        writer.writeDefaultNamespace(namespace);
         writer.writeAttribute(Attributes.VERSION, ver.toString());
         if (metadata != null) {
             final String creator = metadata.creator;
@@ -118,7 +113,7 @@ final class Writer extends StaxStreamWri
                      * In GPX 1.1 format, the metadata are stored under a <metadata>
node.
                      * This can conveniently be written by JAXB.
                      */
-                    marshal(namespace, Tags.METADATA, Metadata.class, metadata);
+                    marshal(Tags.NAMESPACE_V11, Tags.METADATA, Metadata.class, metadata);
                     break;
                 }
                 case 0: {
@@ -136,7 +131,8 @@ final class Writer extends StaxStreamWri
                     writeLinks(metadata.links);
                     writeSingle(Tags.TIME, metadata.time);
                     writeList(Tags.KEYWORDS, metadata.keywords);
-                    marshal(namespace, Tags.BOUNDS, Bounds.class, metadata.bounds);
+                    // Really 1.1 namespace below, not 1.0. See 'marshal(…)' javadoc for
explanation.
+                    marshal(Tags.NAMESPACE_V11, Tags.BOUNDS, Bounds.class, metadata.bounds);
                 }
             }
         }
@@ -250,7 +246,7 @@ final class Writer extends StaxStreamWri
                     switch (version) {
                         default:
                         case 1: {
-                            marshal(namespace, Tags.LINK, Link.class, (Link) link);
+                            marshal(Tags.NAMESPACE_V11, Tags.LINK, Link.class, (Link) link);
                             break;
                         }
                         case 0: {

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -67,6 +67,7 @@
     @XmlNs(prefix = "gpx", namespaceURI = Tags.NAMESPACE_V11)
 })
 @XmlAccessorType(XmlAccessType.NONE)
+@XmlJavaTypeAdapter(UniversalTimeAdapter.class)
 package org.apache.sis.internal.gpx;
 
 import javax.xml.bind.annotation.XmlNs;
@@ -74,3 +75,5 @@ import javax.xml.bind.annotation.XmlNsFo
 import javax.xml.bind.annotation.XmlSchema;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.sis.internal.jaxb.gml.UniversalTimeAdapter;

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -335,7 +335,6 @@ public abstract class StaxDataStore exte
         assert Thread.holdsLock(this);
         if (outputFactory == null) {
             outputFactory = XMLOutputFactory.newInstance();
-            outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
         }
         return outputFactory;
     }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamWriter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamWriter.java?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamWriter.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamWriter.java
[UTF-8] Wed Dec 28 05:32:15 2016
@@ -122,7 +122,18 @@ public abstract class StaxStreamWriter e
      * given at {@link StaxDataStore} construction time.
      *
      * <p>Subclasses should overwrite this method if they need to write metadata in
the XML document before
-     * the features. The overwritten method shall begin by a call to {@code super.writeStartDocument()}.</p>
+     * the features. The overwritten method shall begin by a call to {@code super.writeStartDocument()}.
+     * Example:</p>
+     *
+     * {@preformat java
+     *     &#64;Override
+     *     public void writeStartDocument() throws Exception {
+     *         super.writeStartDocument();
+     *         writer.setDefaultNamespace(namespace);
+     *         writer.writeStartElement(rootElement);
+     *         writer.writeDefaultNamespace(namespace);
+     *     }
+     * }
      *
      * @throws Exception if an error occurred while writing to the XML file.
      *         Possible subtypes include {@link XMLStreamException},
@@ -245,20 +256,36 @@ public abstract class StaxStreamWriter e
 
     /**
      * Delegates to JAXB the marshalling of a part of XML document.
+     * The XML content will be written in an element of the given name with no namespace
(see below).
+     *
+     * <div class="section">Hiding namespace</div>
+     * The {@code hideNS} argument, if non-null, gives a namespace to remove in the marshalling
result.
+     * There is two reasons why we may want to hide a namespace. The most straightforward
reason is to
+     * simplify the XML document when the {@linkplain javax.xml.bind.annotation.XmlElement#namespace()
+     * namespace of elements} to marshal is the {@linkplain XMLStreamWriter#setDefaultNamespace(String)
+     * default namespace}. Since some JAXB implementation systematically inserts a prefix
no matter if
+     * the namespace is the default one or not, we have to manually erase the namespace when
it is the
+     * default one.
+     *
+     * <p>But a more convolved reason is to reuse an element defined for another version
of the file format.
+     * For example some elements may be identical in 1.0 and 1.1 versions of a file format,
so we may want
+     * to define only one JAXB annotated class for both versions. In that case the {@code
hideNS} argument is
+     * <strong>not</strong> necessarily the {@linkplain XMLStreamWriter#setDefaultNamespace(String)
default namespace}.
+     * It is rather the namespace of the JAXB element that we want to erase (for example
{@code "foo/1.1"}),
+     * in order to pretend that it is the element of a different version specified by the
default namespace
+     * (for example defined by {@code xmlns = "foo/1.0"}).</p>
      *
      * @param  <T>     compile-time value of the {@code type} argument.
+     * @param  hideNS  the namespace to erase from the marshalling output, or {@code null}
if none.
      * @param  name    the XML tag to write.
      * @param  type    the Java class that define the XML schema of the object to marshal.
      * @param  object  the object to marshal, or {@code null} if none.
-     * @param  defaultNamespace  the namespace to omit (i.e. the namespace of elements to
move in the default namespace),
-     *                 or {@code null} if none. This is used for removing the redundant {@code
xmlns} attributes inserted
-     *                 by JAXB.
      * @throws XMLStreamException if the XML stream is closed.
      * @throws JAXBException if an error occurred during marshalling.
      *
      * @see javax.xml.bind.Marshaller#marshal(Object, XMLStreamWriter)
      */
-    protected final <T> void marshal(final String defaultNamespace, final String name,
final Class<T> type, final T object)
+    protected final <T> void marshal(final String hideNS, final String name, final
Class<T> type, final T object)
             throws XMLStreamException, JAXBException
     {
         Marshaller m = marshaller;
@@ -271,9 +298,9 @@ public abstract class StaxStreamWriter e
         }
         final QName qn;
         XMLStreamWriter out = writer;
-        if (defaultNamespace != null) {
-            out = new DefaultNamespaceStreamWriter(out, defaultNamespace);
-            qn  = new QName(defaultNamespace, name);
+        if (hideNS != null) {
+            out = new DefaultNamespaceStreamWriter(out, hideNS);
+            qn  = new QName(hideNS, name);
         } else {
             qn  = new QName(name);
         }

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=1776228&r1=1776227&r2=1776228&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 05:32:15 2016
@@ -170,9 +170,11 @@ public final strictfp class ReaderTest e
         assertEquals      ("links.size()", numLinks,                            md.links.size());
         switch (numLinks) {
             default: // Fallthrough everywhere.
-            case 3:  assertStringEquals("http://third-address.org",  md.links.get(2));
+            case 3:  assertStringEquals("website",                   md.links.get(2).type);
+                     assertStringEquals("http://third-address.org",  md.links.get(2));
             case 2:  assertStringEquals("http://second-address.org", md.links.get(1));
             case 1:  assertStringEquals("http://first-address.org",  md.links.get(0));
+                     assertStringEquals("first",                     md.links.get(0).text);
             case 0:  break;
         }
     }

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=1776228&r1=1776227&r2=1776228&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 05:32:15 2016
@@ -19,7 +19,6 @@ package org.apache.sis.internal.gpx;
 import java.net.URI;
 import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.Date;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -28,6 +27,7 @@ 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 org.apache.sis.test.TestCase;
@@ -35,7 +35,8 @@ import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.TestUtilities.date;
 
 // Branch-dependent imports
 import java.time.LocalDate;
@@ -106,17 +107,35 @@ public final strictfp class WriterTest e
     }
 
     /**
-     * Test writing GPX metadata.
+     * 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.
      *
      * @throws Exception if an error occurred while writing the XML data.
      */
     @Test
-    @org.junit.Ignore("Writer not yet synchronized with changes in reader.")
-    public void testMetadata() throws Exception {
+    public void testMetadata100() throws Exception {
+        testMetadata(Store.V1_0, "1.0/metadata.xml");
+    }
+
+    /**
+     * 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.
+     *
+     * @throws Exception if an error occurred while writing the XML data.
+     */
+    @Test
+    public void testMetadata110() throws Exception {
+        testMetadata(Store.V1_1, "1.1/metadata.xml");
+    }
+
+    /**
+     * Implementations of {@link #testMetadata100()} and {@link #testMetadata110()}.
+     */
+    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://son-site.com"));
+        person.email = "jean.pierre@test.com";
+        person.link  = new Link(new URI("http://someone-site.org"));
 
         final Copyright copyright = new Copyright();
         copyright.author  = "Apache";
@@ -124,29 +143,33 @@ public final strictfp class WriterTest e
         copyright.license = new URI("http://www.apache.org/licenses/LICENSE-2.0");
 
         final Bounds bounds = new Bounds();
-        bounds.westBoundLongitude = -10;
-        bounds.eastBoundLongitude =  20;
-        bounds.southBoundLatitude = -30;
+        bounds.westBoundLongitude = -20;
+        bounds.eastBoundLongitude =  30;
+        bounds.southBoundLatitude =  10;
         bounds.northBoundLatitude =  40;
 
-        final Metadata metaData = new Metadata();
-        metaData.name        = "name";
-        metaData.description = "description";
-        metaData.author      = person;
-        metaData.copyright   = copyright;
-        metaData.keywords    = Arrays.asList("test", "sample");
-        metaData.bounds      = bounds;
-        metaData.time        = new Date();
-        metaData.links.add(new Link(new URI("http://address1.org")));
-        metaData.links.add(new Link(new URI("http://address2.org")));
+        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.add(new Link(new URI("http://first-address.org")));
+        metadata.links.add(new Link(new URI("http://second-address.org")));
+        metadata.links.add(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.write(metaData, null);
-
-            // Re-read the data we just wrote.
-            assertEquals(metaData,      store.getMetadata());
-            assertEquals(Store.V1_1, store.getVersion());
+            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"});
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/internal/gpx/1.1/metadata.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/internal/gpx/1.1/metadata.xml?rev=1776228&r1=1776227&r2=1776228&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/internal/gpx/1.1/metadata.xml
(original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/resources/org/apache/sis/internal/gpx/1.1/metadata.xml
Wed Dec 28 05:32:15 2016
@@ -34,7 +34,9 @@
       <year>2004</year>
       <license>http://www.apache.org/licenses/LICENSE-2.0</license>
     </copyright>
-    <link href="http://first-address.org"/>
+    <link href="http://first-address.org">
+      <text>first</text>
+    </link>
     <link href="http://second-address.org"/>
     <link href="http://third-address.org">
       <type>website</type>



Mime
View raw message