sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1723082 [2/2] - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-referencing/src/main/java/org/apache/sis/parameter/ sis-referencing/src/main/java/org/apache/sis/referencing/factory/ sis-referenc...
Date Tue, 05 Jan 2016 14:20:08 GMT
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -601,14 +601,16 @@ public class DefaultMathTransformFactory
          * or something equivalent, copies those parameters into the structure expected by
the provider.
          * The intend is to make sure that we have room for the parameters that {@code setEllipsoids(…)}
          * may write.
+         *
+         * @param writable {@code true} if this method should also check that the parameters
group is not
+         *        an instance of {@link UnmodifiableParameterValueGroup}. Current implementation
assumes
+         *        that modifiable parameters are instances of {@link DefaultParameterValueGroup}.
          */
-        private void ensureCompatibleParameters() {
+        private void ensureCompatibleParameters(final boolean writable) {
             final ParameterDescriptorGroup expected = provider.getParameters();
-            if (parameters.getDescriptor() != expected || !(parameters instanceof DefaultParameterValueGroup))
{
-                /*
-                 * The above check for DefaultParameterValueGroup is for replacing ImmutableParameterValueGroup
-                 * by a writable instance.
-                 */
+            if (parameters.getDescriptor() != expected ||
+                    (writable && !(parameters instanceof DefaultParameterValueGroup)))
+            {
                 final ParameterValueGroup copy = expected.createValue();
                 Parameters.copy(parameters, copy);
                 parameters = copy;
@@ -678,7 +680,7 @@ public class DefaultMathTransformFactory
              * projections, which is not allowed.
              */
             if (ellipsoid != null) {
-                ensureCompatibleParameters();
+                ensureCompatibleParameters(true);
                 ParameterValue<?> mismatchedParam = null;
                 double mismatchedValue = 0;
                 try {
@@ -758,6 +760,7 @@ public class DefaultMathTransformFactory
          *         informative exception.
          */
         final RuntimeException setEllipsoids(final OperationMethod method) {
+            ensureCompatibleParameters(false);
             int n;
             if (method instanceof AbstractProvider) {
                 n = ((AbstractProvider) method).getEllipsoidsMask();
@@ -775,7 +778,7 @@ public class DefaultMathTransformFactory
                 case 3: {
                     RuntimeException failure = null;
                     if (sourceCS != null) try {
-                        ensureCompatibleParameters();
+                        ensureCompatibleParameters(true);
                         final ParameterValue<?> p = parameters.parameter("dim");
                         if (p.getValue() == null) {
                             p.setValue(sourceCS.getDimension());
@@ -824,7 +827,7 @@ public class DefaultMathTransformFactory
      * The complete group of parameters, including {@code "semi_major"}, {@code "semi_minor"}
or other calculated values,
      * can be obtained by a call to {@link Context#getCompletedParameters()} after {@code
createParameterizedTransform(…)}
      * returned. Note that the completed parameters may only have additional parameters compared
to the given parameter
-     * group; existing parameter values are never modified.
+     * group; existing parameter values should not be modified.
      *
      * <p>The {@code OperationMethod} instance used by this constructor can be obtained
by a call to
      * {@link #getLastMethodUsed()}.</p>

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2001.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2001.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2001.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2001.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -23,8 +23,10 @@ import org.apache.sis.internal.system.Lo
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.referencing.factory.sql.EPSGFactory;
 
 import static org.opengis.test.Assert.*;
@@ -44,6 +46,7 @@ import static org.opengis.test.Assert.*;
  * @module
  */
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2001 extends org.opengis.test.referencing.gigs.GIGS2001 {
     /**
      * The factory instance to use for the tests, or {@code null} if not available.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -44,6 +46,7 @@ import org.apache.sis.test.DependsOn;
     GIGS3002.class      // Ellipsoids created from properties
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2002 extends org.opengis.test.referencing.gigs.GIGS2002 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2003.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2003.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2003.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2003.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -44,6 +46,7 @@ import org.apache.sis.test.DependsOn;
     GIGS3003.class      // Prime meridians created from properties
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2003 extends org.opengis.test.referencing.gigs.GIGS2003 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -46,6 +48,7 @@ import org.apache.sis.test.DependsOn;
     GIGS3004.class      // Geodetic datums created from properties
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2004 extends org.opengis.test.referencing.gigs.GIGS2004 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -45,6 +47,7 @@ import org.apache.sis.test.DependsOn;
     GIGS3005.class      // Conversions created from properties
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2005 extends org.opengis.test.referencing.gigs.GIGS2005 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -45,6 +47,7 @@ import org.apache.sis.test.DependsOn;
     GIGS2005.class      // Conversions created from EPSG codes
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2006 extends org.opengis.test.referencing.gigs.GIGS2006 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2007.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2007.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2007.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2007.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -44,6 +46,7 @@ import org.apache.sis.test.DependsOn;
     GIGS2006.class      // Projected CRSs created from EPSG codes
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2007 extends org.opengis.test.referencing.gigs.GIGS2007 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2008.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2008.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2008.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2008.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -44,6 +46,7 @@ import org.apache.sis.test.DependsOn;
     GIGS2001.class      // Units created from EPSG codes
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2008 extends org.opengis.test.referencing.gigs.GIGS2008 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2009.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2009.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2009.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2009.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.util.FactoryException
 // Test imports
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 import org.apache.sis.test.DependsOn;
 
 
@@ -44,6 +46,7 @@ import org.apache.sis.test.DependsOn;
     GIGS2008.class      // Vertical CRSs created from EPSG codes
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS2009 extends org.opengis.test.referencing.gigs.GIGS2009 {
     /**
      * Creates a new test using the default authority factory.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3002.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3002.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3002.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3002.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -19,8 +19,10 @@ package org.apache.sis.referencing.facto
 import org.opengis.referencing.datum.DatumFactory;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.test.DependsOn;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 
 
 /**
@@ -36,6 +38,7 @@ import org.junit.runners.JUnit4;
     org.apache.sis.referencing.datum.DefaultEllipsoidTest.class
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS3002 extends org.opengis.test.referencing.gigs.GIGS3002 {
     /**
      * Creates a new test suite using the singleton factory instance.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3003.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3003.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3003.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3003.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -19,8 +19,10 @@ package org.apache.sis.referencing.facto
 import org.opengis.referencing.datum.DatumFactory;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.test.DependsOn;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 
 
 /**
@@ -36,6 +38,7 @@ import org.junit.runners.JUnit4;
     org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS3003 extends org.opengis.test.referencing.gigs.GIGS3003 {
     /**
      * Creates a new test suite using the singleton factory instance.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3004.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3004.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3004.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3004.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -21,8 +21,10 @@ import org.opengis.referencing.crs.CRSFa
 import org.opengis.referencing.datum.DatumFactory;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.test.DependsOn;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 
 
 /**
@@ -41,6 +43,7 @@ import org.junit.runners.JUnit4;
     org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS3004 extends org.opengis.test.referencing.gigs.GIGS3004 {
     /**
      * Creates a new test suite using the singleton factory instance.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3005.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3005.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3005.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS3005.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -19,8 +19,10 @@ package org.apache.sis.referencing.facto
 import org.opengis.referencing.operation.CoordinateOperationFactory;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.test.DependsOn;
+import org.junit.FixMethodOrder;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.junit.runners.MethodSorters;
 
 
 /**
@@ -36,6 +38,7 @@ import org.junit.runners.JUnit4;
     org.apache.sis.referencing.operation.DefaultConversionTest.class
 })
 @RunWith(JUnit4.class)
+@FixMethodOrder(MethodSorters.JVM)      // Intentionally want some randomness
 public final strictfp class GIGS3005 extends org.opengis.test.referencing.gigs.GIGS3005 {
     /**
      * Creates a new test suite using the singleton factory instance.

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/IdentifiedObjectFinderTest.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -116,7 +116,7 @@ public final strictfp class IdentifiedOb
         private final GeodeticAuthorityFactory factory;
 
         public Cached(final GeodeticAuthorityFactory factory) {
-            super(factory.nameFactory);
+            super(GeodeticAuthorityFactory.class, factory.nameFactory);
             this.factory = factory;
         }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -16,22 +16,98 @@
  */
 package org.apache.sis.referencing.factory.sql;
 
-import org.apache.sis.test.TestCase;
+import org.opengis.metadata.Identifier;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.crs.*;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.util.FactoryException;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.referencing.factory.UnavailableFactoryException;
+
+// Test imports
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.LoggingWatcher;
 
-import static org.junit.Assert.*;
+import static org.opengis.test.Assert.*;
+import static org.junit.Assume.assumeNotNull;
 
 
 /**
  * Tests {@link EPSGFactory}.
+ * More tests are provided by the {@code GIGS2000} series
+ * in the {@code org.apache.sis.referencing.factory} package.
  *
- * @author  Martin Desruisseaux (Geomatys)
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @author  Vadim Semenov
  * @since   0.7
  * @version 0.7
  * @module
  */
 public final strictfp class EPSGFactoryTest extends TestCase {
     /**
+     * The factory instance to use for the tests, or {@code null} if not available.
+     */
+    private static EPSGFactory factory;
+
+    /**
+     * Creates the factory to use for all tests in this class.
+     *
+     * @throws FactoryException if an error occurred while creating the factory.
+     */
+    @BeforeClass
+    public static void createFactory() throws FactoryException {
+        if (factory == null) try {
+            factory = new EPSGFactory();
+        } catch (UnavailableFactoryException e) {
+            Logging.getLogger(Loggers.CRS_FACTORY).warning(e.toString());
+            // Leave INSTANCE to null. This will have the effect of skipping tests.
+        }
+    }
+
+    /**
+     * Force releases of JDBC connections after the tests in this class.
+     *
+     * @throws FactoryException if an error occurred while closing the connections.
+     */
+    @AfterClass
+    public static void close() throws FactoryException {
+        if (factory != null) {
+            factory.close();
+            factory = null;
+        }
+    }
+
+    /**
+     * Words that we expect to find in each log messages to be emitted.
+     */
+    private String[][] expectedLogWords;
+
+    /**
+     * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
+     * because JUnit requires us to do so, but should be considered as an implementation
+     * details (it should have been a private field).
+     */
+    @Rule
+    public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.CRS_FACTORY))
{
+        /**
+         * Ensures that the logging message contains some expected words.
+         */
+        @Override
+        protected void verifyMessage(final String message) {
+            for (final String word : expectedLogWords[expectedLogWords.length - (maximumLogCount
+ 1)]) {
+                assertTrue(message, message.contains(word));
+            }
+        }
+    };
+
+    /**
      * Tests {@link EPSGDataAccess#tableMatches(String, String)}.
      */
     @Test
@@ -39,4 +115,246 @@ public final strictfp class EPSGFactoryT
         assertTrue(EPSGDataAccess.tableMatches("Coordinate_Operation",          "epsg_coordoperation"));
         assertTrue(EPSGDataAccess.tableMatches("[Coordinate Reference System]", "epsg_coordinatereferencesystem"));
     }
+
+    /**
+     * Returns the first identifier for the specified object.
+     *
+     * @param object The object for which to get the identifier.
+     * @return The first identifier of the given object.
+     */
+    private static String getIdentifier(final IdentifiedObject object) {
+        return object.getIdentifiers().iterator().next().getCode();
+    }
+
+    /**
+     * Returns the EPSG code of the operation method for the given projected CRS.
+     */
+    private static String getOperationMethod(final ProjectedCRS crs) {
+        final Identifier id = crs.getConversionFromBase().getMethod().getIdentifiers().iterator().next();
+        return id.getCodeSpace() + ':' + id.getCode();
+    }
+
+    /**
+     * Tests a geographic CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test4274() throws FactoryException {
+        assumeNotNull(factory);
+        final GeographicCRS crs = factory.createGeographicCRS("4274");
+        assertEquals("identifier", "4274", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.NORTH,
AxisDirection.EAST);
+    }
+
+    /**
+     * Tests a geographic CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test4617() throws FactoryException {
+        assumeNotNull(factory);
+        final GeographicCRS crs = factory.createGeographicCRS("EPSG:4617");
+        assertEquals("identifier", "4617", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.NORTH,
AxisDirection.EAST);
+    }
+
+    /**
+     * Tests a vertical CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test5735() throws FactoryException {
+        assumeNotNull(factory);
+        final VerticalCRS crs = factory.createVerticalCRS("EPSG:5735");
+        assertEquals("identifier", "5735", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.UP);
+    }
+
+    /**
+     * Tests a geocentric CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test4915() throws FactoryException {
+        assumeNotNull(factory);
+        final GeocentricCRS crs = factory.createGeocentricCRS("EPSG:4915");
+        assertEquals("identifier", "4915", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(),
+                AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z);
+    }
+
+    /**
+     * Tests a three-dimensional geographic CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test4993() throws FactoryException {
+        assumeNotNull(factory);
+        final GeographicCRS crs = factory.createGeographicCRS("EPSG:4993");
+        assertEquals("identifier", "4993", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(),
+                AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
+    }
+
+    /**
+     * Tests a projected CRS using Transverse Mercator projection.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test2027() throws FactoryException {
+        assumeNotNull(factory);
+        final ProjectedCRS crs = factory.createProjectedCRS("2027");
+        assertEquals("identifier", "2027", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
+
+        final ParameterValueGroup parameters = crs.getConversionFromBase().getParameterValues();
+        assertEquals("central_meridian",     -93, parameters.parameter("central_meridian"
 ).doubleValue(), STRICT);
+        assertEquals("latitude_of_origin",     0, parameters.parameter("latitude_of_origin").doubleValue(),
STRICT);
+        assertEquals("scale_factor",      0.9996, parameters.parameter("scale_factor"   
  ).doubleValue(), STRICT);
+        assertEquals("false_easting",     500000, parameters.parameter("false_easting"  
  ).doubleValue(), STRICT);
+        assertEquals("false_northing",         0, parameters.parameter("false_northing" 
  ).doubleValue(), STRICT);
+    }
+
+    /**
+     * Tests a projected CRS using Transverse Mercator projection.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test2442() throws FactoryException {
+        assumeNotNull(factory);
+        final ProjectedCRS crs = factory.createProjectedCRS(" EPSG : 2442 ");
+        assertEquals("identifier", "2442", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.NORTH,
AxisDirection.EAST);
+
+        final ParameterValueGroup parameters = crs.getConversionFromBase().getParameterValues();
+        assertEquals("central_meridian",     135, parameters.parameter("central_meridian"
 ).doubleValue(), STRICT);
+        assertEquals("latitude_of_origin",     0, parameters.parameter("latitude_of_origin").doubleValue(),
STRICT);
+        assertEquals("scale_factor",           1, parameters.parameter("scale_factor"   
  ).doubleValue(), STRICT);
+        assertEquals("false_easting",     500000, parameters.parameter("false_easting"  
  ).doubleValue(), STRICT);
+        assertEquals("false_northing",         0, parameters.parameter("false_northing" 
  ).doubleValue(), STRICT);
+    }
+
+    /**
+     * Tests a projected CRS using Lambert Azimuthal Equal Area (Spherical) projection.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    @Ignore("“Lambert Azimuthal Equal Area (Spherical)” projection is not yet implemented.")
+    public void test3408() throws FactoryException {
+        assumeNotNull(factory);
+        final ProjectedCRS crs = factory.createProjectedCRS("3408");
+        assertEquals("identifier", "3408", getIdentifier(crs));
+        assertEquals("name", "NSIDC EASE-Grid North", crs.getName().getCode());
+        assertEquals("method", "EPSG:1027", getOperationMethod(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
+    }
+
+    /**
+     * Tests the Google projection.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test3857() throws FactoryException {
+        assumeNotNull(factory);
+        final ProjectedCRS crs = factory.createProjectedCRS("3857");
+        assertEquals("identifier", "3857", getIdentifier(crs));
+        assertEquals("name", "WGS 84 / Pseudo-Mercator", crs.getName().getCode());
+        assertEquals("method", "EPSG:1024", getOperationMethod(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
+    }
+
+    /**
+     * Tests an engineering CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test5801() throws FactoryException {
+        assumeNotNull(factory);
+        final EngineeringCRS crs = factory.createEngineeringCRS("EPSG:5801");
+        assertEquals("identifier", "5801", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.NORTH,
AxisDirection.EAST);
+    }
+
+    /**
+     * Tests a compound CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test7400() throws FactoryException {
+        assumeNotNull(factory);
+        final CompoundCRS crs = factory.createCompoundCRS("EPSG:7400");
+        assertEquals("identifier", "7400", getIdentifier(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(),
+                AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
+    }
+
+    /**
+     * Tests a legacy geographic CRS (no longer supported by EPSG).
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test63266405() throws FactoryException {
+        assumeNotNull(factory);
+
+        listener.maximumLogCount = 2;
+        expectedLogWords = new String[][] {
+            {"EPSG:6405"},                      // Coordinate System 6405 is no longer supported
by EPSG
+            {"EPSG:63266405", "4326"}           // EPSG no longer support codes in the 60000000
series.
+        };
+
+        final GeographicCRS crs = factory.createGeographicCRS("63266405");
+        assertEquals("identifier", "63266405", getIdentifier(crs));
+        assertEquals("name", "WGS 84 (deg)", crs.getName().getCode());
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.NORTH,
AxisDirection.EAST);
+    }
+
+    /**
+     * Tests a deprecated projected CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test3786() throws FactoryException {
+        assumeNotNull(factory);
+
+        listener.maximumLogCount = 3;
+        expectedLogWords = new String[][] {
+            {"EPSG:9823",  "1029"},              // Operation method 9823 has been replaced
by 1029
+            {"EPSG:19968", "4086"},              // Coordinate Operation 19968 has been replaced
by 4086
+            {"EPSG:3786",  "4088"}               // Coordinate Reference System 3786 has
been replaced by 4088
+        };
+
+        final ProjectedCRS crs = factory.createProjectedCRS("3786");
+        assertEquals("identifier", "3786", getIdentifier(crs));
+        assertEquals("name", "World Equidistant Cylindrical (Sphere)", crs.getName().getCode());
+        assertEquals("method", "EPSG:9823", getOperationMethod(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
+    }
+
+    /**
+     * Tests the replacement of the deprecated EPSG::3786 projected CRS.
+     *
+     * @throws FactoryException if an error occurred while querying the factory.
+     */
+    @Test
+    public void test4088() throws FactoryException {
+        assumeNotNull(factory);
+        final ProjectedCRS crs = factory.createProjectedCRS("4088");
+        assertEquals("identifier", "4088", getIdentifier(crs));
+        assertEquals("name", "World Equidistant Cylindrical (Sphere)", crs.getName().getCode());
+        assertEquals("method", "EPSG:1029", getOperationMethod(crs));
+        assertAxisDirectionsEqual("axes", crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
+    }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -80,7 +80,7 @@ import java.util.Objects;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  *
  * @see java.util.WeakHashMap
@@ -398,7 +398,7 @@ public class WeakValueHashMap<K,V> exten
      * Implementation of {@link #put(Object, Object)} and {@link #remove(Object)} operations
      */
     @SuppressWarnings("unchecked")
-    private synchronized V intern(final Object key, final V value) {
+    private synchronized V intern(final Object key, final V value, final boolean replace)
{
         assert isValid();
         /*
          * If 'value' is already contained in this WeakValueHashMap, we need to clear it.
@@ -410,6 +410,9 @@ public class WeakValueHashMap<K,V> exten
         for (Entry e = table[index]; e != null; e = (Entry) e.next) {
             if (keyEquals(key, e.key)) {
                 oldValue = e.get();
+                if (oldValue != null && !replace) {
+                    return oldValue;
+                }
                 e.dispose();
                 table = this.table; // May have changed.
                 index = hash % table.length;
@@ -435,8 +438,7 @@ public class WeakValueHashMap<K,V> exten
      *
      * @param  key key with which the specified value is to be associated.
      * @param  value value to be associated with the specified key.
-     * @return The previous value associated with specified key, or {@code null}
-     *         if there was no mapping for key.
+     * @return The previous value associated with specified key, or {@code null} if there
was no mapping for key.
      *
      * @throws NullArgumentException if the key or the value is {@code null}.
      */
@@ -446,19 +448,41 @@ public class WeakValueHashMap<K,V> exten
             throw new NullArgumentException(Errors.format(key == null
                     ? Errors.Keys.NullMapKey : Errors.Keys.NullMapValue));
         }
-        return intern(key, value);
+        return intern(key, value, true);
+    }
+
+    /**
+     * Associates the specified value with the specified key in this map if no value were
previously associated.
+     * If an other value is already associated to the given key, then the map is left unchanged
and the current
+     * value is returned. Otherwise the specified value is associated to the key using a
{@link WeakReference}
+     * and {@code null} is returned.
+     *
+     * @param  key key with which the specified value is to be associated.
+     * @param  value value to be associated with the specified key.
+     * @return The current value associated with specified key, or {@code null} if there
was no mapping for key.
+     *
+     * @throws NullArgumentException if the key or the value is {@code null}.
+     *
+     * @since 0.7
+     */
+    @Override
+    public V putIfAbsent(final K key, final V value) throws NullArgumentException {
+        if (key == null || value == null) {
+            throw new NullArgumentException(Errors.format(key == null
+                    ? Errors.Keys.NullMapKey : Errors.Keys.NullMapValue));
+        }
+        return intern(key, value, false);
     }
 
     /**
      * Removes the mapping for this key from this map if present.
      *
      * @param key key whose mapping is to be removed from the map.
-     * @return previous value associated with specified key, or {@code null}
-     *         if there was no entry for key.
+     * @return previous value associated with specified key, or {@code null} if there was
no entry for key.
      */
     @Override
     public V remove(final Object key) {
-        return intern(key, null);
+        return intern(key, null, true);
     }
 
     /**
@@ -477,6 +501,7 @@ public class WeakValueHashMap<K,V> exten
      * @return a set view of the mappings contained in this map.
      */
     @Override
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
     public synchronized Set<Map.Entry<K,V>> entrySet() {
         if (entrySet == null) {
             entrySet = new EntrySet();

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java [UTF-8]
Tue Jan  5 14:20:08 2016
@@ -141,7 +141,7 @@ public abstract strictfp class TestCase
             for (Logger logger=LOGGER; logger!=null; logger=logger.getParent()) {
                 for (final Handler handler : logger.getHandlers()) {
                     if (handler instanceof ConsoleHandler) {
-                        ((ConsoleHandler) handler).setEncoding(encoding);
+                        handler.setEncoding(encoding);
                     }
                 }
                 if (!logger.getUseParentHandlers()) {

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java?rev=1723082&r1=1723081&r2=1723082&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/collection/IntegerListTest.java
[UTF-8] Tue Jan  5 14:20:08 2016
@@ -162,9 +162,6 @@ public final strictfp class IntegerListT
         testReadWrite(100);
         assertEquals(400, list.size());
         final int old100 = list.getInt(100);
-        final int old101 = list.getInt(101);
-        assertFalse(0 == old100);
-        assertFalse(0 == old101);
         list.resize(101);
         assertEquals(old100, list.getInt(100));
         list.resize(200);




Mime
View raw message