sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1653029 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ sis-metadata/src/test/java/org/apache/sis/metadata/ sis-metadata/src/test/j...
Date Mon, 19 Jan 2015 15:27:06 GMT
Author: desruisseaux
Date: Mon Jan 19 15:27:06 2015
New Revision: 1653029

URL: http://svn.apache.org/r1653029
Log:
Added tests for DefaultOperationMethod. Consolidated some other tests as a side-effect.

Added:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameMeaning.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -23,6 +23,7 @@ import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
 import org.opengis.referencing.operation.*;
 import org.apache.sis.util.Static;
+import org.apache.sis.internal.util.Citations;
 
 
 /**
@@ -90,7 +91,7 @@ public final class NameMeaning extends S
      * @return {@code true} if the given code space is known to use the URN syntax.
      */
     public static boolean usesURN(final String codeSpace) {
-        return (codeSpace != null) && codeSpace.equalsIgnoreCase("EPSG");
+        return (codeSpace != null) && codeSpace.equalsIgnoreCase(Citations.EPSG);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -38,6 +38,9 @@ import org.apache.sis.util.resources.Err
  * This class searches for the {@link org.apache.sis.internal.referencing.ServicesForMetadata}
  * implementation using Java reflection.
  *
+ * <p>This class also opportunistically defines some constants related to "referencing
by coordinates"
+ * but needed by metadata.</p>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.18)
  * @version 0.5
@@ -45,12 +48,13 @@ import org.apache.sis.util.resources.Err
  */
 public abstract class ReferencingServices extends SystemListener {
     /**
-     * The length of one nautical mile, in metres.
+     * The length of one nautical mile, which is {@value} metres.
      */
     public static final double NAUTICAL_MILE = 1852;
 
     /**
-     * The GRS80 {@linkplain org.apache.sis.referencing.datum.DefaultEllipsoid#getAuthalicRadius()
authalic radius}.
+     * The GRS80 {@linkplain org.apache.sis.referencing.datum.DefaultEllipsoid#getAuthalicRadius()
authalic radius},
+     * which is {@value} metres.
      */
     public static final double AUTHALIC_RADIUS = 6371007;
 

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -18,9 +18,9 @@ package org.apache.sis.metadata.iso.cita
 
 import org.opengis.metadata.citation.Citation;
 import org.apache.sis.util.Static;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.xml.IdentifierSpace;
 import org.apache.sis.internal.simple.SimpleCitation;
-import org.apache.sis.util.CharSequences;
 
 
 /**
@@ -125,11 +125,17 @@ public final class Citations extends Sta
     public static final IdentifierSpace<String> PROJ4 = new Authority<>("Proj.4",
"PROJ4");
 
     /**
-     * The <a href="http://www.epsg.org">European Petroleum Survey Group</a>
authority.
-     * This citation is used as an authority for
+     * The <a href="http://www.epsg.org">EPSG</a> dataset. This citation is used
as an authority for
      * {@linkplain org.opengis.referencing.crs.CoordinateReferenceSystem coordinate reference
system}
      * identifiers.
      *
+     * <div class="note"><b>Historical note:</b>
+     * The EPSG acronym meaning was <cite>European Petroleum Survey Group</cite>.
+     * But this meaning does not apply anymore since the European and American associations
merged
+     * into the <cite>International Association of Oil &amp; Gas producers</cite>
(IOGP).
+     * The legacy acronym now applies only to the database Coordinate Reference System definitions,
+     * known as <cite>EPSG dataset</cite>.</div>
+     *
      * @see #OGP
      * @see #AUTO
      * @see #AUTO2
@@ -138,7 +144,9 @@ public final class Citations extends Sta
      *
      * @since 0.4
      */
-    public static final IdentifierSpace<Integer> EPSG = new Authority<>("EPSG",
"EPSG");
+    public static final IdentifierSpace<Integer> EPSG = new Authority<>(
+            org.apache.sis.internal.util.Citations.EPSG,
+            org.apache.sis.internal.util.Citations.EPSG);
 
     /**
      * <cite>International Standard Book Number</cite> (ISBN) defined by ISO-2108.

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -40,7 +40,7 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static java.util.Collections.singleton;
-import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
@@ -253,7 +253,7 @@ public final strictfp class MetadataStan
         assertEquals("title", "European Petroleum Survey Group", map.get("getTitle").toString());
         final Object identifiers = map.get("identifiers");
         assertInstanceOf("identifiers", Collection.class, identifiers);
-        HardCodedCitations.assertIdentifiersFor("EPSG", (Collection<?>) identifiers);
+        assertContainsIdentifierCode("EPSG", (Collection<?>) identifiers);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -63,7 +63,7 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static java.util.Collections.singleton;
-import static org.opengis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 import static org.apache.sis.test.TestUtilities.getSingleton;
 import static org.apache.sis.metadata.PropertyAccessor.APPEND;
 import static org.apache.sis.metadata.PropertyAccessor.RETURN_NULL;
@@ -294,7 +294,7 @@ public final strictfp class PropertyAcce
         // Collection of Identifiers
         final Object identifiers = accessor.get(accessor.indexOf("identifiers", true), instance);
         assertInstanceOf("identifiers", Collection.class, identifiers);
-        HardCodedCitations.assertIdentifiersFor("ISO", (Collection<?>) identifiers);
+        assertContainsIdentifierCode("ISO", (Collection<?>) identifiers);
     }
 
     /**
@@ -608,7 +608,7 @@ public final strictfp class PropertyAcce
         assertInstanceOf("identifiers", Collection.class, target);
         assertNotSame("Distinct objects shall have distinct collections.", source, target);
         assertEquals ("The two collections shall have the same content.",  source, target);
-        HardCodedCitations.assertIdentifiersFor("EPSG", (Collection<?>) target);
+        assertContainsIdentifierCode("EPSG", (Collection<?>) target);
 
         // Set the identifiers to null, which should clear the collection.
         assertEquals("Expected the previous value.", source, accessor.set(index, citation,
null, RETURN_PREVIOUS));

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -17,8 +17,6 @@
 package org.apache.sis.metadata.iso.citation;
 
 import java.net.URI;
-import java.util.Collection;
-import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Role;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.OnLineFunction;
@@ -27,7 +25,6 @@ import org.apache.sis.metadata.iso.Defau
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.util.Static;
 
-import static org.opengis.test.Assert.*;
 import static java.util.Collections.singleton;
 
 
@@ -40,7 +37,7 @@ import static java.util.Collections.sing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.4)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final strictfp class HardCodedCitations extends Static {
@@ -169,23 +166,4 @@ public final strictfp class HardCodedCit
      */
     private HardCodedCitations() {
     }
-
-    /**
-     * Asserts that the given {@linkplain Identifier#getCode() identifier code}
-     * is found in the collection of identifiers.
-     *
-     * @param expected The expected identifier code (typically {@code "ISO"} or {@code "EPSG"}).
-     * @param identifiers The collection to validate. Should be a collection of {@link Identifier}.
-     */
-    public static void assertIdentifiersFor(final String expected, final Collection<?>
identifiers) {
-        assertNotNull("identifiers", identifiers);
-        int count = 0;
-        for (final Object id : identifiers) {
-            assertInstanceOf("identifier", Identifier.class, id);
-            if (((Identifier) id).getCode().equals(expected)) {
-                count++;
-            }
-        }
-        assertEquals("Unexpected amount of identifiers.", 1, count);
-    }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -16,10 +16,13 @@
  */
 package org.apache.sis.test;
 
+import java.util.Collection;
+import org.opengis.metadata.Identifier;
 import org.opengis.referencing.IdentifiedObject;
 import org.apache.sis.io.wkt.Symbols;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.internal.util.Citations;
 
 
 /**
@@ -28,7 +31,7 @@ import org.apache.sis.io.wkt.Convention;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4 (derived from geotk-3.00)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public strictfp class MetadataAssert extends Assert {
@@ -51,6 +54,44 @@ public strictfp class MetadataAssert ext
     }
 
     /**
+     * Asserts that the given identifier has the expected code and the {@code "EPSG"} code
space.
+     * The authority is expected to have the {@code "OGP"} title or alternate title.
+     *
+     * @param expected   The expected identifier code.
+     * @param identifier The identifier to verify.
+     *
+     * @since 0.5
+     */
+    public static void assertEpsgIdentifierEquals(final String expected, final Identifier
identifier) {
+        assertNotNull(identifier);
+        assertEquals("code",      expected, identifier.getCode());
+        assertEquals("codeSpace", Citations.EPSG, identifier.getCodeSpace());
+        assertEquals("authority", "OGP",  Citations.getIdentifier(identifier.getAuthority()));
+    }
+
+    /**
+     * Asserts that the given collection contains exactly one identifier with the given
+     * {@linkplain Identifier#getCode() code}. The {@linkplain Identifier#getCodeSpace()
+     * code space} and authority are ignored.
+     *
+     * @param expected The expected identifier code (typically {@code "ISO"} or {@code "EPSG"}).
+     * @param identifiers The collection to validate. Should be a collection of {@link Identifier}.
+     *
+     * @since 0.5
+     */
+    public static void assertContainsIdentifierCode(final String expected, final Collection<?>
identifiers) {
+        assertNotNull("identifiers", identifiers);
+        int count = 0;
+        for (final Object id : identifiers) {
+            assertInstanceOf("identifier", Identifier.class, id);
+            if (((Identifier) id).getCode().equals(expected)) {
+                count++;
+            }
+        }
+        assertEquals("Unexpected amount of identifiers.", 1, count);
+    }
+
+    /**
      * Asserts that the WKT 2 of the given object is equal to the expected one.
      * This method expected the {@code “…”} quotation marks instead of {@code "…"}
      * for easier readability of {@link String} constants in Java code.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/HardCoded.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.referencing;
 
 import org.apache.sis.util.Static;
+import org.apache.sis.internal.util.Citations;
 
 
 /**
@@ -31,7 +32,7 @@ public final class HardCoded extends Sta
     /**
      * The {@value} code space.
      */
-    public static final String EPSG = "EPSG";
+    public static final String EPSG = Citations.EPSG;
 
     /**
      * The {@value} code space.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -410,8 +410,8 @@ public class AbstractDatum extends Abstr
                  * have already been compared by the subclass.
                  */
                 final Datum that = (Datum) object;
-                return isHeuristicMatchForName(that. getName().getCode()) ||
-                       IdentifiedObjects.isHeuristicMatchForName(that, getName().getCode());
+                return isHeuristicMatchForName(that.getName().getCode())
+                        || IdentifiedObjects.isHeuristicMatchForName(that, getName().getCode());
             }
         }
     }

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=1653029&r1=1653028&r2=1653029&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] Mon Jan 19 15:27:06 2015
@@ -362,7 +362,6 @@ public class DefaultOperationMethod exte
      * @return {@code true} if both objects are equal.
      */
     @Override
-    @SuppressWarnings("fallthrough")
     public boolean equals(final Object object, final ComparisonMode mode) {
         if (object == this) {
             return true; // Slight optimization.
@@ -370,6 +369,7 @@ public class DefaultOperationMethod exte
         if (super.equals(object, mode)) {
             switch (mode) {
                 case STRICT: {
+                    // Name and identifiers have been compared by super.equals(object, mode).
                     final DefaultOperationMethod that = (DefaultOperationMethod) object;
                     return Objects.equals(this.formula,         that.formula) &&
                            Objects.equals(this.sourceDimension, that.sourceDimension) &&
@@ -377,18 +377,28 @@ public class DefaultOperationMethod exte
                            Objects.equals(this.parameters,      that.parameters);
                 }
                 case BY_CONTRACT: {
+                    // Name and identifiers have been compared by super.equals(object, mode).
                     if (!Objects.equals(getFormula(), ((OperationMethod) object).getFormula()))
{
                         return false;
                     }
-                    // Fall through
+                    break;
                 }
                 default: {
+                    // Name and identifiers have been ignored by super.equals(object, mode).
+                    // Since they are significant for OperationMethod, compare them here.
                     final OperationMethod that = (OperationMethod) object;
-                    return Objects.equals(getSourceDimensions(), that.getSourceDimensions())
&&
-                           Objects.equals(getTargetDimensions(), that.getTargetDimensions())
&&
-                           Utilities.deepEquals(getParameters(), that.getParameters(), mode);
+                    if (!isHeuristicMatchForName(that.getName().getCode())
+                            && !IdentifiedObjects.isHeuristicMatchForName(that, getName().getCode()))
+                    {
+                        return false;
+                    }
+                    break;
                 }
             }
+            final OperationMethod that = (OperationMethod) object;
+            return Objects.equals(getSourceDimensions(), that.getSourceDimensions()) &&
+                   Objects.equals(getTargetDimensions(), that.getTargetDimensions()) &&
+                   Utilities.deepEquals(getParameters(), that.getParameters(), mode);
         }
         return false;
     }
@@ -413,7 +423,6 @@ public class DefaultOperationMethod exte
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        formatter.newLine();
         return (formatter.getConvention().majorVersion() == 1) ? "Projection" : "Method";
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -50,7 +50,7 @@ public final strictfp class ParameterBui
     public void testMercatorProjection() {
         final ParameterBuilder builder = new ParameterBuilder();
         builder.setCodeSpace(HardCodedCitations.OGP, "EPSG").setRequired(true);
-        final ParameterDescriptor[] parameters = {
+        final ParameterDescriptor<?>[] parameters = {
             builder.addName("Longitude of natural origin")
                    .addName(HardCodedCitations.OGC, "central_meridian")
                    .addName(HardCodedCitations.GEOTIFF, "NatOriginLong")

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java?rev=1653029&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -0,0 +1,148 @@
+/*
+ * 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 org.opengis.metadata.Identifier;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+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.test.MetadataAssert.*;
+import static org.apache.sis.test.TestUtilities.getSingleton;
+
+
+/**
+ * Tests {@link DefaultOperationMethod}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.5
+ * @since   0.5
+ * @module
+ */
+@DependsOn({
+    DefaultFormulaTest.class,
+    org.apache.sis.referencing.AbstractIdentifiedObjectTest.class
+})
+public final strictfp class DefaultOperationMethodTest extends TestCase {
+    /**
+     * Creates a new two-dimensional operation method for an operation of the given name
and identifier.
+     *
+     * @param  method     The operation name (example: "Mercator (variant A)").
+     * @param  identifier The EPSG numeric identifier (example: "9804").
+     * @param  formula    Formula citation (example: "EPSG guidance note #7-2").
+     * @return The operation method.
+     */
+    private static DefaultOperationMethod create(final String method, final String identifier,
final String formula) {
+        final Map<String,Object> properties = new HashMap<>(8);
+        assertNull(properties.put(OperationMethod.NAME_KEY, method));
+        assertNull(properties.put(Identifier.CODESPACE_KEY, "EPSG"));
+        assertNull(properties.put(Identifier.AUTHORITY_KEY, HardCodedCitations.OGP));
+        /*
+         * The parameter group for a Mercator projection is actually not empty, but it is
not the purpose of
+         * this class to test DefaultParameterDescriptorGroup. So we use an empty group of
parameters here.
+         */
+        final ParameterDescriptorGroup parameters = new DefaultParameterDescriptorGroup(properties,
1, 1);
+        /*
+         * NAME_KEY share the same Identifier instance for saving a little bit of memory.
+         * Then define the other properties to be given to OperationMethod.
+         */
+        assertNotNull(properties.put(OperationMethod.NAME_KEY, parameters.getName()));
+        assertNull(properties.put(OperationMethod.IDENTIFIERS_KEY, new ImmutableIdentifier(HardCodedCitations.OGP,
"EPSG", identifier)));
+        assertNull(properties.put(OperationMethod.FORMULA_KEY, new DefaultCitation(formula)));
+        return new DefaultOperationMethod(properties, 2, 2, parameters);
+    }
+
+    /**
+     * Tests the {@link DefaultOperationMethod#DefaultOperationMethod(Map)} constructor.
+     */
+    @Test
+    public void testConstruction() {
+        final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance
note #7-2");
+        assertEpsgIdentifierEquals("Mercator (variant A)", method.getName());
+        assertEpsgIdentifierEquals("9804", getSingleton(method.getIdentifiers()));
+        assertEquals("formula", "EPSG guidance note #7-2", method.getFormula().getCitation().getTitle().toString());
+        assertEquals("sourceDimensions", Integer.valueOf(2), method.getSourceDimensions());
+        assertEquals("targetDimensions", Integer.valueOf(2), method.getTargetDimensions());
+    }
+
+    /**
+     * Tests {@link DefaultOperationMethod#equals(Object, ComparisonMode)}.
+     */
+    @Test
+    public void testEquals() {
+        final DefaultOperationMethod m1 = create("Mercator (variant A)", "9804", "EPSG guidance
note #7-2");
+        final DefaultOperationMethod m2 = create("Mercator (variant A)", "9804", "E = FE
+ a*ko(lon - lonO)");
+        assertFalse ("STRICT",          m1.equals(m2, ComparisonMode.STRICT));
+        assertFalse ("BY_CONTRACT",     m1.equals(m2, ComparisonMode.BY_CONTRACT));
+        assertTrue  ("IGNORE_METADATA", m1.equals(m2, ComparisonMode.IGNORE_METADATA));
+        assertEquals("Hash code should ignore metadata.", m1.hashCode(), m2.hashCode());
+
+        final DefaultOperationMethod m3 = create("Mercator (variant B)", "9805", "EPSG guidance
note #7-2");
+        final DefaultOperationMethod m4 = create("mercator (variant b)", "9805", "EPSG guidance
note #7-2");
+        assertFalse("IGNORE_METADATA", m1.equals(m3, ComparisonMode.IGNORE_METADATA));
+        assertTrue ("IGNORE_METADATA", m3.equals(m4, ComparisonMode.IGNORE_METADATA));
+        assertFalse("BY_CONTRACT",     m3.equals(m4, ComparisonMode.BY_CONTRACT));
+    }
+
+    /**
+     * Tests {@link DefaultOperationMethod#redimension(OperationMethod, Integer, Integer)}.
+     */
+    @Test
+    @DependsOnMethod({"testConstruction", "testEquals"})
+    public void testResize() {
+        final OperationMethod method = create("Affine geometric transformation", "9623",
"EPSG guidance note #7-2");
+        OperationMethod other = DefaultOperationMethod.redimension(method, 2, 2);
+        assertSame(method, other);
+        assertTrue(method.equals(other));
+        assertEquals("sourceDimensions", Integer.valueOf(2), other.getSourceDimensions());
+        assertEquals("targetDimensions", Integer.valueOf(2), other.getTargetDimensions());
+
+        other = DefaultOperationMethod.redimension(method, 2, 3);
+        assertNotSame(method, other);
+        assertFalse(method.equals(other));
+        assertEquals("sourceDimensions", Integer.valueOf(2), other.getSourceDimensions());
+        assertEquals("targetDimensions", Integer.valueOf(3), other.getTargetDimensions());
+
+        other = DefaultOperationMethod.redimension(method, 3, 2);
+        assertNotSame(method, other);
+        assertFalse(method.equals(other));
+        assertEquals("sourceDimensions", Integer.valueOf(3), other.getSourceDimensions());
+        assertEquals("targetDimensions", Integer.valueOf(2), other.getTargetDimensions());
+    }
+
+    /**
+     * Tests {@link DefaultOperationMethod#toWKT()}.
+     */
+    @Test
+    @DependsOnMethod("testConstruction")
+    public void testWKT() {
+        final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance
note #7-2");
+        assertWktEquals("Method[“Mercator (variant A)”, Id[“EPSG”, 9804, Citation[“OGP”],
URI[“urn:ogc:def:method:EPSG::9804”]]]", method);
+        assertWktEquals(Convention.WKT1, "PROJECTION[“Mercator (variant A)”, AUTHORITY[“EPSG”,
“9804”]]", method);
+    }
+}

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

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.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=1653029&r1=1653028&r2=1653029&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] Mon Jan 19 15:27:06 2015
@@ -107,6 +107,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.CRSTest.class,
 
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,
+    org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
 
     org.apache.sis.geometry.AbstractDirectPositionTest.class,
     org.apache.sis.geometry.GeneralDirectPositionTest.class,

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -50,6 +50,11 @@ import java.util.Objects;
  */
 public final class Citations extends Static {
     /**
+     * The {@value} code space.
+     */
+    public static final String EPSG = "EPSG";
+
+    /**
      * Do not allows instantiation of this class.
      */
     private Citations() {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8]
Mon Jan 19 15:27:06 2015
@@ -32,6 +32,7 @@ import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.DefinitionURI;
+import org.apache.sis.internal.util.Citations;
 import org.apache.sis.internal.util.XPaths;
 
 import static java.lang.Math.PI;
@@ -355,7 +356,7 @@ public final class Units extends Static
          * we want to try to parse as a xpointer before to give up.
          */
         if (isURI(uom)) {
-            String code = DefinitionURI.codeOf("uom", "EPSG", uom);
+            String code = DefinitionURI.codeOf("uom", Citations.EPSG, uom);
             if (code != null && code != uom) try { // Really identity check, see
above comment.
                 return valueOfEPSG(Integer.parseInt(code));
             } catch (NumberFormatException e) {

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java?rev=1653029&r1=1653028&r2=1653029&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/AbstractNameTest.java
[UTF-8] Mon Jan 19 15:27:06 2015
@@ -21,8 +21,9 @@ import org.opengis.util.GenericName;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
 import static org.opengis.test.Validators.*;
+import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.internal.util.Citations.EPSG;
 import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR_STRING;
 
 
@@ -43,7 +44,6 @@ public final strictfp class AbstractName
      */
     @Test
     public void testGlobalNamespace() {
-        final String EPSG = "EPSG";
         final DefaultLocalName name = new DefaultLocalName(null, EPSG);
         assertSame(EPSG, name.toString());
         assertSame(EPSG, name.toInternationalString().toString());
@@ -59,7 +59,6 @@ public final strictfp class AbstractName
      */
     @Test
     public void testEpsgNamespace() {
-        final String EPSG = "EPSG";
         final DefaultNameSpace ns = DefaultNameSpace.forName(new DefaultLocalName(null, EPSG),
                 DEFAULT_SEPARATOR_STRING, DEFAULT_SEPARATOR_STRING);
         assertSame(EPSG, ns.name().toString());



Mime
View raw message