sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1554675 - in /sis/branches/JDK7/core: sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/ sis-referencing/src/main/java/org/apache/sis/referencing/cs/ sis-referencing/src/test/java/org/apache/sis/referencing/ sis-refere...
Date Wed, 01 Jan 2014 21:01:26 GMT
Author: desruisseaux
Date: Wed Jan  1 21:01:25 2014
New Revision: 1554675

URL: http://svn.apache.org/r1554675
Log:
Completed unmarshalling test for DefaultEllipsoidalCS.

Added:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java   (with props)
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/GeoapiAssert.java
      - copied, changed from r1554591, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_AxisDirection.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -21,10 +21,9 @@ import org.apache.sis.internal.jaxb.gml.
 
 
 /**
- * JAXB adapter mapping implementing class to the GeoAPI interface. See
- * package documentation for more information about JAXB and interface.
+ * JAXB adapter for (un)marshalling of GeoAPI code list.
  *
- * @author Guilhem Legal (Geomatys)
+ * @author  Guilhem Legal (Geomatys)
  * @since   0.4 (derived from geotk-3.04)
  * @version 0.4
  * @module

Added: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java?rev=1554675&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CS_RangeMeaning.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -0,0 +1,57 @@
+/*
+ * 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 org.opengis.referencing.cs.RangeMeaning;
+import org.apache.sis.internal.jaxb.gml.CodeListAdapter;
+
+
+/**
+ * JAXB adapter for (un)marshalling of GeoAPI code list.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public final class CS_RangeMeaning extends CodeListAdapter<RangeMeaning> {
+    /**
+     * Empty constructor for JAXB only.
+     */
+    public CS_RangeMeaning() {
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@code RangeMeaning.class}
+     */
+    @Override
+    protected Class<RangeMeaning> getCodeListClass() {
+        return RangeMeaning.class;
+    }
+
+    /**
+     * Sets the default code space to {@code "EPSG"}.
+     *
+     * @return {@code "EPSG"}.
+     */
+    @Override
+    protected String getCodeSpace() {
+        return "EPSG";
+    }
+}

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

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

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -39,6 +39,7 @@ import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -144,12 +145,15 @@ public class DefaultCoordinateSystemAxis
 
     /**
      * Minimal and maximal value for this axis, or negative/positive infinity if none.
+     *
+     * Consider this field as final. It is not final only for XML unmarshalling.
      */
-    private final double minimum, maximum;
+    private double minimumValue, maximumValue;
 
     /**
      * The range meaning for this axis, or {@code null} if unspecified.
      */
+    @XmlElement
     private final RangeMeaning rangeMeaning;
 
     /**
@@ -163,8 +167,8 @@ public class DefaultCoordinateSystemAxis
         direction    = null;
         unit         = null;
         rangeMeaning = null;
-        minimum      = Double.NEGATIVE_INFINITY;
-        maximum      = Double.POSITIVE_INFINITY;
+        minimumValue = Double.NEGATIVE_INFINITY;
+        maximumValue = Double.POSITIVE_INFINITY;
     }
 
     /**
@@ -205,31 +209,37 @@ public class DefaultCoordinateSystemAxis
      * @param abbreviation The {@linkplain #getAbbreviation() abbreviation} used for this coordinate system axis.
      * @param direction    The {@linkplain #getDirection() direction} of this coordinate system axis.
      * @param unit         The {@linkplain #getUnit() unit of measure} used for this coordinate system axis.
-     * @param minimum      The minimum value normally allowed for this axis.
-     * @param maximum      The maximum value normally allowed for this axis.
-     * @param rangeMeaning The meaning of axis value range specified by the minimum and maximum values.
+     * @param minimumValue The minimum value normally allowed for this axis, or {@link Double#NEGATIVE_INFINITY} if none.
+     * @param maximumValue The maximum value normally allowed for this axis, or {@link Double#POSITIVE_INFINITY} if none.
+     * @param rangeMeaning The meaning of axis value range specified by the minimum and maximum values, or {@code null}
+     *                     if it does not apply. Shall not be null if the minimum and maximum values are not infinite.
      */
     public DefaultCoordinateSystemAxis(final Map<String,?> properties,
                                        final String        abbreviation,
                                        final AxisDirection direction,
                                        final Unit<?>       unit,
-                                       final double        minimum,
-                                       final double        maximum,
-                                       final RangeMeaning  rangeMeaning)
+                                       final double        minimumValue,
+                                       final double        maximumValue,
+                                             RangeMeaning  rangeMeaning)
     {
         super(properties);
         this.abbreviation = abbreviation;
         this.direction    = direction;
         this.unit         = unit;
-        this.minimum      = minimum;
-        this.maximum      = maximum;
-        this.rangeMeaning = rangeMeaning;
+        this.minimumValue = minimumValue;
+        this.maximumValue = maximumValue;
         ensureNonNull("abbreviation", abbreviation);
         ensureNonNull("direction",    direction);
         ensureNonNull("unit",         unit);
-        if (!(minimum < maximum)) { // Use '!' for catching NaN
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalRange_2, minimum, maximum));
+        if (!(minimumValue < maximumValue)) { // Use '!' for catching NaN
+            throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalRange_2, minimumValue, maximumValue));
+        }
+        if ((minimumValue != Double.NEGATIVE_INFINITY) || (maximumValue != Double.POSITIVE_INFINITY)) {
+            ensureNonNull("rangeMeaning", rangeMeaning);
+        } else {
+            rangeMeaning = null;
         }
+        this.rangeMeaning = rangeMeaning;
     }
 
     /**
@@ -258,13 +268,14 @@ public class DefaultCoordinateSystemAxis
         ensureNonNull("unit",         unit);
         double min = Double.NEGATIVE_INFINITY;
         double max = Double.POSITIVE_INFINITY;
-        RangeMeaning r = RangeMeaning.EXACT;
+        RangeMeaning r = null;
         if (Units.isAngular(unit)) {
             final UnitConverter fromDegrees = NonSI.DEGREE_ANGLE.getConverterTo(unit.asType(Angle.class));
             final AxisDirection dir = AxisDirections.absolute(direction);
             if (dir.equals(AxisDirection.NORTH)) {
                 min = fromDegrees.convert(Latitude.MIN_VALUE);
                 max = fromDegrees.convert(Latitude.MAX_VALUE);
+                r = RangeMeaning.EXACT;
             } else if (dir.equals(AxisDirection.EAST)) {
                 min = fromDegrees.convert(Longitude.MIN_VALUE);
                 max = fromDegrees.convert(Longitude.MAX_VALUE);
@@ -276,8 +287,8 @@ public class DefaultCoordinateSystemAxis
                 max = t;
             }
         }
-        minimum = min;
-        maximum = max;
+        minimumValue = min;
+        maximumValue = max;
         rangeMeaning = r;
     }
 
@@ -297,8 +308,8 @@ public class DefaultCoordinateSystemAxis
         abbreviation = axis.getAbbreviation();
         direction    = axis.getDirection();
         unit         = axis.getUnit();
-        minimum      = axis.getMinimumValue();
-        maximum      = axis.getMaximumValue();
+        minimumValue = axis.getMinimumValue();
+        maximumValue = axis.getMaximumValue();
         rangeMeaning = axis.getRangeMeaning();
     }
 
@@ -367,7 +378,29 @@ public class DefaultCoordinateSystemAxis
      */
     @Override
     public double getMinimumValue() {
-        return minimum;
+        return minimumValue;
+    }
+
+    /**
+     * Invoke by JAXB at marshalling time for fetching the minimum value, or {@code null} if none.
+     */
+    @XmlElement(name = "minimumValue")
+    private Double getMinimum() {
+        return (minimumValue != Double.NEGATIVE_INFINITY) ? minimumValue : null;
+    }
+
+    /**
+     * Invoked by JAXB at unmarshalling time for setting the minimum value.
+     */
+    private void setMinimum(final Double value) {
+        if (value != null) {
+            final double min = value.doubleValue();
+            if (min < maximumValue) {
+                minimumValue = min;
+            } else {
+                outOfRange("minimumValue", value);
+            }
+        }
     }
 
     /**
@@ -379,7 +412,41 @@ public class DefaultCoordinateSystemAxis
      */
     @Override
     public double getMaximumValue() {
-        return maximum;
+        return maximumValue;
+    }
+
+    /**
+     * Invoke by JAXB at marshalling time for fetching the maximum value, or {@code null} if none.
+     */
+    @XmlElement(name = "maximumValue")
+    private Double getMaximum() {
+        return (maximumValue != Double.POSITIVE_INFINITY) ? maximumValue : null;
+    }
+
+    /**
+     * Invoked by JAXB at unmarshalling time for setting the maximum value.
+     */
+    private void setMaximum(final Double value) {
+        if (value != null) {
+            final double max = value.doubleValue();
+            if (max > minimumValue) {
+                maximumValue = max;
+            } else {
+                outOfRange("maximumValue", value);
+            }
+        }
+    }
+
+    /**
+     * Invoked at unmarshalling time if a minimum or maximum value is out of range.
+     *
+     * @param name  The property name. Will also be used as "method" name for logging purpose,
+     *              since the setter method "conceptually" do not exist (it is only for JAXB).
+     * @param value The invalid value.
+     */
+    private static void outOfRange(final String name, final Double value) {
+        Context.warningOccured(Context.current(), DefaultCoordinateSystemAxis.class, name,
+                Errors.class, Errors.Keys.InconsistentAttribute_2, name, value);
     }
 
     /**
@@ -499,8 +566,8 @@ public class DefaultCoordinateSystemAxis
         if (compareMetadata) {
             if (!Objects.equals(this.abbreviation, that.abbreviation) ||
                 !Objects.equals(this.rangeMeaning, that.rangeMeaning) ||
-                Double.doubleToLongBits(minimum) != Double.doubleToLongBits(that.minimum) ||
-                Double.doubleToLongBits(maximum) != Double.doubleToLongBits(that.maximum))
+                Double.doubleToLongBits(minimumValue) != Double.doubleToLongBits(that.minimumValue) ||
+                Double.doubleToLongBits(maximumValue) != Double.doubleToLongBits(that.maximumValue))
             {
                 return false;
             }
@@ -564,7 +631,7 @@ public class DefaultCoordinateSystemAxis
          * differentiate this CoordinateSystemAxis implementation from implementations of other GeoAPI interfaces.
          */
         return serialVersionUID ^ (super.computeHashCode() + Objects.hashCode(unit) + Objects.hashCode(direction)
-                + Double.doubleToLongBits(minimum) + 31*Double.doubleToLongBits(maximum));
+                + Double.doubleToLongBits(minimumValue) + 31*Double.doubleToLongBits(maximumValue));
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -37,6 +37,7 @@
 @XmlJavaTypeAdapters({
     @XmlJavaTypeAdapter(CS_AxisDirection.class),
     @XmlJavaTypeAdapter(CS_CoordinateSystemAxis.class),
+    @XmlJavaTypeAdapter(CS_RangeMeaning.class),
     @XmlJavaTypeAdapter(UnitAdapter.class)
 })
 package org.apache.sis.referencing.cs;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -29,6 +29,7 @@ import org.opengis.referencing.datum.Ver
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.cs.EllipsoidalCS;
 import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.RangeMeaning;
 
 import static org.apache.sis.test.Assert.*;
 
@@ -228,10 +229,20 @@ public final strictfp class GeodeticObje
      * <tr><th>Property</th> <th>Expected value</th></tr>
      * <tr><td>{@linkplain EllipsoidalCS#getDimension() Dimension}</td>
      *     <td>2</td></tr>
-     * <tr><td>Axis names</td>
-     *     <td>{@code "Geodetic latitude"}, {@code "Geodetic longitude"}</td></tr>
-     * <tr><td>Axis directions</td>
-     *     <td>{@link AxisDirection#NORTH NORTH}, {@link AxisDirection#EAST EAST}</td></tr>
+     * <tr><td>Axis[0] name code</td>
+     *     <td>{@code "Geodetic latitude"}</td></tr>
+     * <tr><td>Axis[1] name code</td>
+     *     <td>{@code "Geodetic longitude"}</td></tr>
+     * <tr><td>Axis[0] {@linkplain CoordinateSystemAxis#getDirection() direction}</td>
+     *     <td>{@link AxisDirection#NORTH NORTH}</td></tr>
+     * <tr><td>Axis[1] {@linkplain CoordinateSystemAxis#getDirection() direction}</td>
+     *     <td>{@link AxisDirection#EAST EAST}</td></tr>
+     * <tr><td>Axes {@linkplain CoordinateSystemAxis#getUnit() units}</td>
+     *     <td>{@link NonSI#DEGREE_ANGLE}</td></tr>
+     * <tr><td>Axis[0] range</td>
+     *     <td>[-90 … 90] with {@link RangeMeaning#EXACT}, or all range properties missing</td></tr>
+     * <tr><td>Axis[1] range</td>
+     *     <td>[-180 … 180] with {@link RangeMeaning#WRAPAROUND}, or all range properties missing</td></tr>
      * </table>
      *
      * @param cs The coordinate system to verify.
@@ -242,9 +253,29 @@ public final strictfp class GeodeticObje
         final CoordinateSystemAxis longitude = cs.getAxis(1);
         assertNotNull("axis", latitude);
         assertNotNull("axis", longitude);
-        assertEquals("axis.name", "Geodetic latitude",  latitude .getName().getCode());
-        assertEquals("axis.name", "Geodetic longitude", longitude.getName().getCode());
-        assertEquals("axis.direction", AxisDirection.NORTH, latitude.getDirection());
-        assertEquals("axis.direction", AxisDirection.EAST, longitude.getDirection());
+        assertEquals("axis[0].name",      "Geodetic latitude",  latitude .getName().getCode());
+        assertEquals("axis[1].name",      "Geodetic longitude", longitude.getName().getCode());
+        assertEquals("axis[0].direction", AxisDirection.NORTH,  latitude .getDirection());
+        assertEquals("axis[1].direction", AxisDirection.EAST,   longitude.getDirection());
+        assertEquals("axis[0].unit",      NonSI.DEGREE_ANGLE,   latitude .getUnit());
+        assertEquals("axis[1].unit",      NonSI.DEGREE_ANGLE,   longitude.getUnit());
+        verifyRange(latitude,   -90,  +90, RangeMeaning.EXACT);
+        verifyRange(longitude, -180, +180, RangeMeaning.WRAPAROUND);
+    }
+
+    /**
+     * Asserts that the axis range is either fully missing, or defined to exactly the given properties.
+     */
+    private static void verifyRange(final CoordinateSystemAxis axis,
+            final double min, final double max, final RangeMeaning rm)
+    {
+        final double       minimumValue = axis.getMinimumValue();
+        final double       maximumValue = axis.getMaximumValue();
+        final RangeMeaning rangeMeaning = axis.getRangeMeaning();
+        if (minimumValue != Double.NEGATIVE_INFINITY || maximumValue != Double.POSITIVE_INFINITY || rangeMeaning != null) {
+            assertEquals("axis.minimumValue", min, minimumValue, STRICT);
+            assertEquals("axis.maximumValue", max, maximumValue, STRICT);
+            assertEquals("axis.rangeMeaning", rm,  rangeMeaning);
+        }
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -18,12 +18,15 @@ package org.apache.sis.referencing.cs;
 
 import javax.xml.bind.JAXBException;
 import org.opengis.test.Validators;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.cs.RangeMeaning;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.referencing.GeodeticObjectVerifier;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
 /**
@@ -57,5 +60,19 @@ public final strictfp class DefaultEllip
          */
         assertEquals("name",    "Latitude (north), Longitude (east)",     cs.getName().getCode());
         assertEquals("remarks", "Used in two-dimensional GeographicCRS.", cs.getRemarks().toString());
+        assertIdentifierEquals("identifier", "OGP", "EPSG", null, "6422", getSingleton(cs.getIdentifiers()));
+
+        final CoordinateSystemAxis latitude  = cs.getAxis(0);
+        final CoordinateSystemAxis longitude = cs.getAxis(1);
+        assertIdentifierEquals("axis[0].identifier", "OGP", "EPSG", null, "106", getSingleton(latitude.getIdentifiers()));
+        assertIdentifierEquals("axis[1].identifier", "OGP", "EPSG", null, "107", getSingleton(longitude.getIdentifiers()));
+        assertEquals("axis[0].abbreviation", "Lat",                   latitude .getAbbreviation());
+        assertEquals("axis[1].abbreviation", "Long",                  longitude.getAbbreviation());
+        assertEquals("axis[0].rangeMeaning", RangeMeaning.EXACT,      latitude .getRangeMeaning());
+        assertEquals("axis[1].abbreviation", RangeMeaning.WRAPAROUND, longitude.getRangeMeaning());
+        /*
+         * Minimum and maximum values have been verified by GeodeticObjectVerifier.assertIsGeodetic2D(cs)
+         * if range meanings were not null.
+         */
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml Wed Jan  1 21:01:25 2014
@@ -33,7 +33,7 @@
       <gml:axisDirection codeSpace="EPSG">north</gml:axisDirection>
       <gml:minimumValue>-90</gml:minimumValue>
       <gml:maximumValue>+90</gml:maximumValue>
-      <gml:rangeMeaning codeSpace="EPSG">wraparound</gml:rangeMeaning>
+      <gml:rangeMeaning codeSpace="EPSG">exact</gml:rangeMeaning>
     </gml:CoordinateSystemAxis>
   </gml:axis>
   <gml:axis>
@@ -44,7 +44,7 @@
       <gml:axisDirection codeSpace="EPSG">east</gml:axisDirection>
       <gml:minimumValue>-180</gml:minimumValue>
       <gml:maximumValue>+180</gml:maximumValue>
-      <gml:rangeMeaning codeSpace="EPSG">exact</gml:rangeMeaning>
+      <gml:rangeMeaning codeSpace="EPSG">wraparound</gml:rangeMeaning>
     </gml:CoordinateSystemAxis>
   </gml:axis>
 </gml:EllipsoidalCS>

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1554675&r1=1554674&r2=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -29,7 +29,6 @@ import java.io.ByteArrayOutputStream;
 import javax.swing.tree.TreeNode;
 import javax.xml.parsers.ParserConfigurationException;
 import org.xml.sax.SAXException;
-import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
@@ -46,7 +45,7 @@ import java.util.Objects;
  * @version 0.3
  * @module
  */
-public strictfp class Assert extends org.opengis.test.Assert {
+public strictfp class Assert extends GeoapiAssert {
     /**
      * For subclass constructor only.
      */
@@ -54,33 +53,6 @@ public strictfp class Assert extends org
     }
 
     /**
-     * Asserts that the given matrix is equals to the expected one, up to the given tolerance value.
-     *
-     * @param message   Header of the exception message in case of failure, or {@code null} if none.
-     * @param expected  The expected matrix.
-     * @param actual    The matrix to compare.
-     * @param tolerance The tolerance threshold.
-     */
-    public static void assertMatrixEquals(final String message, final Matrix expected, final Matrix actual, final double tolerance) {
-        if (TestCase.PENDING_NEXT_GEOAPI_RELEASE) {
-            // TODO: Remove this method, so we inherit the GeoAPI one instead.
-        }
-        final int numRow = actual.getNumRow();
-        final int numCol = actual.getNumCol();
-        assertEquals("numRow", expected.getNumRow(), numRow);
-        assertEquals("numCol", expected.getNumCol(), numCol);
-        for (int j=0; j<numRow; j++) {
-            for (int i=0; i<numCol; i++) {
-                final double e = expected.getElement(j,i);
-                final double a = actual.getElement(j,i);
-                if (!(StrictMath.abs(e - a) <= tolerance) && Double.doubleToLongBits(a) != Double.doubleToLongBits(e)) {
-                    fail("Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a);
-                }
-            }
-        }
-    }
-
-    /**
      * Asserts that the two given objects are not equal.
      * This method tests all {@link ComparisonMode} except {@code DEBUG}.
      *

Copied: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/GeoapiAssert.java (from r1554591, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/GeoapiAssert.java?p2=sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/GeoapiAssert.java&p1=sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java&r1=1554591&r2=1554675&rev=1554675&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/GeoapiAssert.java [UTF-8] Wed Jan  1 21:01:25 2014
@@ -16,371 +16,148 @@
  */
 package org.apache.sis.test;
 
-import java.util.Set;
-import java.util.Map;
-import java.util.Enumeration;
-import java.util.LinkedHashSet;
-import java.util.LinkedHashMap;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import javax.swing.tree.TreeNode;
-import javax.xml.parsers.ParserConfigurationException;
-import org.xml.sax.SAXException;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.referencing.operation.Matrix;
-import org.apache.sis.util.Utilities;
-import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.ComparisonMode;
+import org.opengis.util.InternationalString;
 
-// Related to JDK7
-import java.util.Objects;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 
 /**
- * Assertion methods used by the SIS project in addition of the JUnit and GeoAPI assertions.
+ * Temporary class for test methods that are expected to be provided in next GeoAPI release.
+ * Those methods are defined in a separated class in order to make easier for us to identify
+ * which methods may be removed from SIS (actually moved to GeoAPI) in a future GeoAPI release.
+ *
+ * <p>This class is needed for Apache SIS trunk, since the later is linked to GeoAPI official release.
+ * But this class can be removed on Apache SIS branches which are linked to a GeoAPI development branch.</p>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
  * @module
+ *
+ * @see TestCase#PENDING_NEXT_GEOAPI_RELEASE
  */
-public strictfp class Assert extends org.opengis.test.Assert {
+strictfp class GeoapiAssert extends org.opengis.test.Assert {
     /**
-     * For subclass constructor only.
+     * The keyword for unrestricted value in {@link String} arguments.
      */
-    protected Assert() {
-    }
+    private static final String UNRESTRICTED = "##unrestricted";
 
     /**
-     * Asserts that the given matrix is equals to the expected one, up to the given tolerance value.
-     *
-     * @param message   Header of the exception message in case of failure, or {@code null} if none.
-     * @param expected  The expected matrix.
-     * @param actual    The matrix to compare.
-     * @param tolerance The tolerance threshold.
-     */
-    public static void assertMatrixEquals(final String message, final Matrix expected, final Matrix actual, final double tolerance) {
-        if (TestCase.PENDING_NEXT_GEOAPI_RELEASE) {
-            // TODO: Remove this method, so we inherit the GeoAPI one instead.
-        }
-        final int numRow = actual.getNumRow();
-        final int numCol = actual.getNumCol();
-        assertEquals("numRow", expected.getNumRow(), numRow);
-        assertEquals("numCol", expected.getNumCol(), numCol);
-        for (int j=0; j<numRow; j++) {
-            for (int i=0; i<numCol; i++) {
-                final double e = expected.getElement(j,i);
-                final double a = actual.getElement(j,i);
-                if (!(StrictMath.abs(e - a) <= tolerance) && Double.doubleToLongBits(a) != Double.doubleToLongBits(e)) {
-                    fail("Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a);
-                }
-            }
-        }
-    }
-
-    /**
-     * 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.
-     */
-    public static void assertNotDeepEquals(final Object o1, final Object o2) {
-        assertNotSame("same", o1, o2);
-        assertFalse("equals",                      Objects  .equals    (o1, o2));
-        assertFalse("deepEquals",                  Objects  .deepEquals(o1, o2));
-        assertFalse("deepEquals(STRICT)",          Utilities.deepEquals(o1, o2, ComparisonMode.STRICT));
-        assertFalse("deepEquals(BY_CONTRACT)",     Utilities.deepEquals(o1, o2, ComparisonMode.BY_CONTRACT));
-        assertFalse("deepEquals(IGNORE_METADATA)", Utilities.deepEquals(o1, o2, ComparisonMode.IGNORE_METADATA));
-        assertFalse("deepEquals(APPROXIMATIVE)",   Utilities.deepEquals(o1, o2, ComparisonMode.APPROXIMATIVE));
-    }
-
-    /**
-     * Asserts that the two given objects are approximatively equal, while slightly different.
-     * More specifically, this method asserts that the given objects are equal according the
-     * {@link ComparisonMode#APPROXIMATIVE} criterion, but not equal according the
-     * {@link ComparisonMode#IGNORE_METADATA} criterion.
-     *
-     * @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));
-        assertFalse("Shall be slightly different",           Utilities.deepEquals(expected, actual, ComparisonMode.IGNORE_METADATA));
-        assertTrue ("Shall be approximatively equals",       Utilities.deepEquals(expected, actual, ComparisonMode.DEBUG));
-        assertTrue ("DEBUG inconsistent with APPROXIMATIVE", Utilities.deepEquals(expected, actual, ComparisonMode.APPROXIMATIVE));
-    }
-
-    /**
-     * 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.
+     * For subclass constructor only.
      */
-    public static void assertEqualsIgnoreMetadata(final Object expected, final Object actual) {
-        assertTrue("Shall be approximatively equals",       Utilities.deepEquals(expected, actual, ComparisonMode.DEBUG));
-        assertTrue("DEBUG inconsistent with APPROXIMATIVE", Utilities.deepEquals(expected, actual, ComparisonMode.APPROXIMATIVE));
-        assertTrue("Shall be equal, ignoring metadata",     Utilities.deepEquals(expected, actual, ComparisonMode.IGNORE_METADATA));
+    GeoapiAssert() {
     }
 
     /**
-     * Asserts that two strings are equal, ignoring the differences in EOL characters.
-     * The comparisons is performed one a line-by-line basis. For each line, leading
-     * and trailing spaces are ignored in order to make the comparison independent of
-     * indentation.
+     * Returns the concatenation of the given message with the given extension.
+     * This method returns the given extension if the message is null or empty.
      *
-     * @param expected The expected string.
-     * @param actual   The actual string.
-     */
-    public static void assertMultilinesEquals(final CharSequence expected, final CharSequence actual) {
-        assertArrayEquals(CharSequences.split(expected, '\n'), CharSequences.split(actual, '\n'));
-    }
-
-    /**
-     * Asserts that two strings are equal, ignoring the differences in EOL characters.
-     * The comparisons is performed one a line-by-line basis. For each line, leading
-     * and trailing spaces are ignored in order to make the comparison independent of
-     * indentation.
+     * <p>Invoking this method is equivalent to invoking {@code nonNull(message) + ext},
+     * but avoid the creation of temporary objects in the common case where the message
+     * is null.</p>
      *
-     * @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, or {@code null}.
+     * @param  ext The extension to append after the message.
+     * @return The concatenated string.
      */
-    public static void assertMultilinesEquals(final String message, final CharSequence expected, final CharSequence actual) {
-        assertArrayEquals(message, CharSequences.split(expected, '\n'), CharSequences.split(actual, '\n'));
-    }
-
-    /**
-     * Asserts that the given set contains the same elements.
-     * In case of failure, this method lists the missing or unexpected elements.
-     *
-     * @param expected The expected set, or {@code null}.
-     * @param actual   The actual set, or {@code null}.
-     */
-    public static void assertSetEquals(final Set<?> expected, final Set<?> actual) {
-        if (expected != null && actual != null && !expected.isEmpty()) {
-            final Set<Object> r = new LinkedHashSet<>(expected);
-            assertTrue("The two sets are disjoint.",                 r.removeAll(actual));
-            assertTrue("The set is missing elements: " + r,          r.isEmpty());
-            assertTrue("The set unexpectedly became empty.",         r.addAll(actual));
-            assertTrue("The two sets are disjoint.",                 r.removeAll(expected));
-            assertTrue("The set contains unexpected elements: " + r, r.isEmpty());
+    private static String concat(String message, final String ext) {
+        if (message == null || (message = message.trim()).isEmpty()) {
+            return ext;
         }
-        assertEquals("Set.equals(Object) failed:", expected, actual);
+        return message + ' ' + ext;
     }
 
     /**
-     * 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}.
+     * Verifies if we expected a null value, then returns {@code true} if the value is null as expected.
      */
-    public static void assertMapEquals(final Map<?,?> expected, final Map<?,?> actual) {
-        if (expected != null && actual != null && !expected.isEmpty()) {
-            final Map<Object,Object> r = new LinkedHashMap<>(expected);
-            for (final Map.Entry<?,?> entry : actual.entrySet()) {
-                final Object key = entry.getKey();
-                if (!r.containsKey(key)) {
-                    fail("Unexpected entry for key " + key);
-                }
-                final Object ve = r.remove(key);
-                final Object va = entry.getValue();
-                if (!Objects.equals(ve, va)) {
-                    fail("Wrong value for key " + key + ": expected " + ve + " but got " + va);
-                }
-            }
-            if (!r.isEmpty()) {
-                fail("The map is missing entries: " + r);
-            }
-            r.putAll(actual);
-            for (final Map.Entry<?,?> entry : expected.entrySet()) {
-                final Object key = entry.getKey();
-                if (!r.containsKey(key)) {
-                    fail("Missing an entry for key " + key);
-                }
-                final Object ve = entry.getValue();
-                final Object va = r.remove(key);
-                if (!Objects.equals(ve, va)) {
-                    fail("Wrong value for key " + key + ": expected " + ve + " but got " + va);
-                }
-            }
-            if (!r.isEmpty()) {
-                fail("The map contains unexpected elements:" + r);
-            }
+    private static boolean isNull(final String message, final Object expected, final Object actual) {
+        final boolean isNull = (actual == null);
+        if (isNull != (expected == null)) {
+            fail(concat(message, isNull ? "Value is null." : "Expected null."));
         }
-        assertEquals("Map.equals(Object) failed:", expected, actual);
+        return isNull;
     }
 
     /**
-     * Ensures that a tree is equals to an other tree.
-     * This method invokes itself recursively for every child nodes.
+     * Asserts that the title or an alternate title of the given citation is equal to the given string.
+     * This method is typically used for testing if a citation stands for the OGC, OGP or EPSG authority
+     * for instance. Such abbreviations are often declared as {@linkplain Citation#getAlternateTitles()
+     * alternate titles} rather than the main {@linkplain Citation#getTitle() title}, but this method
+     * tests both for safety.
      *
-     * @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 message  Header of the exception message in case of failure, or {@code null} if none.
+     * @param expected The expected title or alternate title.
+     * @param actual   The citation to test.
      */
-    public static int assertTreeEquals(final TreeNode expected, final TreeNode actual) {
-        if (expected == null) {
-            assertNull(actual);
-            return 0;
+    public static void assertTitleEquals(final String message, final String expected, final Citation actual) {
+        if (isNull(message, expected, actual)) {
+            return;
         }
-        int n = 1;
-        assertNotNull(actual);
-        assertEquals("isLeaf()",            expected.isLeaf(),            actual.isLeaf());
-        assertEquals("getAllowsChildren()", expected.getAllowsChildren(), actual.getAllowsChildren());
-        assertEquals("getChildCount()",     expected.getChildCount(),     actual.getChildCount());
-        @SuppressWarnings("unchecked") final Enumeration<? extends TreeNode> ec = expected.children();
-        @SuppressWarnings("unchecked") final Enumeration<? extends TreeNode> ac = actual  .children();
-
-        int childIndex = 0;
-        while (ec.hasMoreElements()) {
-            assertTrue("hasMoreElements()", ac.hasMoreElements());
-            final TreeNode nextExpected = ec.nextElement();
-            final TreeNode nextActual   = ac.nextElement();
-            final String message = "getChildAt(" + childIndex + ')';
-            assertSame(message, nextExpected, expected.getChildAt(childIndex));
-            assertSame(message, nextActual,   actual  .getChildAt(childIndex));
-            assertSame("getParent()", expected, nextExpected.getParent());
-            assertSame("getParent()", actual,   nextActual  .getParent());
-            assertSame("getIndex(TreeNode)", childIndex, expected.getIndex(nextExpected));
-            assertSame("getIndex(TreeNode)", childIndex, actual  .getIndex(nextActual));
-            n += assertTreeEquals(nextExpected, nextActual);
-            childIndex++;
+        InternationalString title = actual.getTitle();
+        if (title != null && expected.equals(title.toString())) {
+            return;
         }
-        assertFalse("hasMoreElements()", ac.hasMoreElements());
-        assertEquals("toString()", expected.toString(), actual.toString());
-        return n;
-    }
-
-    /**
-     * Parses two XML tree as DOM documents, and compares the nodes.
-     * The inputs given to this method can be any of the following types:
-     *
-     * <ul>
-     *   <li>{@link org.w3c.dom.Node}: used directly without further processing.</li>
-     *   <li>{@link java.io.File}, {@link java.net.URL} or {@link java.net.URI}: the
-     *       stream is opened and parsed as a XML document.</li>
-     *   <li>{@link String}: The string content is parsed directly as a XML document.</li>
-     * </ul>
-     *
-     * This method will ignore comments and the optional attributes given in arguments.
-     *
-     * {@section Ignored attributes substitution}
-     * For convenience, this method replaces some well known prefixes in the {@code ignoredAttributes}
-     * array by their full namespace URLs. For example this method replaces{@code "xsi:schemaLocation"}
-     * by {@code "http://www.w3.org/2001/XMLSchema-instance:schemaLocation"}.
-     * If such substitution is not desired, consider using {@link XMLComparator} directly instead.
-     *
-     * <p>The current substitution map is as below (may be expanded in any future SIS version):</p>
-     *
-     * <table class="sis">
-     *   <tr><th>Prefix</th> <th>URL</th></tr>
-     *   <tr><td>xmlns</td>  <td>{@code "http://www.w3.org/2000/xmlns"}</td></tr>
-     *   <tr><td>xlink</td>  <td>{@value org.apache.sis.xml.Namespaces#XLINK}</td></tr>
-     *   <tr><td>xsi</td>    <td>{@value org.apache.sis.xml.Namespaces#XSI}</td></tr>
-     *   <tr><td>gml</td>    <td>{@value org.apache.sis.xml.Namespaces#GML}</td></tr>
-     *   <tr><td>gmd</td>    <td>{@value org.apache.sis.xml.Namespaces#GMD}</td></tr>
-     *   <tr><td>gmx</td>    <td>{@value org.apache.sis.xml.Namespaces#GMX}</td></tr>
-     *   <tr><td>gmi</td>    <td>{@value org.apache.sis.xml.Namespaces#GMI}</td></tr>
-     *   <tr><td>gco</td>    <td>{@value org.apache.sis.xml.Namespaces#GCO}</td></tr>
-     * </table>
-     *
-     * <p>For example in order to ignore the namespace, type and schema location declaration,
-     * the following strings can be given to the {@code ignoredAttributes} argument:</p>
-     *
-     * {@preformat text
-     *   "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"}).
-     *
-     * @see XMLComparator
-     */
-    public static void assertXmlEquals(final Object expected, final Object actual,
-            final String... ignoredAttributes)
-    {
-        assertXmlEquals(expected, actual, 0, ignoredAttributes);
+        for (final InternationalString t : actual.getAlternateTitles()) {
+            if (expected.equals(t.toString())) {
+                return;
+            }
+        }
+        fail(concat(message, '"' + expected + "\" not found in title or alternate titles."));
     }
 
     /**
-     * Parses two XML tree as DOM documents, and compares the nodes with the given tolerance
-     * threshold for numerical values. The inputs given to this method can be any of the types
-     * documented {@linkplain #assertXmlEquals(Object, Object, String[]) above}. This method
-     * 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  ignoredAttributes The fully-qualified names of attributes to ignore
-     *         (typically {@code "xmlns:*"} and {@code "xsi:schemaLocation"}).
+     * Asserts that the given identifier is equals to the given authority, code space, version and code.
+     * If any of the above-cited properties is {@code ""##unrestricted"}, then it will not be verified.
+     * This flexibility is useful in the common case where a test accepts any {@code version} value.
      *
-     * @see XMLComparator
+     * @param message    Header of the exception message in case of failure, or {@code null} if none.
+     * @param authority  The expected authority title or alternate title (may be {@code null}), or {@code "##unrestricted"}.
+     * @param codeSpace  The expected code space (may be {@code null}), or {@code "##unrestricted"}.
+     * @param version    The expected version    (may be {@code null}), or {@code "##unrestricted"}.
+     * @param code       The expected code value (may be {@code null}), or {@code "##unrestricted"}.
+     * @param actual     The identifier to test.
      */
-    public static void assertXmlEquals(final Object expected, final Object actual,
-            final double tolerance, final String... ignoredAttributes)
+    public static void assertIdentifierEquals(final String message, final String authority, final String codeSpace,
+            final String version, final String code, final ReferenceIdentifier actual)
     {
-        final XMLComparator comparator;
-        try {
-            comparator = new XMLComparator(expected, actual);
-        } catch (IOException | ParserConfigurationException | SAXException e) {
-            // We don't throw directly those exceptions since failing to parse the XML file can
-            // be considered as part of test failures and the JUnit exception for such failures
-            // is AssertionError. Having no checked exception in "assert" methods allow us to
-            // declare the checked exceptions only for the library code being tested.
-            throw new AssertionError(e);
-        }
-        comparator.tolerance = tolerance;
-        comparator.ignoreComments = true;
-        for (final String attribute : ignoredAttributes) {
-            comparator.ignoredAttributes.add(XMLComparator.substitutePrefix(attribute));
+        if (actual == null) {
+            fail(concat(message, "Identifier is null"));
+        } else {
+            if (!UNRESTRICTED.equals(authority)) assertTitleEquals(message,                         authority, actual.getAuthority());
+            if (!UNRESTRICTED.equals(codeSpace)) assertEquals (concat(message, "Wrong code space"), codeSpace, actual.getCodeSpace());
+            if (!UNRESTRICTED.equals(version))   assertEquals (concat(message, "Wrong version"),    version,   actual.getVersion());
+            if (!UNRESTRICTED.equals(code))      assertEquals (concat(message, "Wrong code"),       code,      actual.getCode());
         }
-        comparator.compare();
     }
 
     /**
-     * Serializes the given object in memory, deserialize it and ensures that the deserialized
-     * object is equals to the original one. This method doesn't write anything to the disk.
-     *
-     * <p>If the serialization fails, then this method thrown an {@link AssertionError}
-     * as do the other JUnit assertion methods.</p>
+     * Asserts that the given matrix is equals to the expected one, up to the given tolerance value.
      *
-     * @param  <T> The type of the object to serialize.
-     * @param  object The object to serialize.
-     * @return The deserialized object.
+     * @param message   Header of the exception message in case of failure, or {@code null} if none.
+     * @param expected  The expected matrix, which may be {@code null}.
+     * @param actual    The matrix to compare, or {@code null}.
+     * @param tolerance The tolerance threshold.
      */
-    public static <T> T assertSerializedEquals(final T object) {
-        final Object deserialized;
-        try {
-            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-            try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
-                out.writeObject(object);
-            }
-            // Now reads the object we just serialized.
-            final byte[] data = buffer.toByteArray();
-            try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data))) {
-                try {
-                    deserialized = in.readObject();
-                } catch (ClassNotFoundException e) {
-                    throw new AssertionError(e);
+    public static void assertMatrixEquals(final String message, final Matrix expected, final Matrix actual, final double tolerance) {
+        if (isNull(message, expected, actual)) {
+            return;
+        }
+        final int numRow = actual.getNumRow();
+        final int numCol = actual.getNumCol();
+        assertEquals("numRow", expected.getNumRow(), numRow);
+        assertEquals("numCol", expected.getNumCol(), numCol);
+        for (int j=0; j<numRow; j++) {
+            for (int i=0; i<numCol; i++) {
+                final double e = expected.getElement(j,i);
+                final double a = actual.getElement(j,i);
+                if (!(StrictMath.abs(e - a) <= tolerance) && Double.doubleToLongBits(a) != Double.doubleToLongBits(e)) {
+                    fail("Matrix.getElement(" + j + ", " + i + "): expected " + e + " but got " + a);
                 }
             }
-        } catch (IOException e) {
-            throw new AssertionError(e.toString(), e);
         }
-        // Compares with the original object and returns it.
-        @SuppressWarnings("unchecked")
-        final Class<? extends T> type = (Class<? extends T>) object.getClass();
-        assertEquals("Deserialized object not equal to the original one.", object, deserialized);
-        assertEquals("Deserialized object has a different hash code.",
-                object.hashCode(), deserialized.hashCode());
-        return type.cast(deserialized);
     }
 }



Mime
View raw message