diff --git a/hibernate-spatial/databases/oracle11g_connection_finder/matrix.gradle b/hibernate-spatial/databases/oracle11g_connection_finder/matrix.gradle new file mode 100644 index 0000000000..3a4d4751a6 --- /dev/null +++ b/hibernate-spatial/databases/oracle11g_connection_finder/matrix.gradle @@ -0,0 +1,7 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +jdbcDependency "com.oracle.jdbc:ojdbc6:11.1.0.7.0" diff --git a/hibernate-spatial/databases/oracle11g_connection_finder/resources/hibernate.properties b/hibernate-spatial/databases/oracle11g_connection_finder/resources/hibernate.properties new file mode 100644 index 0000000000..6c44837d92 --- /dev/null +++ b/hibernate-spatial/databases/oracle11g_connection_finder/resources/hibernate.properties @@ -0,0 +1,25 @@ +# +# Hibernate, Relational Persistence for Idiomatic Java +# +# License: GNU Lesser General Public License (LGPL), version 2.1 or later. +# See the lgpl.txt file in the root directory or . +# + +hibernate.dialect org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect +hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver +hibernate.connection.url jdbc:oracle:thin:@ec2-54-216-171-204.eu-west-1.compute.amazonaws.com:1521/ORCL +hibernate.connection.username hibspa +hibernate.connection.password L9un5Bh6 + +## uncommenting this will fail a unit test!! +hibernate.spatial.connection_finder org.hibernate.spatial.dialect.oracle.TestConnectionFinder + +hibernate.connection.pool_size 5 + +hibernate.show_sql true +hibernate.format_sql true + +hibernate.max_fetch_depth 5 + +hibernate.cache.region_prefix hibernate.test +hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory diff --git a/hibernate-spatial/databases/oracle11g_spatial/matrix.gradle b/hibernate-spatial/databases/oracle11g_spatial/matrix.gradle index c23f80c756..3a4d4751a6 100644 --- a/hibernate-spatial/databases/oracle11g_spatial/matrix.gradle +++ b/hibernate-spatial/databases/oracle11g_spatial/matrix.gradle @@ -4,4 +4,4 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ -jdbcDependency "com.oracle.jdbc:ojdbc6:11.2.0.3" +jdbcDependency "com.oracle.jdbc:ojdbc6:11.1.0.7.0" diff --git a/hibernate-spatial/databases/oracle11g_spatial/resources/hibernate.properties b/hibernate-spatial/databases/oracle11g_spatial/resources/hibernate.properties index 6b9897401e..c2e0f2308d 100644 --- a/hibernate-spatial/databases/oracle11g_spatial/resources/hibernate.properties +++ b/hibernate-spatial/databases/oracle11g_spatial/resources/hibernate.properties @@ -7,7 +7,7 @@ hibernate.dialect org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver -hibernate.connection.url jdbc:oracle:thin:@hibernatespatial-oracle.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:1521/ORCL +hibernate.connection.url jdbc:oracle:thin:@ec2-54-216-171-204.eu-west-1.compute.amazonaws.com:1521/ORCL hibernate.connection.username hibspa hibernate.connection.password L9un5Bh6 diff --git a/hibernate-spatial/hibernate-spatial.gradle b/hibernate-spatial/hibernate-spatial.gradle index 64187b3788..87c5cbcb5b 100644 --- a/hibernate-spatial/hibernate-spatial.gradle +++ b/hibernate-spatial/hibernate-spatial.gradle @@ -46,10 +46,13 @@ dependencies { // for test runtime transitive = true } + + testRuntime( libraries.expression_language_api ) + testRuntime( libraries.expression_language_impl ) + testRuntime('jaxen:jaxen:1.1') testRuntime(libraries.javassist) -// matrixRuntime( 'jaxen:jaxen:1.1' ) } sourceSets.test.resources { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/HSMessageLogger.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/HSMessageLogger.java index 4b81f96c4a..e51cac003b 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/HSMessageLogger.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/HSMessageLogger.java @@ -26,4 +26,9 @@ public interface HSMessageLogger extends BasicLogger { @LogMessage(level = INFO) @Message(value = "hibernate-spatial integration enabled : %s", id = 80000001) void spatialEnabled(boolean enabled); + + @LogMessage(level = INFO) + @Message(value = "hibernate-spatial using Connection Finder for creating Oracle types : %s", id = 80000002) + void connectionFinder(String className); + } diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/HibernateSpatialConfiguration.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/HibernateSpatialConfiguration.java deleted file mode 100644 index 52322c7811..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/HibernateSpatialConfiguration.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.spatial; - -import org.geolatte.geom.codec.db.oracle.ConnectionFinder; - -import java.io.Serializable; - -import org.jboss.logging.Logger; - -/** - * A global configuration object that is is used by - * some Dialects during construction. - * - * @author Karel Maesen, Geovise BVBA - * creation-date: 8/16/13 - */ -public class HibernateSpatialConfiguration implements Serializable { - - private static final HSMessageLogger LOG = Logger.getMessageLogger( - HSMessageLogger.class, - HibernateSpatialConfiguration.class.getName() - ); - private Boolean isOgcStrict = Boolean.TRUE; - private ConnectionFinder connectionFinder; - - /** - * Holds the configuration for Hibernate Spatial dialects. - */ - public HibernateSpatialConfiguration() { - } - - /** - * Creates a Configuration for Hibernate spatial - * - * @param ogcStrict true for OGC Strict mode - * @param connectionFinder the fully-qualified Class name for the {@code ConnectionFinder} - */ - public HibernateSpatialConfiguration(Boolean ogcStrict, ConnectionFinder connectionFinder) { - if ( ogcStrict != null ) { - this.isOgcStrict = ogcStrict; - LOG.debugf( "Setting OGC_STRICT mode for Oracle Spatial dialect to %s.", ogcStrict ); - } - if ( connectionFinder != null ) { - this.connectionFinder = connectionFinder; - LOG.debugf( - "Using ConnectionFinder implementation: %s (only relevant for Oracle Spatial dialect).", - connectionFinder.getClass().getCanonicalName() - ); - } - } - - public Boolean isOgcStrictMode() { - return isOgcStrict; - } - - public ConnectionFinder getConnectionFinder() { - return connectionFinder; - } - - /** - * Collects the property names for Hibernate Spatial configuration properties. - */ - public static class AvailableSettings { - /** - * Determines whether or nog to use the OracleSpatial10gDialect in OGC_STRICT mode or not (values: true or false) - */ - public static final String OGC_STRICT = "hibernate.spatial.ogc_strict"; - /** - * The canonical class name to use as Oracle ConnectionFinder implementation. - */ - public static final String CONNECTION_FINDER = "hibernate.spatial.connection_finder"; - } - - -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/HibernateSpatialConfigurationSettings.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/HibernateSpatialConfigurationSettings.java new file mode 100644 index 0000000000..c0fc433e5c --- /dev/null +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/HibernateSpatialConfigurationSettings.java @@ -0,0 +1,30 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.spatial; + +import org.geolatte.geom.codec.db.oracle.ConnectionFinder; + +import java.io.Serializable; + +import org.jboss.logging.Logger; + +/** + * Hibernate Spatial specific configuration settings. + * + * @author Karel Maesen, Geovise BVBA + * creation-date: 8/16/13 + */ +public class HibernateSpatialConfigurationSettings implements Serializable { + + /** + * The canonical class name to use as Oracle ConnectionFinder implementation. + */ + public static final String CONNECTION_FINDER = "hibernate.spatial.connection_finder"; + + + +} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gDialect.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gDialect.java index 85083084f9..c8cd5d6ebc 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gDialect.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gDialect.java @@ -12,18 +12,22 @@ import java.sql.Types; import java.util.List; import org.geolatte.geom.codec.db.oracle.ConnectionFinder; -import org.geolatte.geom.codec.db.oracle.DefaultConnectionFinder; import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory; +import org.jboss.logging.Logger; + import org.hibernate.QueryException; import org.hibernate.boot.model.TypeContributions; +import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.dialect.Oracle10gDialect; import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.service.ServiceRegistry; import org.hibernate.spatial.GeolatteGeometryType; -import org.hibernate.spatial.HibernateSpatialConfiguration; +import org.hibernate.spatial.HSMessageLogger; +import org.hibernate.spatial.HibernateSpatialConfigurationSettings; import org.hibernate.spatial.JTSGeometryType; import org.hibernate.spatial.SpatialAnalysis; import org.hibernate.spatial.SpatialDialect; @@ -41,27 +45,19 @@ import org.hibernate.type.Type; public class OracleSpatial10gDialect extends Oracle10gDialect implements SpatialDialect, Serializable { private final boolean isOgcStrict; - private final ConnectionFinder connectionFinder; - - /** - * Constructs the dialect with a default configuration - */ - public OracleSpatial10gDialect() { - this( new HibernateSpatialConfiguration() ); - } + private static final HSMessageLogger log = Logger.getMessageLogger( + HSMessageLogger.class, + OracleSpatial10gDialect.class.getName() + ); /** * Constructs the dialect with the specified configuration * - * @param config the {@code HibernateSpatialConfiguration} that configures this dialect. */ - public OracleSpatial10gDialect(HibernateSpatialConfiguration config) { + public OracleSpatial10gDialect() { super(); - this.isOgcStrict = config.isOgcStrictMode(); - final ConnectionFinder finder = config.getConnectionFinder(); - this.connectionFinder = finder == null ? new DefaultConnectionFinder() : finder; - + this.isOgcStrict = true; // register geometry type registerColumnType( Types.STRUCT, "MDSYS.SDO_GEOMETRY" ); @@ -158,15 +154,26 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements Spatial serviceRegistry ); + final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); + final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class ); + + final ConnectionFinder connectionFinder = strategySelector.resolveStrategy( + ConnectionFinder.class, + cfgService.getSetting( HibernateSpatialConfigurationSettings.CONNECTION_FINDER, String.class, "org.geolatte.geom.codec.db.oracle.DefaultConnectionFinder" ) + ); + + log.connectionFinder( connectionFinder.getClass().getCanonicalName() ); + final SDOGeometryTypeDescriptor sdoGeometryTypeDescriptor = new SDOGeometryTypeDescriptor( new OracleJDBCTypeFactory( - this.connectionFinder + connectionFinder ) ); typeContributions.contributeType( new GeolatteGeometryType( sdoGeometryTypeDescriptor ) ); typeContributions.contributeType( new JTSGeometryType( sdoGeometryTypeDescriptor ) ); + } String getNativeSpatialRelateSQL(String arg1, String arg2, int spatialRelation) { @@ -418,16 +425,6 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements Spatial return isOgcStrict; } - /** - * Reports the ConnectionFinder used by this Dialect (or rather its associated TypeDescriptor). - *

- * This method is mainly used for testing purposes. - * - * @return the ConnectionFinder in use - */ - public ConnectionFinder getConnectionFinder() { - return connectionFinder; - } @Override public boolean supportsFiltering() { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialDialectFactory.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialDialectFactory.java deleted file mode 100644 index af6caaf0d6..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialDialectFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.spatial.integration; - -import java.util.Map; - -import org.hibernate.HibernateException; -import org.hibernate.dialect.Dialect; -import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl; -import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource; -import org.hibernate.spatial.HibernateSpatialConfiguration; -import org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect; - -/** - * A {@code DialectFactory} that may inject configuration into {@code SpatialDialect}s. - * - * This implementation extends the Standard Hibernate {@code DialectFactory}. It is currently only used - * for special handling of the {@code OracleSpatial10gDialect}. - * - * @author Karel Maesen, Geovise BVBA - * creation-date: 8/23/13 - */ -public class SpatialDialectFactory extends DialectFactoryImpl { - private final HibernateSpatialConfiguration spatialConfig; - - /** - * Constructs an instance with the specified configuration - * - * @param spatialConfig the spatial configuration to use. - */ - public SpatialDialectFactory(HibernateSpatialConfiguration spatialConfig) { - super(); - this.spatialConfig = spatialConfig; - } - - @Override - public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException { - final Dialect dialect = super.buildDialect( configValues, resolutionInfoSource ); - if (dialect instanceof OracleSpatial10gDialect) { - return new OracleSpatial10gDialect( spatialConfig ); - } - else { - return dialect; - } - } -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialDialectFactoryInitiator.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialDialectFactoryInitiator.java deleted file mode 100644 index e8be3b23ca..0000000000 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialDialectFactoryInitiator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.spatial.integration; - -import java.util.Map; - -import org.hibernate.boot.registry.StandardServiceInitiator; -import org.hibernate.boot.registry.selector.spi.StrategySelector; -import org.hibernate.engine.config.spi.ConfigurationService; -import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; -import org.hibernate.service.spi.ServiceRegistryImplementor; -import org.hibernate.spatial.HibernateSpatialConfiguration; - -import org.geolatte.geom.codec.db.oracle.ConnectionFinder; - -import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN; -import static org.hibernate.spatial.HibernateSpatialConfiguration.AvailableSettings.CONNECTION_FINDER; -import static org.hibernate.spatial.HibernateSpatialConfiguration.AvailableSettings.OGC_STRICT; - -/** - * The {@code StandardServiceInitiator} for Hibernate Spatial's specialized DialectFactory. - * - * @author Karel Maesen, Geovise BVBA - * @author Steve Ebersole - */ -public class SpatialDialectFactoryInitiator implements StandardServiceInitiator { - /** - * Singleton access - */ - public static final SpatialDialectFactoryInitiator INSTANCE = new SpatialDialectFactoryInitiator(); - - @Override - public Class getServiceInitiated() { - return DialectFactory.class; - } - - @Override - public SpatialDialectFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { - final ConfigurationService cfgService = registry.getService( ConfigurationService.class ); - final StrategySelector strategySelector = registry.getService( StrategySelector.class ); - - final HibernateSpatialConfiguration spatialConfig = new HibernateSpatialConfiguration( - cfgService.getSetting( OGC_STRICT, BOOLEAN, null ), - strategySelector.resolveStrategy( - ConnectionFinder.class, - cfgService.getSettings().get( CONNECTION_FINDER ) - ) - ); - - return new SpatialDialectFactory( spatialConfig ); - } -} diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialInitializer.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialInitializer.java index d9fb5b9355..52eeba502d 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialInitializer.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialInitializer.java @@ -21,12 +21,6 @@ public class SpatialInitializer implements ServiceContributor { public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) { final SpatialService spatialService = new SpatialService( serviceRegistryBuilder ); serviceRegistryBuilder.addService( SpatialService.class, spatialService ); - - if ( !spatialService.isEnabled() ) { - return; - } - - serviceRegistryBuilder.addInitiator( SpatialDialectFactoryInitiator.INSTANCE ); } } diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialService.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialService.java index 82340dae05..9b289cd0c0 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialService.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/integration/SpatialService.java @@ -11,6 +11,7 @@ import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.Service; import org.hibernate.spatial.HSMessageLogger; + import org.jboss.logging.Logger; /** @@ -39,11 +40,11 @@ public class SpatialService implements Service { serviceRegistryBuilder.getSettings(), true ); - log.spatialEnabled( integrationEnabled ); } public boolean isEnabled() { return integrationEnabled; } + } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/MockConnectionFinder.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/MockConnectionFinder.java deleted file mode 100644 index 059e06faa4..0000000000 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/MockConnectionFinder.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.spatial.dialect.oracle; - -import java.sql.Connection; - -import org.geolatte.geom.codec.db.oracle.ConnectionFinder; - - -public class MockConnectionFinder implements ConnectionFinder { - @Override - public Connection find(Connection subject) { - return null; - } -} diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gConfigurationTest.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gConfigurationTest.java deleted file mode 100644 index 6a2f6e49e6..0000000000 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/OracleSpatial10gConfigurationTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.spatial.dialect.oracle; - -import org.geolatte.geom.codec.db.oracle.ConnectionFinder; -import org.geolatte.geom.codec.db.oracle.DefaultConnectionFinder; -import org.junit.Assert; -import org.junit.Test; - -import org.hibernate.HibernateException; -import org.hibernate.SessionFactory; -import org.hibernate.boot.registry.StandardServiceRegistry; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.Configuration; -import org.hibernate.dialect.Dialect; -import org.hibernate.internal.SessionFactoryImpl; -import org.hibernate.spatial.HibernateSpatialConfiguration; -import org.hibernate.testing.RequiresDialect; -import org.hibernate.testing.ServiceRegistryBuilder; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -@RequiresDialect(OracleSpatial10gDialect.class) -public class OracleSpatial10gConfigurationTest extends BaseCoreFunctionalTestCase{ - - - private Configuration addToConfiguration(Configuration cfg, Boolean ogcStrict, String connFinderClassName) { - cfg.setProperty( HibernateSpatialConfiguration.AvailableSettings.CONNECTION_FINDER, connFinderClassName ); - cfg.setProperty( HibernateSpatialConfiguration.AvailableSettings.OGC_STRICT, ogcStrict.toString() ); - return cfg; - } - - private void createdOracleSpatialDialect(Boolean ogcStrict, String connFinderClassName) { - createdOracleSpatialDialect( ogcStrict, connFinderClassName, true ); - } - - private void createdOracleSpatialDialect(Boolean ogcStrict, String connFinderClassName, boolean doConfiguration) { - Configuration cfg = new Configuration(); - if (doConfiguration){ - addToConfiguration( cfg, ogcStrict, connFinderClassName ); - } - cfg.setProperty( AvailableSettings.DIALECT, OracleSpatial10gDialect.class.getCanonicalName() ); - StandardServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ); - SessionFactory sessionFactory = cfg.buildSessionFactory( serviceRegistry ); - Dialect d = ( (SessionFactoryImpl) sessionFactory ).getDialect(); - OracleSpatial10gDialect osd = (OracleSpatial10gDialect) d; - Assert.assertTrue( ogcStrict == osd.isOGCStrict() ); - ConnectionFinder finder = osd.getConnectionFinder(); - Assert.assertNotNull( finder ); - Assert.assertEquals( connFinderClassName, finder.getClass().getCanonicalName() ); - } - - @Test - public void testOgcStrictMockFinder() { - createdOracleSpatialDialect( true, MockConnectionFinder.class.getCanonicalName() ); - } - - @Test - public void testOgcNonStrictMockFinder() { - createdOracleSpatialDialect( false, MockConnectionFinder.class.getCanonicalName() ); - } - - @Test - public void testOgcStrictDefaultFinder() { - createdOracleSpatialDialect( true, DefaultConnectionFinder.class.getCanonicalName() ); - } - - @Test - public void testOgcNonStrictDefaultFinder() { - createdOracleSpatialDialect( false, DefaultConnectionFinder.class.getCanonicalName() ); - } - - @Test(expected = HibernateException.class) - public void testOgcStrictNonExistentClass() { - createdOracleSpatialDialect( false, "doesntexist" ); - } - - @Test - public void testNoConfiguration(){ - createdOracleSpatialDialect( true, DefaultConnectionFinder.class.getCanonicalName(), false ); - } -} diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/TestConnectionFinder.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/TestConnectionFinder.java new file mode 100644 index 0000000000..1a43217b01 --- /dev/null +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/TestConnectionFinder.java @@ -0,0 +1,29 @@ +package org.hibernate.spatial.dialect.oracle; + +import java.sql.Connection; + +import org.geolatte.geom.codec.db.oracle.ConnectionFinder; +import org.geolatte.geom.codec.db.oracle.DefaultConnectionFinder; + +/** + * Created by Karel Maesen, Geovise BVBA on 20/02/16. + */ +public class TestConnectionFinder implements ConnectionFinder { + + + final private ConnectionFinder internal = new DefaultConnectionFinder(); + /** + * Find an instance of Connection that can be cast to an {@code OracleConnection} instance. + * + * @param conn the object that is being searched for an OracleConnection + * + * @return the object sought + * + * @throws RuntimeException thrown when the feature can be found; + */ + @Override + public Connection find(Connection conn) { + return internal.find( conn ); + } + +}