### Eclipse Workspace Patch 1.0
#P gt-epsg-hsql
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.util.Set;
 import javax.sql.DataSource;
@@ -26,6 +26,8 @@
 import org.geotools.referencing.AbstractIdentifiedObject;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.factory.IdentifiedObjectFinder;
+import org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator;
+import org.geotools.referencing.factory.epsg.hsql.HsqlEpsgDatabase;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.IdentifiedObject;
Index: src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java	(working copy)
@@ -1,61 +0,0 @@
-package org.geotools.referencing.factory.epsg;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Properties;
-
-import org.geotools.referencing.CRS;
-import org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-/**
- * Dumps the contents of the EPSG database out to a java property file for use by the wkt plugin.
- */
-public class PropertyDumper {
-    public static void main(String[] args) throws Exception {
-        String filename = "/tmp/wkt.properties";
-        Properties diff = new Properties();
-        String compare = null;
-        if( args.length > 0 ){
-            filename = args[0];
-        }
-        
-        if( args.length > 1 ){
-            File file = new File( args[1] );
-            if( file.exists() ){
-                InputStream in = new FileInputStream( file );
-                diff.load( in );
-            }
-        }
-        
-        FileOutputStream out = new FileOutputStream( filename );
-        Writer writer = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
-        writer.append("Generate from EPSG database version "+ThreadedHsqlEpsgFactory.VERSION );
-        
-        Properties props = new Properties();
-        for (String code : CRS.getSupportedCodes("EPSG")) {
-            try {
-                CoordinateReferenceSystem crs = CRS.decode("EPSG:" + code, true);
-                // use toString, it's more lenient that toWKT
-                props.put(code, crs.toString().replaceAll("\n", "").replaceAll("  ", ""));
-                
-                diff.remove(code);
-                
-            } catch (Exception e) {
-                // we cannot actually decode all codes, but let's list what we can't
-                // System.out.println("# "+code + " -> " + e.getMessage());
-                props.put( "_"+code, e.getMessage() );
-            }
-        }
-        props.store(out,"Generated from EPSG database version " + ThreadedHsqlEpsgFactory.VERSION);
-        if(!diff.isEmpty() ){
-            diff.store(out, "Extra Definitions Supplied from Community");
-        }
-        out.close();
-    }
-}
\ No newline at end of file
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/DialectEpsgMediatorTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/DialectEpsgMediatorTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/DialectEpsgMediatorTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.sql.Connection;
 import java.util.Set;
@@ -25,6 +25,8 @@
 import org.geotools.referencing.AbstractIdentifiedObject;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.factory.IdentifiedObjectFinder;
+import org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator;
+import org.geotools.referencing.factory.epsg.hsql.HsqlEpsgDatabase;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.IdentifiedObject;
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/OperationFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/OperationFactoryTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/OperationFactoryTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.util.Iterator;
 import java.util.logging.Level;
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgFactory.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgFactory.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgFactory.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 // J2SE dependencies
 import java.sql.Statement;
@@ -25,6 +25,7 @@
 
 // Geotools dependencies
 import org.geotools.factory.Hints;
+import org.geotools.referencing.factory.epsg.AnsiDialectEpsgFactory;
 
 
 /**
Index: src/main/resources/org/geotools/referencing/factory/epsg/UpdateEPSGDatabase.txt
===================================================================
--- src/main/resources/org/geotools/referencing/factory/epsg/UpdateEPSGDatabase.txt	(revision 37250)
+++ src/main/resources/org/geotools/referencing/factory/epsg/UpdateEPSGDatabase.txt	(working copy)
@@ -1,57 +0,0 @@
-Updating the EPSG database
----------------------------
-
-The database in the zip file is a HSQL version of the official EPSG database.
-
-1) Download from www.epsg.org the "geodetic dataset" creation scripts for the PostgreSQL database
-2) Unzip them in _this_ directory, you should get three files named EPSG_v<version>.mdb_Data_PostgreSQL.sql,
-   EPSG_v<version>.mdb_FKeys_PostgreSQL.sql and EPSG_v<version>.mdb_Tables_PostgreSQL.sql, where
-   <version> is the the version of the EPSG database ("7_1" at the time of writing)  
-3) Modify the PrepareForHSQL.xml file so that it points to the three files above 
-4) Run the PrepareForHSQL.xml file:
-   ant -f PrepareForHSQL.xml
-   (or run it directly from Eclipse, this will work too and it's handier)
-   This will create three new files, EPSG_Data.sql, EPSG_FKeys.sql and EPSG_Tables.sql whose
-   content has been (mostly) amended to respect the HSQL syntax
-5) Hand modify the EPSG_Tables.sql file so that the UNIQUE constraints are declared at the end
-   of the table definition:
-   
-   Before:
-   CREATE CACHED TABLE epsg_change (
-    change_id     DOUBLE PRECISION NOT NULL UNIQUE,
-    report_date   DATE NOT NULL,
-    action        VARCHAR);
-   
-   After:
-   CREATE CACHED TABLE epsg_change (
-    change_id     DOUBLE PRECISION NOT NULL,
-    report_date   DATE NOT NULL,
-    action        VARCHAR,
-    UNIQUE(CHANGE_ID) );
-6) Update ThreadedHsqlEpsgFactory.VERSION to the current version
-7) Run the DatabaseCreationScript.java
-8) Check the EPSG.zip file has been updated
-9) Run the build with extensive tests in the epsg-hsql module:
-   mvn clean install -Pextensive.tests
-   
-   This step might force you to amend tests or modify the referencing subsystem to handle new
-   axis direction definitions, new unit of measure and the like
-10) Remove all the sql files in this directory, keeping only EPSG_Indexes.sql (which was already
-    there when you started)
-11) Commit the changes
-12) Congratulations, you're done!
-
-
-PostgreSQL notes
-------------------------------
-
-Sometimes it is handy to have the database loaded in PostgreSQL to run random queries
-against it. In order to load it you'll have to change the psql encoding thought:
-createdb epsg<version>
-psql espg<version>
-\encoding latin9
-\i EPSG_v<version>.mdb_Tables_PostgreSQL.sql
-\i EPSG_v<version>.mdb_Data_PostgreSQL.sql
-\i EPSG_v<version>.mdb_FKeys_PostgreSQL.sql
-
-     
\ No newline at end of file
Index: src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorConnectionLeakTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorConnectionLeakTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorConnectionLeakTest.java	(working copy)
@@ -1,89 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import javax.sql.DataSource;
-
-import junit.framework.TestCase;
-import net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner;
-import net.sourceforge.groboutils.junit.v1.TestRunnable;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.geotools.factory.Hints;
-import org.geotools.referencing.factory.epsg.HsqlDialectEpsgMediatorStressTest.ClientThread;
-
-/**
- * Multi-threaded test to check that no connections are leaked by the EPSG
- * mediator/factory code.
- * 
- * @author Cory Horner (Refractions Research)
- *
- * @source $URL$
- */
-public class HsqlDialectEpsgMediatorConnectionLeakTest extends TestCase {
-
-    final static int RUNNER_COUNT = 3;
-    final static int ITERATIONS = 3;
-    final static int MAX_TIME = 2 * 60 * 1000;
-    final static int MAX_WORKERS = 2;
-    final static boolean VERBOSE = false;
-    
-    HsqlDialectEpsgMediator mediator;
-    BasicDataSource datasource;
-    //DataSourceWrapper datasource;
-    String[] codes;
-    Hints hints;
-    
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        hints = new Hints(Hints.CACHE_POLICY, "none");
-        hints.put(Hints.AUTHORITY_MAX_ACTIVE, Integer.valueOf(MAX_WORKERS));
-
-        final DataSource database = HsqlEpsgDatabase.createDataSource();
-        datasource = new BasicDataSource(){
-        	{
-        		this.dataSource = database;
-        	}        	
-        };
-        mediator = new HsqlDialectEpsgMediator(80, hints, datasource);
-        codes = HsqlDialectEpsgMediatorStressTest.getCodes();
-    }
-
-    public void testLeak() throws Throwable {
-        TestRunnable runners[] = new TestRunnable[RUNNER_COUNT];
-        for (int i = 0; i < RUNNER_COUNT; i++) {
-            ClientThread thread = new HsqlDialectEpsgMediatorStressTest.ClientThread(i, mediator); 
-            thread.iterations = ITERATIONS;
-            runners[i] = thread;
-        }
-        MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(runners, null);
-        mttr.runTestRunnables(MAX_TIME);
-        
-        //count exceptions and metrics
-        int exceptions = 0;
-        for (int i = 0; i < RUNNER_COUNT; i++) {
-            ClientThread thread = (ClientThread) runners[i];
-            exceptions += thread.exceptions;
-        }
-        //destroy the mediator, check for open connections or exceptions
-        mediator.dispose();
-        assertEquals(0, datasource.getNumActive());
-        assertEquals(0, exceptions);
-    }
-    
-}
Index: src/test/java/org/geotools/referencing/factory/epsg/DefaultFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/DefaultFactoryTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/DefaultFactoryTest.java	(working copy)
@@ -1,895 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.io.*;
-import java.util.*;
-import java.sql.SQLException;
-import java.awt.geom.AffineTransform;
-import javax.measure.unit.Unit;
-
-import org.opengis.referencing.*;
-import org.opengis.referencing.cs.*;
-import org.opengis.referencing.crs.*;
-import org.opengis.referencing.datum.*;
-import org.opengis.referencing.operation.*;
-import org.opengis.metadata.extent.GeographicBoundingBox;
-import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.geometry.Envelope;
-
-import org.geotools.TestData;
-import org.geotools.factory.Hints;
-import org.geotools.referencing.CRS;
-import org.geotools.referencing.ReferencingFactoryFinder;
-import org.geotools.referencing.AbstractIdentifiedObject;
-import org.geotools.referencing.crs.AbstractCRS;
-import org.geotools.referencing.crs.DefaultGeographicCRS;
-import org.geotools.referencing.datum.DefaultGeodeticDatum;
-import org.geotools.referencing.operation.AbstractCoordinateOperation;
-import org.geotools.referencing.operation.projection.MapProjection;
-import org.geotools.referencing.operation.transform.AbstractMathTransform;
-import org.geotools.referencing.operation.transform.ConcatenatedTransform;
-import org.geotools.referencing.factory.IdentifiedObjectFinder;
-import org.geotools.metadata.iso.extent.GeographicBoundingBoxImpl;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-
-/**
- * Tests transformations from CRS and/or operations created from the EPSG factory, using
- * the default plugin. If the MS-Access database is installed and the {@code epsg-access}
- * plugin is in the classpath, then the default plugin will be the factory backed by the
- * MS-Access database. Otherwise, the default will probably be the one backed by the HSQL
- * database, since this test live in the {@code epsg-hsql} module.
- *
- * @source $URL$
- * @version $Id$
- * @author Martin Desruisseaux
- * @author Vadim Semenov
- *
- * @todo Rename as {@code ThreadedEpsgFactoryTest}.
- */
-public class DefaultFactoryTest {
-    /**
-     * Set to {@code true} for verbose tests.
-     */
-    private static boolean verbose = false;
-
-    /**
-     * Set to {@code true} for more extensive tests.
-     */
-    private static boolean extensive = false;
-
-    /**
-     * Small value for parameter value comparaisons.
-     */
-    private static final double EPS = 1E-6;
-
-    /**
-     * The EPSG factory to test. Will be setup only when first needed.
-     */
-    private ThreadedEpsgFactory factory;
-
-    /**
-     * Sets up the authority factory.
-     *
-     * @throws SQLException If the connection to the database failed.
-     */
-    @Before
-    public void setUp() throws Exception {
-        if (factory == null) {
-            factory = (ThreadedEpsgFactory) ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG",
-                        new Hints(Hints.CRS_AUTHORITY_FACTORY, ThreadedEpsgFactory.class));
-            extensive |= TestData.isExtensiveTest();
-            if (verbose) {
-                System.out.print("Database version: ");
-                System.out.println(factory.getImplementationHints().get(Hints.VERSION));
-            }
-        }
-        // calling dispose clears all the caches, making tests runs independent of each other
-        factory.dispose();
-        // No 'tearDown()' method: we rely on the DefaultFactory shutdown hook.
-    }
-
-    /**
-     * Make sure that the factory extracted from the registry in the {@link #setUp} method
-     * is a singleton. It may not be the case when there is a bug in {@code FactoryRegistry}.
-     */
-    @Test
-    public void testRegistry() {
-        final Object candidate = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);
-        if (candidate instanceof ThreadedEpsgFactory) {
-            assertSame(factory, candidate);
-        }
-    }
-
-    /**
-     * Returns the first identifier for the specified object.
-     */
-    private static String getIdentifier(final IdentifiedObject object) {
-        return object.getIdentifiers().iterator().next().getCode();
-    }
-
-    /**
-     * Tests creations of CRS objects.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testCreation() throws FactoryException {
-        final CoordinateOperationFactory opf = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
-        CoordinateReferenceSystem sourceCRS, targetCRS;
-        CoordinateOperation operation;
-        ParameterValueGroup parameters;
-
-        sourceCRS = factory.createCoordinateReferenceSystem("4274");
-        assertEquals("4274", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof GeographicCRS);
-        assertEquals(2, sourceCRS.getCoordinateSystem().getDimension());
-
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:4140");
-        assertEquals("4140", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof GeographicCRS);
-        assertEquals(2, sourceCRS.getCoordinateSystem().getDimension());
-
-        sourceCRS = factory.createCoordinateReferenceSystem("2027");
-        assertEquals("2027", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof ProjectedCRS);
-        assertEquals(2, sourceCRS.getCoordinateSystem().getDimension());
-        parameters = ((ProjectedCRS) sourceCRS).getConversionFromBase().getParameterValues();
-        assertEquals(   -93, parameters.parameter("central_meridian"  ).doubleValue(), EPS);
-        assertEquals(     0, parameters.parameter("latitude_of_origin").doubleValue(), EPS);
-        assertEquals(0.9996, parameters.parameter("scale_factor"      ).doubleValue(), EPS);
-        assertEquals(500000, parameters.parameter("false_easting"     ).doubleValue(), EPS);
-        assertEquals(     0, parameters.parameter("false_northing"    ).doubleValue(), EPS);
-
-        sourceCRS = factory.createCoordinateReferenceSystem(" EPSG : 2442 ");
-        assertEquals("2442", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof ProjectedCRS);
-        assertEquals(2, sourceCRS.getCoordinateSystem().getDimension());
-        parameters = ((ProjectedCRS) sourceCRS).getConversionFromBase().getParameterValues();
-        assertEquals(   135, parameters.parameter("central_meridian"  ).doubleValue(), EPS);
-        assertEquals(     0, parameters.parameter("latitude_of_origin").doubleValue(), EPS);
-        assertEquals(     1, parameters.parameter("scale_factor"      ).doubleValue(), EPS);
-        assertEquals(500000, parameters.parameter("false_easting"     ).doubleValue(), EPS);
-        assertEquals(     0, parameters.parameter("false_northing"    ).doubleValue(), EPS);
-
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:4915");
-        assertEquals("4915", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof GeocentricCRS);
-        assertEquals(3, sourceCRS.getCoordinateSystem().getDimension());
-
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:4993");
-        assertEquals("4993", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof GeographicCRS);
-        assertEquals(3, sourceCRS.getCoordinateSystem().getDimension());
-
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:5735");
-        assertEquals("5735", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof VerticalCRS);
-        assertEquals(1, sourceCRS.getCoordinateSystem().getDimension());
-
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:5801");
-        assertEquals("5801", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof EngineeringCRS);
-        assertEquals(2, sourceCRS.getCoordinateSystem().getDimension());
-
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:7400");
-        assertEquals("7400", getIdentifier(sourceCRS));
-        assertTrue(sourceCRS instanceof CompoundCRS);
-        assertEquals(3, sourceCRS.getCoordinateSystem().getDimension());
-
-        // GeographicCRS without datum
-        sourceCRS = factory.createCoordinateReferenceSystem("63266405");
-        assertTrue(sourceCRS instanceof GeographicCRS);
-        assertEquals("WGS 84 (deg)", sourceCRS.getName().getCode());
-        assertEquals(2, sourceCRS.getCoordinateSystem().getDimension());
-
-        // Operations
-        sourceCRS = factory.createCoordinateReferenceSystem("4273");
-        targetCRS = factory.createCoordinateReferenceSystem("4979");
-        operation = opf.createOperation(sourceCRS, targetCRS);
-        assertNotSame(sourceCRS, targetCRS);
-        assertFalse(operation.getMathTransform().isIdentity());
-
-        assertSame(sourceCRS, factory.createCoordinateReferenceSystem("EPSG:4273"));
-        assertSame(targetCRS, factory.createCoordinateReferenceSystem("EPSG:4979"));
-
-        assertSame(sourceCRS, factory.createCoordinateReferenceSystem(" EPSG : 4273 "));
-        assertSame(targetCRS, factory.createCoordinateReferenceSystem(" EPSG : 4979 "));
-
-        // CRS with "South along 180 deg" and "South along 90 deg East" axis
-        sourceCRS = factory.createCoordinateReferenceSystem("EPSG:32661");
-        targetCRS = factory.createCoordinateReferenceSystem("4326");
-        operation = opf.createOperation(sourceCRS, targetCRS);
-        final MathTransform    transform = operation.getMathTransform();
-        final CoordinateSystem  sourceCS = sourceCRS.getCoordinateSystem();
-        final CoordinateSystemAxis axis0 = sourceCS.getAxis(0);
-        final CoordinateSystemAxis axis1 = sourceCS.getAxis(1);
-        assertEquals("Northing",                axis0.getName().getCode());
-        assertEquals("Easting",                 axis1.getName().getCode());
-        assertEquals("South along 180 deg",     axis0.getDirection().name());
-        assertEquals("South along 90 deg East", axis1.getDirection().name());
-        assertFalse(transform.isIdentity());
-        assertTrue(transform instanceof ConcatenatedTransform);
-        ConcatenatedTransform ct = (ConcatenatedTransform) transform;
-        // An affine transform for swapping axis should be
-        // performed before and after the map projection.
-        final int mask = AffineTransform.TYPE_FLIP              |
-                         AffineTransform.TYPE_QUADRANT_ROTATION |
-                         AffineTransform.TYPE_UNIFORM_SCALE;
-        assertTrue(ct.transform1 instanceof AffineTransform);
-        assertEquals(mask, ((AffineTransform) ct.transform1).getType());
-        assertTrue(ct.transform2 instanceof ConcatenatedTransform);
-        ct = (ConcatenatedTransform) ct.transform2;
-        assertTrue(ct.transform1 instanceof AbstractMathTransform);
-        assertTrue(ct.transform2 instanceof AffineTransform);
-        assertEquals(mask, ((AffineTransform) ct.transform2).getType());
-    }
-
-    /**
-     * Tests closing the factory after the timeout. <strong>IMPORTANT:</strong> This test must
-     * be run after {@link #testCreation} and before any call to {@code getAuthorityCodes()}.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testTimeout() throws FactoryException {
-        System.gc();              // If there is any object holding a connection to the EPSG
-        System.runFinalization(); // database, running finalizers may help to close them.
-        factory.setTimeout(200);
-        // Fetch this CRS first in order to prevent garbage collection.
-        CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("4273");
-        assertEquals("4273", getIdentifier(crs));
-        try {
-            assertTrue(factory.isConnected());
-            Thread.sleep(800);
-            System.gc();
-            System.runFinalization();
-            Thread.sleep(200);
-            System.gc();
-            System.runFinalization();
-            assertFalse(factory.isConnected());
-        } catch (InterruptedException e) {
-            fail(e.getLocalizedMessage());
-        }
-        assertFalse(factory.isConnected());
-        // Should be in the cache.
-        assertSame(crs, factory.createCoordinateReferenceSystem("4273"));
-        assertFalse(factory.isConnected());
-        // Was not in the cache
-        assertEquals("4275", getIdentifier(factory.createCoordinateReferenceSystem("4275")));
-        assertTrue(factory.isConnected());
-        factory.setTimeout(30*60*1000L);
-    }
-
-    /**
-     * Tests the creation of CRS using name instead of primary keys. Note that this test
-     * contains a call to {@code getDescriptionText(...)}, and concequently must be run
-     * after {@link #testTimeout}. See {@link #testDescriptionText}.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testNameUsage() throws FactoryException {
-        /*
-         * Tests unit
-         */
-        assertSame   (factory.createUnit("9002"), factory.createUnit("foot"));
-        assertNotSame(factory.createUnit("9001"), factory.createUnit("foot"));
-        /*
-         * Tests CRS
-         */
-        final CoordinateReferenceSystem primary, byName;
-        primary = factory.createCoordinateReferenceSystem("27581");
-        assertEquals("27581", getIdentifier(primary));
-        assertTrue(primary instanceof ProjectedCRS);
-        assertEquals(2, primary.getCoordinateSystem().getDimension());
-        /*
-         * Gets the CRS by name. It should be the same.
-         */
-        byName = factory.createCoordinateReferenceSystem("NTF (Paris) / France I");
-        assertEquals(primary, byName);
-        /*
-         * Gets the CRS using 'createObject'. It will requires ony more
-         * SQL statement internally in order to determines the object type.
-         */
-        factory.dispose(); // Clear the cache. This is not a real disposal.
-        assertEquals(primary, factory.createObject("27581"));
-        assertEquals(byName,  factory.createObject("NTF (Paris) / France I"));
-        /*
-         * Tests descriptions.
-         */
-        assertEquals("NTF (Paris) / France I", factory.getDescriptionText("27581").toString());
-        /*
-         * Tests fetching an object with name containing semi-colon.
-         */
-        final IdentifiedObject cs = factory.createCoordinateSystem(
-                "Ellipsoidal 2D CS. Axes: latitude, longitude. Orientations: north, east. UoM: DMS");
-        assertEquals("6411", getIdentifier(cs));
-        /*
-         * Tests with a unknown name. The exception should be NoSuchAuthorityCodeException
-         * (some previous version wrongly threw a SQLException when using HSQL database).
-         */
-        try {
-            factory.createGeographicCRS("WGS84");
-            fail();
-        } catch (NoSuchAuthorityCodeException e) {
-            // This is the expected exception.
-            assertEquals("WGS84", e.getAuthorityCode());
-        }
-    }
-
-    /**
-     * Tests the {@link AuthorityFactory#getDescriptionText} method. Note that the default
-     * implementation of {@code getDescriptionText(...)} invokes {@code getAuthorityCodes()},
-     * and concequently this test must be run after {@link #testTimeout}.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testDescriptionText() throws FactoryException {
-        assertEquals("World Geodetic System 1984", factory.getDescriptionText( "6326").toString(Locale.ENGLISH));
-        assertEquals("Mean Sea Level",             factory.getDescriptionText( "5100").toString(Locale.ENGLISH));
-        assertEquals("NTF (Paris) / Nord France",  factory.getDescriptionText("27591").toString(Locale.ENGLISH));
-        assertEquals("Ellipsoidal height",         factory.getDescriptionText(   "84").toString(Locale.ENGLISH));
-    }
-
-    /**
-     * Tests the {@code getAuthorityCodes()} method.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testAuthorityCodes() throws FactoryException {
-        final Set<String> crs = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
-        assertFalse(crs.isEmpty());
-        assertEquals("Check size() consistency", crs.size(), crs.size());
-        assertTrue(crs.size() > 0); // Must be after the 'assertEquals' above.
-
-        final Set<String> geographicCRS = factory.getAuthorityCodes(GeographicCRS.class);
-        assertTrue (geographicCRS instanceof AuthorityCodes);
-        assertFalse(geographicCRS.isEmpty());
-        assertTrue (geographicCRS.size() > 0);
-        assertTrue (geographicCRS.size() < crs.size());
-        assertFalse(geographicCRS.containsAll(crs));
-        assertTrue (crs.containsAll(geographicCRS));
-
-        final Set<String> projectedCRS = factory.getAuthorityCodes(ProjectedCRS.class);
-        assertTrue (projectedCRS instanceof AuthorityCodes);
-        assertFalse(projectedCRS.isEmpty());
-        assertTrue (projectedCRS.size() > 0);
-        assertTrue (projectedCRS.size() < crs.size());
-        assertFalse(projectedCRS.containsAll(crs));
-        assertTrue (crs.containsAll(projectedCRS));
-        assertTrue(Collections.disjoint(geographicCRS, projectedCRS));
-
-        final Set<String> datum = factory.getAuthorityCodes(Datum.class);
-        assertTrue (datum instanceof AuthorityCodes);
-        assertFalse(datum.isEmpty());
-        assertTrue (datum.size() > 0);
-        assertTrue(Collections.disjoint(datum, crs));
-
-        final Set<String> geodeticDatum = factory.getAuthorityCodes(GeodeticDatum.class);
-        assertTrue (geodeticDatum instanceof AuthorityCodes);
-        assertFalse(geodeticDatum.isEmpty());
-        assertTrue (geodeticDatum.size() > 0);
-        assertFalse(geodeticDatum.containsAll(datum));
-        assertTrue (datum.containsAll(geodeticDatum));
-
-        // Ensures that the factory keept the set in its cache.
-        assertSame(crs,           factory.getAuthorityCodes(CoordinateReferenceSystem.class));
-        assertSame(geographicCRS, factory.getAuthorityCodes(            GeographicCRS.class));
-        assertSame(projectedCRS,  factory.getAuthorityCodes(             ProjectedCRS.class));
-        assertSame(datum,         factory.getAuthorityCodes(                    Datum.class));
-        assertSame(geodeticDatum, factory.getAuthorityCodes(            GeodeticDatum.class));
-        assertSame(geodeticDatum, factory.getAuthorityCodes(     DefaultGeodeticDatum.class));
-
-        // Try a dummy type.
-        assertTrue("Dummy type", factory.getAuthorityCodes((Class) String.class).isEmpty());
-
-        // Tests projections, which are handle in a special way.
-        final Set<String> operations      = factory.getAuthorityCodes(Operation     .class);
-        final Set<String> conversions     = factory.getAuthorityCodes(Conversion    .class);
-        final Set<String> projections     = factory.getAuthorityCodes(Projection    .class);
-        final Set<String> transformations = factory.getAuthorityCodes(Transformation.class);
-
-        assertTrue (operations      instanceof AuthorityCodes);
-        assertTrue (conversions     instanceof AuthorityCodes);
-        assertTrue (projections     instanceof AuthorityCodes);
-        assertTrue (transformations instanceof AuthorityCodes);
-
-        assertTrue (conversions    .size() < operations .size());
-        assertTrue (projections    .size() < operations .size());
-        assertTrue (transformations.size() < operations .size());
-        assertTrue (projections    .size() < conversions.size());
-
-        assertFalse(projections.containsAll(conversions));
-        assertTrue (conversions.containsAll(projections));
-        assertTrue (operations .containsAll(conversions));
-        assertTrue (operations .containsAll(transformations));
-
-        assertTrue (Collections.disjoint(conversions, transformations));
-        assertFalse(Collections.disjoint(conversions, projections));
-
-        assertFalse(operations     .isEmpty());
-        assertFalse(conversions    .isEmpty());
-        assertFalse(projections    .isEmpty());
-        assertFalse(transformations.isEmpty());
-
-        assertTrue (conversions.contains("101"));
-        assertFalse(projections.contains("101"));
-        assertTrue (projections.contains("16001"));
-
-        // We are cheating here since we are breaking generic type check.
-        // However in the particular case of our EPSG factory, it works.
-        @SuppressWarnings("unchecked")
-        final Set units = factory.getAuthorityCodes((Class) Unit.class);
-        assertTrue (units instanceof AuthorityCodes);
-        assertFalse(units.isEmpty());
-        assertTrue (units.size() > 0);
-
-        // Tests the fusion of all types
-        final Set<String> all = factory.getAuthorityCodes(IdentifiedObject.class);
-        assertFalse(all instanceof AuthorityCodes); // Usually a HashSet.
-        assertTrue (all.containsAll(crs));
-        assertTrue (all.containsAll(datum));
-        assertTrue (all.containsAll(operations));
-        assertFalse(all.containsAll(units));  // They are not IdentifiedObjects.
-    }
-
-    /**
-     * Tests {@link CRS#getEnvelope} and {@link CRS#getGeographicBoundingBox}.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     * @throws TransformException if a coordinate can't be transformed.
-     */
-    @Test
-    public void testValidArea() throws FactoryException, TransformException {
-        final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("7400");
-        final GeographicBoundingBox bbox = CRS.getGeographicBoundingBox(crs);
-        assertNotNull("No bounding box. Maybe an older EPSG database is running? " +
-                      "Try to clear the tmp/Geotools directory.", bbox);
-        assertEquals(42.25, bbox.getSouthBoundLatitude(), EPS);
-        assertEquals(51.10, bbox.getNorthBoundLatitude(), EPS);
-        assertEquals(-5.20, bbox.getWestBoundLongitude(), EPS);
-        assertEquals( 8.23, bbox.getEastBoundLongitude(), EPS);
-        final Envelope envelope = CRS.getEnvelope(crs);
-        assertEquals(46.944, envelope.getMinimum(0), 1E-3);
-        assertEquals(56.777, envelope.getMaximum(0), 1E-3);
-        assertEquals(-8.375, envelope.getMinimum(1), 1E-3);
-        assertEquals( 6.548, envelope.getMaximum(1), 1E-3);
-        assertNull(CRS.getEnvelope(null));
-        final GeographicBoundingBox rep = new GeographicBoundingBoxImpl(envelope);
-        assertEquals(42.25, rep.getSouthBoundLatitude(), 1E-3);
-        assertEquals(51.10, rep.getNorthBoundLatitude(), 1E-3);
-        assertEquals(-5.20, rep.getWestBoundLongitude(), 1E-3);
-        assertEquals( 8.23, rep.getEastBoundLongitude(), 1E-3);
-    }
-
-    /**
-     * Tests the serialization of many {@link CoordinateOperation} objects.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     * @throws IOException If an error occured during the serialization process.
-     * @throws ClassNotFoundException Should never occur.
-     */
-    @Test
-    public void testSerialization() throws FactoryException, IOException, ClassNotFoundException {
-        CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem("4326");
-        CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem("4322");
-        CoordinateOperationFactory opf = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
-        CoordinateOperation cop = opf.createOperation(crs1, crs2);
-        serialize(cop);
-
-        crs1 = crs2 = null;
-        final String crs1_name  = "4326";
-        final int crs2_ranges[] = {4326,  4326,
-                       /* [ 2] */  4322,  4322,
-                       /* [ 4] */  4269,  4269,
-                       /* [ 6] */  4267,  4267,
-                       /* [ 8] */  4230,  4230,
-                       /* [10] */ 32601, 32660,
-                       /* [12] */ 32701, 32760,
-                       /* [14] */  2759,  2930};
-
-        for (int irange=0; irange<crs2_ranges.length; irange+=2) {
-            int range_start = crs2_ranges[irange  ];
-            int range_end   = crs2_ranges[irange+1];
-            for (int isystem2=range_start; isystem2<=range_end; isystem2++) {
-                if (crs1 == null) {
-                    crs1 = factory.createCoordinateReferenceSystem(crs1_name);
-                }
-                String crs2_name = Integer.toString(isystem2);
-                crs2 = factory.createCoordinateReferenceSystem(crs2_name);
-                cop = opf.createOperation(crs1, crs2);
-                serialize(cop);
-                if (!extensive) {
-                    // If we are not running in extensive test mode,
-                    // tests only the first CRS from each range.
-                    break;
-                }
-            }
-        }
-    }
-
-    /**
-     * Tests the serialization of the specified object.
-     *
-     * @todo assertEquals disabled since the switch to JSR-275, because of serialization
-     *       issue with the later.
-     */
-    private static void serialize(final Object object) throws IOException, ClassNotFoundException {
-        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        final ObjectOutputStream out = new ObjectOutputStream(buffer);
-        out.writeObject(object);
-        out.close();
-        final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
-        final Object read = in.readObject();
-        in.close();
-//        assertEquals(object,            read);
-        assertEquals(object.hashCode(), read.hashCode());
-    }
-
-    /**
-     * Tests the creation of {@link Conversion} objects.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testConversions() throws FactoryException {
-        /*
-         * UTM zone 10N
-         */
-        final CoordinateOperation operation = factory.createCoordinateOperation("16010");
-        assertEquals("16010", getIdentifier(operation));
-        assertTrue(operation instanceof Conversion);
-        assertNull(operation.getSourceCRS());
-        assertNull(operation.getTargetCRS());
-        assertNull(operation.getMathTransform());
-        /*
-         * WGS 72 / UTM zone 10N
-         */
-        final ProjectedCRS crs = factory.createProjectedCRS("32210");
-        final CoordinateOperation projection = crs.getConversionFromBase();
-        assertEquals("32210", getIdentifier(crs));
-        assertEquals("16010", getIdentifier(projection));
-        assertTrue   (projection instanceof Projection);
-        assertNotNull(projection.getSourceCRS());
-        assertNotNull(projection.getTargetCRS());
-        assertNotNull(projection.getMathTransform());
-        assertNotSame(projection, operation);
-        assertSame(((Conversion) operation).getMethod(), ((Conversion) projection).getMethod());
-        /*
-         * WGS 72BE / UTM zone 10N
-         */
-        assertFalse(CRS.equalsIgnoreMetadata(crs, factory.createProjectedCRS("32410")));
-        /*
-         * Creates a projected CRS from base and projected CRS codes.
-         */
-        final Set all = factory.createFromCoordinateReferenceSystemCodes("4322", "32210");
-        assertEquals(1, all.size());
-        assertTrue(all.contains(projection));
-    }
-
-    /**
-     * Tests the creation of {@link Transformation} objects.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testTransformations() throws FactoryException {
-        /*
-         * Longitude rotation
-         */
-        assertTrue(factory.createCoordinateOperation("1764") instanceof Transformation);
-        /*
-         * ED50 (4230)  -->  WGS 84 (4326)  using
-         * Geocentric translations (9603).
-         * Accuracy = 999
-         */
-        final CoordinateOperation      operation1 = factory.createCoordinateOperation("1087");
-        final CoordinateReferenceSystem sourceCRS = operation1.getSourceCRS();
-        final CoordinateReferenceSystem targetCRS = operation1.getTargetCRS();
-        final MathTransform             transform = operation1.getMathTransform();
-        assertEquals("1087", getIdentifier(operation1));
-        assertEquals("4230", getIdentifier(sourceCRS));
-        assertEquals("4326", getIdentifier(targetCRS));
-        assertTrue   (operation1 instanceof Transformation);
-        assertNotSame(sourceCRS, targetCRS);
-        assertFalse  (operation1.getMathTransform().isIdentity());
-        assertEquals (999, AbstractCoordinateOperation.getAccuracy(operation1), 1E-6);
-        /*
-         * ED50 (4230)  -->  WGS 84 (4326)  using
-         * Position Vector 7-param. transformation (9606).
-         * Accuracy = 1.5
-         */
-        final CoordinateOperation operation2 = factory.createCoordinateOperation("1631");
-        assertEquals("1631", getIdentifier(operation2));
-        assertTrue (operation2 instanceof Transformation);
-        assertSame (sourceCRS, operation2.getSourceCRS());
-        assertSame (targetCRS, operation2.getTargetCRS());
-        assertFalse(operation2.getMathTransform().isIdentity());
-        assertFalse(transform.equals(operation2.getMathTransform()));
-        assertEquals(1.5, AbstractCoordinateOperation.getAccuracy(operation2), 1E-6);
-        /*
-         * ED50 (4230)  -->  WGS 84 (4326)  using
-         * Coordinate Frame rotation (9607).
-         * Accuracy = 1.0
-         */
-        final CoordinateOperation operation3 = factory.createCoordinateOperation("1989");
-        assertEquals("1989", getIdentifier(operation3));
-        assertTrue (operation3 instanceof Transformation);
-        assertSame (sourceCRS, operation3.getSourceCRS());
-        assertSame (targetCRS, operation3.getTargetCRS());
-        assertFalse(operation3.getMathTransform().isIdentity());
-        assertFalse(transform.equals(operation3.getMathTransform()));
-        assertEquals(1.0, AbstractCoordinateOperation.getAccuracy(operation3), 1E-6);
-        if (false) {
-            System.out.println(operation3);
-            System.out.println(operation3.getSourceCRS());
-            System.out.println(operation3.getTargetCRS());
-            System.out.println(operation3.getMathTransform());
-        }
-        /*
-         * Tests "BD72 to WGS 84 (1)" (EPSG:1609) creation. This one has an unusual unit for the
-         * "Scale difference" parameter (EPSG:8611). The value is 0.999999 and the unit is "unity"
-         * (EPSG:9201) instead of the usual "parts per million" (EPSG:9202). It was used to thrown
-         * an exception in older EPSG factory implementations.
-         */
-        assertEquals(1.0, AbstractCoordinateOperation.getAccuracy(factory.createCoordinateOperation("1609")), 1E-6);
-        /*
-         * Creates from CRS codes. There is 40 such operations in EPSG version 6.7.
-         * The preferred one (according the "supersession" table) is EPSG:1612.
-         *
-         * Note: the above assertion fails on PostgreSQL because its "ORDER BY" clause put null
-         * values last, while Access and HSQL put them first. The PostgreSQL behavior is better
-         * for what we want (operations with unknow accuracy last). Unfortunatly, I don't know
-         * yet how to instructs Access to put null values last using standard SQL ("IIF" is not
-         * standard, and Access doesn't seem to understand "CASE ... THEN" clauses).
-         */
-        final Set all = factory.createFromCoordinateReferenceSystemCodes("4230", "4326");
-        assertTrue(all.size() >= 3);
-        assertTrue(all.contains(operation1));
-        assertTrue(all.contains(operation2));
-        assertTrue(all.contains(operation3));
-        int count=0;
-        for (final Iterator it=all.iterator(); it.hasNext();) {
-            final CoordinateOperation check = (CoordinateOperation) it.next();
-            assertSame(sourceCRS, check.getSourceCRS());
-            assertSame(targetCRS, check.getTargetCRS());
-            if (count++ == 0) {
-                assertEquals("1612", getIdentifier(check)); // see comment above.
-            }
-        }
-        assertEquals(all.size(), count);
-    }
-
-    /**
-     * Fetchs the accuracy declared in all coordinate operations found in the database.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testAccuracy() throws FactoryException {
-        final Set identifiers = factory.getAuthorityCodes(CoordinateOperation.class);
-        double min     = Double.POSITIVE_INFINITY;
-        double max     = Double.NEGATIVE_INFINITY;
-        double sum     = 0;
-        int    count   = 0; // Number of coordinate operations (minus the skipped ones).
-        int    created = 0; // Number of coordinate operations recognized by the factory.
-        int    valid   = 0; // Number of non-NaN accuracies.
-        for (final Iterator it=identifiers.iterator(); it.hasNext();) {
-            final CoordinateOperation operation;
-            final String code = (String) it.next();
-            final int n = Integer.parseInt(code);
-            if (n>=10087 && n<=10088) {
-                // Valid, but log a warning. Will avoid just in order to keep the output clean.
-                continue;
-            }
-            ++count;
-            if (!extensive && (count % 20) != 0) {
-                // If the tests are not executed in "extensive" mode, tests only 5% of cases.
-                continue;
-            }
-            try {
-                operation = factory.createCoordinateOperation(code);
-            } catch (FactoryException exception) {
-                // Skip unsupported coordinate operations, except if the cause is a SQL exception.
-                if (exception.getCause() instanceof SQLException) {
-                    throw exception;
-                }
-                continue;
-            }
-            created++;
-            assertNotNull(operation);
-            final double accuracy = AbstractCoordinateOperation.getAccuracy(operation);
-            assertFalse(accuracy < 0);
-            if (!Double.isNaN(accuracy)) {
-                if (accuracy < min) min=accuracy;
-                if (accuracy > max) max=accuracy;
-                sum += accuracy;
-                valid++;
-            }
-        }
-        if (verbose) {
-            System.out.print("Number of coordinate operations:    "); System.out.println(identifiers.size());
-            System.out.print("Number of tested operations:        "); System.out.println(count);
-            System.out.print("Number of recognized operations:    "); System.out.println(created);
-            System.out.print("Number of operations with accuracy: "); System.out.println(valid);
-            System.out.print("Minimal accuracy value (meters):    "); System.out.println(min);
-            System.out.print("Maximal accuracy value (meters):    "); System.out.println(max);
-            System.out.print("Average accuracy value (meters):    "); System.out.println(sum / valid);
-        }
-    }
-
-    /**
-     * Compares a WKT found in the field with the EPSG equivalent.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     *
-     * @see http://jira.codehaus.org/browse/GEOT-1268
-     */
-    @Test
-    public void testEquivalent() throws FactoryException {
-        final String wkt =
-            "PROJCS[\"NAD_1983_StatePlane_Massachusetts_Mainland_FIPS_2001\", " +
-              "GEOGCS[\"GCS_North_American_1983\", " +
-                "DATUM[\"D_North_American_1983\", " +
-                  "SPHEROID[\"GRS_1980\", 6378137.0, 298.257222101]], " +
-                "PRIMEM[\"Greenwich\", 0.0], " +
-                "UNIT[\"degree\", 0.017453292519943295], " +
-                "AXIS[\"Longitude\", EAST], " +
-                "AXIS[\"Latitude\", NORTH]], " +
-              "PROJECTION[\"Lambert_Conformal_Conic\"], " +
-              "PARAMETER[\"central_meridian\", -71.5], " +
-              "PARAMETER[\"latitude_of_origin\", 41.0], " +
-              "PARAMETER[\"standard_parallel_1\", 41.71666666666667], " +
-              "PARAMETER[\"scale_factor\", 1.0], " +
-              "PARAMETER[\"false_easting\", 200000.0], " +
-              "PARAMETER[\"false_northing\", 750000.0], " +
-              "PARAMETER[\"standard_parallel_2\", 42.68333333333334], " +
-              "UNIT[\"m\", 1.0], " +
-              "AXIS[\"x\", EAST], " +
-              "AXIS[\"y\", NORTH]]";
-
-        final CoordinateReferenceSystem crs1 = CRS.parseWKT(wkt);
-        final CoordinateReferenceSystem crs2 = CRS.decode("EPSG:26986");
-
-        // This is the current state of Geotools, but it is wrong. The CRS should be equivalent.
-        // We will change to 'assertTrue' if a MapProjection.equivalent(MapProjection) method is
-        // implemented in some future Geotools version.
-        assertFalse(CRS.equalsIgnoreMetadata(crs1, crs2));
-    }
-
-    /**
-     * Tests {@link DefaultFactory#find} method.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testFind() throws FactoryException {
-        final IdentifiedObjectFinder finder = factory.getIdentifiedObjectFinder(
-                CoordinateReferenceSystem.class);
-        assertTrue("Full scan should be enabled by default.", finder.isFullScanAllowed());
-        assertNull("Should not find WGS84 because the axis order is not the same.",
-                   finder.find(DefaultGeographicCRS.WGS84));
-
-        String wkt;
-        wkt = "GEOGCS[\"WGS 84\",\n"                                    +
-              "  DATUM[\"World Geodetic System 1984\",\n"               +
-              "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n"  +
-              "  PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "  UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "  AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "  AXIS[\"Geodetic longitude\", EAST]]";
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-        finder.setFullScanAllowed(false);
-        assertNull("Should not find without a full scan, because the WKT contains no identifier " +
-                   "and the CRS name is ambiguous (more than one EPSG object have this name).",
-                   finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
-                   CRS.equalsIgnoreMetadata(crs, find));
-        assertEquals("4326",
-                AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode());
-        finder.setFullScanAllowed(false);
-
-        ReferenceIdentifier foundri = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority());
-
-        // this is broken because, as we know from above, it is ambiguous, so it may not be EPSG:4326 in the cache at all!
-        //        assertEquals("The CRS should still in the cache.",
-        //                            "EPSG:4326", finder.findIdentifier(crs));
-        assertEquals("The CRS should still in the cache.",
-                foundri.getCodeSpace()+':'+foundri.getCode(), finder.findIdentifier(crs));
-
-        /*
-         * The PROJCS below intentionally uses a name different from the one found in the
-         * EPSG database, in order to force a full scan (otherwise the EPSG database would
-         * find it by name, but we want to test the scan).
-         */
-        wkt = "PROJCS[\"Beijing 1954\",\n"                                 +
-              "   GEOGCS[\"Beijing 1954\",\n"                              +
-              "     DATUM[\"Beijing 1954\",\n"                             +
-              "       SPHEROID[\"Krassowsky 1940\", 6378245.0, 298.3]],\n" +
-              "     PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "     UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "     AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "     AXIS[\"Geodetic longitude\", EAST]],\n"                +
-              "   PROJECTION[\"Transverse Mercator\"],\n"                  +
-              "   PARAMETER[\"central_meridian\", 135.0],\n"               +
-              "   PARAMETER[\"latitude_of_origin\", 0.0],\n"               +
-              "   PARAMETER[\"scale_factor\", 1.0],\n"                     +
-              "   PARAMETER[\"false_easting\", 500000.0],\n"               +
-              "   PARAMETER[\"false_northing\", 0.0],\n"                   +
-              "   UNIT[\"m\", 1.0],\n"                                     +
-              "   AXIS[\"Northing\", NORTH],\n"                            +
-              "   AXIS[\"Easting\", EAST]]";
-        crs = CRS.parseWKT(wkt);
-
-        finder.setFullScanAllowed(false);
-        IdentifiedObject found = finder.find(crs);
-        assertTrue("Should not find the CRS without a full scan.", found == null || found != null );
-
-        finder.setFullScanAllowed(true);
-        find = finder.find(crs);
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
-                   CRS.equalsIgnoreMetadata(crs, find));
-        assertEquals("2442", AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode());
-
-        finder.setFullScanAllowed(false);
-        assertEquals("The CRS should still in the cache.",
-                     "EPSG:2442", finder.findIdentifier(crs));
-
-    }
-
-    /**
-     * We are supposed to be able to get back identical {@link CoordinateReferenceSystem}
-     * objects when we create using the same definition. This test case ensures that we do
-     * get back identical objects when using an EPSG code and when using WKT.
-     * <p>
-     * The same definition is used in each case - will it work?
-     * Answer is no because we lost metadata information in WKT formatting;
-     * however two instances created with the same wkt work out okay.
-     *
-     * @throws FactoryException if an error occured while querying the factory.
-     */
-    @Test
-    public void testIntern() throws FactoryException {
-        final AbstractCRS epsgCrs = (AbstractCRS) CRS.decode("EPSG:4326");
-        final String      wkt     = epsgCrs.toWKT();
-        final AbstractCRS wktCrs  = (AbstractCRS) CRS.parseWKT(wkt);
-
-        assertTrue   ("equals ignore metadata",  epsgCrs.equals(wktCrs, false));
-        assertFalse  ("equals compare metadata", epsgCrs.equals(wktCrs, true));
-        assertFalse  ("equals",   epsgCrs.equals(wktCrs));
-        assertNotSame("identity", epsgCrs, wktCrs);
-
-        // Parsing the same thing twice?
-        final AbstractCRS wktCrs2 = (AbstractCRS) CRS.parseWKT(wkt);
-        assertTrue  ("equals ignore metadata",  wktCrs.equals(wktCrs2, false));
-        assertTrue  ("equals compare metadata", wktCrs.equals(wktCrs2, true));
-        assertEquals("equals",   wktCrs, wktCrs2);
-        assertSame  ("identity", wktCrs, wktCrs2);
-    }
-}
Index: src/main/resources/META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory
===================================================================
--- src/main/resources/META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory	(revision 37250)
+++ src/main/resources/META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory	(working copy)
@@ -1,3 +1,3 @@
-org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
 # pending review
-# org.geotools.referencing.factory.epsg.HsqlDialectEpsgMediator
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/main/resources/META-INF/services/org.opengis.referencing.operation.CoordinateOperationAuthorityFactory
===================================================================
--- src/main/resources/META-INF/services/org.opengis.referencing.operation.CoordinateOperationAuthorityFactory	(revision 37250)
+++ src/main/resources/META-INF/services/org.opengis.referencing.operation.CoordinateOperationAuthorityFactory	(working copy)
@@ -1,3 +1,3 @@
-org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
 # pending review
-# org.geotools.referencing.factory.epsg.HsqlDialectEpsgMediator
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/main/resources/org/geotools/referencing/factory/epsg/EPSG.zip
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/main/resources/org/geotools/referencing/factory/epsg/EPSG_Indexes.sql
===================================================================
--- src/main/resources/org/geotools/referencing/factory/epsg/EPSG_Indexes.sql	(revision 37250)
+++ src/main/resources/org/geotools/referencing/factory/epsg/EPSG_Indexes.sql	(working copy)
@@ -1,55 +0,0 @@
---
--- The EPSG database is shipped with no index except primary keys. This file creates
--- some index appropriate for the queries performed by Geotools DirectEpsgFactory.
---
--- Authors: Andrea Aimes
---          Martin Desruisseaux
---
--- Version: $Id$
---
-
---------------------------------------------------------------------------------
--- Index for queries used by DirectEpsgFactory.createFoo(epsgCode) methods.   --
--- Indexed fields are numeric values used mainly in equality comparaisons.    --
---------------------------------------------------------------------------------
-CREATE INDEX ALIAS_OBJECT_CODE                ON EPSG_ALIAS                     (OBJECT_CODE);
-CREATE INDEX CRS_DATUM_CODE                   ON EPSG_COORDINATEREFERENCESYSTEM (DATUM_CODE);
-CREATE INDEX CRS_PROJECTION_CODE              ON EPSG_COORDINATEREFERENCESYSTEM (PROJECTION_CONV_CODE);
-CREATE INDEX COORDINATE_AXIS_CODE             ON EPSG_COORDINATEAXIS            (COORD_AXIS_CODE);
-CREATE INDEX COORDINATE_AXIS_SYS_CODE         ON EPSG_COORDINATEAXIS            (COORD_SYS_CODE);
-CREATE INDEX COORDINATE_OPERATION_CRS         ON EPSG_COORDOPERATION            (SOURCE_CRS_CODE, TARGET_CRS_CODE);
-CREATE INDEX COORDINATE_OPERATION_METHOD_CODE ON EPSG_COORDOPERATION            (COORD_OP_METHOD_CODE);
-CREATE INDEX PARAMETER_USAGE_METHOD_CODE      ON EPSG_COORDOPERATIONPARAMUSAGE  (COORD_OP_METHOD_CODE);
-CREATE INDEX PARAMETER_VALUES                 ON EPSG_COORDOPERATIONPARAMVALUE  (COORD_OP_CODE, COORD_OP_METHOD_CODE);
-CREATE INDEX PARAMETER_VALUE_CODE             ON EPSG_COORDOPERATIONPARAMVALUE  (PARAMETER_CODE);
-CREATE INDEX PATH_CONCAT_OPERATION_CODE       ON EPSG_COORDOPERATIONPATH        (CONCAT_OPERATION_CODE);
-CREATE INDEX SUPERSESSION_OBJECT_CODE         ON EPSG_SUPERSESSION              (OBJECT_CODE);
-
-
---------------------------------------------------------------------------------
--- Index for queries used by DirectEpsgFactory.createFoo(epsgCode) methods.   --
--- Indexed fields are numeric values used in ORDER BY clauses.  I'm not sure  --
--- that their impact on HSQL database is significant, so it is probably safe  --
--- to ignore them.                                                            --
---------------------------------------------------------------------------------
-CREATE INDEX COORDINATE_AXIS_ORDER            ON EPSG_COORDINATEAXIS           (COORD_AXIS_ORDER);
-CREATE INDEX COORDINATE_OPERATION_ACCURACY    ON EPSG_COORDOPERATION           (COORD_OP_ACCURACY);
-CREATE INDEX PARAMETER_ORDER                  ON EPSG_COORDOPERATIONPARAMUSAGE (SORT_ORDER);
-CREATE INDEX PATH_CONCAT_OPERATION_STEP       ON EPSG_COORDOPERATIONPATH       (OP_PATH_STEP);
-CREATE INDEX SUPERSESSION_OBJECT_YEAR         ON EPSG_SUPERSESSION             (SUPERSESSION_YEAR);
-CREATE INDEX VERSION_HISTORY_DATE             ON EPSG_VERSIONHISTORY           (VERSION_DATE);
-
-
---------------------------------------------------------------------------------
--- Index on the object names, used in order to find an EPSG code from a name. --
---------------------------------------------------------------------------------
-CREATE INDEX NAME_CRS            ON EPSG_COORDINATEREFERENCESYSTEM (COORD_REF_SYS_NAME);
-CREATE INDEX NAME_CS             ON EPSG_COORDINATESYSTEM          (COORD_SYS_NAME);
-CREATE INDEX NAME_AXIS           ON EPSG_COORDINATEAXISNAME        (COORD_AXIS_NAME);
-CREATE INDEX NAME_DATUM          ON EPSG_DATUM                     (DATUM_NAME);
-CREATE INDEX NAME_ELLIPSOID      ON EPSG_ELLIPSOID                 (ELLIPSOID_NAME);
-CREATE INDEX NAME_PRIME_MERIDIAN ON EPSG_PRIMEMERIDIAN             (PRIME_MERIDIAN_NAME);
-CREATE INDEX NAME_COORD_OP       ON EPSG_COORDOPERATION            (COORD_OP_NAME);
-CREATE INDEX NAME_METHOD         ON EPSG_COORDOPERATIONMETHOD      (COORD_OP_METHOD_NAME);
-CREATE INDEX NAME_PARAMETER      ON EPSG_COORDOPERATIONPARAM       (PARAMETER_NAME);
-CREATE INDEX NAME_UNIT           ON EPSG_UNITOFMEASURE             (UNIT_OF_MEAS_NAME);
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/ThreadedHsqlEpsgFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/ThreadedHsqlEpsgFactoryTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/ThreadedHsqlEpsgFactoryTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import static org.junit.Assert.*;
 
@@ -27,6 +27,7 @@
 import org.geotools.referencing.datum.BursaWolfParameters;
 import org.geotools.referencing.datum.DefaultGeodeticDatum;
 import org.geotools.referencing.factory.IdentifiedObjectFinder;
+import org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.opengis.geometry.DirectPosition;
Index: src/test/java/org/geotools/referencing/factory/epsg/DialectEpsgMediatorTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/DialectEpsgMediatorTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/DialectEpsgMediatorTest.java	(working copy)
@@ -1,157 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.sql.Connection;
-import java.util.Set;
-
-import org.geotools.TestData;
-import org.geotools.factory.Hints;
-import org.geotools.geometry.DirectPosition2D;
-import org.geotools.referencing.AbstractIdentifiedObject;
-import org.geotools.referencing.CRS;
-import org.geotools.referencing.factory.IdentifiedObjectFinder;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-
-import javax.sql.DataSource;
-import junit.framework.TestCase;
-
-public class DialectEpsgMediatorTest extends TestCase {
-
-    private static HsqlDialectEpsgMediator factory;
-    private static IdentifiedObjectFinder finder;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        if( factory == null ){
-            DataSource datasource = HsqlEpsgDatabase.createDataSource();
-            Connection connection = datasource.getConnection();
-            Hints hints = new Hints(Hints.CACHE_POLICY, "default");
-            factory = new HsqlDialectEpsgMediator( hints );
-        }
-        if( finder == null ){
-            finder = factory.getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
-        }
-    }
-
-    public void testCreation() throws Exception {
-        assertNotNull(factory);
-        CoordinateReferenceSystem epsg4326 = factory.createCoordinateReferenceSystem("EPSG:4326");
-        CoordinateReferenceSystem code4326 = factory.createCoordinateReferenceSystem("4326");
-
-        assertEquals("4326 equals EPSG:4326", code4326, epsg4326);
-        assertSame("4326 == EPSG:4326", code4326, epsg4326);
-    }
-
-    public void testFunctionality() throws Exception {
-        CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem("4326");
-        CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem("3005");
-
-        // reproject
-        MathTransform transform = CRS.findMathTransform(crs1, crs2,true);
-        DirectPosition pos = new DirectPosition2D(48.417, 123.35);
-        transform.transform(pos, null);
-    }
-
-    public void testAuthorityCodes() throws Exception {
-        Set authorityCodes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
-        assertNotNull(authorityCodes);
-        assertTrue(authorityCodes.size() > 3000);
-    }
-
-    public void testFindWSG84() throws FactoryException {
-        if (!TestData.isExtensiveTest()) {
-            return;
-        }
-        String wkt;
-        wkt = "GEOGCS[\"WGS 84\",\n"                                    +
-              "  DATUM[\"World Geodetic System 1984\",\n"               +
-              "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n"  +
-              "  PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "  UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "  AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "  AXIS[\"Geodetic longitude\", EAST]]";
-
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-        finder.setFullScanAllowed(false);
-
-        assertNull("Should not find without a full scan, because the WKT contains no identifier " +
-                   "and the CRS name is ambiguous (more than one EPSG object have this name).",
-                   finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",CRS.equalsIgnoreMetadata(crs, find));
-        String code = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode();
-		assertTrue("4326".equals(code) || "63266405".equals(code));
-
-        finder.setFullScanAllowed(false);
-        assertNotNull("The CRS should still in the cache.",finder.findIdentifier(crs));
-    }
-
-    public void testFindBeijing1954() throws FactoryException {
-        if (!TestData.isExtensiveTest()) {
-            return;
-        }
-        /*
-         * The PROJCS below intentionally uses a name different from the one found in the
-         * EPSG database, in order to force a full scan (otherwise the EPSG database would
-         * find it by name, but we want to test the scan).
-         */
-        String wkt = "PROJCS[\"Beijing 1954\",\n"                          +
-              "   GEOGCS[\"Beijing 1954\",\n"                              +
-              "     DATUM[\"Beijing 1954\",\n"                             +
-              "       SPHEROID[\"Krassowsky 1940\", 6378245.0, 298.3]],\n" +
-              "     PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "     UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "     AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "     AXIS[\"Geodetic longitude\", EAST]],\n"                +
-              "   PROJECTION[\"Transverse Mercator\"],\n"                  +
-              "   PARAMETER[\"central_meridian\", 135.0],\n"               +
-              "   PARAMETER[\"latitude_of_origin\", 0.0],\n"               +
-              "   PARAMETER[\"scale_factor\", 1.0],\n"                     +
-              "   PARAMETER[\"false_easting\", 500000.0],\n"               +
-              "   PARAMETER[\"false_northing\", 0.0],\n"                   +
-              "   UNIT[\"m\", 1.0],\n"                                     +
-              "   AXIS[\"Northing\", NORTH],\n"                            +
-              "   AXIS[\"Easting\", EAST]]";
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-
-        finder.setFullScanAllowed(false);
-        assertNull("Should not find the CRS without a full scan.", finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
-                   CRS.equalsIgnoreMetadata(crs, find));
-        String code = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode();
-        assertEquals("2442", code );
-
-        finder.setFullScanAllowed(false);
-        assertEquals("The CRS should still in the cache.","EPSG:2442", finder.findIdentifier(crs));
-    }
-}
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/ThreadedHsqlEpsgFactory.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/ThreadedHsqlEpsgFactory.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/ThreadedHsqlEpsgFactory.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -34,6 +34,7 @@
 
 import org.geotools.factory.Hints;
 import org.geotools.referencing.factory.AbstractAuthorityFactory;
+import org.geotools.referencing.factory.epsg.ThreadedEpsgFactory;
 import org.geotools.resources.i18n.ErrorKeys;
 import org.geotools.resources.i18n.Errors;
 import org.geotools.resources.i18n.LoggingKeys;
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediator.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediator.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediator.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import javax.sql.DataSource;
 
Index: src/main/resources/org/geotools/referencing/factory/epsg/PrepareForHSQL.xml
===================================================================
--- src/main/resources/org/geotools/referencing/factory/epsg/PrepareForHSQL.xml	(revision 37250)
+++ src/main/resources/org/geotools/referencing/factory/epsg/PrepareForHSQL.xml	(working copy)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- ========================================================================
-
-     ANT BUILD FILE (Ref. http://jakarta.apache.org/ant )
-
-     Ant script preparing SQL scripts for HSQL. The scripts provided by EPSG
-     can't be run "as is" because of minor SQL language differences. Some
-     keywords must be replaced, and the date format must be changed from
-     "yyyy/mm/dd" to "yyyy-mm-dd". This scripts performs those changes in a
-     copy of EPSG scripts.
-
-     There is one change that this script doesn't performs. Column creation
-     in the form "columnName UNIQUE" must move the "unique" keyword at the
-     end of table creation in the form "UNIQUE (columnName)". This change
-     needs to be done by hand in the "EPSG_Tables.sql" file.
-
-     The SQL scripts must be executed in the following order:
-
-         EPSG_Tables.sql
-         EPSG_Data.sql
-         EPSG_FKeys.sql
-
-     Author:  Martin Desruisseaux
-     Version: $Id$
-     ======================================================================== -->
-
-<project name="Creates HSQL scripts" default="create">
-  <target name="create">
-    <copy file="EPSG_v7_5.mdb_Tables_PostgreSQL.sql" tofile="EPSG_Tables.sql"/>
-    <copy file="EPSG_v7_5.mdb_FKeys_PostgreSQL.sql"  tofile="EPSG_FKeys.sql" />
-    <copy file="EPSG_v7_5.mdb_Data_PostgreSQL.sql"   tofile="EPSG_Data.sql"  />
-
-    <replace file="EPSG_Tables.sql">
-      <replacefilter token="CREATE TABLE" value="CREATE CACHED TABLE"/>
-      <replacefilter token="TEXT"         value="VARCHAR"            />
-    </replace>
-
-    <replaceregexp file="EPSG_Data.sql" byline="true">
-      <regexp pattern="'(\d{4})/(\d{2})/(\d{2})',\s*"/>
-      <substitution expression="'\1-\2-\3',"/>
-    </replaceregexp>
-
-  </target>
-</project>
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/DefaultFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/DefaultFactoryTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/DefaultFactoryTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.*;
 import java.util.*;
@@ -44,6 +44,9 @@
 import org.geotools.referencing.operation.transform.AbstractMathTransform;
 import org.geotools.referencing.operation.transform.ConcatenatedTransform;
 import org.geotools.referencing.factory.IdentifiedObjectFinder;
+import org.geotools.referencing.factory.epsg.AuthorityCodes;
+import org.geotools.referencing.factory.epsg.DefaultFactory;
+import org.geotools.referencing.factory.epsg.ThreadedEpsgFactory;
 import org.geotools.metadata.iso.extent.GeographicBoundingBoxImpl;
 
 import org.junit.*;
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/PropertyDumper.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/PropertyDumper.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/PropertyDumper.java	(working copy)
@@ -1,4 +1,4 @@
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -10,7 +10,7 @@
 import java.util.Properties;
 
 import org.geotools.referencing.CRS;
-import org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory;
+import org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 /**
Index: src/main/resources/META-INF/services/org.opengis.referencing.cs.CSAuthorityFactory
===================================================================
--- src/main/resources/META-INF/services/org.opengis.referencing.cs.CSAuthorityFactory	(revision 37250)
+++ src/main/resources/META-INF/services/org.opengis.referencing.cs.CSAuthorityFactory	(working copy)
@@ -1,3 +1,3 @@
-org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
 # pending review
-# org.geotools.referencing.factory.epsg.HsqlDialectEpsgMediator
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/FactoryUsingHSQL.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/FactoryUsingHSQL.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/FactoryUsingHSQL.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 // J2SE dependencies
 import java.sql.Statement;
@@ -25,6 +25,7 @@
 
 // Geotools dependencies
 import org.geotools.factory.Hints;
+import org.geotools.referencing.factory.epsg.FactoryUsingAnsiSQL;
 
 
 /**
Index: META-INF/services/org.opengis.referencing.operation.CoordinateOperationAuthorityFactory
===================================================================
--- META-INF/services/org.opengis.referencing.operation.CoordinateOperationAuthorityFactory	(revision 0)
+++ META-INF/services/org.opengis.referencing.operation.CoordinateOperationAuthorityFactory	(revision 0)
@@ -0,0 +1,3 @@
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
+# pending review
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/main/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediator.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediator.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediator.java	(working copy)
@@ -1,126 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- * 
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import javax.sql.DataSource;
-
-import org.geotools.factory.GeoTools;
-import org.geotools.factory.Hints;
-import org.geotools.referencing.factory.AbstractCachedAuthorityFactory;
-import org.geotools.referencing.factory.AbstractEpsgMediator;
-import org.opengis.referencing.FactoryException;
-
-/**
- * Mediator which delegates the creation of referencing objects to the
- * HsqlDialectEpsgFactory.
- * 
- * @author Cory Horner (Refractions Research)
- *
- * @source $URL$
- */
-public class HsqlDialectEpsgMediator extends AbstractEpsgMediator {
-
-    Hints hints;
-    
-    /**
-     * Creates a new instance of this factory.
-     */
-    public HsqlDialectEpsgMediator() throws FactoryException {
-        this( GeoTools.getDefaultHints() );
-    }
-    
-    /**
-     * Creates a new instance of this data source using the specified hints. The priority
-     * is set to a lower value than the {@linkplain FactoryOnAccess}'s one in order to give
-     * precedence to the Access-backed database, if presents. Priorities are set that way
-     * because:
-     * <ul>
-     *   <li>The MS-Access format is the primary EPSG database format.</li>
-     *   <li>If a user downloads the MS-Access database himself, he probably wants to use it.</li>
-     * </ul>
-     */
-    public HsqlDialectEpsgMediator(final Hints hints) throws FactoryException {
-        super(hints, HsqlEpsgDatabase.createDataSource( hints ));
-    }
-    
-    /**
-     * Creates an HsqlDialectEpsgMediator with a 20 min timeout, single worker,
-     * and no cache.
-     * 
-     * @param priority
-     * @param datasource
-     */
-    public HsqlDialectEpsgMediator(int priority, DataSource datasource) {
-        this( priority, 
-             new Hints(Hints.AUTHORITY_MAX_ACTIVE, 
-                 Integer.valueOf(1),
-                 new Object[] {
-                     Hints.AUTHORITY_MIN_EVICT_IDLETIME, Integer.valueOf(20 * 60 * 1000),
-                     Hints.CACHE_POLICY, "none"
-                 }
-             ),
-             datasource
-         );
-    }
-    
-    public HsqlDialectEpsgMediator(int priority, Hints hints, DataSource datasource) {
-        super(hints, datasource);
-        this.hints = hints;
-    }
-
-    /**
-     * Reinitialize an instance to be returned by the pool.
-     */
-    protected void activateWorker(AbstractCachedAuthorityFactory obj) throws Exception {
-        HsqlDialectEpsgFactory factory = (HsqlDialectEpsgFactory) obj;
-        factory.connect();
-    }
-
-    /**
-     * Destroys an instance no longer needed by the pool.
-     */
-    protected void destroyWorker(AbstractCachedAuthorityFactory obj) throws Exception {
-        HsqlDialectEpsgFactory factory = (HsqlDialectEpsgFactory) obj;
-        factory.disconnect();
-        factory.dispose();
-        factory = null;
-    }
-
-    /**
-     * Creates an instance that can be returned by the pool.
-     */
-    protected AbstractCachedAuthorityFactory makeWorker() throws Exception {
-        HsqlDialectEpsgFactory factory = new HsqlDialectEpsgFactory(hints, datasource);
-        return factory;
-    }
-
-    /**
-     * Uninitialize an instance to be returned to the pool.
-     */
-    protected void passivateWorker(AbstractCachedAuthorityFactory obj) throws Exception {
-        HsqlDialectEpsgFactory factory = (HsqlDialectEpsgFactory) obj;
-        factory.disconnect();
-    }
-
-    /**
-     * Ensures that the instance is safe to be returned by the pool.
-     */
-    protected boolean validateWorker(AbstractCachedAuthorityFactory obj) {
-        return true;
-    }
-
-}
Index: src/main/java/org/geotools/referencing/factory/epsg/SqlScriptReader.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/SqlScriptReader.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/SqlScriptReader.java	(working copy)
@@ -1,81 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * Reads a multiline SQL file extracting each command separately. Skips empty lines, assumes
- * comments start with "--" and are on their own line 
- *
- * @source $URL$
- */
-public class SqlScriptReader {
-    boolean fetched = true;
-    StringBuilder builder = new StringBuilder();
-    BufferedReader reader;
-
-    public SqlScriptReader(Reader reader) {
-        this.reader = new BufferedReader(reader);
-    }
-    
-    public boolean hasNext() throws IOException {
-        // do we have an un-fetched command?
-        if(!fetched) {
-            return builder.length() > 0;
-        }
-        
-        builder.setLength(0);
-        String line = null;
-        while((line = reader.readLine()) != null) {
-            line = line.trim();
-            // skip empty and comment lines
-            if(!"".equals(line) && !line.startsWith("--"))
-                builder.append(line).append("\n");
-            if(line.endsWith(";")) {
-                fetched = false;
-                break;
-            }
-        }
-        
-        if(line == null && builder.length() > 0) {
-            throw new IOException("The file ends with a non ; terminated command");
-        }
-        
-        return line != null;
-    }
-    
-    public String next() throws IOException  {
-        if(fetched)
-            throw new IOException("hasNext was not called, or was called and it returned false");
-            
-        fetched = true;
-        return builder.toString();
-    }
-    
-    public void dispose() {
-        try {
-            reader.close();
-        } catch(IOException e) {
-            // never mind
-        }
-    }
-    
-
-}
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorStressTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorStressTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorStressTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -32,6 +32,8 @@
 import org.geotools.factory.Hints;
 import org.geotools.geometry.DirectPosition2D;
 import org.geotools.referencing.CRS;
+import org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator;
+import org.geotools.referencing.factory.epsg.hsql.HsqlEpsgDatabase;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorConnectionLeakTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorConnectionLeakTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgMediatorConnectionLeakTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import javax.sql.DataSource;
 
@@ -24,7 +24,9 @@
 
 import org.apache.commons.dbcp.BasicDataSource;
 import org.geotools.factory.Hints;
-import org.geotools.referencing.factory.epsg.HsqlDialectEpsgMediatorStressTest.ClientThread;
+import org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator;
+import org.geotools.referencing.factory.epsg.hsql.HsqlEpsgDatabase;
+import org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediatorStressTest.ClientThread;
 
 /**
  * Multi-threaded test to check that no connections are leaked by the EPSG
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/DatabaseCreationScript.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/DatabaseCreationScript.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/DatabaseCreationScript.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.File;
 import java.io.FileInputStream;
Index: src/main/java/org/geotools/referencing/factory/epsg/FactoryUsingHSQL.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/FactoryUsingHSQL.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/FactoryUsingHSQL.java	(working copy)
@@ -1,102 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- * 
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-// J2SE dependencies
-import java.sql.Statement;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-// Geotools dependencies
-import org.geotools.factory.Hints;
-
-
-/**
- * Adapts SQL statements for HSQL. The HSQL database engine doesn't understand
- * the parenthesis in (INNER JOIN ... ON) statements for the "BursaWolfParameters"
- * query. Unfortunatly, those parenthesis are required by MS-Access. We need to
- * removes them programmatically here.
- *
- * @since 2.2
- * @source $URL$
- * @version $Id$
- * @author Martin Desruisseaux
- */
-final class FactoryUsingHSQL extends FactoryUsingAnsiSQL {
-    /**
-     * The regular expression pattern for searching the "FROM (" clause.
-     * This is the pattern for the opening parenthesis.
-     */
-    private static final Pattern OPENING_PATTERN =
-            Pattern.compile("\\s+FROM\\s*\\(",
-            Pattern.CASE_INSENSITIVE);
-
-    /**
-     * Constructs the factory for the given connection to the HSQL database.
-     */
-    public FactoryUsingHSQL(final Hints hints, final Connection connection) {
-        super(hints, connection);
-    }
-
-    /**
-     * If the query contains a "FROM (" expression, remove the parenthesis.
-     */
-    public String adaptSQL(String query) {
-        query = super.adaptSQL(query);
-        final Matcher matcher = OPENING_PATTERN.matcher(query);
-        if (matcher.find()) {
-            final int opening = matcher.end()-1;
-            final int length  = query.length();
-            int closing = opening;
-            for (int count=0; ; closing++) {
-                if (closing >= length) {
-                    // Should never happen with well formed SQL statement.
-                    // If it happen anyway, don't change anything and let
-                    // the HSQL driver produces a "syntax error" message.
-                    return query;
-                }
-                switch (query.charAt(closing)) {
-                    case '(': count++; break;
-                    case ')': count--; break;
-                    default : continue;
-                }
-                if (count == 0) {
-                    break;
-                }
-            }
-            query = query.substring(0,         opening) +
-                    query.substring(opening+1, closing) +
-                    query.substring(closing+1);
-        }
-        return query;
-    }
-
-    /**
-     * Shutdown the HSQL database engine. This method is invoked automatically at JVM
-     * shutdown time just before to close the connection.
-     */
-    protected void shutdown(final boolean active) throws SQLException {
-        if (active) {
-            final Statement statement = getConnection().createStatement();
-            statement.execute("SHUTDOWN");
-            statement.close();
-        }
-        super.shutdown(active);
-    }
-}
Index: src/main/java/org/geotools/referencing/factory/epsg/ThreadedHsqlEpsgFactory.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/ThreadedHsqlEpsgFactory.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/ThreadedHsqlEpsgFactory.java	(working copy)
@@ -1,360 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.nio.channels.OverlappingFileLockException;
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import javax.sql.DataSource;
-
-import org.geotools.factory.Hints;
-import org.geotools.referencing.factory.AbstractAuthorityFactory;
-import org.geotools.resources.i18n.ErrorKeys;
-import org.geotools.resources.i18n.Errors;
-import org.geotools.resources.i18n.LoggingKeys;
-import org.geotools.resources.i18n.Loggings;
-import org.geotools.util.Version;
-import org.geotools.util.logging.Logging;
-import org.hsqldb.jdbc.jdbcDataSource;
-import org.opengis.referencing.FactoryException;
-
-
-/**
- * Connection to the EPSG database in HSQL database engine format using JDBC. The EPSG
- * database can be downloaded from <A HREF="http://www.epsg.org">http://www.epsg.org</A>.
- * The SQL scripts (modified for the HSQL syntax as <A HREF="doc-files/HSQL.html">explained
- * here</A>) are bundled into this plugin. The database version is given in the
- * {@linkplain org.opengis.metadata.citation.Citation#getEdition edition attribute}
- * of the {@linkplain org.opengis.referencing.AuthorityFactory#getAuthority authority}.
- * The HSQL database is read only.
- * <P>
- * <H3>Implementation note</H3>
- * The SQL scripts are executed the first time a connection is required. The database
- * is then created as cached tables ({@code HSQL.properties} and {@code HSQL.data} files)
- * in a temporary directory. Future connections to the EPSG database while reuse the cached
- * tables, if available. Otherwise, the scripts will be executed again in order to recreate
- * them.
- * <p>
- * If the EPSG database should be created in a different directory (or already exists in that
- * directory), it may be specified as a {@linkplain System#getProperty(String) system property}
- * nammed {@value #DIRECTORY_KEY}.
- *
- * @since 2.4
- * @source $URL$
- * @version $Id$
- * @author Martin Desruisseaux
- * @author Didier Richard
- */
-public class ThreadedHsqlEpsgFactory extends ThreadedEpsgFactory {
-    /**
-     * Current version of EPSG-HSQL plugin. This is usually the same version number than the
-     * one in the EPSG database bundled in this plugin. However this field may contains
-     * additional minor version number if there is some changes related to the EPSG-HSQL
-     * plugin rather then the EPSG database itself (for example additional database index).
-     */
-    public static final Version VERSION = new Version("7.5.0");
-
-    /**
-     * The key for fetching the database directory from {@linkplain System#getProperty(String)
-     * system properties}.
-     */
-    public static final String DIRECTORY_KEY = "EPSG-HSQL.directory";
-
-    /**
-     * The name of the ZIP file to read in order to create the cached database.
-     */
-    private static final String ZIP_FILE = "EPSG.zip";
-
-    /**
-     * The database name.
-     */
-    public static final String DATABASE_NAME = "EPSG";
-    
-    /**
-     * The successful database creation marker
-     */
-    static final String MARKER_FILE = "EPSG_creation_marker.txt";
-    
-    /**
-     * The database creation lock file
-     */
-    static final String LOCK_FILE = "EPSG_creation_lock.txt";
-
-    /**
-     * The prefix to put in front of URL to the database.
-     */
-    static final String PREFIX = "jdbc:hsqldb:file:";
-
-    /**
-     * The logger name.
-     */
-    static final String LOGGER = "org.geotools.referencing.factory.epsg";
-
-    /**
-     * Creates a new instance of this factory. If the {@value #DIRECTORY_KEY}
-     * {@linkplain System#getProperty(String) system property} is defined and contains
-     * the name of a directory with a valid {@linkplain File#getParent parent}, then the
-     * {@value #DATABASE_NAME} database will be saved in that directory. Otherwise, a
-     * temporary directory will be used.
-     */
-    public ThreadedHsqlEpsgFactory() {
-        this(null);
-    }
-
-    /**
-     * Creates a new instance of this data source using the specified hints. The priority
-     * is set to a lower value than the {@linkplain FactoryOnAccess}'s one in order to give
-     * precedence to the Access-backed database, if presents. Priorities are set that way
-     * because:
-     * <ul>
-     *   <li>The MS-Access format is the primary EPSG database format.</li>
-     *   <li>If a user downloads the MS-Access database himself, he probably wants to use it.</li>
-     * </ul>
-     */
-    public ThreadedHsqlEpsgFactory(final Hints hints) {
-        super(hints, PRIORITY + 1);
-    }
-
-    /**
-     * Returns the default directory for the EPSG database. If the {@value #DIRECTORY_KEY}
-     * {@linkplain System#getProperty(String) system property} is defined and contains the
-     * name of a directory with a valid {@linkplain File#getParent parent}, then the
-     * {@value #DATABASE_NAME} database will be saved in that directory. Otherwise,
-     * a temporary directory will be used.
-     */
-    private static File getDirectory() {
-        try {
-            final String property = System.getProperty(DIRECTORY_KEY);
-            if (property != null) {
-                final File directory = new File(property);
-                /*
-                 * Creates the directory if needed (mkdir), but NOT the parent directories (mkdirs)
-                 * because a missing parent directory may be a symptom of an installation problem.
-                 * For example if 'directory' is a subdirectory in the temporary directory (~/tmp/),
-                 * this temporary directory should already exists. If it doesn't, an administrator
-                 * should probably looks at this problem.
-                 */
-                if (directory.isDirectory() || directory.mkdir()) {
-                    return directory;
-                }
-            }
-        } catch (SecurityException e) {
-            /*
-             * Can't fetch the base directory from system properties.
-             * Fallback on the default temporary directory.
-             */
-        }
-        return getTemporaryDirectory();
-    }
-
-    /**
-     * Returns the directory to uses in the temporary directory folder.
-     */
-    private static File getTemporaryDirectory() {
-        File directory = new File(System.getProperty("java.io.tmpdir", "."), "Geotools");
-        if (directory.isDirectory() || directory.mkdir()) {
-            directory = new File(directory, "Databases/HSQL");
-            if (directory.isDirectory() || directory.mkdirs()) {
-                return directory;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Extract the directory from the specified data source, or {@code null} if this
-     * information is not available.
-     */
-    private static File getDirectory(final DataSource source) {
-        if (source instanceof jdbcDataSource) {
-            String path = ((jdbcDataSource) source).getDatabase();
-            if (path!=null && PREFIX.regionMatches(true, 0, path, 0, PREFIX.length())) {
-                path = path.substring(PREFIX.length());
-                return new File(path).getParentFile();
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Returns a data source for the HSQL database.
-     */
-    protected DataSource createDataSource() throws SQLException {
-        DataSource candidate = super.createDataSource();
-        if (candidate instanceof jdbcDataSource) {
-            return candidate;
-        }
-        final jdbcDataSource source = new jdbcDataSource();
-        File directory = new File(getDirectory(), "v" + VERSION);
-        if (directory != null) {
-            /*
-             * Constructs the full path to the HSQL database. Note: we do not use
-             * File.toURI() because HSQL doesn't seem to expect an encoded URL
-             * (e.g. "%20" instead of spaces).
-             */
-            final StringBuilder url = new StringBuilder(PREFIX);
-            final String path = directory.getAbsolutePath().replace(File.separatorChar, '/');
-            if (path.length()==0 || path.charAt(0)!='/') {
-                url.append('/');
-            }
-            url.append(path);
-            if (url.charAt(url.length()-1) != '/') {
-                url.append('/');
-            }
-            url.append(DATABASE_NAME);
-            url.append(";shutdown=true");
-            source.setDatabase(url.toString());
-            assert directory.equals(getDirectory(source)) : url;
-        }
-        /*
-         * If the temporary directory do not exists or can't be created, lets the 'database'
-         * attribute unset. If the user do not set it explicitly (through JNDI or by overrding
-         * this method), an exception will be thrown when 'createBackingStore()' will be invoked.
-         */
-        source.setUser("SA"); // System administrator. No password.
-        return source;
-    }
-
-    /**
-     * Returns {@code true} if the database contains data. This method returns {@code false}
-     * if an empty EPSG database has been automatically created by HSQL and not yet populated.
-     */
-    private static boolean dataExists(File directory) throws SQLException {
-        // check if the marker file is there, and all the other database files as well
-        // (as some windows cleanup tools delete the .data file only)
-        return new File(directory, MARKER_FILE).exists() &&
-               new File(directory, DATABASE_NAME + ".data").exists() &&
-               new File(directory, DATABASE_NAME + ".properties").exists() &&
-               new File(directory, DATABASE_NAME + ".script").exists();
-    }
-
-    /**
-     * Returns the backing-store factory for HSQL syntax. If the cached tables are not available,
-     * they will be created now from the SQL scripts bundled in this plugin.
-     *
-     * @param  hints A map of hints, including the low-level factories to use for CRS creation.
-     * @return The EPSG factory using HSQL syntax.
-     * @throws SQLException if connection to the database failed.
-     */
-    protected AbstractAuthorityFactory createBackingStore(final Hints hints) throws SQLException {
-        final DataSource source = getDataSource();
-        final File directory    = getDirectory(source);
-        directory.mkdirs();
-        if (!dataExists(directory)) {
-            FileLock lock = null;
-            try {
-                // get an exclusive lock
-                lock = acquireLock(directory);
-                
-                // if after getting the lock the database is still incomplete let's work on it
-                if(!dataExists(directory)) {
-                    /*
-                     * HSQL has created automatically an empty database. We need to populate it.
-                     * Executes the SQL scripts bundled in the JAR. In theory, each line contains
-                     * a full SQL statement. For this plugin however, we have compressed "INSERT
-                     * INTO" statements using Compactor class in this package.
-                     */
-                    final Logger logger = Logging.getLogger(LOGGER);
-                    final LogRecord record = Loggings.format(Level.INFO,
-                            LoggingKeys.CREATING_CACHED_EPSG_DATABASE_$1, VERSION);
-                    record.setLoggerName(logger.getName());
-                    logger.log(record);
-                
-                    ZipInputStream zin = new ZipInputStream(ThreadedHsqlEpsgFactory.class.getResourceAsStream(ZIP_FILE));
-                    ZipEntry ze = null;
-                    byte[] buf = new byte[1024];
-                    int read = 0;
-                    while ((ze = zin.getNextEntry()) != null) {
-                      FileOutputStream fout = new FileOutputStream(new File(directory, ze.getName()));
-                      while((read = zin.read(buf)) > 0) {
-                        fout.write(buf, 0, read);
-                      }
-                      zin.closeEntry();
-                      fout.close();
-                    }
-                    zin.close();
-                    
-                    // mark the successful creation
-                    new File(directory, MARKER_FILE).createNewFile();
-                }
-            } catch (IOException exception) {
-                SQLException e = new SQLException(Errors.format(ErrorKeys.CANT_READ_$1, ZIP_FILE));
-                e.initCause(exception); // TODO: inline cause when we will be allowed to target Java 6.
-                throw e;
-            } finally {
-                if(lock != null) {
-                    try {
-                        lock.release();
-                        lock.channel().close();
-                        new File(directory, LOCK_FILE).delete();
-                    } catch(IOException e) {
-                        // does not matter, was just cleanup
-                    }
-                }
-            }
-            
-        }
-        FactoryUsingHSQL factory = new FactoryUsingHSQL(hints, getDataSource().getConnection());
-        factory.setValidationQuery("CALL NOW()");
-        return factory;
-    }
-    
-    /**
-     * 
-     * @param directory
-     * @return
-     * @throws IOException
-     */
-    FileLock acquireLock(File directory) throws IOException {
-        // Get a file channel for the file
-        File file = new File(directory, LOCK_FILE);
-        FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
-    
-        // Use the file channel to create a lock on the file.
-        // This method blocks until it can retrieve the lock.
-        FileLock lock = channel.lock();
-    
-        // Try acquiring the lock without blocking. This method returns
-        // null or throws an exception if the file is already locked.
-        while(!lock.isValid()) {
-            try {
-                lock = channel.tryLock();
-            } catch (OverlappingFileLockException e) {
-                // File is already locked in this thread or virtual machine
-            }
-            // wait for the other process to unlock it, should take a couple of seconds
-            try {
-                Thread.sleep(500);
-            } catch(InterruptedException e) {
-                // someone waked us earlier, no problem
-            }
-        }
-        
-        return lock;
-    }
-}
Index: src/main/java/org/geotools/referencing/factory/epsg/DatabaseCreationScript.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/DatabaseCreationScript.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/DatabaseCreationScript.java	(working copy)
@@ -1,181 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- * 
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.hsqldb.jdbc.jdbcDataSource;
-
-/**
- * Utility used to create a HSQL zipped version of the official EPSG database 
- *
- * @source $URL$
- */
-public class DatabaseCreationScript {
-
-    public static void main(String[] args) throws Exception {
-        /**
-         * BEFORE USING THIS SCRIPT
-         * - make sure you've created modified .sql files following the instructions 
-         * - update ThreadedHsqlEpsgFactory.VERSION 
-         * - modify the "directory" variable below to point to the folder containing the SQL scripts
-         */
-        String inputDirectory = "./src/main/resources/org/geotools/referencing/factory/epsg/";
-
-        /**
-         * The files we're interested into
-         */
-        File directory = new File(inputDirectory);
-        File propertyFile = new File(directory, ThreadedHsqlEpsgFactory.DATABASE_NAME + ".properties");
-        File databaseFile = new File(directory, ThreadedHsqlEpsgFactory.DATABASE_NAME + ".data");
-        File backupFile = new File(directory, ThreadedHsqlEpsgFactory.DATABASE_NAME + ".backup");
-        File scriptFile = new File(directory, ThreadedHsqlEpsgFactory.DATABASE_NAME + ".script");
-        File zipFile =  new File(directory, ThreadedHsqlEpsgFactory.DATABASE_NAME + ".zip");
-
-        /**
-         * Preventive cleanup of the files should an old run was broken or stopped in the middle
-         */
-        propertyFile.delete();
-        databaseFile.delete();
-        backupFile.delete(); 
-        scriptFile.delete();
-        zipFile.delete();
-
-
-        /*
-         * Constructs the datasource. Note: we do not use
-         * File.toURI() because HSQL doesn't seem to expect an encoded URL
-         * (e.g. "%20" instead of spaces).
-         */
-        final jdbcDataSource source = new jdbcDataSource();
-        final StringBuilder url = new StringBuilder(ThreadedHsqlEpsgFactory.PREFIX);
-        final String path = directory.getAbsolutePath().replace(File.separatorChar, '/');
-        if (path.length()==0 || path.charAt(0)!='/') {
-            url.append('/');
-        }
-        url.append(path);
-        if (url.charAt(url.length()-1) != '/') {
-            url.append('/');
-        }
-        url.append(ThreadedHsqlEpsgFactory.DATABASE_NAME);
-        source.setDatabase(url.toString());
-        source.setUser("SA"); 
-        
-        Connection connection = source.getConnection();
-        /*
-         * HSQL has created automatically an empty database. We need to populate it. Executes
-         * the SQL scripts bundled in the JAR. In theory, each line contains a full SQL
-         * statement. For this plugin however, we have compressed "INSERT INTO" statements using
-         * Compactor class in this package.
-         */
-        System.out.println("Creating the EPSG database");
-        final Statement statement = connection.createStatement();
-        try {
-            // read and execute the scripts that make up the database
-            executeScript(new File(directory, "EPSG_Tables.sql"), statement);
-            executeScript(new File(directory, "EPSG_Data.sql"), statement);
-            statement.execute("UPDATE EPSG_DATUM SET REALIZATION_EPOCH = NULL WHERE REALIZATION_EPOCH = ''");
-            statement.execute("ALTER TABLE EPSG_DATUM ALTER COLUMN REALIZATION_EPOCH INTEGER");
-            executeScript(new File(directory, "EPSG_FKeys.sql"), statement);
-            executeScript(new File(directory, "EPSG_Indexes.sql"), statement);
-            statement.execute("SHUTDOWN COMPACT");
-        } catch (IOException exception) {
-            SQLException e = new SQLException("Error occurred while executing "
-                    + "the EPSG database creation scripts");
-            e.initCause(exception);
-            throw e;
-        } finally {
-            statement.close();
-            connection.close();
-        }
-        System.out.println("EPSG database created");
-
-        /*
-         * The database has been fully created. Mark some extra properties in the property
-         * file (among others, the version and make it read only)
-         * 
-         */
-        final InputStream propertyIn = new FileInputStream(propertyFile);
-        final Properties properties  = new Properties();
-        properties.load(propertyIn);
-        propertyIn.close();
-        properties.put("epsg.version", ThreadedHsqlEpsgFactory.VERSION.toString());
-        properties.put("readonly", "true");
-        final OutputStream out = new FileOutputStream(propertyFile);
-        properties.store(out, "EPSG database on HSQL");
-        out.close();
-
-        /*
-         * Zip the database
-         */
-        System.out.println("Creating the zipped database");
-        byte[] buf = new byte[1024];
-        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile));
-        File[] files = new File[] {databaseFile, propertyFile, scriptFile};
-        for(File file : files) {
-            FileInputStream in = new FileInputStream(file);
-    
-            zos.putNextEntry(new ZipEntry(file.getName()));
-            int len;
-            while ((len = in.read(buf)) > 0) {
-                zos.write(buf, 0, len);
-            }
-            zos.closeEntry();
-            in.close();
-        }
-        zos.close();
-
-        /**
-         * Cleanup, delete the database files
-         */
-        System.out.println("Cleaning up the unzipped database files");
-        propertyFile.delete();
-        databaseFile.delete();
-        backupFile.delete(); 
-        scriptFile.delete();
-        
-        System.out.println("Done. The zipped database file is available at " + zipFile.getAbsolutePath());
-    }
-    
-    static void executeScript(File scriptFile, Statement statement) throws IOException, SQLException {
-        System.out.println("Executing script " + scriptFile.getPath());
-        SqlScriptReader reader = null;
-        try {
-            // first read in the tables
-            reader = new SqlScriptReader(new InputStreamReader(new FileInputStream(scriptFile), "ISO-8859-15"));
-            while(reader.hasNext()) {
-                statement.execute(reader.next());
-            }
-        } finally {
-            if(reader != null) 
-                reader.dispose();
-        }
-    }
-
-}
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlEpsgDatabase.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlEpsgDatabase.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/HsqlEpsgDatabase.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.BufferedReader;
 import java.io.File;
Index: META-INF/MANIFEST.MF
===================================================================
--- META-INF/MANIFEST.MF	(revision 0)
+++ META-INF/MANIFEST.MF	(revision 0)
@@ -0,0 +1,61 @@
+Manifest-Version: 1.0
+Build-Timestamp: 22-May-2011 08:08
+Built-By: mbaudier
+Class-Path: gt-referencing-8-SNAPSHOT.jar vecmath-1.3.2.jar commons-po
+ ol-1.5.4.jar gt-metadata-8-SNAPSHOT.jar gt-opengis-8-SNAPSHOT.jar jsr
+ -275-1.0-beta-2.jar hsqldb-1.8.0.7.jar
+Tool: Bnd-1.15.0
+Bundle-Name: EPSG Authority Service using HSQL database
+Created-By: Apache Maven Bundle Plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: Geotools
+Svn-Revision: 37250
+Build-Jdk: 1.6.0_17
+Bundle-Version: 8.0.0.SNAPSHOT
+Project-Version: 8-SNAPSHOT
+Bnd-LastModified: 1306044706306
+Bundle-ManifestVersion: 2
+Bundle-License: http://svn.osgeo.org/geotools/trunk/modules/plugin/eps
+ g-hsql/LICENSE.html, http://svn.osgeo.org/geotools/trunk/licenses/EPS
+ G.html, http://svn.osgeo.org/geotools/trunk/licenses/HSQL.html
+Bundle-Description: Connection to an embedded EPSG database in HSQL fo
+ rmat.    This database is built from the SQL scripts delivered by EPS
+ G.
+Import-Package: javax.measure.converter,
+ javax.measure.unit,
+ javax.naming,
+ javax.sql,
+ org.geotools.factory,
+ org.geotools.io,
+ org.geotools.measure,
+ org.geotools.metadata,
+ org.geotools.metadata.iso.citation,
+ org.geotools.metadata.iso.extent,
+ org.geotools.metadata.iso.quality,
+ org.geotools.parameter,
+ org.geotools.referencing,
+ org.geotools.referencing.crs,
+ org.geotools.referencing.cs,
+ org.geotools.referencing.datum,
+ org.geotools.referencing.factory,
+ org.geotools.referencing.factory.epsg.hsql,
+ org.geotools.referencing.operation,
+ org.geotools.resources,
+ org.geotools.resources.i18n,
+ org.geotools.util,
+ org.geotools.util.logging,
+ org.hsqldb.jdbc,
+ org.opengis.metadata,
+ org.opengis.metadata.citation,
+ org.opengis.metadata.extent,
+ org.opengis.metadata.quality,
+ org.opengis.parameter,
+ org.opengis.referencing,
+ org.opengis.referencing.crs,
+ org.opengis.referencing.cs,
+ org.opengis.referencing.datum,
+ org.opengis.referencing.operation,
+ org.opengis.util
+Bundle-SymbolicName: org.geotools.gt-epsg-hsql
+Bundle-DocURL: http://www.geotools.org
+Export-Package: org.geotools.referencing.factory.epsg.hsql;org.geotools.gt-epsg-hsql=split
Index: META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory
===================================================================
--- META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory	(revision 0)
+++ META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory	(revision 0)
@@ -0,0 +1,3 @@
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
+# pending review
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgFactoryTest.java	(revision 0)
+++ src/test/java/org/geotools/referencing/factory/epsg/hsql/HsqlDialectEpsgFactoryTest.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.util.Set;
 import javax.sql.DataSource;
@@ -26,6 +26,8 @@
 import org.geotools.referencing.AbstractIdentifiedObject;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.factory.IdentifiedObjectFinder;
+import org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgFactory;
+import org.geotools.referencing.factory.epsg.hsql.HsqlEpsgDatabase;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.IdentifiedObject;
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/SqlScriptReader.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/SqlScriptReader.java	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/SqlScriptReader.java	(working copy)
@@ -14,7 +14,7 @@
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *    Lesser General Public License for more details.
  */
-package org.geotools.referencing.factory.epsg;
+package org.geotools.referencing.factory.epsg.hsql;
 
 import java.io.BufferedReader;
 import java.io.IOException;
Index: META-INF/services/org.opengis.referencing.datum.DatumAuthorityFactory
===================================================================
--- META-INF/services/org.opengis.referencing.datum.DatumAuthorityFactory	(revision 0)
+++ META-INF/services/org.opengis.referencing.datum.DatumAuthorityFactory	(revision 0)
@@ -0,0 +1,3 @@
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
+# pending review
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/main/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgFactory.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgFactory.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgFactory.java	(working copy)
@@ -1,110 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- * 
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-// J2SE dependencies
-import java.sql.Statement;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-// Geotools dependencies
-import org.geotools.factory.Hints;
-
-
-/**
- * Adapts SQL statements for HSQL. The HSQL database engine doesn't understand
- * the parenthesis in (INNER JOIN ... ON) statements for the "BursaWolfParameters"
- * query. Unfortunately, those parenthesis are required by MS-Access. We need to
- * removes them programmatically here.
- *
- * @since 2.2
- * @source $URL$
- * @version $Id$
- * @author Martin Desruisseaux
- */
-final class HsqlDialectEpsgFactory extends AnsiDialectEpsgFactory {
-    /**
-     * The regular expression pattern for searching the "FROM (" clause.
-     * This is the pattern for the opening parenthesis.
-     */
-    private static final Pattern OPENING_PATTERN =
-            Pattern.compile("\\s+FROM\\s*\\(",
-            Pattern.CASE_INSENSITIVE);
-
-    /**
-     * Constructs the factory for the given connection to the HSQL database.
-     * @throws SQLException 
-     */
-    public HsqlDialectEpsgFactory(final Hints hints) throws SQLException {
-        super(hints, HsqlEpsgDatabase.createDataSource());
-    }
-    
-    /**
-     * Constructs the factory for the given connection to the HSQL database.
-     */
-    public HsqlDialectEpsgFactory(final Hints hints, final javax.sql.DataSource dataSource) {
-        super(hints, dataSource);
-    }
-
-    /**
-     * If the query contains a "FROM (" expression, remove the parenthesis.
-     */
-    public String adaptSQL(String query) {
-        query = super.adaptSQL(query);
-        final Matcher matcher = OPENING_PATTERN.matcher(query);
-        if (matcher.find()) {
-            final int opening = matcher.end()-1;
-            final int length  = query.length();
-            int closing = opening;
-            for (int count=0; ; closing++) {
-                if (closing >= length) {
-                    // Should never happen with well formed SQL statement.
-                    // If it happen anyway, don't change anything and let
-                    // the HSQL driver produces a "syntax error" message.
-                    return query;
-                }
-                switch (query.charAt(closing)) {
-                    case '(': count++; break;
-                    case ')': count--; break;
-                    default : continue;
-                }
-                if (count == 0) {
-                    break;
-                }
-            }
-            query = query.substring(0,         opening) +
-                    query.substring(opening+1, closing) +
-                    query.substring(closing+1);
-        }
-        return query;
-    }
-
-    /**
-     * Shutdown the HSQL database engine. This method is invoked automatically at JVM
-     * shutdown time just before to close the connection.
-     */
-    protected void shutdown(final boolean active) throws SQLException {
-        if (active) {
-            final Statement statement = getConnection().createStatement();
-            statement.execute("SHUTDOWN");
-            statement.close();
-        }
-        super.shutdown(active);
-    }
-}
Index: src/main/java/org/geotools/referencing/factory/epsg/hsql/overview.html
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/hsql/overview.html	(revision 0)
+++ src/main/java/org/geotools/referencing/factory/epsg/hsql/overview.html	(working copy)
@@ -3,11 +3,11 @@
 <!-- NOTE: This file was used to be "package.html" in the factory directory.
            However, it caused javadoc aggregation to fail with the following
            error message: Multiple sources of package comments found for
-           package "org.geotools.referencing.factory.epsg". -->
+           package "org.geotools.referencing.factory.epsg.hsql.hsql". -->
 
 <HTML>
   <HEAD>
-    <TITLE>package org.geotools.referencing.factory.epsg</TITLE>
+    <TITLE>package org.geotools.referencing.factory.epsg.hsql.hsql</TITLE>
   </HEAD>
   <BODY>
   Allows the EPSG database to be used with the HSQL Java database as an Authority for GeoTools
Index: src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorTest.java	(working copy)
@@ -1,157 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.util.Set;
-import javax.sql.DataSource;
-import junit.framework.TestCase;
-
-import org.geotools.TestData;
-import org.geotools.factory.Hints;
-import org.geotools.geometry.DirectPosition2D;
-import org.geotools.referencing.AbstractIdentifiedObject;
-import org.geotools.referencing.CRS;
-import org.geotools.referencing.factory.IdentifiedObjectFinder;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.ReferenceIdentifier;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-
-public class HsqlDialectEpsgMediatorTest extends TestCase {
-    private HsqlDialectEpsgMediator factory;
-    private IdentifiedObjectFinder finder;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        if( factory == null ){
-            DataSource datasource = HsqlEpsgDatabase.createDataSource();
-            Hints hints = new Hints( Hints.CACHE_POLICY, "default" );
-            factory = new HsqlDialectEpsgMediator(80, hints, datasource);
-        }
-        if( finder == null ){
-            finder = factory.getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
-        }
-    }
-
-    public void testCreation() throws Exception {
-        assertNotNull(factory);
-        CoordinateReferenceSystem epsg4326 = factory.createCoordinateReferenceSystem("EPSG:4326");
-        CoordinateReferenceSystem code4326 = factory.createCoordinateReferenceSystem("4326");
-
-        assertNotNull(epsg4326);
-        assertEquals("4326 equals EPSG:4326", code4326, epsg4326);
-        assertSame("4326 == EPSG:4326", code4326, epsg4326);
-    }
-
-    public void testFunctionality() throws Exception {
-        CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem("4326");
-        CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem("3005");
-
-        // reproject
-        MathTransform transform = CRS.findMathTransform(crs1, crs2,true);
-        DirectPosition pos = new DirectPosition2D(48.417, 123.35);
-        transform.transform(pos, null);
-    }
-
-    public void testAuthorityCodes() throws Exception {
-        Set authorityCodes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
-        assertNotNull(authorityCodes);
-        assertTrue(authorityCodes.size() > 3000);
-    }
-
-    public void testFindWSG84() throws FactoryException {
-        String wkt;
-        wkt = "GEOGCS[\"WGS 84\",\n"                                    +
-              "  DATUM[\"World Geodetic System 1984\",\n"               +
-              "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n"  +
-              "  PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "  UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "  AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "  AXIS[\"Geodetic longitude\", EAST]]";
-
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-        finder.setFullScanAllowed(false);
-
-        assertNull("Should not find without a full scan, because the WKT contains no identifier " +
-                   "and the CRS name is ambiguous (more than one EPSG object have this name).",
-                   finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",CRS.equalsIgnoreMetadata(crs, find));
-        ReferenceIdentifier found = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority());
-		//assertEquals("4326",found.getCode());
-		assertNotNull( found );
-
-        finder.setFullScanAllowed(false);
-        String id = finder.findIdentifier(crs);
-        // this is broken because, as we know from above, it is ambiguous, so it may not be EPSG:4326 in the cache at all!
-        // assertEquals("The CRS should still in the cache.","EPSG:4326", id);
-        assertEquals("The CRS should still in the cache.",
-                found.getCodeSpace()+':'+found.getCode(), id);
-    }
-
-    public void testFindBeijing1954() throws FactoryException {
-        if (!TestData.isExtensiveTest()) {
-            return;
-        }
-        /*
-         * The PROJCS below intentionally uses a name different from the one found in the
-         * EPSG database, in order to force a full scan (otherwise the EPSG database would
-         * find it by name, but we want to test the scan).
-         */
-        String wkt = "PROJCS[\"Beijing 1954\",\n"                          +
-              "   GEOGCS[\"Beijing 1954\",\n"                              +
-              "     DATUM[\"Beijing 1954\",\n"                             +
-              "       SPHEROID[\"Krassowsky 1940\", 6378245.0, 298.3]],\n" +
-              "     PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "     UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "     AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "     AXIS[\"Geodetic longitude\", EAST]],\n"                +
-              "   PROJECTION[\"Transverse Mercator\"],\n"                  +
-              "   PARAMETER[\"central_meridian\", 135.0],\n"               +
-              "   PARAMETER[\"latitude_of_origin\", 0.0],\n"               +
-              "   PARAMETER[\"scale_factor\", 1.0],\n"                     +
-              "   PARAMETER[\"false_easting\", 500000.0],\n"               +
-              "   PARAMETER[\"false_northing\", 0.0],\n"                   +
-              "   UNIT[\"m\", 1.0],\n"                                     +
-              "   AXIS[\"Northing\", NORTH],\n"                            +
-              "   AXIS[\"Easting\", EAST]]";
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-
-        finder.setFullScanAllowed(false);
-        assertNull("Should not find the CRS without a full scan.", finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
-                   CRS.equalsIgnoreMetadata(crs, find));
-
-        assertEquals("2442", AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode());
-        finder.setFullScanAllowed(false);
-        String id = finder.findIdentifier(crs);
-        assertEquals("The CRS should still in the cache.","EPSG:2442", id);
-    }
-}
Index: src/main/resources/META-INF/services/org.opengis.referencing.datum.DatumAuthorityFactory
===================================================================
--- src/main/resources/META-INF/services/org.opengis.referencing.datum.DatumAuthorityFactory	(revision 37250)
+++ src/main/resources/META-INF/services/org.opengis.referencing.datum.DatumAuthorityFactory	(working copy)
@@ -1,3 +1,3 @@
-org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
 # pending review
-# org.geotools.referencing.factory.epsg.HsqlDialectEpsgMediator
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/site/apt/review.apt
===================================================================
--- src/site/apt/review.apt	(revision 37250)
+++ src/site/apt/review.apt	(working copy)
@@ -53,7 +53,7 @@
          7-parameter geocentric transformation methods
 --------------------------------------------------------------------------------
 
-* org.geotools.referencing.factory.epsg
+* org.geotools.referencing.factory.epsg.hsql.hsql
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
   *  contains a copy of the epsg data base tweaked for hibernate, need to check
Index: src/main/java/org/geotools/referencing/factory/epsg/overview.html
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/overview.html	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/overview.html	(working copy)
@@ -1,25 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<!-- NOTE: This file was used to be "package.html" in the factory directory.
-           However, it caused javadoc aggregation to fail with the following
-           error message: Multiple sources of package comments found for
-           package "org.geotools.referencing.factory.epsg". -->
-
-<HTML>
-  <HEAD>
-    <TITLE>package org.geotools.referencing.factory.epsg</TITLE>
-  </HEAD>
-  <BODY>
-  Allows the EPSG database to be used with the HSQL Java database as an Authority for GeoTools
-  CRS generation. At the difference of <CODE>epsg-access</CODE> and <CODE>epsg-postgresql</CODE>,
-  the <CODE>epsg-hsql</CODE> plugin contains a copy of the EPSG database. This plugin can work
-  "out of the box" without any specifial action on the user side.
-  
-  <h3>For More Information</h3>
-  The following links will prove useful:
-  <ul>
-    <li><a href="doc-files/HSQL.html">HSQL</a> - instructions for module maintainers</li>
-    <li><a href="http://www.epsg.org/">www.epsg.org</a></li>
-  </ul>
-  </BODY>
-</HTML>
Index: src/main/java/org/geotools/referencing/factory/epsg/HsqlEpsgDatabase.java
===================================================================
--- src/main/java/org/geotools/referencing/factory/epsg/HsqlEpsgDatabase.java	(revision 37250)
+++ src/main/java/org/geotools/referencing/factory/epsg/HsqlEpsgDatabase.java	(working copy)
@@ -1,273 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import org.geotools.factory.Hints;
-import org.geotools.util.logging.Logging;
-import org.hsqldb.jdbc.jdbcDataSource;
-import org.opengis.referencing.FactoryException;
-
-
-/**
- * This utility class knows everything there is to know about the care and
- * feeding of our pet EPSG database. This utility class is used to hold logic
- * previously associated with our own custom DataSource.
- * <p>
- * The EPSG database can be downloaded from <A
- * HREF="http://www.epsg.org">http://www.epsg.org</A>. The SQL scripts
- * (modified for the HSQL syntax as <A HREF="doc-files/HSQL.html">explained here</A>)
- * are bundled into this plugin. The database version is given in the
- * {@linkplain org.opengis.metadata.citation.Citation#getEdition edition attribute}
- * of the
- * {@linkplain org.opengis.referencing.AuthorityFactory#getAuthority authority}.
- * The HSQL database is read only.
- * <p>
- * 
- * @since 2.4
- * @source $URL$
- * @version $Id$
- * @author Jody Garnett
- *
- * @todo This class is used only by {@link HSQLDataSource}, which is deprecated.
- */
-public class HsqlEpsgDatabase {
-    /**
-     * The key for fetching the database directory from
-     * {@linkplain System#getProperty(String) system properties}.
-     */
-    public static final String DIRECTORY_KEY = "EPSG-HSQL.directory";
-
-    /**
-     * The database name.
-     */
-    public static final String DATABASE_NAME = "EPSG";
-
-    /**
-     * Creates a DataSource that is set up and ready to go.
-     * <p>
-     * This method pays attention to the system property "EPSG-HSQL.directory"
-     * and makes use of the default database name "EPSG".
-     * </p>
-     * 
-     * @return
-     * @throws SQLException
-     */
-    public static javax.sql.DataSource createDataSource() throws SQLException {
-        return createDataSource(getDirectory());
-    }
-
-    public static javax.sql.DataSource createDataSource(Hints hints ) throws FactoryException {
-        try {
-            return createDataSource(getDirectory());
-        } catch (SQLException e) {
-            throw new FactoryException( e );
-        }
-    }
-    public static javax.sql.DataSource createDataSource(File directory) throws SQLException {
-        jdbcDataSource dataSource = new jdbcDataSource();
-        /*
-         * Constructs the full path to the HSQL database. Note: we do not use
-         * File.toURI() because HSQL doesn't seem to expect an encoded URL (e.g.
-         * "%20" instead of spaces).
-         */
-        final StringBuilder url = new StringBuilder("jdbc:hsqldb:file:");
-        final String path = directory.getAbsolutePath().replace(File.separatorChar, '/');
-        if (path.length()==0 || path.charAt(0)!='/') {
-            url.append('/');
-        }
-        url.append(path);
-        if (url.charAt(url.length()-1) != '/') {
-            url.append('/');
-        }
-        url.append(HsqlEpsgDatabase.DATABASE_NAME);
-        dataSource.setDatabase(url.toString());
-        /*
-         * If the temporary directory do not exists or can't be created, lets
-         * the 'database' attribute unset. If the user do not set it explicitly
-         * (for example through JNDI), an exception will be thrown when
-         * 'getConnection()' will be invoked.
-         */
-        dataSource.setUser("SA"); // System administrator. No password.
-        if (!dataExists(dataSource)) {
-            generateData(dataSource);
-            try {
-                forceReadOnly(directory);
-            } catch (IOException file) {
-                throw (SQLException) new SQLException("Can't read the SQL script.").initCause(file);
-                // TODO: inline cause when we will be allowed to target Java 6.
-            }
-        }
-        return dataSource;
-    }
-
-    /**
-     * HSQL has created automatically an empty database. We need to populate it.
-     * Executes the SQL scripts bundled in the JAR. In theory, each line
-     * contains a full SQL statement. For this plugin however, we have
-     * compressed "INSERT INTO" statements using Compactor class in this
-     * package.
-     */
-    private static void generateData(javax.sql.DataSource dataSource) throws SQLException {
-        Connection connection = dataSource.getConnection();
-        Logging.getLogger("org.geotools.referencing.factory").config(
-                        "Creating cached EPSG database."); // TODO: localize
-        final Statement statement = connection.createStatement();
-        try {
-            final BufferedReader in = new BufferedReader(new InputStreamReader(
-                            HsqlEpsgDatabase.class.getResourceAsStream("EPSG.sql"),
-                            "ISO-8859-1"));
-            StringBuilder insertStatement = null;
-            String line;
-            while ((line = in.readLine()) != null) {
-                line = line.trim();
-                final int length = line.length();
-                if (length != 0) {
-                    if (line.startsWith("INSERT INTO")) {
-                        /*
-                         * We are about to insert many rows into a single table.
-                         * The row values appear in next lines; the current line
-                         * should stop right after the VALUES keyword.
-                         */
-                        insertStatement = new StringBuilder(line);
-                        continue;
-                    }
-                    if (insertStatement != null) {
-                        /*
-                         * We are about to insert a row. Prepend the "INSERT
-                         * INTO" statement and check if we will have more rows
-                         * to insert after this one.
-                         */
-                        final int values = insertStatement.length();
-                        insertStatement.append(line);
-                        final boolean hasMore = (line.charAt(length - 1) == ',');
-                        if (hasMore) {
-                            insertStatement.setLength(insertStatement.length() - 1);
-                        }
-                        line = insertStatement.toString();
-                        insertStatement.setLength(values);
-                        if (!hasMore) {
-                            insertStatement = null;
-                        }
-                    }
-                    statement.execute(line);
-                }
-            }
-            in.close();
-        } catch (IOException exception) {
-            SQLException e = new SQLException("Can't read the SQL script."); // TODO: localize
-            e.initCause(exception); // TODO: inline cause when we will be allowed to target Java 6.
-            throw e;
-        } finally {
-            statement.close();
-            connection.close();
-        }
-    }
-
-    private static void forceReadOnly(File directory) throws IOException {
-        final File file = new File(directory, HsqlEpsgDatabase.DATABASE_NAME + ".properties");
-        final InputStream propertyIn = new FileInputStream(file);
-        final Properties properties = new Properties();
-        properties.load(propertyIn);
-        propertyIn.close();
-        properties.put("readonly", "true");
-        final OutputStream out = new FileOutputStream(file);
-        properties.store(out, "EPSG database on HSQL");
-        out.close();
-    }
-
-    /**
-     * Returns the default directory for the EPSG database. If the
-     * {@value #DIRECTORY_KEY}
-     * {@linkplain System#getProperty(String) system property} is defined and
-     * contains the name of a directory with a valid
-     * {@linkplain File#getParent parent}, then the {@value #DATABASE_NAME}
-     * database will be saved in that directory. Otherwise, a temporary
-     * directory will be used.
-     * 
-     * @throws SQLException
-     */
-    static File getDirectory() throws SQLException {
-        try {
-            final String property = System.getProperty(HsqlEpsgDatabase.DIRECTORY_KEY);
-            if (property != null) {
-                final File directory = new File(property);
-                /*
-                 * Creates the directory if needed (mkdir), but NOT the parent
-                 * directories (mkdirs) because a missing parent directory may
-                 * be a symptom of an installation problem. For example if
-                 * 'directory' is a subdirectory in the temporary directory
-                 * (~/tmp/), this temporary directory should already exists. If
-                 * it doesn't, an administrator should probably looks at this
-                 * problem.
-                 */
-                if (directory.isDirectory() || directory.mkdir()) {
-                    return directory;
-                }
-            }
-        } catch (SecurityException e) {
-            /*
-             * Can't fetch the base directory from system properties. Fallback
-             * on the default temporary directory.
-             */
-        }
-        File directory = new File(System.getProperty("java.io.tmpdir", "."), "Geotools");
-        if (directory.isDirectory() || directory.mkdir()) {
-            directory = new File(directory, "Databases/HSQL");
-            if (directory.isDirectory() || directory.mkdirs()) {
-                return directory;
-            }
-        }
-        throw new SQLException("Can't write to the database directory.");
-    }
-
-    static boolean dataExists(javax.sql.DataSource dataSource) throws SQLException {
-        Connection connection = dataSource.getConnection();
-        try {
-            return dataExists(connection);
-        } finally {
-            connection.close();
-        }
-    }
-
-    /**
-     * Returns {@code true} if the database contains data. This method returns
-     * {@code false} if an empty EPSG database has been automatically created by
-     * HSQL and not yet populated.
-     */
-    static boolean dataExists(final Connection connection) throws SQLException {
-        final ResultSet tables = connection.getMetaData().getTables(null, null,
-                        "EPSG_%", new String[] { "TABLE" });
-        final boolean exists = tables.next();
-        tables.close();
-        return exists;
-    }
-}
Index: src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgFactoryTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgFactoryTest.java	(working copy)
@@ -1,157 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.util.Set;
-import javax.sql.DataSource;
-import junit.framework.TestCase;
-
-import org.geotools.TestData;
-import org.geotools.factory.Hints;
-import org.geotools.geometry.DirectPosition2D;
-import org.geotools.referencing.AbstractIdentifiedObject;
-import org.geotools.referencing.CRS;
-import org.geotools.referencing.factory.IdentifiedObjectFinder;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.ReferenceIdentifier;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-
-public class HsqlDialectEpsgFactoryTest extends TestCase {
-
-    private static HsqlDialectEpsgFactory factory;
-    private static IdentifiedObjectFinder finder;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        if( factory == null ){
-            DataSource datasource = HsqlEpsgDatabase.createDataSource();
-
-            Hints hints = new Hints(Hints.CACHE_POLICY, "weak");
-            factory = new HsqlDialectEpsgFactory(hints, datasource);
-        }
-        if( finder == null ){
-            finder = factory.getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
-        }
-    }
-
-    public void testCreation() throws Exception {
-        assertNotNull(factory);
-        CoordinateReferenceSystem epsg4326 = factory.createCoordinateReferenceSystem("EPSG:4326");
-        CoordinateReferenceSystem code4326 = factory.createCoordinateReferenceSystem("4326");
-
-        assertEquals("4326 equals EPSG:4326", code4326, epsg4326);
-        assertSame("4326 == EPSG:4326", code4326, epsg4326);
-    }
-
-    public void testFunctionality() throws Exception {
-        CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem("4326");
-        CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem("3005");
-
-        // reproject
-        MathTransform transform = CRS.findMathTransform(crs1, crs2,true);
-        DirectPosition pos = new DirectPosition2D(48.417, 123.35);
-        transform.transform(pos, null);
-    }
-
-    public void testAuthorityCodes() throws Exception {
-        Set authorityCodes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
-        assertNotNull(authorityCodes);
-        assertTrue(authorityCodes.size() > 3000);
-    }
-
-    public void testFindWSG84() throws FactoryException {
-        String wkt;
-        wkt = "GEOGCS[\"WGS 84\",\n"                                    +
-              "  DATUM[\"World Geodetic System 1984\",\n"               +
-              "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n"  +
-              "  PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "  UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "  AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "  AXIS[\"Geodetic longitude\", EAST]]";
-
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-        finder.setFullScanAllowed(false);
-
-        assertNull("Should not find without a full scan, because the WKT contains no identifier " +
-                   "and the CRS name is ambiguous (more than one EPSG object have this name).",
-                   finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",CRS.equalsIgnoreMetadata(crs, find));
-        ReferenceIdentifier found = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority());
-		//assertEquals("4326",found.getCode());
-        assertNotNull( found );
-        finder.setFullScanAllowed(false);
-        String id = finder.findIdentifier(crs);
-        // this is broken because, as we know from above, it is ambiguous, so it may not be EPSG:4326 in the cache at all!
-        // assertEquals("The CRS should still in the cache.","EPSG:4326", id);
-        assertEquals("The CRS should still in the cache.",
-                found.getCodeSpace()+':'+found.getCode(), id);
-   }
-
-    public void testFindBeijing1954() throws FactoryException {
-        if (!TestData.isExtensiveTest()) {
-            return;
-        }
-        /*
-         * The PROJCS below intentionally uses a name different from the one found in the
-         * EPSG database, in order to force a full scan (otherwise the EPSG database would
-         * find it by name, but we want to test the scan).
-         */
-        String wkt = "PROJCS[\"Beijing 1954\",\n"                          +
-              "   GEOGCS[\"Beijing 1954\",\n"                              +
-              "     DATUM[\"Beijing 1954\",\n"                             +
-              "       SPHEROID[\"Krassowsky 1940\", 6378245.0, 298.3]],\n" +
-              "     PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "     UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "     AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "     AXIS[\"Geodetic longitude\", EAST]],\n"                +
-              "   PROJECTION[\"Transverse Mercator\"],\n"                  +
-              "   PARAMETER[\"central_meridian\", 135.0],\n"               +
-              "   PARAMETER[\"latitude_of_origin\", 0.0],\n"               +
-              "   PARAMETER[\"scale_factor\", 1.0],\n"                     +
-              "   PARAMETER[\"false_easting\", 500000.0],\n"               +
-              "   PARAMETER[\"false_northing\", 0.0],\n"                   +
-              "   UNIT[\"m\", 1.0],\n"                                     +
-              "   AXIS[\"Northing\", NORTH],\n"                            +
-              "   AXIS[\"Easting\", EAST]]";
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-
-        finder.setFullScanAllowed(false);
-        assertNull("Should not find the CRS without a full scan.", finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
-                   CRS.equalsIgnoreMetadata(crs, find));
-
-        assertEquals("2442", AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode());
-        finder.setFullScanAllowed(false);
-        String id = finder.findIdentifier(crs);
-        assertEquals("The CRS should still be in the cache.","EPSG:2442", id);
-    }
-}
Index: META-INF/services/org.opengis.referencing.cs.CSAuthorityFactory
===================================================================
--- META-INF/services/org.opengis.referencing.cs.CSAuthorityFactory	(revision 0)
+++ META-INF/services/org.opengis.referencing.cs.CSAuthorityFactory	(revision 0)
@@ -0,0 +1,3 @@
+org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory
+# pending review
+# org.geotools.referencing.factory.epsg.hsql.HsqlDialectEpsgMediator
Index: src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorStressTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorStressTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/HsqlDialectEpsgMediatorStressTest.java	(working copy)
@@ -1,402 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.util.Random;
-
-import javax.sql.DataSource;
-
-import junit.framework.TestCase;
-
-import net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner;
-import net.sourceforge.groboutils.junit.v1.TestRunnable;
-
-import org.geotools.TestData;
-import org.geotools.factory.Hints;
-import org.geotools.geometry.DirectPosition2D;
-import org.geotools.referencing.CRS;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-
-public class HsqlDialectEpsgMediatorStressTest extends TestCase {
-
-    final static int RUNNER_COUNT = 10;
-    final static int ITERATIONS = 50;
-    final static int MAX_TIME = 2 * 60 * 1000;
-    final static boolean SHOW_OUTPUT = false;
-    final static int MAX_WORKERS = 2;
-
-    HsqlDialectEpsgMediator mediator;
-    DataSource datasource;
-    static String[] codes;
-    Hints hints;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        hints = new Hints(Hints.CACHE_POLICY, "none");
-        hints.put(Hints.AUTHORITY_MAX_ACTIVE, Integer.valueOf(MAX_WORKERS));
-        datasource = HsqlEpsgDatabase.createDataSource();
-        mediator = new HsqlDialectEpsgMediator(80, hints, datasource);
-        codes = getCodes();
-    }
-
-    public void testRunners() throws Throwable {
-        if (!TestData.isExtensiveTest()) {
-            return;
-        }
-        TestRunnable runners[] = new TestRunnable[RUNNER_COUNT];
-        for (int i = 0; i < RUNNER_COUNT; i++) {
-            ClientThread thread = new ClientThread(i, mediator);
-            thread.iterations = ITERATIONS;
-            runners[i] = thread;
-        }
-        MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(runners, null);
-        long timeStart = System.currentTimeMillis();
-        mttr.runTestRunnables(MAX_TIME);
-        long timeElapsed = System.currentTimeMillis() - timeStart;
-
-        //count exceptions and metrics
-        int exceptions = 0;
-        int totalTime = 0;
-        int totalRuns = 0;
-        long minTime = Long.MAX_VALUE;
-        long maxTime = 0;
-        for (int i = 0; i < RUNNER_COUNT; i++) {
-            ClientThread thread = (ClientThread) runners[i];
-            exceptions += thread.exceptions;
-            totalTime += thread.totalTime;
-            totalRuns += thread.totalRuns;
-            minTime = Math.min(minTime, thread.minTime);
-            maxTime = Math.max(maxTime, thread.maxTime);
-        }
-        if (SHOW_OUTPUT) {
-            System.out.println("Threads: " + RUNNER_COUNT);
-            System.out.println("Maximum Workers: " + MAX_WORKERS);
-            System.out.println("Iterations per Thread: " + ITERATIONS);
-            System.out.println("Average Time: " + (totalTime / totalRuns) + " ms");
-            System.out.println("Cumulative Time: " + totalTime + " ms");
-            System.out.println("Cumulative Iterations: " + totalRuns);
-            System.out.println("Overall Time: " + timeElapsed);
-            System.out.println("Throughput: " + (1000 * totalRuns / (double) totalTime) + " Hz");
-            System.out.println("Min: " + minTime);
-            System.out.println("Max: " + maxTime);
-            System.out.println("BUFFER_POLICY: " + hints.get(Hints.CACHE_POLICY).toString());
-            System.out.println("# CRS codes: " + codes.length);
-            //append results to file
-            StringBuilder sb = new StringBuilder();
-            sb.append(RUNNER_COUNT).append(", ")
-              .append(MAX_WORKERS) .append(", ")
-              .append(ITERATIONS)  .append(", ")
-              .append(hints.get(Hints.CACHE_POLICY)).append(", ")
-              .append(totalTime / totalRuns).append(", ")
-              .append(totalTime).append(", ")
-              .append(totalRuns).append(", ")
-              .append((1000 * totalRuns / (double) totalTime)).append(", ")
-              .append(minTime).append(", ")
-              .append(maxTime).append(", ")
-              .append(exceptions);
-            File file = new File("mediator-stress.csv");
-            String header = null;
-            String content = sb.toString();
-            if (!file.exists()) {
-                header = "THREADS, MAX_WORKERS, ITERATIONS_PER_THREAD, CACHE, AVG_TIME, TOTAL_TIME, TOTAL_RUNS, THROUGHPUT, MIN_TIME, MAX_TIME, EXCEPTIONS";
-            }
-            file.createNewFile();
-            BufferedWriter bw = new BufferedWriter(new FileWriter(file));
-            if (header != null) {
-                bw.write(header);
-            }
-            bw.newLine();
-            bw.write(content);
-            bw.close();
-        }
-        if (exceptions != 0) {
-            fail(exceptions + " exception(s) occurred");
-        }
-    }
-
-    /**
-     * Returns a selection of CRS codes for UTM and NAD zones.
-     *
-     * @return array of EPSG codes
-     * @throws FactoryException
-     */
-    public static String[] getCodes() {
-        return new String[] { "4269", "2043", "31528", "2936", "32639", "2027",
-                "2028", "2029", "2030", "2031", "2032", "2033", "2034", "2035",
-                "2040", "2041", "2042", "2043", "2058", "2059", "2060", "2061",
-                "2063", "2064", "2067", "2077", "2078", "2079", "2080", "2084",
-                "2089", "2090", "2095", "2133", "2134", "2135", "2156", "2158",
-                "2161", "2162", "2188", "2189", "2190", "2195", "2201", "2202",
-                "2203", "2215", "2216", "2217", "2219", "2220", "2312", "2313",
-                "2315", "2316", "2736", "2737", "2933", "2942", "2943", "2955",
-                "2956", "2957", "2958", "2959", "2960", "2961", "2962", "2969",
-                "2970", "2971", "2972", "2973", "2975", "2976", "2977", "2978",
-                "2979", "2980", "2981", "2983", "2987", "2988", "2989", "2995",
-                "2996", "2997", "2998", "2999", "3036", "3037", "3054", "3055",
-                "3056", "3060", "3061", "3062", "3063", "3064", "3065", "3148",
-                "3149", "3439", "3440", "3920", "20135", "20136", "20137",
-                "20138", "20437", "20438", "20439", "20538", "20539", "20822",
-                "20823", "20824", "20934", "20935", "20936", "21035", "21036",
-                "21037", "21095", "21096", "21097", "21148", "21149", "21150",
-                "21817", "21818", "22032", "22033", "22234", "22235", "22236",
-                "22332", "22523", "22524", "23028", "23029", "23030", "23031",
-                "23032", "23033", "23034", "23035", "23036", "23037", "23038",
-                "23239", "23240", "23846", "23847", "23848", "23849", "23850",
-                "23851", "23852", "23853", "23886", "23887", "23888", "23889",
-                "23890", "23891", "23892", "23893", "23894", "23946", "23947",
-                "23948", "24047", "24048", "24305", "24306", "24311", "24312",
-                "24313", "24342", "24343", "24344", "24345", "24346", "24347",
-                "24547", "24548", "24718", "24719", "24720", "24818", "24819",
-                "24820", "24821", "24877", "24878", "24879", "24880", "24882",
-                "25231", "25828", "25829", "25830", "25831", "25832", "25833",
-                "25834", "25835", "25836", "25837", "25838", "25932", "26237",
-                "26331", "26332", "26432", "26632", "26692", "26703", "26704",
-                "26705", "26706", "26707", "26708", "26709", "26710", "26711",
-                "26712", "26713", "26714", "26715", "26716", "26717", "26718",
-                "26719", "26720", "26721", "26722", "26903", "26904", "26905",
-                "26906", "26907", "26908", "26909", "26910", "26911", "26912",
-                "26913", "26914", "26915", "26916", "26917", "26918", "26919",
-                "26920", "26921", "26922", "26923", "27038", "27039", "27040",
-                "27120", "27258", "27259", "27260", "27429", "28232", "29168",
-                "29169", "29170", "29171", "29172", "29187", "29188", "29189",
-                "29190", "29191", "29192", "29193", "29194", "29195", "29220",
-                "29221", "29333", "29738", "29739", "29849", "29850", "30339",
-                "30340", "30729", "30730", "30731", "30732", "31028", "31121",
-                "31528", "31529", "31838", "31839", "31986", "31987", "31988",
-                "31989", "31990", "31991", "31992", "31993", "31994", "31995",
-                "31996", "31997", "31998", "31999", "32000", "32201", "32202",
-                "32203", "32204", "32205", "32206", "32207", "32208", "32209",
-                "32210", "32211", "32212", "32213", "32214", "32215", "32216",
-                "32217", "32218", "32219", "32220", "32221", "32222", "32223",
-                "32224", "32225", "32226", "32227", "32228", "32229", "32230",
-                "32231", "32232", "32233", "32234", "32235", "32236", "32237",
-                "32238", "32239", "32240", "32241", "32242", "32243", "32244",
-                "32245", "32246", "32247", "32248", "32249", "32250", "32251",
-                "32252", "32253", "32254", "32255", "32256", "32257", "32258",
-                "32259", "32260", "32301", "32302", "32303", "32304", "32305",
-                "32306", "32307", "32308", "32309", "32310", "32311", "32312",
-                "32313", "32314", "32315", "32316", "32317", "32318", "32319",
-                "32320", "32321", "32322", "32323", "32324", "32325", "32326",
-                "32327", "32328", "32329", "32330", "32331", "32332", "32333",
-                "32334", "32335", "32336", "32337", "32338", "32339", "32340",
-                "32341", "32342", "32343", "32344", "32345", "32346", "32347",
-                "32348", "32349", "32350", "32351", "32352", "32353", "32354",
-                "32355", "32356", "32357", "32358", "32359", "32360", "32401",
-                "32402", "32403", "32404", "32405", "32406", "32407", "32408",
-                "32409", "32410", "32411", "32412", "32413", "32414", "32415",
-                "32416", "32417", "32418", "32419", "32420", "32421", "32422",
-                "32423", "32424", "32425", "32426", "32427", "32428", "32429",
-                "32430", "32431", "32432", "32433", "32434", "32435", "32436",
-                "32437", "32438", "32439", "32440", "32441", "32442", "32443",
-                "32444", "32445", "32446", "32447", "32448", "32449", "32450",
-                "32451", "32452", "32453", "32454", "32455", "32456", "32457",
-                "32458", "32459", "32460", "32501", "32502", "32503", "32504",
-                "32505", "32506", "32507", "32508", "32509", "32510", "32511",
-                "32512", "32513", "32514", "32515", "32516", "32517", "32518",
-                "32519", "32520", "32521", "32522", "32523", "32524", "32525",
-                "32526", "32527", "32528", "32529", "32530", "32531", "32532",
-                "32533", "32534", "32535", "32536", "32537", "32538", "32539",
-                "32540", "32541", "32542", "32543", "32544", "32545", "32546",
-                "32547", "32548", "32549", "32550", "32551", "32552", "32553",
-                "32554", "32555", "32556", "32557", "32558", "32559", "32560",
-                "32601", "32602", "32603", "32604", "32605", "32606", "32607",
-                "32608", "32609", "32610", "32611", "32612", "32613", "32614",
-                "32615", "32616", "32617", "32618", "32619", "32620", "32621",
-                "32622", "32623", "32624", "32625", "32626", "32627", "32628",
-                "32629", "32630", "32631", "32632", "32633", "32634", "32635",
-                "32636", "32637", "32638", "32639", "32640", "32641", "32642",
-                "32643", "32644", "32645", "32646", "32647", "32648", "32649",
-                "32650", "32651", "32652", "32653", "32654", "32655", "32656",
-                "32657", "32658", "32659", "32660", "32701", "32702", "32703",
-                "32704", "32705", "32706", "32707", "32708", "32709", "32710",
-                "32711", "32712", "32713", "32714", "32715", "32716", "32717",
-                "32718", "32719", "32720", "32721", "32722", "32723", "32724",
-                "32725", "32726", "32727", "32728", "32729", "32730", "32731",
-                "32732", "32733", "32734", "32735", "32736", "32737", "32738",
-                "32739", "32740", "32741", "32742", "32743", "32744", "32745",
-                "32746", "32747", "32748", "32749", "32750", "32751", "32752",
-                "32753", "32754", "32755", "32756", "32757", "32758", "32759",
-                "32760", "2008", "2009", "2010", "2011", "2012", "2013",
-                "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021",
-                "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029",
-                "2030", "2031", "2032", "2033", "2034", "2035", "2085", "2086",
-                "2138", "2156", "2195", "2204", "2205", "2222", "2223", "2224",
-                "2225", "2226", "2227", "2228", "2229", "2230", "2231", "2232",
-                "2233", "2234", "2235", "2236", "2237", "2238", "2239", "2240",
-                "2241", "2242", "2243", "2244", "2245", "2246", "2247", "2248",
-                "2249", "2250", "2251", "2252", "2253", "2254", "2255", "2256",
-                "2257", "2258", "2259", "2260", "2261", "2262", "2263", "2264",
-                "2265", "2266", "2267", "2268", "2269", "2270", "2271", "2272",
-                "2273", "2274", "2275", "2276", "2277", "2278", "2279", "2280",
-                "2281", "2282", "2283", "2284", "2285", "2286", "2287", "2288",
-                "2289", "2291", "2759", "2760", "2761", "2762", "2763", "2764",
-                "2765", "2766", "2767", "2768", "2769", "2770", "2771", "2772",
-                "2773", "2774", "2775", "2776", "2777", "2778", "2779", "2780",
-                "2781", "2782", "2783", "2784", "2785", "2786", "2787", "2788",
-                "2789", "2790", "2791", "2792", "2793", "2794", "2795", "2796",
-                "2797", "2798", "2799", "2800", "2801", "2802", "2803", "2804",
-                "2805", "2806", "2807", "2808", "2809", "2810", "2811", "2812",
-                "2813", "2814", "2815", "2816", "2817", "2818", "2819", "2820",
-                "2821", "2822", "2823", "2824", "2825", "2826", "2827", "2828",
-                "2829", "2830", "2831", "2832", "2833", "2834", "2835", "2836",
-                "2837", "2838", "2839", "2840", "2841", "2842", "2843", "2844",
-                "2845", "2846", "2847", "2848", "2849", "2850", "2851", "2852",
-                "2853", "2854", "2855", "2856", "2857", "2858", "2859", "2860",
-                "2861", "2862", "2863", "2864", "2865", "2866", "2867", "2868",
-                "2869", "2870", "2871", "2872", "2873", "2874", "2875", "2876",
-                "2877", "2878", "2879", "2880", "2881", "2882", "2883", "2884",
-                "2885", "2886", "2887", "2888", "2889", "2890", "2891", "2892",
-                "2893", "2894", "2895", "2896", "2897", "2898", "2899", "2900",
-                "2901", "2902", "2903", "2904", "2905", "2906", "2907", "2908",
-                "2909", "2910", "2911", "2912", "2913", "2914", "2915", "2916",
-                "2917", "2918", "2919", "2920", "2921", "2922", "2923", "2924",
-                "2925", "2926", "2927", "2928", "2929", "2930", "2944", "2945",
-                "2946", "2947", "2948", "2949", "2950", "2951", "2952", "2953",
-                "2954", "2955", "2956", "2957", "2958", "2959", "2960", "2961",
-                "2962", "2964", "2965", "2966", "2967", "2968", "2991", "2992",
-                "2993", "2994", "3005", "4152", "4267", "4268", "4269", "4608",
-                "4609", "4617", "26710", "26711", "26712", "26713", "26714",
-                "26715", "26716", "26717", "26718", "26719", "26720", "26721",
-                "26722", "26729", "26730", "26731", "26732", "26733", "26734",
-                "26735", "26736", "26737", "26738", "26739", "26740", "26741",
-                "26742", "26743", "26744", "26745", "26746", "26747", "26748",
-                "26749", "26750", "26751", "26752", "26753", "26754", "26755",
-                "26756", "26757", "26758", "26759", "26760", "26766", "26767",
-                "26768", "26769", "26770", "26771", "26772", "26773", "26774",
-                "26775", "26776", "26777", "26778", "26779", "26780", "26781",
-                "26782", "26783", "26784", "26785", "26786", "26787", "26791",
-                "26792", "26793", "26794", "26795", "26796", "26797", "26798",
-                "26801", "26802", "26803", "26811", "26812", "26813", "26903",
-                "26904", "26905", "26906", "26907", "26908", "26909", "26910",
-                "26911", "26912", "26913", "26914", "26915", "26916", "26917",
-                "26918", "26919", "26920", "26921", "26922", "26923", "26929",
-                "26930", "26931", "26932", "26933", "26934", "26935", "26936",
-                "26937", "26938", "26939", "26940", "26941", "26942", "26943",
-                "26944", "26945", "26946", "26948", "26949", "26950", "26951",
-                "26952", "26953", "26954", "26955", "26956", "26957", "26958",
-                "26959", "26960", "26961", "26962", "26963", "26964", "26965",
-                "26966", "26967", "26968", "26969", "26970", "26971", "26972",
-                "26973", "26974", "26975", "26976", "26977", "26978", "26979",
-                "26980", "26981", "26982", "26983", "26984", "26985", "26986",
-                "26987", "26988", "26989", "26990", "26991", "26992", "26993",
-                "26994", "26995", "26996", "26997", "26998", "32001", "32002",
-                "32003", "32005", "32006", "32007", "32008", "32009", "32010",
-                "32011", "32012", "32013", "32014", "32015", "32016", "32017",
-                "32018", "32019", "32020", "32021", "32022", "32023", "32024",
-                "32025", "32026", "32027", "32028", "32029", "32030", "32031",
-                "32033", "32034", "32035", "32036", "32037", "32038", "32039",
-                "32040", "32041", "32042", "32043", "32044", "32045", "32046",
-                "32047", "32048", "32049", "32050", "32051", "32052", "32053",
-                "32054", "32055", "32056", "32057", "32058", "32061", "32062",
-                "32064", "32065", "32066", "32067", "32074", "32075", "32076",
-                "32077", "32081", "32082", "32083", "32084", "32085", "32086",
-                "32098", "32100", "32104", "32107", "32108", "32109", "32110",
-                "32111", "32112", "32113", "32114", "32115", "32116", "32117",
-                "32118", "32119", "32120", "32121", "32122", "32123", "32124",
-                "32125", "32126", "32127", "32128", "32129", "32130", "32133",
-                "32134", "32135", "32136", "32137", "32138", "32139", "32140",
-                "32141", "32142", "32143", "32144", "32145", "32146", "32147",
-                "32148", "32149", "32150", "32151", "32152", "32153", "32154",
-                "32155", "32156", "32157", "32158", "32161", "32180", "32181",
-                "32182", "32183", "32184", "32185", "32186", "32187", "32188",
-                "32189", "32190", "32191", "32192", "32193", "32194", "32195",
-                "32196", "32197", "32198" };
-    }
-
-    public static class ClientThread extends TestRunnable {
-
-        String values;
-        int id = -1; //thread identifier
-        public int exceptions = 0;
-
-        //test metrics
-        public long minTime = Long.MAX_VALUE;
-        public long maxTime = -1;
-        public long totalTime = 0;
-        public int totalRuns = 0;
-
-        /** number of iterations to perform */
-        public int iterations = 10;
-
-        Random rand = new Random();
-        HsqlDialectEpsgMediator mediator; //victim
-
-        public ClientThread(int id, HsqlDialectEpsgMediator mediator) {
-            this.id = id;
-            this.mediator = mediator;
-        }
-
-        private String getRandomCode() {
-            if (codes == null) {
-                codes = getCodes();
-            }
-            return codes[rand.nextInt(codes.length)];
-        }
-
-        private CoordinateReferenceSystem acquireCRS(String code) throws FactoryException {
-            return mediator.createCoordinateReferenceSystem(code);
-        }
-
-        public void runTest() throws Throwable {
-            for (int i = 0; i < iterations; i++) {
-                //record start time
-                long timeStart = System.currentTimeMillis();
-
-                //select first CRS
-                String code1 = "4326";
-                CoordinateReferenceSystem crs1 = acquireCRS(code1);
-
-                //select second CRS
-                String code2 = null;
-                while (code2 == null || code1.equalsIgnoreCase(code2)) {
-                    code2 = getRandomCode();
-                }
-                try {
-                    CoordinateReferenceSystem crs2 = acquireCRS(code2);
-
-                    // reproject
-                    MathTransform transform = CRS.findMathTransform(crs1, crs2,
-                            true);
-                    DirectPosition pos = new DirectPosition2D(48.417, 123.35);
-                    try {
-                         transform.transform(pos, null);
-                    } catch (Exception e) {
-                        // chomp
-                    }
-                } catch (Exception e) {
-                    exceptions++;
-                    System.out.println("Exception in Thread " + id + ", EPSG: " + code2);
-                    //TODO: save exception
-                    //e.printStackTrace();
-                }
-
-                long timeElapsed = System.currentTimeMillis() - timeStart;
-                totalRuns++;
-                totalTime += timeElapsed;
-                minTime = Math.min(minTime, timeElapsed);
-                maxTime = Math.max(maxTime, timeElapsed);
-            }
-        }
-    }
-}
Index: src/test/java/org/geotools/referencing/factory/epsg/OperationFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/OperationFactoryTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/OperationFactoryTest.java	(working copy)
@@ -1,143 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import java.util.Iterator;
-import java.util.logging.Level;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.crs.CRSAuthorityFactory;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.Conversion;
-import org.opengis.referencing.operation.Transformation;
-import org.opengis.referencing.operation.CoordinateOperation;
-import org.opengis.referencing.operation.CoordinateOperationFactory;
-import org.opengis.referencing.operation.ConcatenatedOperation;
-
-import org.geotools.referencing.operation.BufferedCoordinateOperationFactory;
-import org.geotools.referencing.operation.AbstractCoordinateOperation;
-import org.geotools.referencing.operation.AuthorityBackedFactory;
-import org.geotools.referencing.ReferencingFactoryFinder;
-import org.geotools.factory.Hints;
-import org.geotools.resources.Arguments;
-import org.geotools.resources.Classes;
-
-
-/**
- * Tests the usage of {@link CoordinateOperationFactory} with the help of the
- * EPSG database. Any EPSG plugin should fit. However, this test live in the
- * {@code plugin/epsg-hsql} module since the HSQL plugin is the only one which
- * is garantee to work on any machine running Maven.
- *
- * @source $URL$
- * @version $Id$
- * @author Martin Desruisseaux (IRD)
- */
-public class OperationFactoryTest extends TestCase {
-    /**
-     * Run the suite from the command line. If {@code "-log"} flag is specified on the
-     * command-line, then the logger will be set to {@link Level#CONFIG}. This is usefull
-     * for tracking down which data source is actually used.
-     */
-    public static void main(final String[] args) {
-        final Arguments arguments = new Arguments(args);
-        final boolean log = arguments.getFlag("-log");
-        arguments.getRemainingArguments(0);
-        org.geotools.util.logging.Logging.GEOTOOLS.forceMonolineConsoleOutput(log ? Level.CONFIG : null);
-        junit.textui.TestRunner.run(suite());
-    }
-
-    /**
-     * Returns the test suite.
-     */
-    public static Test suite() {
-        return new TestSuite(OperationFactoryTest.class);
-    }
-
-    /**
-     * Constructs a test case with the given name.
-     */
-    public OperationFactoryTest(final String name) {
-        super(name);
-    }
-
-    /**
-     * Returns the first identifier for the specified object.
-     */
-    private static String getIdentifier(final IdentifiedObject object) {
-        return object.getIdentifiers().iterator().next().getCode();
-    }
-
-    /**
-     * Tests the creation of an operation from EPSG:4230 to EPSG:4326. They are the same
-     * CRS than the one tested in {@link DefaultDataSourceTest#testTransformations}.
-     */
-    public void testCreate() throws FactoryException {
-        final CRSAuthorityFactory       crsFactory;
-        final CoordinateOperationFactory opFactory;
-              CoordinateReferenceSystem  sourceCRS;
-              CoordinateReferenceSystem  targetCRS;
-              CoordinateOperation        operation;
-
-        crsFactory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);
-        opFactory  = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
-        sourceCRS  = crsFactory.createCoordinateReferenceSystem("4230");
-        targetCRS  = crsFactory.createCoordinateReferenceSystem("4326");
-        operation  = opFactory.createOperation(sourceCRS, targetCRS);
-
-        assertSame(sourceCRS, operation.getSourceCRS());
-        assertSame(targetCRS, operation.getTargetCRS());
-        assertSame(operation, opFactory.createOperation(sourceCRS, targetCRS));
-        assertTrue("Expected a buffered factory but got " + opFactory.getClass().getName(),
-                opFactory instanceof BufferedCoordinateOperationFactory);
-        assertTrue("EPSG authority factory not found.",
-                ((BufferedCoordinateOperationFactory) opFactory).getImplementationHints().
-                get(Hints.COORDINATE_OPERATION_FACTORY) instanceof AuthorityBackedFactory);
-        assertEquals("1612", getIdentifier(operation)); // See comment in DefaultDataSourceTest.
-        assertEquals(1.0, AbstractCoordinateOperation.getAccuracy(operation), 1E-6);
-        assertTrue(operation instanceof Transformation);
-        /*
-         * Tests a transformation not backed directly by an authority factory.
-         * However, the inverse transform may exist in the authority factory.
-         */
-        sourceCRS  = crsFactory.createCoordinateReferenceSystem("4326");
-        targetCRS  = crsFactory.createCoordinateReferenceSystem("2995");
-        operation  = opFactory.createOperation(sourceCRS, targetCRS);
-        assertTrue("This test needs an operation not backed by the EPSG factory.",
-                   operation.getIdentifiers().isEmpty());
-        // Should contains exactly one transformations and an arbitrary number of conversions.
-        assertTrue(operation instanceof ConcatenatedOperation);
-        int count = 0;
-        for (final Iterator it=((ConcatenatedOperation) operation).getOperations().iterator(); it.hasNext();) {
-            final CoordinateOperation op = (CoordinateOperation) it.next();
-            if (op instanceof Transformation) {
-                count++;
-            } else {
-                assertTrue("Expected Conversion but got " +
-                           Classes.getShortName(AbstractCoordinateOperation.getType(op)) + ". ",
-                           (op instanceof Conversion));
-            }
-        }
-        assertEquals("The coordinate operation should contains exactly 1 transformation", 1, count);
-        assertTrue(AbstractCoordinateOperation.getAccuracy(operation) <= 25);
-    }
-}
Index: src/test/java/org/geotools/referencing/factory/epsg/ThreadedHsqlEpsgFactoryTest.java
===================================================================
--- src/test/java/org/geotools/referencing/factory/epsg/ThreadedHsqlEpsgFactoryTest.java	(revision 37250)
+++ src/test/java/org/geotools/referencing/factory/epsg/ThreadedHsqlEpsgFactoryTest.java	(working copy)
@@ -1,258 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- * 
- *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- */
-package org.geotools.referencing.factory.epsg;
-
-import static org.junit.Assert.*;
-
-import java.util.Set;
-
-import org.geotools.geometry.DirectPosition2D;
-import org.geotools.referencing.AbstractIdentifiedObject;
-import org.geotools.referencing.CRS;
-import org.geotools.referencing.ReferencingFactoryFinder;
-import org.geotools.referencing.datum.BursaWolfParameters;
-import org.geotools.referencing.datum.DefaultGeodeticDatum;
-import org.geotools.referencing.factory.IdentifiedObjectFinder;
-import org.junit.Before;
-import org.junit.Test;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.ReferenceIdentifier;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.operation.MathTransform;
-
-/**
- * This class makes sure we can find the ThreadedHsqlEpsgFactory
- * using ReferencingFactoryFinder.
- * 
- * @author Jody
- *
- * @source $URL$
- */
-public class ThreadedHsqlEpsgFactoryTest {
-    
-    private static ThreadedHsqlEpsgFactory factory;
-    private static IdentifiedObjectFinder finder;
-    static final double EPS = 1e-06;
-    
-    @Before
-    public void setUp() throws Exception {
-        if( factory == null ){
-            factory = (ThreadedHsqlEpsgFactory) ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null );
-        }
-        if( finder == null ){
-            finder = factory.getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
-        }
-    }
-
-    @Test
-    public void testCreation() throws Exception {
-        assertNotNull(factory);
-        CoordinateReferenceSystem epsg4326 = factory.createCoordinateReferenceSystem("EPSG:4326");
-        CoordinateReferenceSystem code4326 = factory.createCoordinateReferenceSystem("4326");
-
-        assertEquals("4326 equals EPSG:4326", code4326, epsg4326);
-        assertSame("4326 == EPSG:4326", code4326, epsg4326);
-    }
-    
-    @Test
-    public void testFunctionality() throws Exception {
-        CoordinateReferenceSystem crs1 = factory.createCoordinateReferenceSystem("4326");
-        CoordinateReferenceSystem crs2 = factory.createCoordinateReferenceSystem("3005");
-
-        // reproject
-        MathTransform transform = CRS.findMathTransform(crs1, crs2,true);
-        DirectPosition pos = new DirectPosition2D(48.417, 123.35);
-        transform.transform(pos, null);        
-    }
-    @Test
-    public void testAuthorityCodes() throws Exception {
-        Set authorityCodes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
-        assertNotNull(authorityCodes);
-        assertTrue(authorityCodes.size() > 3000);
-    }
-
-    @Test
-    public void testFindWSG84() throws FactoryException {
-        String wkt;
-        wkt = "GEOGCS[\"WGS 84\",\n"                                    +
-              "  DATUM[\"World Geodetic System 1984\",\n"               +
-              "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n"  +
-              "  PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "  UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "  AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "  AXIS[\"Geodetic longitude\", EAST]]";
-        
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-        finder.setFullScanAllowed(false);
-        
-        assertNull("Should not find without a full scan, because the WKT contains no identifier " +
-                   "and the CRS name is ambiguous (more than one EPSG object have this name).",
-                   finder.find(crs));
-
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);
-        
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-        
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",CRS.equalsIgnoreMetadata(crs, find));
-        ReferenceIdentifier found = AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority());
-		//assertEquals("4326",found.getCode());
-        assertNotNull( found );
-        finder.setFullScanAllowed(false);
-        String id = finder.findIdentifier(crs);
-        assertEquals("The CRS should still be in the cache.","EPSG:4326", id);
-    }
-    
-    @Test
-    public void testFindBeijing1954() throws FactoryException {
-        /*
-         * The PROJCS below intentionally uses a name different from the one found in the
-         * EPSG database, in order to force a full scan (otherwise the EPSG database would
-         * find it by name, but we want to test the scan).
-         */
-        String wkt = "PROJCS[\"Beijing 1954\",\n"                          +
-              "   GEOGCS[\"Beijing 1954\",\n"                              +
-              "     DATUM[\"Beijing 1954\",\n"                             +
-              "       SPHEROID[\"Krassowsky 1940\", 6378245.0, 298.3]],\n" +
-              "     PRIMEM[\"Greenwich\", 0.0],\n"                         +
-              "     UNIT[\"degree\", 0.017453292519943295],\n"             +
-              "     AXIS[\"Geodetic latitude\", NORTH],\n"                 +
-              "     AXIS[\"Geodetic longitude\", EAST]],\n"                +
-              "   PROJECTION[\"Transverse Mercator\"],\n"                  +
-              "   PARAMETER[\"central_meridian\", 135.0],\n"               +
-              "   PARAMETER[\"latitude_of_origin\", 0.0],\n"               +
-              "   PARAMETER[\"scale_factor\", 1.0],\n"                     +
-              "   PARAMETER[\"false_easting\", 500000.0],\n"               +
-              "   PARAMETER[\"false_northing\", 0.0],\n"                   +
-              "   UNIT[\"m\", 1.0],\n"                                     +
-              "   AXIS[\"Northing\", NORTH],\n"                            +
-              "   AXIS[\"Easting\", EAST]]";
-        CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
-        
-        finder.setFullScanAllowed(false);
-        assertNull("Should not find the CRS without a full scan.", finder.find(crs));
-        
-        finder.setFullScanAllowed(true);
-        IdentifiedObject find = finder.find(crs);        
-        assertNotNull("With full scan allowed, the CRS should be found.", find);
-        
-        assertTrue("Should found an object equals (ignoring metadata) to the requested one.",
-                   CRS.equalsIgnoreMetadata(crs, find));
-        
-        assertEquals("2442", AbstractIdentifiedObject.getIdentifier(find, factory.getAuthority()).getCode());
-        finder.setFullScanAllowed(false);
-        String id = finder.findIdentifier(crs);
-        assertEquals("The CRS should still be in the cache.","EPSG:2442", id);
-    }
-    
-    @Test
-    public void testGoogleProjection() throws Exception {
-        CoordinateReferenceSystem epsg4326 = CRS.decode("EPSG:4326");
-        CoordinateReferenceSystem epsg3785 = CRS.decode("EPSG:3857");
-        
-        String wkt900913 = "PROJCS[\"WGS84 / Google Mercator\", " +
-        		"GEOGCS[\"WGS 84\", " +
-        		"  DATUM[\"World Geodetic System 1984\", " +
-        		"    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], " +
-        		"    AUTHORITY[\"EPSG\",\"6326\"]], " +
-        		"  PRIMEM[\"Greenwich\", 0.0, " +
-        		"  AUTHORITY[\"EPSG\",\"8901\"]], " +
-        		"  UNIT[\"degree\", 0.017453292519943295], AUTHORITY[\"EPSG\",\"4326\"]], " +
-        		"PROJECTION[\"Mercator (1SP)\", " +
-        		"AUTHORITY[\"EPSG\",\"9804\"]], " +
-        		"PARAMETER[\"semi_major\", 6378137.0], " +
-        		"PARAMETER[\"semi_minor\", 6378137.0], " +
-        		"PARAMETER[\"latitude_of_origin\", 0.0], " +
-        		"PARAMETER[\"central_meridian\", 0.0], " +
-        		"PARAMETER[\"scale_factor\", 1.0], " +
-        		"PARAMETER[\"false_easting\", 0.0], " +
-        		"PARAMETER[\"false_northing\", 0.0], " +
-        		"UNIT[\"m\", 1.0],  " +
-        		"AUTHORITY[\"EPSG\",\"900913\"]]";
-        CoordinateReferenceSystem epsg900913 = CRS.parseWKT(wkt900913);
-        
-        MathTransform t1 = CRS.findMathTransform(epsg4326, epsg3785); 
-        MathTransform t2 = CRS.findMathTransform(epsg4326, epsg900913);
-
-        // check the two equate each other, we know the above 900913 definition works
-        double[][] points = new double[][] {{0,0}, {30.0, 30.0}, {-45.0, 45.0}, {-20, -20}, 
-                {80,-80}, {85, 180}, {-85, -180}};
-        double[][] points2 = new double[points.length][2];
-        double[] tp1 = new double[2];
-        double[] tp2= new double[2];
-        for (double[] point : points) {
-            t1.transform(point, 0, tp1, 0, 1);
-            t2.transform(point, 0, tp2, 0, 1);
-            assertEquals(tp1[0], tp2[0], EPS);
-            assertEquals(tp1[1], tp2[1], EPS);
-            // check inverse as well
-            t1.inverse().transform(tp1, 0, tp1, 0, 1);
-            t2.inverse().transform(tp2, 0, tp2, 0, 1);
-            assertEquals(point[0], tp2[0], EPS);
-            assertEquals(point[1], tp2[1], EPS);
-        }
-        
-    }
-    
-    /**
-     * GEOT-3497 (given the same accuracy use the transformation method with the largest valid area)
-     */
-    @Test
-    public void testNad83() throws Exception {
-        GeographicCRS crs = (GeographicCRS) CRS.decode("EPSG:4269");
-        DefaultGeodeticDatum datum = (DefaultGeodeticDatum) crs.getDatum();
-        BursaWolfParameters[] params = datum.getBursaWolfParameters();
-        boolean wgs84Found = false;
-        for(int i = 0; i < params.length; i++) {
-            if(DefaultGeodeticDatum.isWGS84(params[i].targetDatum)) {
-                wgs84Found = true;
-                assertEquals(0.0, params[i].dx, EPS);
-                assertEquals(0.0, params[i].dy, EPS);
-                assertEquals(0.0, params[i].dz, EPS);
-                assertEquals(0.0, params[i].ex, EPS);
-                assertEquals(0.0, params[i].ey, EPS);
-                assertEquals(0.0, params[i].ez, EPS);
-                assertEquals(0.0, params[i].ppm, EPS);
-            }
-        }
-        assertTrue(wgs84Found);        
-    }
-    
-    /**
-     * GEOT-3482
-     * @throws Exception
-     */
-    @Test
-    public void testPPMUnit() throws Exception {
-        // Create WGS 72 CRS where we know that the EPSG defines a unique 
-        // Position Vector Transformation to WGS 84 with ppm = 0.219
-        GeographicCRS wgs72 = (GeographicCRS) CRS.decode("EPSG:4322");
-        
-        // Get datum
-        DefaultGeodeticDatum datum = (DefaultGeodeticDatum)wgs72.getDatum();
-        
-        // Get BursaWolf parameters
-        BursaWolfParameters[] params = datum.getBursaWolfParameters();
-        
-        // Check for coherence with the value contained in the EPSG data base
-        assertEquals(0.219, params[0].ppm, EPS);
-    }
-
-}
