sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1661139 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/parameter/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/ sis-referencing/src/test/java/org/apache/sis/parameter/ sis-referencin...
Date Fri, 20 Feb 2015 15:24:53 GMT
Author: desruisseaux
Date: Fri Feb 20 15:24:52 2015
New Revision: 1661139

URL: http://svn.apache.org/r1661139
Log:
Better separation of matrix using WKT1 and EPSG parameters.
- The WKT1 case is implemented by MatrixParameters and still a general case, despite understanding the EPSG names (but only as alias).
- The EPSG case, which contains a little bit of "magic" that depends on the matrix size, is isolated in MatrixParametersEPSG.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersEPSG.java
      - copied, changed from r1661029, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersEPSGTest.java
      - copied, changed from r1661029, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -24,11 +24,8 @@ import org.opengis.parameter.ParameterDe
 import org.apache.sis.referencing.NamedIdentifier;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.referencing.provider.Affine;
-import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 
-import static org.apache.sis.internal.util.CollectionsExt.first;
-
 
 /**
  * A special case of {@link TensorParameters} restricted to the two-dimensional case.
@@ -59,7 +56,7 @@ import static org.apache.sis.internal.ut
  * @version 0.6
  * @module
  */
-final class MatrixParameters extends TensorParameters<Double> {
+class MatrixParameters extends TensorParameters<Double> {
     /**
      * For cross-version compatibility.
      */
@@ -68,74 +65,25 @@ final class MatrixParameters extends Ten
     /**
      * Constructs a descriptors provider.
      *
-     * @param prefix    The prefix to insert in front of parameter name for each tensor elements.
-     * @param separator The separator between dimension (row, column, …) indices in parameter names.
-     * @param numRow    The parameter for the number of rows.
-     * @param numCol    The parameter for the number of columns.
-     */
-    MatrixParameters(final String prefix, final String separator,
-            final ParameterDescriptor<Integer> numRow, final ParameterDescriptor<Integer> numCol)
-    {
-        super(Double.class, prefix, separator, numRow, numCol);
-    }
-
-    /**
-     * {@code true} for using the EPSG names, or {@code false} for using the WKT1 names.
-     * Current implementation uses {@link #separator} emptiness as a criterion. This is
-     * an arbitrary choice that may change in any future SIS version. However we need a
-     * criterion which is preserved during serialization.
-     *
-     * @see #EPSG
+     * @param numRow The parameter for the number of rows.
+     * @param numCol The parameter for the number of columns.
      */
-    final boolean isEPSG() {
-        return separator.isEmpty();
+    MatrixParameters(final ParameterDescriptor<Integer> numRow, final ParameterDescriptor<Integer> numCol) {
+        super(Double.class, "elt_", "_", numRow, numCol);
     }
 
     /**
      * Returns {@code true} if an official EPSG parameter exists for the given indices. Those parameters
      * are {@code "A0"}, {@code "A1"}, {@code "A2"}, {@code "B0"}, {@code "B1"} and {@code "B2"}.
      */
-    private static boolean isEPSG(final int[] indices) {
+    static boolean isEPSG(final int[] indices) {
         return indices[0] <  Affine.EPSG_DIMENSION &&
                indices[1] <= Affine.EPSG_DIMENSION;   // Include translation column.
     }
 
     /**
-     * Returns 0 if the dimension parameters ({@code "num_row"} and {@code "num_col"}) shall be hidden.
-     * Those parameters need to be hidden for the EPSG:9624 operation method, since the EPSG database
-     * does not define those parameters.
-     */
-    @Override
-    final int numDimensions(final int[] actualSize) {
-        if (isEPSG() && actualSize[0] == Affine.EPSG_DIMENSION + 1
-                     && actualSize[1] == Affine.EPSG_DIMENSION + 1)
-        {
-            return 0;
-        }
-        return super.numDimensions(actualSize);
-    }
-
-    /**
-     * Returns the number of elements (e.g. {@code "elt_0_0"}) when formatting the parameter descriptors for a tensor
-     * of the given size.  This is the total number of elements in the tensor, except for matrices which are intended
-     * to be affine (like {@link #EPSG}) where the last row is omitted.
-     */
-    @Override
-    final int numElements(final int[] actualSize) {
-        int numRow = actualSize[0];
-        int numCol = actualSize[1];
-        assert super.numElements(actualSize) == (numRow * numCol);
-        if (isEPSG() && numRow == Affine.EPSG_DIMENSION + 1
-                     && numCol == Affine.EPSG_DIMENSION + 1)
-        {
-            numRow--; // Ommit last row of an affine matrix.
-        }
-        return numRow * numCol;
-    }
-
-    /**
      * Returns an alias for the given indices, or {@code null} if none.
-     * The default implementation formats:
+     * The current implementation formats:
      *
      * <ul>
      *   <li>the first index (the matrix row) as letter, starting from {@code 'A'},</li>
@@ -178,15 +126,6 @@ final class MatrixParameters extends Ten
     }
 
     /**
-     * Returns the parameter descriptor name of a matrix element at the given indices.
-     * Overridden as a matter of principle, but not used directly by this implementation.
-     */
-    @Override
-    protected String indicesToName(final int[] indices) throws IllegalArgumentException {
-        return isEPSG() ? indicesToAlias(indices) : super.indicesToName(indices);
-    }
-
-    /**
      * Returns the indices of matrix element for the given parameter name, or {@code null} if none.
      * This implementation unconditionally checks for the EPSG name first since this is a very quick check.
      * If the given name does not use the EPSG syntax, then this method fallback on the WKT1 syntax.
@@ -195,70 +134,35 @@ final class MatrixParameters extends Ten
     protected int[] nameToIndices(final String name) throws IllegalArgumentException {
         int[] indices = aliasToIndices(name);
         if (indices == null) {
-            if (isEPSG()) {
-                if (WKT1 == this) {
-                    // Should never happen, but still unconditionally tested
-                    // (no 'assert' keyword) for preventing stack overflow.
-                    throw new AssertionError();
-                }
-                indices = WKT1.nameToIndices(name);
-            } else {
-                indices = super.nameToIndices(name);
-            }
+            indices = super.nameToIndices(name);
         }
         return indices;
     }
 
     /**
-     * Creates a new parameter descriptor for a matrix element at the given indices. This method creates both the
-     * OGC name (e.g. {@code "elt_1_2"}) and the EPSG name (e.g. {@code "B2"}), together with the EPSG identifier
-     * (e.g. {@code "EPSG:8641"}) it it exists. See {@link org.apache.sis.internal.referencing.provider.Affine}
-     * for a table summarizing the parameter names and identifiers.
+     * Creates a new parameter descriptor for a matrix element at the given indices.
+     * This method creates both the OGC name (e.g. {@code "elt_1_2"}) and the EPSG name (e.g. {@code "B2"}).
+     * The EPSG identifier are not created by this method, but rather by the {@link MatrixParametersEPSG} subclass.
      */
     @Override
     protected ParameterDescriptor<Double> createElementDescriptor(final int[] indices) throws IllegalArgumentException {
-        final Object name, alias, identifier;
-        if (isEPSG()) {
-            /*
-             * For the EPSG convention, we recycle the names and identifiers created for the WKT1 convention but
-             * interchanging the name with the alias (since our WKT1 convention adds the EPSG names as aliases).
-             * We use WKT1 as the primary source because it is still very widely used, and works for arbitrary
-             * dimensions while the EPSG parameters are (officially) restricted to 3×3 matrices.
-             */
-            if (WKT1 == this) {
-                // Should never happen, but still unconditionally tested
-                // (no 'assert' keyword) for preventing stack overflow.
-                throw new AssertionError();
-            }
-            final ParameterDescriptor<Double> wkt = WKT1.getElementDescriptor(indices);
-            name       = first(wkt.getAlias());
-            alias      = wkt.getName();
-            identifier = first(wkt.getIdentifiers());
-        } else {
-            /*
-             * For the WKT1 convention, create an alias matching the EPSG pattern ("A0", "A1", etc.) for all
-             * indices but declare the EPSG authority and identifier only for A0, A1, A2, B0, B1 and B2.
-             */
-            name = new NamedIdentifier(Citations.OGC, Constants.OGC, super.indicesToName(indices), null, null);
+        final Map<String,Object> properties = new HashMap<>(4);
+        properties.put(ParameterDescriptor.NAME_KEY,
+                new NamedIdentifier(Citations.OGC, Constants.OGC, indicesToName(indices), null, null));
+        final String c = indicesToAlias(indices);
+        if (c != null) {
             final Citation authority;
             final String codeSpace;
             if (isEPSG(indices)) {
                 authority = Citations.OGP;
                 codeSpace = Constants.EPSG;
-                final int code = (indices[0] == 0 ? Constants.A0 : Constants.B0) + indices[1];
-                identifier = new ImmutableIdentifier(authority, codeSpace, String.valueOf(code));
             } else {
                 authority  = Citations.SIS;
                 codeSpace  = Constants.SIS;
-                identifier = null;
             }
-            final String c = indicesToAlias(indices);
-            alias = (c != null) ? new NamedIdentifier(authority, codeSpace, c, null, null) : null;
+            properties.put(ParameterDescriptor.ALIAS_KEY,
+                    new NamedIdentifier(authority, codeSpace, c, null, null));
         }
-        final Map<String,Object> properties = new HashMap<>(4);
-        properties.put(ParameterDescriptor.NAME_KEY,        name);
-        properties.put(ParameterDescriptor.ALIAS_KEY,       alias);
-        properties.put(ParameterDescriptor.IDENTIFIERS_KEY, identifier);
         return new DefaultParameterDescriptor<>(properties, 0, 1, Double.class, null, null, getDefaultValue(indices));
     }
 
@@ -266,7 +170,6 @@ final class MatrixParameters extends Ten
      * On deserialization, replaces the deserialized instance by the unique instance if possible.
      */
     Object readResolve() throws ObjectStreamException {
-        final TensorParameters<?> candidate = isEPSG() ? EPSG : WKT1;
-        return equals(candidate) ? candidate : this;
+        return equals(WKT1) ? WKT1 : this;
     }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersEPSG.java (from r1661029, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersEPSG.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersEPSG.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java&r1=1661029&r2=1661139&rev=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParameters.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersEPSG.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -19,9 +19,7 @@ package org.apache.sis.parameter;
 import java.util.Map;
 import java.util.HashMap;
 import java.io.ObjectStreamException;
-import org.opengis.metadata.citation.Citation;
 import org.opengis.parameter.ParameterDescriptor;
-import org.apache.sis.referencing.NamedIdentifier;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.referencing.provider.Affine;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
@@ -31,73 +29,30 @@ import static org.apache.sis.internal.ut
 
 
 /**
- * A special case of {@link TensorParameters} restricted to the two-dimensional case.
- * The main purpose for this class is to use the EPSG:9624 parameter names, either as
- * alias or as primary name.
- *
- * <table class="sis">
- *   <caption>{@code Affine} parameters</caption>
- *   <tr><th>EPSG code</th><th>EPSG name</th><th>OGC name</th><th>Default value</th></tr>
- *   <tr><td>    </td> <td>          </td> <td>{@code num_row}</td> <td>3</td></tr>
- *   <tr><td>    </td> <td>          </td> <td>{@code num_col}</td> <td>3</td></tr>
- *   <tr><td>8623</td> <td>{@code A0}</td> <td>{@code elt_0_0}</td> <td>1</td></tr>
- *   <tr><td>8624</td> <td>{@code A1}</td> <td>{@code elt_0_1}</td> <td>0</td></tr>
- *   <tr><td>8625</td> <td>{@code A2}</td> <td>{@code elt_0_2}</td> <td>0</td></tr>
- *   <tr><td>8639</td> <td>{@code B0}</td> <td>{@code elt_1_0}</td> <td>0</td></tr>
- *   <tr><td>8640</td> <td>{@code B1}</td> <td>{@code elt_1_1}</td> <td>1</td></tr>
- *   <tr><td>8641</td> <td>{@code B2}</td> <td>{@code elt_1_2}</td> <td>0</td></tr>
- *   <tr><td>    </td> <td>          </td> <td>{@code elt_2_0}</td> <td>0</td></tr>
- *   <tr><td>    </td> <td>          </td> <td>{@code elt_2_1}</td> <td>0</td></tr>
- *   <tr><td>    </td> <td>          </td> <td>{@code elt_2_2}</td> <td>1</td></tr>
- * </table>
- *
- * Note that the EPSG database contains A3, A4, A5, A6, A7, A8 and B3 parameters,
- * but they are for polynomial transformations, not affine transformations.
+ * A special case of {@link MatrixParameters} implementing the "magic" for the EPSG:9624 parameters.
+ * The "magical" behavior is to hide {@code "num_row"}, {@cod "num_col"} and last row parameters if
+ * the matrix has exactly the dimensions required by the EPSG:9624 operation method, which is 3×3.
+ * The intend is to get a descriptor matching the one defined in the EPSG database.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
  * @version 0.6
  * @module
  */
-final class MatrixParameters extends TensorParameters<Double> {
+final class MatrixParametersEPSG extends MatrixParameters {
     /**
      * For cross-version compatibility.
      */
-    private static final long serialVersionUID = 8452879524565700115L;
+    private static final long serialVersionUID = 476760046257432637L;
 
     /**
      * Constructs a descriptors provider.
      *
-     * @param prefix    The prefix to insert in front of parameter name for each tensor elements.
-     * @param separator The separator between dimension (row, column, …) indices in parameter names.
-     * @param numRow    The parameter for the number of rows.
-     * @param numCol    The parameter for the number of columns.
-     */
-    MatrixParameters(final String prefix, final String separator,
-            final ParameterDescriptor<Integer> numRow, final ParameterDescriptor<Integer> numCol)
-    {
-        super(Double.class, prefix, separator, numRow, numCol);
-    }
-
-    /**
-     * {@code true} for using the EPSG names, or {@code false} for using the WKT1 names.
-     * Current implementation uses {@link #separator} emptiness as a criterion. This is
-     * an arbitrary choice that may change in any future SIS version. However we need a
-     * criterion which is preserved during serialization.
-     *
-     * @see #EPSG
+     * @param numRow The parameter for the number of rows.
+     * @param numCol The parameter for the number of columns.
      */
-    final boolean isEPSG() {
-        return separator.isEmpty();
-    }
-
-    /**
-     * Returns {@code true} if an official EPSG parameter exists for the given indices. Those parameters
-     * are {@code "A0"}, {@code "A1"}, {@code "A2"}, {@code "B0"}, {@code "B1"} and {@code "B2"}.
-     */
-    private static boolean isEPSG(final int[] indices) {
-        return indices[0] <  Affine.EPSG_DIMENSION &&
-               indices[1] <= Affine.EPSG_DIMENSION;   // Include translation column.
+    MatrixParametersEPSG(final ParameterDescriptor<Integer> numRow, final ParameterDescriptor<Integer> numCol) {
+        super(numRow, numCol);
     }
 
     /**
@@ -107,8 +62,8 @@ final class MatrixParameters extends Ten
      */
     @Override
     final int numDimensions(final int[] actualSize) {
-        if (isEPSG() && actualSize[0] == Affine.EPSG_DIMENSION + 1
-                     && actualSize[1] == Affine.EPSG_DIMENSION + 1)
+        if (actualSize[0] == Affine.EPSG_DIMENSION + 1 &&
+            actualSize[1] == Affine.EPSG_DIMENSION + 1)
         {
             return 0;
         }
@@ -125,8 +80,8 @@ final class MatrixParameters extends Ten
         int numRow = actualSize[0];
         int numCol = actualSize[1];
         assert super.numElements(actualSize) == (numRow * numCol);
-        if (isEPSG() && numRow == Affine.EPSG_DIMENSION + 1
-                     && numCol == Affine.EPSG_DIMENSION + 1)
+        if (numRow == Affine.EPSG_DIMENSION + 1 &&
+            numCol == Affine.EPSG_DIMENSION + 1)
         {
             numRow--; // Ommit last row of an affine matrix.
         }
@@ -134,79 +89,12 @@ final class MatrixParameters extends Ten
     }
 
     /**
-     * Returns an alias for the given indices, or {@code null} if none.
-     * The default implementation formats:
-     *
-     * <ul>
-     *   <li>the first index (the matrix row) as letter, starting from {@code 'A'},</li>
-     *   <li>the second index (the matrix column) as digit, starting from {@code '0'}.</li>
-     * </ul>
-     *
-     * Note that for <var>row</var> &lt; 2 and <var>column</var> &lt; 3, the returned aliases are the names
-     * used by the EPSG database. For other row and column indices, the same pattern is still used but the
-     * result is not an official EPSG parameter name.
-     *
-     * @param  indices The indices of the tensor element for which to create a parameter alias.
-     * @return The parameter descriptor alias for the tensor element at the given indices, or {@code null} if none.
-     */
-    static String indicesToAlias(final int[] indices) {
-        final int row = indices[0];
-        if (row >= 0 && row < 26) {
-            final int col = indices[1];
-            if (col >= 0 && col < 10) {
-                return String.valueOf(new char[] {(char) ('A' + row), (char) ('0' + col)});
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Returns the indices for the given alias, or {@code null} if none.
-     * This method is the converse of {@link #indicesToAlias(int[])}.
-     */
-    static int[] aliasToIndices(final String alias) {
-        if (alias.length() == 2) {
-            final int row = alias.charAt(0) - 'A';
-            if (row >= 0 && row < 26) {
-                final int col = alias.charAt(1) - '0';
-                if (col >= 0 && col < 10) {
-                    return new int[] {row, col};
-                }
-            }
-        }
-        return null;
-    }
-
-    /**
      * Returns the parameter descriptor name of a matrix element at the given indices.
      * Overridden as a matter of principle, but not used directly by this implementation.
      */
     @Override
     protected String indicesToName(final int[] indices) throws IllegalArgumentException {
-        return isEPSG() ? indicesToAlias(indices) : super.indicesToName(indices);
-    }
-
-    /**
-     * Returns the indices of matrix element for the given parameter name, or {@code null} if none.
-     * This implementation unconditionally checks for the EPSG name first since this is a very quick check.
-     * If the given name does not use the EPSG syntax, then this method fallback on the WKT1 syntax.
-     */
-    @Override
-    protected int[] nameToIndices(final String name) throws IllegalArgumentException {
-        int[] indices = aliasToIndices(name);
-        if (indices == null) {
-            if (isEPSG()) {
-                if (WKT1 == this) {
-                    // Should never happen, but still unconditionally tested
-                    // (no 'assert' keyword) for preventing stack overflow.
-                    throw new AssertionError();
-                }
-                indices = WKT1.nameToIndices(name);
-            } else {
-                indices = super.nameToIndices(name);
-            }
-        }
-        return indices;
+        return indicesToAlias(indices);
     }
 
     /**
@@ -217,56 +105,39 @@ final class MatrixParameters extends Ten
      */
     @Override
     protected ParameterDescriptor<Double> createElementDescriptor(final int[] indices) throws IllegalArgumentException {
-        final Object name, alias, identifier;
-        if (isEPSG()) {
-            /*
-             * For the EPSG convention, we recycle the names and identifiers created for the WKT1 convention but
-             * interchanging the name with the alias (since our WKT1 convention adds the EPSG names as aliases).
-             * We use WKT1 as the primary source because it is still very widely used, and works for arbitrary
-             * dimensions while the EPSG parameters are (officially) restricted to 3×3 matrices.
-             */
-            if (WKT1 == this) {
-                // Should never happen, but still unconditionally tested
-                // (no 'assert' keyword) for preventing stack overflow.
-                throw new AssertionError();
-            }
-            final ParameterDescriptor<Double> wkt = WKT1.getElementDescriptor(indices);
-            name       = first(wkt.getAlias());
-            alias      = wkt.getName();
-            identifier = first(wkt.getIdentifiers());
-        } else {
-            /*
-             * For the WKT1 convention, create an alias matching the EPSG pattern ("A0", "A1", etc.) for all
-             * indices but declare the EPSG authority and identifier only for A0, A1, A2, B0, B1 and B2.
-             */
-            name = new NamedIdentifier(Citations.OGC, Constants.OGC, super.indicesToName(indices), null, null);
-            final Citation authority;
-            final String codeSpace;
-            if (isEPSG(indices)) {
-                authority = Citations.OGP;
-                codeSpace = Constants.EPSG;
-                final int code = (indices[0] == 0 ? Constants.A0 : Constants.B0) + indices[1];
-                identifier = new ImmutableIdentifier(authority, codeSpace, String.valueOf(code));
-            } else {
-                authority  = Citations.SIS;
-                codeSpace  = Constants.SIS;
-                identifier = null;
-            }
-            final String c = indicesToAlias(indices);
-            alias = (c != null) ? new NamedIdentifier(authority, codeSpace, c, null, null) : null;
+        /*
+         * For the EPSG convention, we recycle the names created for the WKT1 convention but interchanging
+         * the name with the alias (since our WKT1 convention adds the EPSG names as aliases). We use WKT1
+         * as the primary source because it is still very widely used,  and works for arbitrary dimensions
+         * while the EPSG parameters are (officially) restricted to 3×3 matrices.
+         */
+        if (WKT1 == this) {
+            // Should never happen, but still unconditionally tested
+            // (no 'assert' keyword) for preventing stack overflow.
+            throw new AssertionError();
+        }
+        final ParameterDescriptor<Double> wkt = WKT1.getElementDescriptor(indices);   // Really 'WKT1', not 'super'.
+        final Map<String,Object> properties = new HashMap<>(6);
+        properties.put(ParameterDescriptor.NAME_KEY, first(wkt.getAlias()));
+        properties.put(ParameterDescriptor.ALIAS_KEY, wkt.getName());
+        /*
+         * For the WKT1 convention, create an alias matching the EPSG pattern ("A0", "A1", etc.) for all
+         * indices but declare the EPSG authority and identifier only for A0, A1, A2, B0, B1 and B2.
+         */
+        if (isEPSG(indices)) {
+            final ImmutableIdentifier id;
+            final int code = (indices[0] == 0 ? Constants.A0 : Constants.B0) + indices[1];
+            id = new ImmutableIdentifier(Citations.OGP, Constants.EPSG, String.valueOf(code));
+            properties.put(ParameterDescriptor.IDENTIFIERS_KEY, id);
         }
-        final Map<String,Object> properties = new HashMap<>(4);
-        properties.put(ParameterDescriptor.NAME_KEY,        name);
-        properties.put(ParameterDescriptor.ALIAS_KEY,       alias);
-        properties.put(ParameterDescriptor.IDENTIFIERS_KEY, identifier);
         return new DefaultParameterDescriptor<>(properties, 0, 1, Double.class, null, null, getDefaultValue(indices));
     }
 
     /**
-     * On deserialization, replaces the deserialized instance by the unique instance if possible.
+     * On deserialization, replaces the deserialized instance by the unique instance.
      */
+    @Override
     Object readResolve() throws ObjectStreamException {
-        final TensorParameters<?> candidate = isEPSG() ? EPSG : WKT1;
-        return equals(candidate) ? candidate : this;
+        return EPSG;
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -60,8 +60,8 @@ import java.util.Objects;
  * <ul>
  *   <li>Parameters (usually mandatory) for the tensor dimensions:
  *     <ul>
- *       <li>number of rows ({@code "num_row"} in WKT 1),</li>
- *       <li>number of columns ({@code "num_col"} in WKT 1),</li>
+ *       <li>number of rows (named {@code "num_row"} in {@linkplain #WKT1} conventions),</li>
+ *       <li>number of columns (named {@code "num_col"} in WKT1 conventions),</li>
  *       <li><i>etc.</i> for third-order or higher-order tensors.</li>
  *     </ul>
  *   </li>
@@ -76,7 +76,8 @@ import java.util.Objects;
  * <p><b>Parameters are not an efficient storage format for large tensors.</b>
  * Parameters are used only for small matrices/tensors to be specified in coordinate operations or processing libraries.
  * In particular, those parameters integrate well in <cite>Well Known Text</cite> (WKT) format.
- * For a more efficient matrix storage, see {@link org.apache.sis.referencing.operation.matrix.MatrixSIS}.</p>
+ * For a more efficient matrix storage,
+ * see the {@linkplain org.apache.sis.referencing.operation.matrix matrix package}.</p>
  *
  * {@section Formatting}
  * In the particular case of a tensor of {@linkplain #rank() rank} 2 (i.e. a matrix),
@@ -84,24 +85,24 @@ import java.util.Objects;
  * the matrix is implicitly {@linkplain Matrices#isAffine affine} and of dimension 3×3.
  *
  * <table class="sis">
- *   <caption>Well Known Text format for a matrix</caption>
+ *   <caption>Well Known Text (WKT) formats for matrix parameters</caption>
  * <tr>
- *   <th>Using EPSG names</th>
+ *   <th>Using EPSG:9624 names and identifiers</th>
  *   <th class="sep">Using OGC names</th>
  * </tr>
  * <tr><td>
  * {@preformat wkt
- *   Parameter["A0", <value>, ID["EPSG",8623]],
- *   Parameter["A1", <value>, ID["EPSG",8624]],
- *   Parameter["A2", <value>, ID["EPSG",8625]],
- *   Parameter["B0", <value>, ID["EPSG",8639]],
- *   Parameter["B1", <value>, ID["EPSG",8640]],
- *   Parameter["B2", <value>, ID["EPSG",8641]]
+ *   Parameter["A0", <value>, Id["EPSG", 8623]],
+ *   Parameter["A1", <value>, Id["EPSG", 8624]],
+ *   Parameter["A2", <value>, Id["EPSG", 8625]],
+ *   Parameter["B0", <value>, Id["EPSG", 8639]],
+ *   Parameter["B1", <value>, Id["EPSG", 8640]],
+ *   Parameter["B2", <value>, Id["EPSG", 8641]]
  * }
  *
  * <div class="note"><b>Note:</b>
  * the EPSG database contains also A3, A4, A5, A6, A7, A8 and B3 parameters,
- * but they are for polynomial transformations, not affine transformations.</div>
+ * but they are for polynomial transformations, not for affine transformations.</div>
  *
  * </td><td class="sep">
  * {@preformat wkt
@@ -122,7 +123,7 @@ import java.util.Objects;
  * depends on the {@code "num_row"} and {@code "num_col"} parameter values. For this reason, the descriptor of
  * matrix or tensor parameters is not immutable.
  *
- * {@section Usage}
+ * {@section Usage examples}
  * For creating a new group of parameters for a matrix using the {@link #WKT1} naming conventions,
  * one can use the following code:
  *
@@ -131,6 +132,14 @@ import java.util.Objects;
  *   ParameterValueGroup p = TensorParameters.WKT1.createValueGroup(properties);
  * }
  *
+ * For setting the elements of a few values, then create a matrix from the parameter values:
+ *
+ * {@preformat java
+ *   p.parameter("elt_0_0").setValue(4);    // "A0" also accepted as a synonymous of "elt_0_0".
+ *   p.parameter("elt_1_1").setValue(6);    // "B1" also accepted as a synonymous of "elt_1_1".
+ *   Matrix m = TensorParameters.WKT1.toMatrix(p);
+ * }
+ *
  * @param <E> The type of tensor element values.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
@@ -138,7 +147,7 @@ import java.util.Objects;
  * @version 0.6
  * @module
  *
- * @see MatrixSIS
+ * @see org.apache.sis.referencing.operation.matrix.Matrices
  */
 public class TensorParameters<E> implements Serializable {
     /**
@@ -204,7 +213,7 @@ public class TensorParameters<E> impleme
         properties.put(Identifier.CODE_KEY, Constants.NUM_COL);
         ParameterDescriptor<Integer> numCol = new DefaultParameterDescriptor<>(
                 properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
-        WKT1 = new MatrixParameters("elt_", "_", numRow, numCol);
+        WKT1 = new MatrixParameters(numRow, numCol);
         /*
          * For the EPSG convention, there is no "num_row" or "num_col" parameters since the matrix
          * size if fixed to 3×3. However since we still need them, we will declare them as optional
@@ -214,7 +223,7 @@ public class TensorParameters<E> impleme
                 0, 1, Integer.class, valueDomain, null, defaultSize);
         numCol = new DefaultParameterDescriptor<>(IdentifiedObjects.getProperties(numCol),
                 0, 1, Integer.class, valueDomain, null, defaultSize);
-        EPSG = new MatrixParameters("", "", numRow, numCol);
+        EPSG = new MatrixParametersEPSG(numRow, numCol);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -66,6 +66,8 @@ import java.util.Objects;
  * @since   0.4
  * @version 0.5
  * @module
+ *
+ * @see org.apache.sis.parameter.TensorParameters
  */
 public final class Matrices extends Static {
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/MatrixSIS.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -41,6 +41,8 @@ import org.apache.sis.util.resources.Err
  * @since   0.4
  * @version 0.4
  * @module
+ *
+ * @see Matrices
  */
 public abstract class MatrixSIS implements Matrix, LenientComparable, Cloneable, Serializable {
     /**

Copied: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersEPSGTest.java (from r1661029, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersEPSGTest.java?p2=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersEPSGTest.java&p1=sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java&r1=1661029&r2=1661139&rev=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersEPSGTest.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -16,17 +16,16 @@
  */
 package org.apache.sis.parameter;
 
-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.Assert.*;
 
 
 /**
- * Tests the {@link MatrixParameters} class using the {@link TensorParameters#WKT1} and
- * {@link TensorParameters#EPSG} constants.
+ * Tests the {@link MatrixParametersEPSG} class using the {@link TensorParameters#EPSG} constant.
+ * This class inherits all the tests from {@link TensorParametersTest}, but applies them on a
+ * different instance.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
@@ -34,19 +33,7 @@ import static org.apache.sis.test.Assert
  * @module
  */
 @DependsOn(TensorParametersTest.class)
-public final strictfp class MatrixParametersTest extends TestCase {
-    /**
-     * The expected parameter names according the EPSG convention for the matrix elements.
-     *
-     * @see TensorParametersTest#ELEMENT_NAMES
-     */
-    private static final String[][] NAMES = {
-        {"A0", "A1", "A2", "A3"},
-        {"B0", "B1", "B2", "B3"},
-        {"C0", "C1", "C2", "C3"},
-        {"D0", "D1", "D2", "D3"}
-    };
-
+public final strictfp class MatrixParametersEPSGTest extends MatrixParametersTest {
     /**
      * The expected parameter identifiers for the matrix elements, or 0 if none.
      * Note that the EPSG database contains A3 and B3 parameters, but they are
@@ -60,18 +47,17 @@ public final strictfp class MatrixParame
     };
 
     /**
-     * Tests {@link MatrixParameters#isEPSG()}.
+     * Creates a new test case for {@link MatrixParameters}.
      */
-    @Test
-    public void testIsEPSG() {
-        assertTrue (((MatrixParameters) TensorParameters.EPSG).isEPSG());
-        assertFalse(((MatrixParameters) TensorParameters.WKT1).isEPSG());
+    public MatrixParametersEPSGTest() {
+        super(TensorParameters.EPSG, ALPHANUM_NAMES, ELEMENT_NAMES, IDENTIFIERS);
     }
 
     /**
      * Tests {@link MatrixParameters#indicesToAlias(int[])}.
      */
     @Test
+    @Override
     public void testIndicesToAlias() {
         assertEquals("A0", MatrixParameters.indicesToAlias(new int[] {0, 0}));
         assertEquals("A1", MatrixParameters.indicesToAlias(new int[] {0, 1}));
@@ -79,14 +65,13 @@ public final strictfp class MatrixParame
         assertEquals("B0", MatrixParameters.indicesToAlias(new int[] {1, 0}));
         assertEquals("B1", MatrixParameters.indicesToAlias(new int[] {1, 1}));
         assertEquals("B2", MatrixParameters.indicesToAlias(new int[] {1, 2}));
-        assertNull(MatrixParameters.indicesToAlias(new int[] {27, 2}));
-        assertNull(MatrixParameters.indicesToAlias(new int[] {2, 10}));
     }
 
     /**
      * Tests {@link MatrixParameters#aliasToIndices(String)}.
      */
     @Test
+    @Override
     public void testAliasToIndices() {
         assertArrayEquals(new int[] {0, 0}, MatrixParameters.aliasToIndices("A0"));
         assertArrayEquals(new int[] {0, 1}, MatrixParameters.aliasToIndices("A1"));
@@ -94,70 +79,15 @@ public final strictfp class MatrixParame
         assertArrayEquals(new int[] {1, 0}, MatrixParameters.aliasToIndices("B0"));
         assertArrayEquals(new int[] {1, 1}, MatrixParameters.aliasToIndices("B1"));
         assertArrayEquals(new int[] {1, 2}, MatrixParameters.aliasToIndices("B2"));
-        assertNull(MatrixParameters.aliasToIndices("2B"));
-        assertNull(MatrixParameters.aliasToIndices("elt_1_2"));
     }
 
     /**
-     * Tests {@link MatrixParameters#indicesToName(int[])}.
+     * Tests {@link MatrixParametersEPSG#indicesToName(int[])}.
      */
     @Test
-    @DependsOnMethod({"testIsEPSG", "testIndicesToAlias"})
+    @Override
     public void testIndicesToName() {
-        TensorParametersTest.testIndicesToName(TensorParameters.WKT1);
-        assertEquals("E8", TensorParameters.EPSG.indicesToName(new int[] {4, 8}));
-        assertEquals("H2", TensorParameters.EPSG.indicesToName(new int[] {7, 2}));
-    }
-
-    /**
-     * Tests {@link MatrixParameters#nameToIndices(String)}.
-     */
-    @Test
-    @DependsOnMethod({"testIsEPSG", "testAliasToIndices"})
-    public void testNameToIndices() {
-        TensorParametersTest.testNameToIndices(TensorParameters.WKT1);
-        assertArrayEquals(new int[] {4, 8}, TensorParameters.EPSG.nameToIndices("E8"));
-        assertArrayEquals(new int[] {7, 2}, TensorParameters.EPSG.nameToIndices("H2"));
-        assertNull(TensorParameters.EPSG.nameToIndices("other_7_2"));
-        assertNull(TensorParameters.EPSG.nameToIndices("elt_7"));
-    }
-
-    /**
-     * Tests {@link MatrixParameters#getDimensionDescriptor(int)}.
-     */
-    @Test
-    public void testGetDimensionDescriptor() {
-        TensorParametersTest.testGetDimensionDescriptor(TensorParameters.WKT1);
-        TensorParametersTest.testGetDimensionDescriptor(TensorParameters.EPSG);
-    }
-
-    /**
-     * Tests {@link TensorParameters#getElementDescriptor(int[])}.
-     */
-    @Test
-    @DependsOnMethod("testIndicesToName")
-    public void testGetElementDescriptor() {
-        TensorParametersTest.testGetElementDescriptor(TensorParameters.WKT1, TensorParametersTest.ELEMENT_NAMES, NAMES, IDENTIFIERS);
-        TensorParametersTest.testGetElementDescriptor(TensorParameters.EPSG, NAMES, TensorParametersTest.ELEMENT_NAMES, IDENTIFIERS);
-    }
-
-    /**
-     * Tests {@link TensorParameters#descriptors(int[])} for a 1×1, 2×3 and 3×3 matrices.
-     */
-    @Test
-    @DependsOnMethod("testGetElementDescriptor")
-    public void testDescriptors() {
-        TensorParametersTest.testDescriptors(TensorParameters.WKT1, false, TensorParametersTest.ELEMENT_NAMES, NAMES, IDENTIFIERS);
-        TensorParametersTest.testDescriptors(TensorParameters.EPSG, true,  NAMES, TensorParametersTest.ELEMENT_NAMES, IDENTIFIERS);
-    }
-
-    /**
-     * Tests serialization.
-     */
-    @Test
-    @DependsOnMethod("testIsEPSG")
-    public void testSerialization() {
-        assertSame(TensorParameters.EPSG, assertSerializedEquals(TensorParameters.EPSG));
-        assertSame(TensorParameters.WKT1, assertSerializedEquals(TensorParameters.WKT1));
+        assertEquals("E8", param.indicesToName(new int[] {4, 8}));
+        assertEquals("H2", param.indicesToName(new int[] {7, 2}));
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/MatrixParametersTest.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -16,17 +16,16 @@
  */
 package org.apache.sis.parameter;
 
-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.Assert.*;
 
 
 /**
- * Tests the {@link MatrixParameters} class using the {@link TensorParameters#WKT1} and
- * {@link TensorParameters#EPSG} constants.
+ * Tests the {@link MatrixParameters} class using the {@link TensorParameters#WKT1} constant.
+ * This class inherits all the tests from {@link TensorParametersTest}, but applies them on a
+ * different instance.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
@@ -34,13 +33,13 @@ import static org.apache.sis.test.Assert
  * @module
  */
 @DependsOn(TensorParametersTest.class)
-public final strictfp class MatrixParametersTest extends TestCase {
+public strictfp class MatrixParametersTest extends TensorParametersTest {
     /**
      * The expected parameter names according the EPSG convention for the matrix elements.
      *
      * @see TensorParametersTest#ELEMENT_NAMES
      */
-    private static final String[][] NAMES = {
+    static final String[][] ALPHANUM_NAMES = {
         {"A0", "A1", "A2", "A3"},
         {"B0", "B1", "B2", "B3"},
         {"C0", "C1", "C2", "C3"},
@@ -48,24 +47,22 @@ public final strictfp class MatrixParame
     };
 
     /**
-     * The expected parameter identifiers for the matrix elements, or 0 if none.
-     * Note that the EPSG database contains A3 and B3 parameters, but they are
-     * for polynomial transformation, not affine transformation.
-     */
-    private static final short[][] IDENTIFIERS = {
-        {8623, 8624, 8625, 0},
-        {8639, 8640, 8641, 0},
-        {   0,    0,    0, 0},
-        {   0,    0,    0, 0}
-    };
+     * Creates a new test case for {@link MatrixParameters}.
+     */
+    public MatrixParametersTest() {
+        super(TensorParameters.WKT1, ELEMENT_NAMES, ALPHANUM_NAMES, null);
+    }
 
     /**
-     * Tests {@link MatrixParameters#isEPSG()}.
+     * Creates a new test case for a {@link MatrixParameters} defined by the subclass.
+     *
+     * @param param       The instance tested by this class.
+     * @param names       The expected parameter names for all matrix elements.
+     * @param aliases     The expected parameter aliases for all matrix elements, or {@code null} for no alias.
+     * @param identifiers The expected parameter identifiers for all matrix elements, or {@code null} for no identifier.
      */
-    @Test
-    public void testIsEPSG() {
-        assertTrue (((MatrixParameters) TensorParameters.EPSG).isEPSG());
-        assertFalse(((MatrixParameters) TensorParameters.WKT1).isEPSG());
+    MatrixParametersTest(TensorParameters<Double> param, String[][] names, String[][] aliases, short[][] identifiers) {
+        super(param, names, aliases, identifiers);
     }
 
     /**
@@ -73,12 +70,9 @@ public final strictfp class MatrixParame
      */
     @Test
     public void testIndicesToAlias() {
-        assertEquals("A0", MatrixParameters.indicesToAlias(new int[] {0, 0}));
-        assertEquals("A1", MatrixParameters.indicesToAlias(new int[] {0, 1}));
-        assertEquals("A2", MatrixParameters.indicesToAlias(new int[] {0, 2}));
-        assertEquals("B0", MatrixParameters.indicesToAlias(new int[] {1, 0}));
-        assertEquals("B1", MatrixParameters.indicesToAlias(new int[] {1, 1}));
-        assertEquals("B2", MatrixParameters.indicesToAlias(new int[] {1, 2}));
+        assertEquals("K0", MatrixParameters.indicesToAlias(new int[] {10, 0}));
+        assertEquals("A6", MatrixParameters.indicesToAlias(new int[] { 0, 6}));
+        assertEquals("G4", MatrixParameters.indicesToAlias(new int[] { 6, 4}));
         assertNull(MatrixParameters.indicesToAlias(new int[] {27, 2}));
         assertNull(MatrixParameters.indicesToAlias(new int[] {2, 10}));
     }
@@ -88,76 +82,19 @@ public final strictfp class MatrixParame
      */
     @Test
     public void testAliasToIndices() {
-        assertArrayEquals(new int[] {0, 0}, MatrixParameters.aliasToIndices("A0"));
-        assertArrayEquals(new int[] {0, 1}, MatrixParameters.aliasToIndices("A1"));
-        assertArrayEquals(new int[] {0, 2}, MatrixParameters.aliasToIndices("A2"));
-        assertArrayEquals(new int[] {1, 0}, MatrixParameters.aliasToIndices("B0"));
-        assertArrayEquals(new int[] {1, 1}, MatrixParameters.aliasToIndices("B1"));
-        assertArrayEquals(new int[] {1, 2}, MatrixParameters.aliasToIndices("B2"));
+        assertArrayEquals(new int[] {10, 0}, MatrixParameters.aliasToIndices("K0"));
+        assertArrayEquals(new int[] { 0, 6}, MatrixParameters.aliasToIndices("A6"));
+        assertArrayEquals(new int[] { 6, 4}, MatrixParameters.aliasToIndices("G4"));
         assertNull(MatrixParameters.aliasToIndices("2B"));
         assertNull(MatrixParameters.aliasToIndices("elt_1_2"));
     }
 
     /**
-     * Tests {@link MatrixParameters#indicesToName(int[])}.
-     */
-    @Test
-    @DependsOnMethod({"testIsEPSG", "testIndicesToAlias"})
-    public void testIndicesToName() {
-        TensorParametersTest.testIndicesToName(TensorParameters.WKT1);
-        assertEquals("E8", TensorParameters.EPSG.indicesToName(new int[] {4, 8}));
-        assertEquals("H2", TensorParameters.EPSG.indicesToName(new int[] {7, 2}));
-    }
-
-    /**
-     * Tests {@link MatrixParameters#nameToIndices(String)}.
-     */
-    @Test
-    @DependsOnMethod({"testIsEPSG", "testAliasToIndices"})
-    public void testNameToIndices() {
-        TensorParametersTest.testNameToIndices(TensorParameters.WKT1);
-        assertArrayEquals(new int[] {4, 8}, TensorParameters.EPSG.nameToIndices("E8"));
-        assertArrayEquals(new int[] {7, 2}, TensorParameters.EPSG.nameToIndices("H2"));
-        assertNull(TensorParameters.EPSG.nameToIndices("other_7_2"));
-        assertNull(TensorParameters.EPSG.nameToIndices("elt_7"));
-    }
-
-    /**
-     * Tests {@link MatrixParameters#getDimensionDescriptor(int)}.
-     */
-    @Test
-    public void testGetDimensionDescriptor() {
-        TensorParametersTest.testGetDimensionDescriptor(TensorParameters.WKT1);
-        TensorParametersTest.testGetDimensionDescriptor(TensorParameters.EPSG);
-    }
-
-    /**
-     * Tests {@link TensorParameters#getElementDescriptor(int[])}.
-     */
-    @Test
-    @DependsOnMethod("testIndicesToName")
-    public void testGetElementDescriptor() {
-        TensorParametersTest.testGetElementDescriptor(TensorParameters.WKT1, TensorParametersTest.ELEMENT_NAMES, NAMES, IDENTIFIERS);
-        TensorParametersTest.testGetElementDescriptor(TensorParameters.EPSG, NAMES, TensorParametersTest.ELEMENT_NAMES, IDENTIFIERS);
-    }
-
-    /**
-     * Tests {@link TensorParameters#descriptors(int[])} for a 1×1, 2×3 and 3×3 matrices.
-     */
-    @Test
-    @DependsOnMethod("testGetElementDescriptor")
-    public void testDescriptors() {
-        TensorParametersTest.testDescriptors(TensorParameters.WKT1, false, TensorParametersTest.ELEMENT_NAMES, NAMES, IDENTIFIERS);
-        TensorParametersTest.testDescriptors(TensorParameters.EPSG, true,  NAMES, TensorParametersTest.ELEMENT_NAMES, IDENTIFIERS);
-    }
-
-    /**
      * Tests serialization.
      */
     @Test
-    @DependsOnMethod("testIsEPSG")
+    @Override
     public void testSerialization() {
-        assertSame(TensorParameters.EPSG, assertSerializedEquals(TensorParameters.EPSG));
-        assertSame(TensorParameters.WKT1, assertSerializedEquals(TensorParameters.WKT1));
+        assertSame(param, assertSerializedEquals(param));
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -24,7 +24,6 @@ import org.opengis.parameter.ParameterDi
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.metadata.Identifier;
-import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import javax.measure.unit.Unit;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorParametersTest.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -28,14 +28,14 @@ import org.apache.sis.test.TestUtilities
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
-import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
 import static org.opengis.test.Validators.validate;
-import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
 import static org.apache.sis.test.ReferencingAssert.*;
+import static org.apache.sis.internal.util.Constants.NUM_ROW;
+import static org.apache.sis.internal.util.Constants.NUM_COL;
 
 
 /**
@@ -46,8 +46,12 @@ import static org.apache.sis.test.Refere
  * @version 0.6
  * @module
  */
-@DependsOn(ParametersTest.class)
-public final strictfp class TensorParametersTest extends TestCase {
+@DependsOn({
+    DefaultParameterDescriptorTest.class,
+    DefaultParameterValueTest.class,
+    ParametersTest.class
+})
+public strictfp class TensorParametersTest extends TestCase {
     /**
      * The parameters to use for testing purpose. Mostly identical to {@link TensorParameters#WKT1},
      * except that it is not an instance of the {@link MatrixParameters} subclass. Those parameters
@@ -56,14 +60,6 @@ public final strictfp class TensorParame
     private static TensorParameters<Double> WKT1;
 
     /**
-     * The expected parameter names according the WKT 1 convention for the matrix size.
-     */
-    private static final String[][] SIZE_NAMES = {
-        {"num_row"},
-        {"num_col"}
-    };
-
-    /**
      * The expected parameter names according the WKT 1 convention for the matrix elements.
      *
      * @see MatrixParametersTest#NAMES
@@ -76,18 +72,64 @@ public final strictfp class TensorParame
     };
 
     /**
-     * Creates the parameters to be used by the tests in this class.
+     * The instance tested by this class.
+     */
+    final TensorParameters<Double> param;
+
+    /**
+     * The expected parameter names for all matrix elements.
+     * Example: {@link #ELEMENT_NAMES}.
+     */
+    private final String[][] names;
+
+    /**
+     * The expected parameter aliases for all matrix elements, or {@code null} for no alias.
+     * Example: {@link MatrixParametersTest#ALPHANUM_NAMES}.
+     */
+    private final String[][] aliases;
+
+    /**
+     * The expected parameter identifiers for all matrix elements, or {@code null} for no identifier.
+     * Example: {@link MatrixParametersEPSGTest#IDENTIFIERS}.
+     */
+    private final short[][] identifiers;
+
+    /**
+     * Creates a new test case for {@link TensorParameters}.
      */
-    @BeforeClass
     @SuppressWarnings("unchecked")
-    public static void createTensorParameters() {
-        WKT1 = new TensorParameters<>(Double.class, "elt_", "_",
-                TensorParameters.WKT1.getDimensionDescriptor(0),
-                TensorParameters.WKT1.getDimensionDescriptor(1));
+    public TensorParametersTest() {
+        if (WKT1 == null) {
+            WKT1 = new TensorParameters<>(Double.class, "elt_", "_",
+                    TensorParameters.WKT1.getDimensionDescriptor(0),
+                    TensorParameters.WKT1.getDimensionDescriptor(1));
+        }
+        param       = WKT1;
+        names       = ELEMENT_NAMES;
+        aliases     = null;
+        identifiers = null;
+    }
+
+    /**
+     * Creates a new test case for a {@link MatrixParameters} defined by the subclass.
+     *
+     * @param param       The instance tested by this class.
+     * @param names       The expected parameter names for all matrix elements.
+     * @param aliases     The expected parameter aliases for all matrix elements, or {@code null} for no alias.
+     * @param identifiers The expected parameter identifiers for all matrix elements, or {@code null} for no identifier.
+     */
+    TensorParametersTest(final TensorParameters<Double> param, final String[][] names, final String[][] aliases,
+            final short[][] identifiers)
+    {
+        this.param       = param;
+        this.names       = names;
+        this.aliases     = aliases;
+        this.identifiers = identifiers;
     }
 
     /**
      * Discards the parameters used by the tests in this class.
+     * This method is invoked by JUnit only after all tests completed.
      */
     @AfterClass
     public static void clearTensorParameters() {
@@ -95,18 +137,29 @@ public final strictfp class TensorParame
     }
 
     /**
+     * Asserts that the given descriptor has the given name.
+     *
+     * @param names        The expected parameter name.
+     * @param defaultValue The expected parameter default value.
+     * @param actual       The actual parameter to verify.
+     */
+    private static void verifyDescriptor(final String name, final Number defaultValue,
+            final GeneralParameterDescriptor actual)
+    {
+        assertEquals("name", name, actual.getName().getCode());
+        assertEquals("defaultValue", defaultValue, ((ParameterDescriptor<?>) actual).getDefaultValue());
+    }
+
+    /**
      * Asserts that the given descriptor has the given name, alias, identifier and default value.
      *
-     * @param names        The expected parameter names for all matrix elements.
-     * @param aliases      The expected parameter aliases for all matrix elements, or {@code null} for no alias.
-     * @param identifiers  The expected parameter identifiers for all matrix elements, or {@code null} for no identifier.
      * @param defaultValue The expected parameter default value.
      * @param actual       The actual parameter to verify.
      * @param row          Row index of the matrix element to test.
      * @param column       Column index of the matrix element to test.
      */
-    private static void verifyDescriptor(final String[][] names, final String[][] aliases, final short[][] identifiers,
-            final Number defaultValue, final GeneralParameterDescriptor actual, final int row, final int column)
+    private void verifyDescriptor(final Number defaultValue, final GeneralParameterDescriptor actual,
+            final int row, final int column)
     {
         assertEquals("name", names[row][column], actual.getName().getCode());
         assertAliasTipEquals((aliases != null) ? aliases[row][column] : null, actual);
@@ -119,14 +172,9 @@ public final strictfp class TensorParame
      */
     @Test
     public void testGetDimensionDescriptor() {
-        testGetDimensionDescriptor(WKT1);
-    }
-
-    /** Implementation of {@link #testGetDimensionDescriptor()} with user-supplied parameters. */
-    static void testGetDimensionDescriptor(final TensorParameters<Double> WKT1) {
         final Integer N3 = 3;
-        verifyDescriptor(SIZE_NAMES, null, null, N3, WKT1.getDimensionDescriptor(0), 0, 0);
-        verifyDescriptor(SIZE_NAMES, null, null, N3, WKT1.getDimensionDescriptor(1), 1, 0);
+        verifyDescriptor(NUM_ROW, N3, param.getDimensionDescriptor(0));
+        verifyDescriptor(NUM_COL, N3, param.getDimensionDescriptor(1));
     }
 
     /**
@@ -135,27 +183,20 @@ public final strictfp class TensorParame
     @Test
     @DependsOnMethod("testIndicesToName")
     public void testGetElementDescriptor() {
-        testGetElementDescriptor(WKT1, ELEMENT_NAMES, null, null);
-    }
-
-    /** Implementation of {@link #testGetElementDescriptor()} with user-supplied parameters. */
-    static void testGetElementDescriptor(final TensorParameters<Double> WKT1,
-            final String[][] names, final String[][] aliases, final short[][] identifiers)
-    {
         final Double N0 = 0.0;
         final Double N1 = 1.0;
-        final ParameterDescriptor<Double> e00 = WKT1.getElementDescriptor(0, 0);
-        final ParameterDescriptor<Double> e01 = WKT1.getElementDescriptor(0, 1);
-        final ParameterDescriptor<Double> e10 = WKT1.getElementDescriptor(1, 0);
-        final ParameterDescriptor<Double> e11 = WKT1.getElementDescriptor(1, 1);
-        verifyDescriptor(names, aliases, identifiers, N1, e00, 0, 0);
-        verifyDescriptor(names, aliases, identifiers, N0, e01, 0, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, e10, 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, e11, 1, 1);
-        assertSame(e00, WKT1.getElementDescriptor(0, 0)); // Test caching.
-        assertSame(e01, WKT1.getElementDescriptor(0, 1));
-        assertSame(e10, WKT1.getElementDescriptor(1, 0));
-        assertSame(e11, WKT1.getElementDescriptor(1, 1));
+        final ParameterDescriptor<Double> e00 = param.getElementDescriptor(0, 0);
+        final ParameterDescriptor<Double> e01 = param.getElementDescriptor(0, 1);
+        final ParameterDescriptor<Double> e10 = param.getElementDescriptor(1, 0);
+        final ParameterDescriptor<Double> e11 = param.getElementDescriptor(1, 1);
+        verifyDescriptor(N1, e00, 0, 0);
+        verifyDescriptor(N0, e01, 0, 1);
+        verifyDescriptor(N0, e10, 1, 0);
+        verifyDescriptor(N1, e11, 1, 1);
+        assertSame(e00, param.getElementDescriptor(0, 0)); // Test caching.
+        assertSame(e01, param.getElementDescriptor(0, 1));
+        assertSame(e10, param.getElementDescriptor(1, 0));
+        assertSame(e11, param.getElementDescriptor(1, 1));
     }
 
     /**
@@ -165,8 +206,7 @@ public final strictfp class TensorParame
     public void testGetElementDescriptorOutsideCache() {
         final int row = TensorParameters.CACHE_SIZE + 1;
         final int col = TensorParameters.CACHE_SIZE + 2;
-        verifyDescriptor(new String[][] {{"elt_" + row + "_" + col}}, null, null, 0.0,
-                WKT1.getElementDescriptor(row, col), 0, 0);
+        verifyDescriptor("elt_" + row + "_" + col, 0.0, param.getElementDescriptor(row, col));
     }
 
     /**
@@ -174,13 +214,8 @@ public final strictfp class TensorParame
      */
     @Test
     public void testIndicesToName() {
-        testIndicesToName(WKT1);
-    }
-
-    /** Implementation of {@link #testIndicesToName()} with user-supplied parameters. */
-    static void testIndicesToName(final TensorParameters<Double> WKT1) {
-        assertEquals("elt_4_8", WKT1.indicesToName(new int[] {4, 8}));
-        assertEquals("elt_7_2", WKT1.indicesToName(new int[] {7, 2}));
+        assertEquals("elt_4_8", param.indicesToName(new int[] {4, 8}));
+        assertEquals("elt_7_2", param.indicesToName(new int[] {7, 2}));
     }
 
     /**
@@ -188,17 +223,12 @@ public final strictfp class TensorParame
      */
     @Test
     public void testNameToIndices() {
-        testNameToIndices(WKT1);
-    }
-
-    /** Implementation of {@link #testNameToIndices()} with user-supplied parameters. */
-    static void testNameToIndices(final TensorParameters<Double> WKT1) {
-        assertArrayEquals(new int[] {4, 8}, WKT1.nameToIndices("elt_4_8"));
-        assertArrayEquals(new int[] {7, 2}, WKT1.nameToIndices("elt_7_2"));
-        assertNull(WKT1.nameToIndices("other_7_2"));
-        assertNull(WKT1.nameToIndices("elt_7"));
+        assertArrayEquals(new int[] {4, 8}, param.nameToIndices("elt_4_8"));
+        assertArrayEquals(new int[] {7, 2}, param.nameToIndices("elt_7_2"));
+        assertNull(param.nameToIndices("other_7_2"));
+        assertNull(param.nameToIndices("elt_7"));
         try {
-            WKT1.nameToIndices("elt_7_2_3");
+            param.nameToIndices("elt_7_2_3");
             fail("Should not have parsed a name with too many indices.");
         } catch (IllegalArgumentException e) {
             // This is the expected exception.
@@ -211,71 +241,66 @@ public final strictfp class TensorParame
     @Test
     @DependsOnMethod("testGetElementDescriptor")
     public void testDescriptors() {
-        testDescriptors(WKT1, false, ELEMENT_NAMES, null, null);
-    }
+        final boolean isEPSG = (identifiers != null);
 
-    /** Implementation of {@link #testDescriptors()} with user-supplied parameters. */
-    static void testDescriptors(final TensorParameters<Double> WKT1, final boolean isEPSG,
-            final String[][] names, final String[][] aliases, final short[][] identifiers)
-    {
         final Double  N0 = 0.0;
         final Double  N1 = 1.0;
         final Integer N3 = 3;
-        List<GeneralParameterDescriptor> descriptors = WKT1.descriptors(new int[] {1, 1});
-        verifyDescriptor(SIZE_NAMES, null, null,      N3, descriptors.get(0), 0, 0);
-        verifyDescriptor(SIZE_NAMES, null, null,      N3, descriptors.get(1), 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(2), 0, 0);
+        List<GeneralParameterDescriptor> descriptors = param.descriptors(new int[] {1, 1});
+        verifyDescriptor(NUM_ROW, N3, descriptors.get(0));
+        verifyDescriptor(NUM_COL, N3, descriptors.get(1));
+        verifyDescriptor(N1, descriptors.get(2), 0, 0);
         assertEquals("size", 3, descriptors.size());
 
-        descriptors = WKT1.descriptors(new int[] {2, 3});
-        verifyDescriptor(SIZE_NAMES, null, null,      N3, descriptors.get(0), 0, 0);
-        verifyDescriptor(SIZE_NAMES, null, null,      N3, descriptors.get(1), 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(2), 0, 0);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(3), 0, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(4), 0, 2);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(5), 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(6), 1, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(7), 1, 2);
+        descriptors = param.descriptors(new int[] {2, 3});
+        verifyDescriptor(NUM_ROW, N3, descriptors.get(0));
+        verifyDescriptor(NUM_COL, N3, descriptors.get(1));
+        verifyDescriptor(N1, descriptors.get(2), 0, 0);
+        verifyDescriptor(N0, descriptors.get(3), 0, 1);
+        verifyDescriptor(N0, descriptors.get(4), 0, 2);
+        verifyDescriptor(N0, descriptors.get(5), 1, 0);
+        verifyDescriptor(N1, descriptors.get(6), 1, 1);
+        verifyDescriptor(N0, descriptors.get(7), 1, 2);
         assertEquals("size", 8, descriptors.size());
 
-        descriptors = WKT1.descriptors(new int[] {3, 3});
+        descriptors = param.descriptors(new int[] {3, 3});
         int i = 0;
         if (!isEPSG) {
-            verifyDescriptor(SIZE_NAMES, null, null,  N3, descriptors.get(i++), 0, 0);
-            verifyDescriptor(SIZE_NAMES, null, null,  N3, descriptors.get(i++), 1, 0);
+            verifyDescriptor(NUM_ROW, N3, descriptors.get(i++));
+            verifyDescriptor(NUM_COL, N3, descriptors.get(i++));
         }
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(i++), 0, 0);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(i++), 0, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(i++), 0, 2);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(i++), 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(i++), 1, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(i++), 1, 2);
+        verifyDescriptor(N1, descriptors.get(i++), 0, 0);
+        verifyDescriptor(N0, descriptors.get(i++), 0, 1);
+        verifyDescriptor(N0, descriptors.get(i++), 0, 2);
+        verifyDescriptor(N0, descriptors.get(i++), 1, 0);
+        verifyDescriptor(N1, descriptors.get(i++), 1, 1);
+        verifyDescriptor(N0, descriptors.get(i++), 1, 2);
         if (!isEPSG) {
-            verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(i++), 2, 0);
-            verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(i++), 2, 1);
-            verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(i++), 2, 2);
+            verifyDescriptor(N0, descriptors.get(i++), 2, 0);
+            verifyDescriptor(N0, descriptors.get(i++), 2, 1);
+            verifyDescriptor(N1, descriptors.get(i++), 2, 2);
         }
         assertEquals("size", i, descriptors.size());
 
-        descriptors = WKT1.descriptors(new int[] {4, 4});
-        verifyDescriptor(SIZE_NAMES, null, null,      N3, descriptors.get( 0), 0, 0);
-        verifyDescriptor(SIZE_NAMES, null, null,      N3, descriptors.get( 1), 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get( 2), 0, 0);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 3), 0, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 4), 0, 2);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 5), 0, 3);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 6), 1, 0);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get( 7), 1, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 8), 1, 2);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get( 9), 1, 3);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(10), 2, 0);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(11), 2, 1);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(12), 2, 2);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(13), 2, 3);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(14), 3, 0);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(15), 3, 1);
-        verifyDescriptor(names, aliases, identifiers, N0, descriptors.get(16), 3, 2);
-        verifyDescriptor(names, aliases, identifiers, N1, descriptors.get(17), 3, 3);
+        descriptors = param.descriptors(new int[] {4, 4});
+        verifyDescriptor(NUM_ROW, N3, descriptors.get(0));
+        verifyDescriptor(NUM_COL, N3, descriptors.get(1));
+        verifyDescriptor(N1, descriptors.get( 2), 0, 0);
+        verifyDescriptor(N0, descriptors.get( 3), 0, 1);
+        verifyDescriptor(N0, descriptors.get( 4), 0, 2);
+        verifyDescriptor(N0, descriptors.get( 5), 0, 3);
+        verifyDescriptor(N0, descriptors.get( 6), 1, 0);
+        verifyDescriptor(N1, descriptors.get( 7), 1, 1);
+        verifyDescriptor(N0, descriptors.get( 8), 1, 2);
+        verifyDescriptor(N0, descriptors.get( 9), 1, 3);
+        verifyDescriptor(N0, descriptors.get(10), 2, 0);
+        verifyDescriptor(N0, descriptors.get(11), 2, 1);
+        verifyDescriptor(N1, descriptors.get(12), 2, 2);
+        verifyDescriptor(N0, descriptors.get(13), 2, 3);
+        verifyDescriptor(N0, descriptors.get(14), 3, 0);
+        verifyDescriptor(N0, descriptors.get(15), 3, 1);
+        verifyDescriptor(N0, descriptors.get(16), 3, 2);
+        verifyDescriptor(N1, descriptors.get(17), 3, 3);
         assertEquals("size", 18, descriptors.size());
     }
 
@@ -286,7 +311,7 @@ public final strictfp class TensorParame
     @Test
     @DependsOnMethod("testDescriptors")
     public void testMatrixConversion() {
-        final int size = 8;
+        final int size = Math.min(6, TensorParameters.CACHE_SIZE);
         final Random random = TestUtilities.createRandomNumberGenerator();
         for (int numRow = 2; numRow <= size; numRow++) {
             for (int numCol = 2; numCol <= size; numCol++) {
@@ -296,12 +321,13 @@ public final strictfp class TensorParame
                         matrix.setElement(j, i, 200*random.nextDouble() - 100);
                     }
                 }
-                final ParameterValueGroup group = WKT1.createValueGroup(singletonMap(NAME_KEY, "Test"), matrix);
+                final ParameterValueGroup group = param.createValueGroup(
+                        singletonMap(GeneralParameterDescriptor.NAME_KEY, "Test"), matrix);
                 validate(group);
                 assertEquals("num_row",  numRow, group.parameter("num_row").intValue());
                 assertEquals("num_col",  numCol, group.parameter("num_col").intValue());
-                assertEquals("elements", matrix, WKT1.toMatrix(group));
-                assertEquals("elements", matrix, WKT1.toMatrix(new ParameterValueGroupWrapper(group)));
+                assertEquals("elements", matrix, param.toMatrix(group));
+                assertEquals("elements", matrix, param.toMatrix(new ParameterValueGroupWrapper(group)));
             }
         }
     }
@@ -311,6 +337,6 @@ public final strictfp class TensorParame
      */
     @Test
     public void testSerialization() {
-        assertSerializedEquals(WKT1);
+        assertSerializedEquals(param);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/TensorValuesTest.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -26,7 +26,6 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.referencing.operation.Matrix;
 import org.apache.sis.referencing.operation.matrix.Matrices;
-import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -311,7 +310,7 @@ public final strictfp class TensorValues
     }
 
     /**
-     * Tests WKT 1 formatting.
+     * Tests {@link TensorParameters#WKT1} formatting.
      * <ul>
      *   <li>Group name shall be {@code "Affine"}.</li>
      *   <li>Parameters {@code "num_row"} and {@code "num_col"} are mandatory.</li>
@@ -328,17 +327,17 @@ public final strictfp class TensorValues
         final ParameterValueGroup group = TensorParameters.WKT1.createValueGroup(
                 singletonMap(TensorValues.NAME_KEY, "Affine"), matrix);
         validate(group);
-        assertWktEquals(Convention.WKT1,
-                "PARAMETERGROUP[“Affine”,\n"      +
-                "  PARAMETER[“num_row”, 4],\n"    +
-                "  PARAMETER[“num_col”, 4],\n"    +
-                "  PARAMETER[“elt_0_2”, 4.0],\n"  +
-                "  PARAMETER[“elt_1_0”, -2.0],\n" +
-                "  PARAMETER[“elt_2_3”, 7.0]]", group);
+        assertWktEquals(
+                "ParameterGroup[“Affine”,\n"      +
+                "  Parameter[“num_row”, 4],\n"    +
+                "  Parameter[“num_col”, 4],\n"    +
+                "  Parameter[“elt_0_2”, 4.0],\n"  +
+                "  Parameter[“elt_1_0”, -2.0],\n" +
+                "  Parameter[“elt_2_3”, 7.0]]", group);
     }
 
     /**
-     * Tests WKT 2 formatting using EPSG parameter names.
+     * Tests {@link TensorParameters#EPSG} formatting.
      * <ul>
      *   <li>Group name shall be {@code "Affine general parametric transformation"}.</li>
      *   <li>No {@code "num_row"} or {@code "num_col"} parameters.</li>

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=1661139&r1=1661138&r2=1661139&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 Feb 20 15:24:52 2015
@@ -76,6 +76,7 @@ import org.junit.BeforeClass;
     org.apache.sis.parameter.ParameterFormatTest.class,
     org.apache.sis.parameter.TensorParametersTest.class,
     org.apache.sis.parameter.MatrixParametersTest.class,
+    org.apache.sis.parameter.MatrixParametersEPSGTest.class,
     org.apache.sis.parameter.TensorValuesTest.class,
 
     org.apache.sis.referencing.operation.DefaultFormulaTest.class,

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1661139&r1=1661138&r2=1661139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] Fri Feb 20 15:24:52 2015
@@ -20,7 +20,6 @@ import java.util.Set;
 import java.util.List;
 import java.util.HashSet;
 import java.util.Arrays;
-import java.util.Comparator;
 import java.io.PrintWriter;
 
 import org.junit.Test;
@@ -249,12 +248,7 @@ public final class TestRunner extends Bl
         for (final FrameworkMethod method : children) {
             sorter.apply(method);
         }
-        Arrays.sort(children, new Comparator<FrameworkMethod>() {
-            @Override
-            public int compare(FrameworkMethod o1, FrameworkMethod o2) {
-                return sorter.compare(describeChild(o1), describeChild(o2));
-            }
-        });
+        Arrays.sort(children, (FrameworkMethod o1, FrameworkMethod o2) -> sorter.compare(describeChild(o1), describeChild(o2)));
         sortDependantTestsLast(children);
         filteredChildren = children;
     }
@@ -298,8 +292,7 @@ public final class TestRunner extends Bl
     public void filter(final Filter filter) throws NoTestsRemainException {
         int count = 0;
         FrameworkMethod[] children = getFilteredChildren();
-        for (int i=0; i<children.length; i++) {
-            final FrameworkMethod method = children[i];
+        for (final FrameworkMethod method : children) {
             if (filter.shouldRun(describeChild(method))) {
                 try {
                     filter.apply(method);



Mime
View raw message