You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/11/18 18:51:35 UTC
svn commit: r1770424 - in /sis/branches/JDK8: ./
core/sis-referencing/src/main/java/org/apache/sis/referencing/
core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/
core/sis-referencing/src/main/java/org/apache/sis/referencing/factory...
Author: desruisseaux
Date: Fri Nov 18 18:51:35 2016
New Revision: 1770424
URL: http://svn.apache.org/viewvc?rev=1770424&view=rev
Log:
Make the referencing module more robust to the case where the SIS_DATA environment variable is defined but the SQL scripts needed for creating the EPSG geodetic dataset are not there.
If the SIS_DATA environment variable is not defined during test execution, set it to the 'target' directory, so a temporary database will be created there.
This fix the test failure introduced by the previous commit in the earth-observation module.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2001.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2003.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2007.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2008.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2009.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
sis/branches/JDK8/pom.xml
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java?rev=1770424&r1=1770423&r2=1770424&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] Fri Nov 18 18:51:35 2016
@@ -102,7 +102,12 @@ final class AuthorityFactories<T extends
}
/**
- * Returns the EPSG factory.
+ * Returns the factory connected to the EPSG geodetic dataset if possible, or the EPSG fallback otherwise.
+ * If an EPSG data source has been found, then this method returns an instance of {@link EPSGFactory} but
+ * there is no guarantee that attempts to use that factory will succeed; for example maybe the EPSG schema
+ * does not exist. Callers should be prepared to either receive an {@link EPSGFactoryFallback} directly if
+ * the EPSG data source does not exist, or replace the {@code EPSGFactory} by a {@code EPSGFactoryFallback}
+ * later if attempt to use the returned factory fails.
*/
static AuthorityFactory EPSG() {
synchronized (EPSG) {
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1770424&r1=1770423&r2=1770424&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Fri Nov 18 18:51:35 2016
@@ -325,7 +325,25 @@ public final class CRS extends Static {
context = new CoordinateOperationContext();
context.setAreaOfInterest(areaOfInterest);
}
- return CoordinateOperations.factory().createOperation(sourceCRS, targetCRS, context);
+ /*
+ * In principle we should just delegate to factory.createOperation(\u2026). However this operation may fail
+ * if a connection to the EPSG database has been found, but the EPSG tables do not yet exist in that
+ * database and
+ */
+ final DefaultCoordinateOperationFactory factory = CoordinateOperations.factory();
+ try {
+ return factory.createOperation(sourceCRS, targetCRS, context);
+ } catch (UnavailableFactoryException e) {
+ if (!AuthorityFactories.failure(e)) {
+ throw e;
+ } try {
+ // Above method call replaced the EPSG factory by a fallback. Try again.
+ return factory.createOperation(sourceCRS, targetCRS, context);
+ } catch (FactoryException ex) {
+ ex.addSuppressed(e);
+ throw ex;
+ }
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java?rev=1770424&r1=1770423&r2=1770424&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] Fri Nov 18 18:51:35 2016
@@ -56,7 +56,7 @@ public class UnavailableFactoryException
/**
* Construct an exception with the specified detail message.
*
- * @param message The detail message. The detail message is saved
+ * @param message the detail message. The detail message is saved
* for later retrieval by the {@link #getMessage()} method.
*/
public UnavailableFactoryException(String message) {
@@ -68,9 +68,9 @@ public class UnavailableFactoryException
* The cause is the exception thrown in the underlying database
* (e.g. {@link java.io.IOException} or {@link java.sql.SQLException}).
*
- * @param message The detail message. The detail message is saved
+ * @param message the detail message. The detail message is saved
* for later retrieval by the {@link #getMessage()} method.
- * @param cause The cause for this exception. The cause is saved
+ * @param cause the cause for this exception. The cause is saved
* for later retrieval by the {@link #getCause()} method.
*/
public UnavailableFactoryException(String message, Throwable cause) {
@@ -90,7 +90,7 @@ public class UnavailableFactoryException
* unavailable. User may want to be informed about which factory is unavailable, for example in order
* to remove it from the list of factory managed by {@link MultiAuthoritiesFactory}.</div>
*
- * @param factory The factory which is unavailable.
+ * @param factory the factory which is unavailable.
*/
public void setUnavailableFactory(final AuthorityFactory factory) {
this.factory = factory;
@@ -100,7 +100,7 @@ public class UnavailableFactoryException
* Returns the factory which has been found unavailable, or {@code null} if unspecified.
* See {@link #setUnavailableFactory(AuthorityFactory)} for more details.
*
- * @return The factory that should be considered as unavailable.
+ * @return the factory that should be considered as unavailable.
*/
public AuthorityFactory getUnavailableFactory() {
return factory;
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java?rev=1770424&r1=1770423&r2=1770424&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java [UTF-8] Fri Nov 18 18:51:35 2016
@@ -224,6 +224,7 @@ public abstract class InstallationScript
} else {
in = openStream(name);
charset = StandardCharsets.ISO_8859_1;
+ name = name.concat(".sql");
}
if (in == null) {
throw new FileNotFoundException(Errors.format(Errors.Keys.FileNotFound_1, name));
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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -16,9 +16,13 @@
*/
package org.apache.sis.referencing.factory;
+import java.util.Map;
+import java.util.HashMap;
import org.opengis.util.FactoryException;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.referencing.factory.sql.EPSGFactory;
// Test imports
import org.junit.AfterClass;
@@ -27,7 +31,6 @@ 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.*;
@@ -42,7 +45,7 @@ import static org.opengis.test.Assert.*;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.7
- * @version 0.7
+ * @version 0.8
* @module
*/
@RunWith(JUnit4.class)
@@ -50,41 +53,60 @@ import static org.opengis.test.Assert.*;
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.
+ * This field is set by {@link #createFactory()} and cleared by {@link #close()}.
*/
- static EPSGFactory INSTANCE;
+ public static EPSGFactory factory;
/**
- * The last failure message logged. Used for avoiding to repeat the same message many times.
+ * {@code true} if we failed to create the {@link #factory}.
*/
- private static String failure;
+ private static boolean isUnavailable;
/**
* Creates a new test using the default authority factory.
*/
public GIGS2001() {
- super(INSTANCE);
+ super(factory);
}
/**
* Creates the factory to use for all tests in this class.
+ * If this method fails to create the factory, then {@link #factory} is left to {@code null} value.
*
* @throws FactoryException if an error occurred while creating the factory.
*/
@BeforeClass
+ @SuppressWarnings("null")
public static void createFactory() throws FactoryException {
- if (INSTANCE == null) try {
- INSTANCE = new EPSGFactory(null);
- } catch (UnavailableFactoryException e) {
- final String message = e.toString();
- if (!message.equals(failure)) {
- failure = message;
- Logging.getLogger(Loggers.CRS_FACTORY).warning(message);
+ if (!isUnavailable) {
+ EPSGFactory af = factory;
+ if (af == null) {
+ final GeodeticObjectFactory f = new GeodeticObjectFactory();
+ final Map<String,Object> properties = new HashMap<>(6);
+ assertNull(properties.put("datumFactory", f));
+ assertNull(properties.put("csFactory", f));
+ assertNull(properties.put("crsFactory", f));
+ try {
+ af = new EPSGFactory(properties);
+ assertEquals("Expected no Data Access Object (DAO) before the first test is run.",
+ 0, ((ConcurrentAuthorityFactory) af).countAvailableDataAccess());
+ /*
+ * Above method call may fail if no data source has been specified.
+ * Following method call may fail if a data source has been specified,
+ * but the database does not contain the required tables.
+ */
+ assertNotNull(af.createUnit(String.valueOf(Constants.EPSG_METRE)));
+ factory = af; // Must be last.
+ } catch (UnavailableFactoryException e) {
+ isUnavailable = true;
+ Logging.getLogger(Loggers.CRS_FACTORY).warning(e.toString());
+ } finally {
+ if (factory != af) {
+ af.close();
+ }
+ }
}
- // Leave INSTANCE to null. This will have the effect of skipping tests.
- return;
}
- assertEquals("Expected no Data Access Object (DAO) before the first test is run.",
- 0, ((ConcurrentAuthorityFactory) INSTANCE).countAvailableDataAccess());
}
/**
@@ -94,10 +116,11 @@ public final strictfp class GIGS2001 ext
*/
@AfterClass
public static void close() throws FactoryException {
- if (INSTANCE != null) {
- final int n = ((ConcurrentAuthorityFactory) INSTANCE).countAvailableDataAccess();
- INSTANCE.close();
- // Do not set INSTANCE to null, as it will be reused by other GIGS tests.
+ final EPSGFactory af = factory;
+ if (af != null) {
+ factory = null;
+ final int n = ((ConcurrentAuthorityFactory) af).countAvailableDataAccess();
+ af.close();
assertBetween("Since we ran all tests sequantially, should have no more than 1 Data Access Object (DAO).", 0, 1, n);
}
}
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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -64,7 +64,7 @@ public final strictfp class GIGS2002 ext
* Creates a new test using the default authority factory.
*/
public GIGS2002() {
- super(GIGS2001.INSTANCE);
+ super(GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -52,7 +52,7 @@ public final strictfp class GIGS2003 ext
* Creates a new test using the default authority factory.
*/
public GIGS2003() {
- super(GIGS2001.INSTANCE);
+ super(GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -68,7 +68,7 @@ public final strictfp class GIGS2004 ext
* Creates a new test using the default authority factory.
*/
public GIGS2004() {
- super(GIGS2001.INSTANCE, GIGS2001.INSTANCE);
+ super(GIGS2001.factory, GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -65,7 +65,7 @@ public final strictfp class GIGS2005 ext
* Creates a new test using the default authority factory.
*/
public GIGS2005() {
- super(GIGS2001.INSTANCE);
+ super(GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -65,7 +65,7 @@ public final strictfp class GIGS2006 ext
* Creates a new test using the default authority factory.
*/
public GIGS2006() {
- super(GIGS2001.INSTANCE);
+ super(GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -52,7 +52,7 @@ public final strictfp class GIGS2007 ext
* Creates a new test using the default authority factory.
*/
public GIGS2007() {
- super(GIGS2001.INSTANCE);
+ super(GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -52,7 +52,7 @@ public final strictfp class GIGS2008 ext
* Creates a new test using the default authority factory.
*/
public GIGS2008() {
- super(GIGS2001.INSTANCE, GIGS2001.INSTANCE);
+ super(GIGS2001.factory, GIGS2001.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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -52,7 +52,7 @@ public final strictfp class GIGS2009 ext
* Creates a new test using the default authority factory.
*/
public GIGS2009() {
- super(GIGS2001.INSTANCE);
+ super(GIGS2001.factory);
}
/**
@@ -73,6 +73,5 @@ public final strictfp class GIGS2009 ext
@AfterClass
public static void close() throws FactoryException {
GIGS2001.close();
- GIGS2001.INSTANCE = null; // Since this is the last test of the 2000 series, we can let GC do its work.
}
}
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=1770424&r1=1770423&r2=1770424&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] Fri Nov 18 18:51:35 2016
@@ -20,7 +20,6 @@ import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Locale;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Collections;
import javax.measure.Unit;
@@ -47,7 +46,6 @@ import org.opengis.referencing.operation
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.Projection;
import org.opengis.util.FactoryException;
-import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.cs.AxesConvention;
@@ -55,9 +53,7 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.referencing.datum.BursaWolfParameters;
import org.apache.sis.referencing.datum.DefaultGeodeticDatum;
import org.apache.sis.referencing.operation.AbstractCoordinateOperation;
-import org.apache.sis.referencing.factory.GeodeticObjectFactory;
import org.apache.sis.referencing.factory.IdentifiedObjectFinder;
-import org.apache.sis.referencing.factory.UnavailableFactoryException;
// Test imports
import org.junit.Rule;
@@ -70,6 +66,7 @@ import org.apache.sis.test.TestCase;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.referencing.factory.GIGS2001;
import static org.junit.Assume.assumeNotNull;
import static org.apache.sis.test.ReferencingAssert.*;
@@ -93,28 +90,13 @@ import static org.apache.sis.test.Refere
})
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 {
- final GeodeticObjectFactory f = new GeodeticObjectFactory();
- final Map<String,Object> properties = new HashMap<>(6);
- assertNull(properties.put("datumFactory", f));
- assertNull(properties.put("csFactory", f));
- assertNull(properties.put("crsFactory", f));
- try {
- factory = new EPSGFactory(properties);
- } catch (UnavailableFactoryException e) {
- Logging.getLogger(Loggers.CRS_FACTORY).warning(e.toString());
- // Leave INSTANCE to null. This will have the effect of skipping tests.
- }
+ GIGS2001.createFactory();
}
/**
@@ -124,10 +106,7 @@ public final strictfp class EPSGFactoryT
*/
@AfterClass
public static void close() throws FactoryException {
- if (factory != null) {
- factory.close();
- factory = null;
- }
+ GIGS2001.close();
}
/**
@@ -161,6 +140,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testWGS84() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326");
assertEpsgNameAndIdentifierEqual("WGS 84", 4326, crs);
@@ -182,6 +162,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testWGS84")
public void testGeographic2D() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final GeographicCRS crs = factory.createGeographicCRS("4274");
assertEpsgNameAndIdentifierEqual("Datum 73", 4274, crs);
@@ -202,6 +183,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testGeographic2D")
public void testGeographic3D() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final GeographicCRS crs = factory.createGeographicCRS("EPSG::4993");
assertEpsgNameAndIdentifierEqual("Lao 1997", 4993, crs);
@@ -219,6 +201,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testGeocentric() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final GeocentricCRS crs = factory.createGeocentricCRS("epsg:4915");
assertEpsgNameAndIdentifierEqual("ITRF93", 4915, crs);
@@ -237,6 +220,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testGeographic2D")
public void testProjected() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS("2027");
assertEpsgNameAndIdentifierEqual("NAD27(76) / UTM zone 15N", 2027, crs);
@@ -274,6 +258,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testProjected")
public void testProjectedNorthEast() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS(" EPSG : 2442 ");
assertEpsgNameAndIdentifierEqual("Beijing 1954 / 3-degree Gauss-Kruger CM 135E", 2442, crs);
@@ -306,6 +291,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testProjected")
public void testProjectedWithSharedConversion() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS("32210");
assertEpsgNameAndIdentifierEqual("WGS 72 / UTM zone 10N", 32210, crs);
@@ -344,6 +330,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testCreateByName")
public void testProjectedByName() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS("NTF (Paris) / Lambert zone I");
assertEpsgNameAndIdentifierEqual("NTF (Paris) / Lambert zone I", 27571, crs);
@@ -371,6 +358,7 @@ public final strictfp class EPSGFactoryT
@Test
@Ignore("\u201cLambert Azimuthal Equal Area (Spherical)\u201d projection is not yet implemented.")
public void testProjectedOnPole() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS("3408");
assertEpsgNameAndIdentifierEqual("NSIDC EASE-Grid North", 3408, crs);
@@ -390,6 +378,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testGoogleProjection() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS("3857");
assertEpsgNameAndIdentifierEqual("WGS 84 / Pseudo-Mercator", 3857, crs);
@@ -408,6 +397,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testEngineering() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final EngineeringCRS crs = factory.createEngineeringCRS("EPSG:5801");
assertEpsgNameAndIdentifierEqual("Barcelona Grid B1", 5801, crs);
@@ -423,6 +413,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testVertical() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final VerticalCRS crs = factory.createVerticalCRS("EPSG:5735");
assertEpsgNameAndIdentifierEqual("Black Sea height", 5735, crs);
@@ -440,6 +431,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod({"testGeographic2D", "testVertical"})
public void testCompound() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final CompoundCRS crs = factory.createCompoundCRS("EPSG:7400");
assertEpsgNameAndIdentifierEqual("NTF (Paris) + NGF IGN69 height", 7400, crs);
@@ -469,6 +461,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testDeprecatedCoordinateSystems() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
for (final Map.Entry<Integer,Integer> entry : EPSGDataAccess.deprecatedCS().entrySet()) {
final CoordinateSystem expected = factory.createEllipsoidalCS(entry.getValue().toString());
@@ -511,6 +504,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod({"testGeographic2D", "testDeprecatedCoordinateSystems"})
public void testDeprecatedGeographic() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final GeographicCRS crs = factory.createGeographicCRS("63266405");
@@ -532,6 +526,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod({"testDeprecatedGeographic", "testDeprecatedCoordinateSystems"})
public void testDeprecatedProjected() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final ProjectedCRS crs = factory.createProjectedCRS("3786");
@@ -564,6 +559,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testCreateByName() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
assertSame (factory.createUnit("9002"), factory.createUnit("foot"));
assertNotSame(factory.createUnit("9001"), factory.createUnit("foot"));
@@ -595,6 +591,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testAuthorityCodes() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
/*
* Most basic objects.
@@ -761,6 +758,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testDescriptionText() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
assertEquals("World Geodetic System 1984", factory.getDescriptionText( "6326").toString(Locale.US));
@@ -778,6 +776,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testProjectedWithSharedConversion")
public void testConversion() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
/*
* Fetch directly the "UTM zone 10N" operation. Because this operation was not obtained in
@@ -834,6 +833,7 @@ public final strictfp class EPSGFactoryT
*/
@Test
public void testSimpleTransformation() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final CoordinateOperation operation = factory.createCoordinateOperation("1764");
assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (2)", 1764, operation);
@@ -851,6 +851,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testSimpleTransformation")
public void testTransformation() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final CoordinateOperation operation = factory.createCoordinateOperation("1609");
assertEpsgNameAndIdentifierEqual("BD72 to WGS 84 (1)", 1609, operation);
@@ -867,6 +868,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testTransformation")
public void testCreateFromCoordinateReferenceSystemCodes() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
/*
* ED50 (4230) to WGS 84 (4326) using
@@ -940,6 +942,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testWGS84")
public void testFindGeographic() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final IdentifiedObjectFinder finder = factory.newIdentifiedObjectFinder();
final DefaultGeographicCRS crs = (DefaultGeographicCRS) CRS.fromWKT(
@@ -987,6 +990,7 @@ public final strictfp class EPSGFactoryT
@Test
@DependsOnMethod("testFindGeographic")
public void testFindProjected() throws FactoryException {
+ final EPSGFactory factory = GIGS2001.factory;
assumeNotNull(factory);
final IdentifiedObjectFinder finder = factory.newIdentifiedObjectFinder();
/*
Modified: sis/branches/JDK8/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/pom.xml?rev=1770424&r1=1770423&r2=1770424&view=diff
==============================================================================
--- sis/branches/JDK8/pom.xml (original)
+++ sis/branches/JDK8/pom.xml Fri Nov 18 18:51:35 2016
@@ -490,12 +490,15 @@ Apache SIS is a free software, Java lang
<profile>
<id>apache-release</id>
<properties>
- <maven.compiler.debug>false</maven.compiler.debug> <!-- For smaller JAR files size. -->
+ <maven.compiler.debug>false</maven.compiler.debug> <!-- For smaller JAR files size. -->
<maven.compiler.optimize>true</maven.compiler.optimize>
<org.apache.sis.test.extensive>true</org.apache.sis.test.extensive>
</properties>
</profile>
+
+ <!-- Cross-version compilation (to be removed with JDK9). -->
<profile>
+ <id>bootclasspath</id>
<activation>
<property>
<name>bootclasspath</name>
@@ -519,6 +522,31 @@ Apache SIS is a free software, Java lang
</configuration>
</plugin>
</plugins>
+ </build>
+ </profile>
+
+ <!-- ===================================================================
+ If the user has not set the SIS_DATA environment variable, set a
+ default value where we can create a minimalist database.
+ =================================================================== -->
+ <profile>
+ <id>sis-data</id>
+ <activation>
+ <property>
+ <name>!env.SIS_DATA</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <environmentVariables>
+ <SIS_DATA>${session.executionRootDirectory}/target</SIS_DATA>
+ </environmentVariables>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
</profile>
</profiles>