sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1546682 - in /sis/branches/JDK7: core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/ core/sis-metadata/src/test/java/org/apache/sis/xml/ core/sis-metadata/src/test/resources/org/apache/sis/xml/ core/sis-referencing/src/main/...
Date Sat, 30 Nov 2013 03:01:44 GMT
Author: desruisseaux
Date: Sat Nov 30 03:01:43 2013
New Revision: 1546682

URL: http://svn.apache.org/r1546682
Log:
Consolidation of XMLTestCase as a preparation for adding tests of referencing XML objects.
Added some JAXB annotations for referencing objects and fixed the RS_Identifier adapter.
Added a partial test case for PrimeMeridian as a proof of concept.

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/
    sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/
    sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/resources/
      - copied from r1542818, sis/branches/JDK7/core/sis-referencing/src/test/testdata/
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
  (with props)
Removed:
    sis/branches/JDK7/core/sis-referencing/src/test/testdata/
Modified:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
    sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
    sis/branches/JDK7/ide-project/NetBeans/build.xml
    sis/branches/JDK7/src/main/docbook/book.entities

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.sis.internal.jaxb.code;
 
-import java.util.Map;
-import java.util.HashMap;
 import java.util.Arrays;
 import java.util.Locale;
 import java.util.Collections;
@@ -34,8 +32,6 @@ import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.test.XMLTestCase;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -47,43 +43,13 @@ import static org.apache.sis.test.Assert
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
  * @since   0.3 (derived from geotk-3.17)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-121">GEOTK-121</a>
  */
 public final strictfp class CodeListMarshallingTest extends XMLTestCase {
     /**
-     * A poll of configured {@link Marshaller} and {@link Unmarshaller}, created when first
needed.
-     */
-    private static MarshallerPool pool;
-
-    /**
-     * Creates the XML (un)marshaller pool to be shared by all test methods.
-     * The (un)marshallers locale and timezone will be set to fixed values.
-     *
-     * @throws JAXBException If an error occurred while creating the pool.
-     *
-     * @see #disposeMarshallerPool()
-     */
-    @BeforeClass
-    public static void createMarshallerPool() throws JAXBException {
-        final Map<String,Object> properties = new HashMap<>(4);
-        assertNull(properties.put(XML.LOCALE, Locale.FRANCE));
-        assertNull(properties.put(XML.TIMEZONE, "CET"));
-        pool = new MarshallerPool(properties);
-    }
-
-    /**
-     * Invoked by JUnit after the execution of every tests in order to dispose
-     * the {@link MarshallerPool} instance used internally by this class.
-     */
-    @AfterClass
-    public static void disposeMarshallerPool() {
-        pool = null;
-    }
-
-    /**
      * Returns a XML string to use for testing purpose.
      *
      * @param baseURL The base URL of XML schemas.
@@ -140,6 +106,7 @@ public final strictfp class CodeListMars
         final ResponsibleParty rp = (ResponsibleParty) XML.unmarshal(expected);
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
 
+        final MarshallerPool pool = getMarshallerPool();
         final Marshaller marshaller = pool.acquireMarshaller();
         marshaller.setProperty(XML.SCHEMAS, Collections.singletonMap("gmd",
                 "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas"));
// Intentionally omit trailing '/'.
@@ -155,6 +122,7 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testLocalization() throws JAXBException {
+        final MarshallerPool pool = getMarshallerPool();
         final Marshaller marshaller = pool.acquireMarshaller();
         /*
          * First, test using the French locale.
@@ -185,6 +153,7 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testExtraCodes() throws JAXBException {
+        final MarshallerPool pool = getMarshallerPool();
         final Marshaller marshaller = pool.acquireMarshaller();
         final DefaultDataIdentification id = new DefaultDataIdentification();
         id.setTopicCategories(Arrays.asList(

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/MetadataMarshallingTest.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.sis.xml;
 
-import java.util.Map;
-import java.util.HashMap;
 import java.util.Locale;
 import java.net.URL;
 import java.io.IOException;
@@ -36,8 +34,6 @@ import org.apache.sis.metadata.iso.quali
 import org.apache.sis.metadata.iso.quality.DefaultConformanceResult;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOn;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -59,42 +55,12 @@ import static org.apache.sis.test.TestUt
 @DependsOn(FreeTextMarshallingTest.class)
 public final strictfp class MetadataMarshallingTest extends XMLTestCase {
     /**
-     * A poll of configured {@link Marshaller} and {@link Unmarshaller}, created when first
needed.
-     */
-    private static MarshallerPool pool;
-
-    /**
-     * Creates the XML (un)marshaller pool to be shared by all test methods.
-     * The (un)marshallers locale and timezone will be set to fixed values.
-     *
-     * @throws JAXBException If an error occurred while creating the pool.
-     *
-     * @see #disposeMarshallerPool()
-     */
-    @BeforeClass
-    public static void createMarshallerPool() throws JAXBException {
-        final Map<String,Object> properties = new HashMap<>(4);
-        assertNull(properties.put(XML.LOCALE, Locale.ENGLISH));
-        assertNull(properties.put(XML.TIMEZONE, "CET"));
-        pool = new MarshallerPool(properties);
-    }
-
-    /**
-     * Invoked by JUnit after the execution of every tests in order to dispose
-     * the {@link MarshallerPool} instance used internally by this class.
-     */
-    @AfterClass
-    public static void disposeMarshallerPool() {
-        pool = null;
-    }
-
-    /**
      * Returns the URL to the XML file of the given name.
      *
      * @param  filename The name of the XML file.
      * @return The URL to the given XML file.
      */
-    private URL getResource(final String filename) {
+    private static URL getResource(final String filename) {
         final URL resource = MetadataMarshallingTest.class.getResource(filename);
         assertNotNull(filename, resource);
         return resource;
@@ -136,10 +102,11 @@ public final strictfp class MetadataMars
      */
     @Test
     public void testPositionalAccuracy() throws IOException, JAXBException {
-        final Marshaller   marshaller   = pool.acquireMarshaller();
-        final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
-        final URL          resource     = getResource("PositionalAccuracy.xml");
-        final Object       metadata     = XML.unmarshal(resource);
+        final MarshallerPool pool         = getMarshallerPool();
+        final Marshaller     marshaller   = pool.acquireMarshaller();
+        final Unmarshaller   unmarshaller = pool.acquireUnmarshaller();
+        final URL            resource     = getResource("PositionalAccuracy.xml");
+        final Object         metadata     = XML.unmarshal(resource);
         assertInstanceOf("PositionalAccuracy.xml", AbstractElement.class, metadata);
         final InternationalString nameOfMeasure = getSingleton(((AbstractElement) metadata).getNamesOfMeasure());
         /*
@@ -174,6 +141,7 @@ public final strictfp class MetadataMars
      */
     @Test
     public void testProcessStep() throws IOException, JAXBException {
+        final MarshallerPool     pool         = getMarshallerPool();
         final Marshaller         marshaller   = pool.acquireMarshaller();
         final Unmarshaller       unmarshaller = pool.acquireUnmarshaller();
         final DefaultProcessing  processing   = new DefaultProcessing();
@@ -208,8 +176,9 @@ public final strictfp class MetadataMars
      */
     @Test
     public void testExtent() throws IOException, JAXBException {
-        final Marshaller   marshaller   = pool.acquireMarshaller();
-        final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
+        final MarshallerPool pool         = getMarshallerPool();
+        final Marshaller     marshaller   = pool.acquireMarshaller();
+        final Unmarshaller   unmarshaller = pool.acquireUnmarshaller();
         final DefaultGeographicBoundingBox bbox = new DefaultGeographicBoundingBox(-99, -79,
14.9844, 31);
         bbox.getIdentifierMap().put(IdentifierSpace.ID, "bbox");
         final DefaultTemporalExtent temporal = new DefaultTemporalExtent();

Modified: sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/resources/org/apache/sis/xml/Extent.xml Sat
Nov 30 03:01:43 2013
@@ -19,10 +19,10 @@
 -->
 
 <gmd:EX_Extent
-    xmlns:gco="http://www.isotc211.org/2005/gco"
-    xmlns:gmd="http://www.isotc211.org/2005/gmd"
-    xmlns:gml="http://www.opengis.net/gml"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:gco = "http://www.isotc211.org/2005/gco"
+    xmlns:gmd = "http://www.isotc211.org/2005/gmd"
+    xmlns:gml = "http://www.opengis.net/gml/3.2"
+    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation = "http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd">
 
   <gmd:geographicElement>

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/RS_Identifier.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -45,50 +45,57 @@ import org.apache.sis.util.StringBuilder
  * @version 0.4
  * @module
  */
-public final class RS_Identifier extends XmlAdapter<RS_Identifier, ReferenceIdentifier>
{
+public final class RS_Identifier extends XmlAdapter<RS_Identifier.Value, ReferenceIdentifier>
{
     /**
-     * The identifier code.
-     *
-     * <p><b>Note:</b> GML (the target of this class) represents that code
as an XML value, while
-     * {@link org.apache.sis.metadata.iso.ImmutableIdentifier} represents it as an XML element.</p>
-     */
-    @XmlValue
-    private String code;
+     * The wrapper for GML identifier marshalled as a code value with a codespace attribute.
+     * Defined in a separated class because JAXB does not allow usage of {@code XmlValue}
in
+     * a class that inherit an other class.
+     */
+    public static final class Value {
+        /**
+         * The identifier code.
+         *
+         * <p><b>Note:</b> GML (the target of this class) represents that
code as an XML value, while
+         * {@link org.apache.sis.metadata.iso.ImmutableIdentifier} represents it as an XML
element.</p>
+         */
+        @XmlValue
+        private String code;
 
-    /**
-     * The code space, which is often {@code "EPSG"} with the version in use.
-     *
-     * <p><b>Note:</b> GML (the target of this class) represents that code
as an XML attribute, while
-     * {@link org.apache.sis.metadata.iso.ImmutableIdentifier} represents it as an XML element.</p>
-     */
-    @XmlAttribute
-    private String codeSpace;
-
-    /**
-     * Empty constructor for JAXB only.
-     */
-    public RS_Identifier() {
-    }
+        /**
+         * The code space, which is often {@code "EPSG"} with the version in use.
+         *
+         * <p><b>Note:</b> GML (the target of this class) represents that
code as an XML attribute, while
+         * {@link org.apache.sis.metadata.iso.ImmutableIdentifier} represents it as an XML
element.</p>
+         */
+        @XmlAttribute
+        private String codeSpace;
 
-    /**
-     * Creates a wrapper initialized to the values of the given identifier.
-     *
-     * @param identifier The identifier from which to get the values.
-     */
-    private RS_Identifier(final ReferenceIdentifier identifier) {
-        code      = identifier.getCode();
-        codeSpace = identifier.getCodeSpace();
-        if (codeSpace == null) {
-            codeSpace = "";
+        /**
+         * Empty constructor for JAXB only.
+         */
+        public Value() {
         }
-        String version = identifier.getVersion();
-        if (version != null) {
-            final StringBuilder buffer = new StringBuilder(codeSpace);
-            if (buffer.length() != 0) {
-                buffer.append('_');
+
+        /**
+         * Creates a wrapper initialized to the values of the given identifier.
+         *
+         * @param identifier The identifier from which to get the values.
+         */
+        Value(final ReferenceIdentifier identifier) {
+            code      = identifier.getCode();
+            codeSpace = identifier.getCodeSpace();
+            if (codeSpace == null) {
+                codeSpace = "";
+            }
+            String version = identifier.getVersion();
+            if (version != null) {
+                final StringBuilder buffer = new StringBuilder(codeSpace);
+                if (buffer.length() != 0) {
+                    buffer.append('_');
+                }
+                StringBuilders.remove(buffer.append('v').append(version), ".");
+                codeSpace = buffer.toString();
             }
-            StringBuilders.remove(buffer.append('v').append(version), ".");
-            codeSpace = buffer.toString();
         }
     }
 
@@ -100,7 +107,7 @@ public final class RS_Identifier extends
      * @return An identifier which represents the value.
      */
     @Override
-    public ReferenceIdentifier unmarshal(final RS_Identifier value) {
+    public ReferenceIdentifier unmarshal(final Value value) {
         if (value != null) {
             final Citation authority = Citations.fromName(value.codeSpace); // May be null.
             return new ImmutableIdentifier(authority, Citations.getIdentifier(authority),
value.code);
@@ -116,7 +123,7 @@ public final class RS_Identifier extends
      * @return The adapter for the given metadata.
      */
     @Override
-    public RS_Identifier marshal(final ReferenceIdentifier value) {
-        return (value != null) ? new RS_Identifier(value) : null;
+    public Value marshal(final ReferenceIdentifier value) {
+        return (value != null) ? new Value(value) : null;
     }
 }

Added: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java?rev=1546682&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing;
+
+import java.util.Collection;
+import org.apache.sis.internal.jaxb.TypeRegistration;
+import org.apache.sis.referencing.AbstractIdentifiedObject;
+
+
+/**
+ * Declares the classes of objects to be marshalled using a default {@code MarshallerPool}.
+ * This class is declared in the {@code META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration}
file.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final class ReferencingTypes extends TypeRegistration {
+    /**
+     * Adds to the given collection the referencing types that should be given to the initial
JAXB context.
+     */
+    @Override
+    public void getTypes(final Collection<Class<?>> addTo) {
+        addTo.add(AbstractIdentifiedObject.class);
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -25,6 +25,7 @@ import java.util.Locale;
 import java.io.Serializable;
 import javax.xml.bind.annotation.XmlID;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -108,6 +109,12 @@ import java.util.Objects;
     "identifier",
     "name"
 })
+@XmlSeeAlso({
+    AbstractReferenceSystem.class,
+    org.apache.sis.referencing.datum.AbstractDatum.class,
+    org.apache.sis.referencing.datum.DefaultEllipsoid.class,
+    org.apache.sis.referencing.datum.DefaultPrimeMeridian.class
+})
 public class AbstractIdentifiedObject extends FormattableObject implements IdentifiedObject,
         LenientComparable, Deprecable, Serializable
 {

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.datum
 import java.util.Date;
 import java.util.Map;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.util.GenericName;
@@ -64,6 +65,9 @@ import java.util.Objects;
  */
 @Immutable
 @XmlType(name="AbstractDatumType")
+@XmlSeeAlso(
+    DefaultGeodeticDatum.class
+)
 public class AbstractDatum extends AbstractIdentifiedObject implements Datum {
     /**
      * Serial number for inter-operability with different versions.

Added: sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration?rev=1546682&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -0,0 +1 @@
+org.apache.sis.internal.referencing.ReferencingTypes

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java?rev=1546682&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DatumTestCase.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.datum;
+
+import java.net.URL;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.JAXBException;
+import org.apache.sis.xml.MarshallerPool;
+import org.apache.sis.test.XMLTestCase;
+
+import static org.opengis.test.Assert.*;
+
+
+/**
+ * Base class of test in the datum package that need XML (un)marshalling.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+abstract strictfp class DatumTestCase extends XMLTestCase {
+    /**
+     * Creates a new test case.
+     */
+    DatumTestCase() {
+    }
+
+    /**
+     * Unmarshalls the given test file.
+     *
+     * @param  type The expected object type.
+     * @param  filename The name of the XML file.
+     * @return The object unmarshalled from the given file.
+     * @throws JAXBException If an error occurred during unmarshalling.
+     */
+    static <T> T unmarshall(final Class<T> type, final String filename) throws
JAXBException {
+        final MarshallerPool pool = getMarshallerPool();
+        final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
+        final Object object = unmarshaller.unmarshal(getResource(filename));
+        pool.recycle(unmarshaller);
+        assertInstanceOf(filename, type, object);
+        return type.cast(object);
+    }
+
+    /**
+     * Returns the URL to the XML file of the given name.
+     *
+     * @param  filename The name of the XML file.
+     * @return The URL to the given XML file.
+     */
+    private static URL getResource(final String filename) {
+        final URL resource = DatumTestCase.class.getResource(filename);
+        assertNotNull(filename, resource);
+        return resource;
+    }
+}

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

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

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -21,7 +21,6 @@ import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Longitude;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.test.mock.GeodeticDatumMock;
-import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
@@ -40,7 +39,7 @@ import static org.apache.sis.referencing
  * @module
  */
 @DependsOn(org.apache.sis.internal.referencing.FormulasTest.class)
-public final strictfp class DefaultEllipsoidTest extends TestCase {
+public final strictfp class DefaultEllipsoidTest extends DatumTestCase {
     /**
      * Half of a minute of angle, in degrees.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -29,7 +29,6 @@ import org.apache.sis.metadata.iso.exten
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.apache.sis.referencing.Assert.*;
@@ -49,7 +48,7 @@ import static org.apache.sis.test.mock.G
   DefaultEllipsoidTest.class,
   BursaWolfParametersTest.class
 })
-public final strictfp class DefaultGeodeticDatumTest extends TestCase {
+public final strictfp class DefaultGeodeticDatumTest extends DatumTestCase {
     /**
      * Tests the creation and serialization of a {@link DefaultGeodeticDatum}.
      */

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -16,7 +16,8 @@
  */
 package org.apache.sis.referencing.datum;
 
-import org.apache.sis.test.TestCase;
+import javax.measure.unit.NonSI;
+import javax.xml.bind.JAXBException;
 import org.junit.Test;
 
 import static org.apache.sis.referencing.Assert.*;
@@ -31,7 +32,7 @@ import static org.apache.sis.test.mock.P
  * @version 0.4
  * @module
  */
-public final strictfp class DefaultPrimeMeridianTest extends TestCase {
+public final strictfp class DefaultPrimeMeridianTest extends DatumTestCase {
     /**
      * Tests {@link DefaultPrimeMeridian#toWKT()}.
      */
@@ -40,4 +41,16 @@ public final strictfp class DefaultPrime
         final DefaultPrimeMeridian pm = new DefaultPrimeMeridian(GREENWICH);
         assertWktEquals(pm, "PRIMEM[“Greenwich”, 0.0]");
     }
+
+    /**
+     * Tests unmarshalling.
+     *
+     * @throws JAXBException If an error occurred during unmarshalling.
+     */
+    @Test
+    public void testUnmarshall() throws JAXBException {
+        DefaultPrimeMeridian pm = unmarshall(DefaultPrimeMeridian.class, "Greenwich.xml");
+        assertEquals("greenwichLongitude", pm.getGreenwichLongitude(), 0, 0);
+//      assertEquals("angularUnit", NonSI.DEGREE_ANGLE, pm.getAngularUnit());
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -20,7 +20,6 @@ import java.lang.reflect.Field;
 import org.opengis.referencing.datum.VerticalDatumType;
 import org.apache.sis.internal.referencing.VerticalDatumTypes;
 import org.apache.sis.test.DependsOn;
-import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.apache.sis.referencing.Assert.*;
@@ -36,7 +35,7 @@ import static java.util.Collections.sing
  * @module
  */
 @DependsOn(org.apache.sis.internal.referencing.VerticalDatumTypesTest.class)
-public final strictfp class DefaultVerticalDatumTest extends TestCase {
+public final strictfp class DefaultVerticalDatumTest extends DatumTestCase {
     /**
      * Tests the {@link DefaultVerticalDatum#getVerticalDatumType()} method in a state
      * simulating unmarshalling of GML 3.2 document.

Added: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml?rev=1546682&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/datum/Greenwich.xml
Sat Nov 30 03:01:43 2013
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<gml:PrimeMeridian gml:id = "epsg-meridian-8901"
+    xmlns:gml = "http://www.opengis.net/gml/3.2"
+    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/datums.xsd">
+
+  <gml:identifier codeSpace="OGP">urn:ogc:def:meridian:EPSG::8901</gml:identifier>
+  <gml:name>Greenwich</gml:name>
+  <gml:greenwichLongitude uom="urn:ogc:def:uom:EPSG::9102">0</gml:greenwichLongitude>
+</gml:PrimeMeridian>

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

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

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8]
Sat Nov 30 03:01:43 2013
@@ -109,14 +109,16 @@ public final class Namespaces extends St
     /**
      * The <code>{@value}</code> URL.
      * The usual prefix for this namespace is {@code "gml"}.
+     * The current version is 3.2, but this may change in any future SIS release.
      *
      * @category OGC
      */
-    public static final String GML = "http://www.opengis.net/gml";
+    public static final String GML = "http://www.opengis.net/gml/3.2";
 
     /**
      * The <code>{@value}</code> URL.
      * The usual prefix for this namespace is {@code "csw"}.
+     * The current version is 2.0.2, but this may change in any future SIS release.
      *
      * @category OGC
      */

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/XMLTestCase.java
[UTF-8] Sat Nov 30 03:01:43 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.sis.test;
 
+import java.util.Map;
+import java.util.HashMap;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.io.StringReader;
@@ -25,6 +27,8 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBException;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.xml.MarshallerPool;
+import org.apache.sis.xml.XML;
 import org.junit.After;
 
 import static org.junit.Assert.*;
@@ -41,13 +45,23 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see XMLComparator
  */
 public abstract strictfp class XMLTestCase extends TestCase {
     /**
+     * A poll of configured {@link Marshaller} and {@link Unmarshaller} binded to the default
set of classes.
+     * The locale is set to {@link Locale#UK} (the language of ISO standards) and the timezone
is arbitrarily
+     * set to CET (Central European Time). We intentionally use a timezone different than
UTC in order to have
+     * an error of one or two hours if a code fails to take timezone offset in account.
+     *
+     * <p>This field is initially {@code null} and created when first needed.</p>
+     */
+    private static MarshallerPool defaultPool;
+
+    /**
      * The context containing locale, timezone, GML version and other information.
      * The context is initially {@code null} and can be created either explicitely,
      * or by invoking the {@link #createContext(boolean, Locale, String)} convenience method.
@@ -69,6 +83,27 @@ public abstract strictfp class XMLTestCa
     }
 
     /**
+     * Returns the default XML (un)marshaller pool potentially shared by test methods in
all sub-classes.
+     * The (un)marshallers locale is set to {@link Locale#UK} (the language of ISO standards)
and their
+     * timezone is arbitrarily set to CET (<cite>Central European Time</cite>).
+     *
+     * {@note We intentionally use a timezone different than UTC in order to have an error
of one or two hours
+     *        if a code fails to take timezone offset in account.}
+     *
+     * @return The shared (un)marshaller pool.
+     * @throws JAXBException If an error occurred while creating the JAXB marshaller.
+     */
+    protected static synchronized MarshallerPool getMarshallerPool() throws JAXBException
{
+        if (defaultPool == null) {
+            final Map<String,Object> properties = new HashMap<>(4);
+            assertNull(properties.put(XML.LOCALE, Locale.UK));
+            assertNull(properties.put(XML.TIMEZONE, "CET"));
+            defaultPool = new MarshallerPool(properties);
+        }
+        return defaultPool;
+    }
+
+    /**
      * Initializes the {@link #context} to the given locale and timezone.
      *
      * @param marshal  {@code true} for setting the {@link Context#MARSHALLING} flag.

Modified: sis/branches/JDK7/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/build.xml?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/build.xml Sat Nov 30 03:01:43 2013
@@ -92,6 +92,9 @@
       <fileset dir="${project.root}/core/sis-metadata/src/test/resources">
         <include name="**/*.xml"/>
       </fileset>
+      <fileset dir="${project.root}/core/sis-referencing/src/test/resources">
+        <include name="**/*.xml"/>
+      </fileset>
     </copy>
     <copy todir="${build.test.classes.dir}">
       <fileset dir="${project.root}/storage/sis-shapefile/src/test/resources">

Modified: sis/branches/JDK7/src/main/docbook/book.entities
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/src/main/docbook/book.entities?rev=1546682&r1=1546681&r2=1546682&view=diff
==============================================================================
--- sis/branches/JDK7/src/main/docbook/book.entities (original)
+++ sis/branches/JDK7/src/main/docbook/book.entities Sat Nov 30 03:01:43 2013
@@ -10,5 +10,5 @@
 <!ENTITY xmlns-gmd      "http://www.isotc211.org/2005/gmd">
 <!ENTITY xmlns-gmi      "http://www.isotc211.org/2005/gmi">
 <!ENTITY xmlns-gmx      "http://www.isotc211.org/2005/gmx">
-<!ENTITY xmlns-gml      "http://www.opengis.net/gml">
+<!ENTITY xmlns-gml      "http://www.opengis.net/gml/3.2">
 <!ENTITY xmlns-xlink    "http://www.w3.org/1999/xlink">



Mime
View raw message