sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1698400 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/jaxb/referencing/ main/java/org/apache/sis/referencing/operation/ test/java/org/apache/sis/referencing/operation/ test/java/org/apache/sis/test/suite/
Date Fri, 28 Aug 2015 19:42:48 GMT
Author: desruisseaux
Date: Fri Aug 28 19:42:47 2015
New Revision: 1698400

URL: http://svn.apache.org/r1698400
Log:
Add JAXB annotations on DefaultOperationMethod.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
  (with props)
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java?rev=1698400&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -0,0 +1,92 @@
+/*
+ * 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.jaxb.referencing;
+
+import javax.xml.bind.annotation.XmlElement;
+import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.internal.jaxb.gco.PropertyType;
+import org.apache.sis.referencing.operation.DefaultOperationMethod;
+
+
+/**
+ * JAXB adapter mapping implementing class to the GeoAPI interface. See
+ * package documentation for more information about JAXB and interface.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+public final class CC_OperationMethod extends PropertyType<CC_OperationMethod, OperationMethod>
{
+    /**
+     * Empty constructor for JAXB only.
+     */
+    public CC_OperationMethod() {
+    }
+
+    /**
+     * Returns the GeoAPI interface which is bound by this adapter.
+     * This method is indirectly invoked by the private constructor
+     * below, so it shall not depend on the state of this object.
+     *
+     * @return {@code OperationMethod.class}
+     */
+    @Override
+    protected Class<OperationMethod> getBoundType() {
+        return OperationMethod.class;
+    }
+
+    /**
+     * Constructor for the {@link #wrap} method only.
+     */
+    private CC_OperationMethod(final OperationMethod method) {
+        super(method);
+    }
+
+    /**
+     * Invoked by {@link PropertyType} at marshalling time for wrapping the given value
+     * in a {@code <gml:OperationMethod>} XML element.
+     *
+     * @param  method The element to marshall.
+     * @return A {@code PropertyType} wrapping the given the element.
+     */
+    @Override
+    protected CC_OperationMethod wrap(final OperationMethod method) {
+        return new CC_OperationMethod(method);
+    }
+
+    /**
+     * Invoked by JAXB at marshalling time for getting the actual element to write
+     * inside the {@code <gml:OperationMethod>} XML element.
+     * This is the value or a copy of the value given in argument to the {@code wrap} method.
+     *
+     * @return The element to be marshalled.
+     */
+    @XmlElement(name = "OperationMethod")
+    public DefaultOperationMethod getElement() {
+        return DefaultOperationMethod.castOrCopy(metadata);
+    }
+
+    /**
+     * Invoked by JAXB at unmarshalling time for storing the result temporarily.
+     *
+     * @param method The unmarshalled element.
+     */
+    public void setElement(final DefaultOperationMethod method) {
+        metadata = method;
+    }
+}

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

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

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1698400&r1=1698399&r2=1698400&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.opera
 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.XmlRootElement;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
@@ -55,7 +56,7 @@ import java.util.Objects;
  * @module
  */
 @XmlType(name="AbstractSingleOperationType", propOrder = {
-//  "method",   // TODO
+    "method",
 //  "parameters"
 })
 @XmlRootElement(name = "AbstractSingleOperation")
@@ -71,6 +72,7 @@ class AbstractSingleOperation extends Ab
     /**
      * The operation method.
      */
+    @XmlElement
     private final OperationMethod method;
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java?rev=1698400&r1=1698399&r2=1698400&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultFormula.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -67,6 +67,16 @@ public class DefaultFormula extends Form
     private final Citation citation;
 
     /**
+     * Creates a new formula. This constructor is not public because of {@code Formula} object
should not have
+     * both the formula literal and the citation. But we use this constructor an unmarshalling
time if the XML
+     * document have both. Having both is not valid GML, but SIS is tolerant to this situation.
+     */
+    DefaultFormula(final InternationalString formula, final Citation citation) {
+        this.formula  = formula;
+        this.citation = citation;
+    }
+
+    /**
      * Creates a new formula from the given string.
      *
      * @param formula The formula.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1698400&r1=1698399&r2=1698400&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -18,7 +18,13 @@ package org.apache.sis.referencing.opera
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Collections;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Formula;
@@ -26,14 +32,20 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.SingleOperation;
+import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.ParameterDescriptor;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Workaround;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.internal.util.Citations;
 import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.internal.jaxb.gco.StringAdapter;
 import org.apache.sis.internal.referencing.NilReferencingObject;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
 import org.apache.sis.parameter.Parameterized;
 import org.apache.sis.referencing.NamedIdentifier;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -108,6 +120,14 @@ import java.util.Objects;
  * @see DefaultTransformation
  * @see org.apache.sis.referencing.operation.transform.MathTransformProvider
  */
+@XmlType(name="OperationMethodType", propOrder = {
+    "formulaCitation",
+    "formulaDescription",
+    "sourceDimensions",
+    "targetDimensions",
+    "descriptors"
+})
+@XmlRootElement(name = "OperationMethod")
 public class DefaultOperationMethod extends AbstractIdentifiedObject implements OperationMethod
{
     /*
      * NOTE FOR JAVADOC WRITER:
@@ -124,14 +144,19 @@ public class DefaultOperationMethod exte
      * Formula(s) or procedure used by this operation method. This may be a reference to
a publication.
      * Note that the operation method may not be analytic, in which case this attribute references
or
      * contains the procedure, not an analytic formula.
+     *
+     * <p><b>Consider this field as final!</b>
+     * This field is modified only at unmarshalling time by {@link #setFormula(Object)}</p>
      */
-    private final Formula formula;
+    private Formula formula;
 
     /**
      * Number of dimensions in the source CRS of this operation method.
      * May be {@code null} if this method can work with any number of
      * source dimensions (e.g. <cite>Affine Transform</cite>).
      */
+    @XmlElement
+    @XmlSchemaType(name = "positiveInteger")
     private final Integer sourceDimensions;
 
     /**
@@ -139,12 +164,28 @@ public class DefaultOperationMethod exte
      * May be {@code null} if this method can work with any number of
      * target dimensions (e.g. <cite>Affine Transform</cite>).
      */
+    @XmlElement
+    @XmlSchemaType(name = "positiveInteger")
     private final Integer targetDimensions;
 
     /**
      * The set of parameters, or {@code null} if none.
+     *
+     * <p><b>Consider this field as final!</b>
+     * This field is modified only at unmarshalling time by {@link #setDescriptors(GeneralParameterDescriptor[])}</p>
+     */
+    private ParameterDescriptorGroup parameters;
+
+    /**
+     * Creates a new object in which every attributes are set to a null value.
+     * <strong>This is not a valid object.</strong> This constructor is strictly
+     * reserved to JAXB, which will assign values to the fields using reflexion.
      */
-    private final ParameterDescriptorGroup parameters;
+    private DefaultOperationMethod() {
+        super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
+        sourceDimensions = null;
+        targetDimensions = null;
+    }
 
     /**
      * Constructs an operation method from a set of properties and a descriptor group. The
properties map is given
@@ -673,4 +714,105 @@ public class DefaultOperationMethod exte
         }
         return WKTKeywords.Method;
     }
+
+    // ---- XML SUPPORT ----------------------------------------------------
+
+    /**
+     * Invoked by JAXB for marshalling a citation to the formula. In principle at most one
of
+     * {@code getFormulaCitation()} and {@link #getFormulaDescription()} methods can return
a
+     * non-null value. However SIS accepts both coexist (but this is invalid GML).
+     */
+    @XmlElement(name = "formulaCitation")
+    private Citation getFormulaCitation() {
+        final Formula formula = getFormula();   // Give to users a chance to override.
+        return (formula != null) ? formula.getCitation() : null;
+    }
+
+    /**
+     * Invoked by JAXB for marshalling the formula literally. In principle at most one of
+     * {@code getFormulaDescription()} and {@link #getFormulaCitation()} methods can return
+     * a non-null value. However SIS accepts both to coexist (but this is invalid GML).
+     */
+    @XmlElement(name = "formula")
+    private String getFormulaDescription() {
+        final Formula formula = getFormula();   // Give to users a chance to override.
+        return (formula != null) ? StringAdapter.toString(formula.getFormula()) : null;
+    }
+
+    /**
+     * Invoked by JAXB for setting the citation to the formula.
+     */
+    private void setFormulaCitation(final Citation citation) {
+        if (ReferencingUtilities.canSetProperty(DefaultOperationMethod.class, "setFormulaCitation",
+                "formulaCitation", formula != null && formula.getCitation() != null))
+        {
+            formula = (formula == null) ? new DefaultFormula(citation)
+                      : new DefaultFormula(formula.getFormula(), citation);
+        }
+    }
+
+    /**
+     * Invoked by JAXB for setting the formula description.
+     */
+    private void setFormulaDescription(final String description) {
+        if (ReferencingUtilities.canSetProperty(DefaultOperationMethod.class, "setFormulaDescription",
+                "formula", formula != null && formula.getFormula() != null))
+        {
+            formula = (formula == null) ? new DefaultFormula(description)
+                      : new DefaultFormula(new SimpleInternationalString(description), formula.getCitation());
+        }
+    }
+
+    /**
+     * Invoked by JAXB for getting the parameters to marshal. This method usually marshals
the sequence of
+     * descriptors without their {@link ParameterDescriptorGroup} wrapper, because GML is
defined that way.
+     * The {@code ParameterDescriptorGroup} wrapper is a GeoAPI addition done for allowing
usage of its
+     * methods as a convenience (e.g. {@link ParameterDescriptorGroup#descriptor(String)}).
+     *
+     * <p>However it could happen that the user really wanted to specify a {@code ParameterDescriptorGroup}
as
+     * the sole {@code <gml:parameter>} element. We currently have no easy way to distinguish
those cases.</p>
+     *
+     * <div class="note"><b>Tip:</b>
+     * One possible way to distinguish the two cases would be to check that the parameter
group does not contain
+     * any property that this method does not have:
+     *
+     * {@preformat java
+     *   if (IdentifiedObjects.getProperties(this).entrySet().containsAll(
+     *       IdentifiedObjects.getProperties(parameters).entrySet())) ...
+     * }
+     *
+     * But we would need to make sure that {@link AbstractSingleOperation#getParameters()}
is consistent
+     * with the decision taken by this method.</div>
+     */
+    @XmlElement(name = "parameter")
+    private GeneralParameterDescriptor[] getDescriptors() {
+        if (parameters != null) {
+            final List<GeneralParameterDescriptor> descriptors = parameters.descriptors();
+            if (descriptors != null) {      // Paranoiac check (should not be allowed).
+                return descriptors.toArray(new GeneralParameterDescriptor[descriptors.size()]);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Invoked by JAXB for setting the unmarshalled parameters.
+     * This method wraps the given descriptors in an {@link DefaultParameterDescriptorGroup},
+     * unless the given descriptors was already a {@code ParameterDescriptorGroup}.
+     *
+     * <p>The parameter descriptors created by this method are incomplete, since they
can not
+     * provide a non-null value for {@link ParameterDescriptor#getValueClass()}.</p>
+     */
+    private void setDescriptors(final GeneralParameterDescriptor[] descriptors) {
+        if (ReferencingUtilities.canSetProperty(DefaultOperationMethod.class,
+                "setDescriptors", "parameter", parameters != null))
+        {
+            if (descriptors.length == 1 && descriptors[0] instanceof ParameterDescriptorGroup)
{
+                parameters = (ParameterDescriptorGroup) descriptors[0];
+            } else {
+                parameters = new DefaultParameterDescriptorGroup(
+                        Collections.singletonMap(NAME_KEY, super.getName()), 1, 1, descriptors);
+            }
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java?rev=1698400&r1=1698399&r2=1698400&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -65,8 +65,10 @@
 @XmlAccessorType(XmlAccessType.NONE)
 @XmlJavaTypeAdapters({
     @XmlJavaTypeAdapter(EX_Extent.class),
+    @XmlJavaTypeAdapter(CI_Citation.class),
     @XmlJavaTypeAdapter(DQ_PositionalAccuracy.class),
-    @XmlJavaTypeAdapter(StringAdapter.class),
+    @XmlJavaTypeAdapter(CC_OperationMethod.class),
+    @XmlJavaTypeAdapter(CC_GeneralOperationParameter.class),
     @XmlJavaTypeAdapter(InternationalStringConverter.class)
 })
 package org.apache.sis.referencing.operation;
@@ -80,5 +82,7 @@ import javax.xml.bind.annotation.adapter
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.internal.jaxb.gco.*;
+import org.apache.sis.internal.jaxb.referencing.*;
 import org.apache.sis.internal.jaxb.metadata.EX_Extent;
+import org.apache.sis.internal.jaxb.metadata.CI_Citation;
 import org.apache.sis.internal.jaxb.metadata.DQ_PositionalAccuracy;

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java?rev=1698400&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -0,0 +1,127 @@
+/*
+ * 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.operation;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import org.opengis.parameter.GeneralParameterDescriptor;
+import javax.xml.bind.JAXBException;
+import javax.measure.unit.NonSI;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.xml.Namespaces;
+import org.apache.sis.xml.XML;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.XMLTestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.ReferencingAssert.*;
+import static org.apache.sis.metadata.iso.citation.Citations.EPSG;
+
+
+/**
+ * Tests XML (un)marshalling of various coordinate operation objects.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+@DependsOn({
+    DefaultOperationMethodTest.class,
+    org.apache.sis.parameter.ParameterMarshallingTest.class
+})
+public final strictfp class OperationMarshallingTest extends XMLTestCase {
+    /**
+     * Creates the test operation method.
+     */
+    private static DefaultOperationMethod createMercatorMethod() {
+        final ParameterBuilder builder = new ParameterBuilder();
+        builder.setCodeSpace(EPSG, "EPSG").setRequired(true);
+        ParameterDescriptor<?>[] parameters = {
+            builder.addName("Latitude of natural origin" ).create(0, NonSI.DEGREE_ANGLE),
+            builder.addName("Longitude of natural origin").create(0, NonSI.DEGREE_ANGLE)
+            // There is more parameters for a Mercator projection, but 2 is enough for this
test.
+        };
+        builder.addName(null, "Mercator");
+        final ParameterDescriptorGroup descriptor = builder.createGroup(parameters);
+        final Map<String,Object> properties = new HashMap<>(4);
+        properties.put(DefaultOperationMethod.NAME_KEY, descriptor.getName());
+        properties.put(DefaultOperationMethod.FORMULA_KEY, new DefaultFormula("See EPSG guide."));
+        return new DefaultOperationMethod(properties, 2, 2, descriptor);
+    }
+
+    /**
+     * Tests (un)marshalling of an operation method.
+     *
+     * @throws JAXBException if an error occurred during marshalling or unmarshalling.
+     */
+    @Test
+    public void testOperationMethod() throws JAXBException {
+        final String xml = XML.marshal(createMercatorMethod());
+        assertXmlEquals("<gml:OperationMethod xmlns:gml=\"" + Namespaces.GML + "\">\n"
+                      + "  <gml:name>Mercator</gml:name>\n"
+                      + "  <gml:formula>See EPSG guide.</gml:formula>\n"
+                      + "  <gml:sourceDimensions>2</gml:sourceDimensions>\n"
+                      + "  <gml:targetDimensions>2</gml:targetDimensions>\n"
+                      + "  <gml:parameter>\n"
+                      + "    <gml:OperationParameter gml:id=\"LatitudeOfNaturalOrigin\">\n"
+                      + "      <gml:name codeSpace=\"EPSG\">Latitude of natural origin</gml:name>\n"
+                      + "    </gml:OperationParameter>\n"
+                      + "  </gml:parameter>\n"
+                      + "  <gml:parameter>\n"
+                      + "    <gml:OperationParameter gml:id=\"LongitudeOfNaturalOrigin\">\n"
+                      + "      <gml:name codeSpace=\"EPSG\">Longitude of natural origin</gml:name>\n"
+                      + "    </gml:OperationParameter>\n"
+                      + "  </gml:parameter>\n"
+                      + "</gml:OperationMethod>", xml, "xmlns:*");
+
+        verifyMethod((DefaultOperationMethod) XML.unmarshal(xml));
+    }
+
+    /**
+     * Verifies the unmarshalled parameter descriptors.
+     */
+    private static void verifyMethod(final DefaultOperationMethod method) {
+        assertIdentifierEquals("name", null, null, null, "Mercator", method.getName());
+        assertEquals("formula", "See EPSG guide.", method.getFormula().getFormula().toString());
+        assertEquals("sourceDimensions", Integer.valueOf(2), method.getSourceDimensions());
+        assertEquals("targetDimensions", Integer.valueOf(2), method.getTargetDimensions());
+        final ParameterDescriptorGroup parameters = method.getParameters();
+        assertEquals("parameters.name", method.getName(), parameters.getName());
+        final Iterator<GeneralParameterDescriptor> it = parameters.descriptors().iterator();
+        verifyIncompleteDescriptor("Latitude of natural origin",  it.next());
+        verifyIncompleteDescriptor("Longitude of natural origin", it.next());
+        assertFalse("Unexpected parameter.", it.hasNext());
+    }
+
+    /**
+     * Verifies that the given parameter descriptor has the expected EPSG name. This method
does not
+     * verify that {@link ParameterDescriptor#getValueClass()} returns {@code Double.class},
because
+     * this information is not known to {@code OperationMethod}.
+     *
+     * @param name       The expected EPSG name.
+     * @param descriptor The parameter descriptor to verify.
+     */
+    private static void verifyIncompleteDescriptor(final String name, final GeneralParameterDescriptor
descriptor) {
+        assertIdentifierEquals("name", "##unrestricted", "EPSG", null, name, descriptor.getName());
+        assertEquals("maximumOccurs", 1, descriptor.getMaximumOccurs());
+        assertEquals("minimumOccurs", 1, descriptor.getMinimumOccurs());
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1698400&r1=1698399&r2=1698400&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Aug 28 19:42:47 2015
@@ -134,6 +134,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
     org.apache.sis.referencing.operation.DefaultTransformationTest.class,
     org.apache.sis.referencing.operation.DefaultConversionTest.class,
+    org.apache.sis.referencing.operation.OperationMarshallingTest.class,
     org.apache.sis.referencing.crs.DefaultProjectedCRSTest.class,
     org.apache.sis.referencing.crs.DefaultDerivedCRSTest.class,
     org.apache.sis.referencing.crs.SubTypesTest.class,



Mime
View raw message