From f114ca29443f897e974f1baeb67846c1c8ad2be5 Mon Sep 17 00:00:00 2001 From: Karel Maesen Date: Sat, 14 Jan 2012 00:22:30 +0100 Subject: [PATCH] HHH-6511 Adds Postgis integration tests. The integration tests now make us of the matrix testing set-up. --- hibernate-spatial/hibernate-spatial.gradle | 16 +- .../AbstractExpectationsFactory.java | 2 +- .../spatial/integration}/DataSourceUtils.java | 25 +--- .../spatial/integration}/EWKTReader.java | 2 +- .../spatial/integration}/GeomEntity.java | 2 +- .../integration}/GeometryEquality.java | 2 +- .../integration}/NativeSQLStatement.java | 2 +- .../integration}/SQLExpressionTemplate.java | 2 +- .../integration/SpatialDialectMatcher.java | 16 ++ .../SpatialFunctionalTestCase.java | 31 ++-- .../spatial/integration}/TestData.java | 2 +- .../spatial/integration}/TestDataElement.java | 2 +- .../spatial/integration}/TestDataReader.java | 2 +- .../spatial/integration}/TestFeature.java | 2 +- .../integration}/TestSpatialFunctions.java | 24 +-- .../integration}/TestSpatialRestrictions.java | 23 +-- .../integration}/TestStoreRetrieve.java | 21 +-- .../spatial/integration}/TestSupport.java | 2 +- .../integration}/TestSupportFactories.java | 9 +- .../dialects}/oracle/JDBCConnectionProxy.java | 2 +- .../oracle/OracleSDOTestSupport.java | 12 +- .../dialects}/oracle/SDODataSourceUtils.java | 6 +- .../SDOGeometryExpectationsFactory.java | 9 +- .../oracle/SDOGeometryExpressionTemplate.java | 6 +- .../dialects}/oracle/SDOTestDataElement.java | 4 +- .../dialects}/oracle/SDOTestDataReader.java | 6 +- .../postgis/PostgisExpectationsFactory.java | 9 +- .../postgis/PostgisExpressionTemplate.java | 6 +- .../dialects}/postgis/PostgisTestSupport.java | 14 +- .../SQLServerExpressionTemplate.java | 6 +- .../sqlserver/SQLServerTestSupport.java | 10 +- .../SqlServerExpectationsFactory.java | 8 +- .../convertors/AbstractConvertorTest.java | 139 ++++++++++++++++++ .../GeometryCollectionConvertorTest.java | 19 ++- .../convertors/LineStringConvertorTest.java | 13 +- .../MultiLineStringConvertorTest.java | 10 +- .../convertors/MultiPointConvertorTest.java | 10 +- .../convertors/MultiPolygonConvertorTest.java | 10 +- .../convertors/PointConvertorTest.java | 13 +- .../convertors/PolygonConvertorTest.java | 10 +- .../src/matrix/resources/GeomEntity.hbm.xml | 42 ++++++ .../src/matrix/resources/log4j.properties | 9 ++ .../spatial/{test => }/TestCircle.java | 2 +- .../{unittests => }/PostgisDialectTest.java | 2 +- .../convertors/AbstractConvertorTest.java | 132 ----------------- .../convertors/ConvertorTestData.java | 16 -- .../convertors/SpatialObjectGenerator.java | 134 ----------------- .../{test => }/mgeom/MLineStringTest.java | 10 +- .../mgeom/MultiMLineStringTest.java | 7 +- .../{test => }/mgeom/TestEventLocator.java | 2 +- .../TestMLineStringGetCoordinatesBetween.java | 2 +- .../src/test/resources/GeomEntity.hbm.xml | 2 +- .../src/test/resources/hibernate.properties | 50 +++++-- ...ibernate-spatial-sqlserver-test.properties | 10 +- 54 files changed, 450 insertions(+), 479 deletions(-) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/AbstractExpectationsFactory.java (99%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/DataSourceUtils.java (96%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/EWKTReader.java (99%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/GeomEntity.java (98%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/GeometryEquality.java (98%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/NativeSQLStatement.java (97%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/SQLExpressionTemplate.java (97%) create mode 100644 hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialDialectMatcher.java rename hibernate-spatial/src/{test/java/org/hibernate/spatial => matrix/java/org/hibernate/spatial/integration}/SpatialFunctionalTestCase.java (91%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/TestData.java (98%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/TestDataElement.java (97%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/TestDataReader.java (98%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/TestFeature.java (89%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial => matrix/java/org/hibernate/spatial/integration}/TestSpatialFunctions.java (98%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial => matrix/java/org/hibernate/spatial/integration}/TestSpatialRestrictions.java (96%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial => matrix/java/org/hibernate/spatial/integration}/TestStoreRetrieve.java (95%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/test => matrix/java/org/hibernate/spatial/integration}/TestSupport.java (96%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial => matrix/java/org/hibernate/spatial/integration}/TestSupportFactories.java (87%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/JDBCConnectionProxy.java (99%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/OracleSDOTestSupport.java (72%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/SDODataSourceUtils.java (92%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/SDOGeometryExpectationsFactory.java (97%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/SDOGeometryExpressionTemplate.java (88%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/SDOTestDataElement.java (92%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/oracle/SDOTestDataReader.java (90%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/postgis/PostgisExpectationsFactory.java (96%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/postgis/PostgisExpressionTemplate.java (88%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/postgis/PostgisTestSupport.java (66%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/SQLServerExpressionTemplate.java (89%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/SQLServerTestSupport.java (68%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/SqlServerExpectationsFactory.java (97%) create mode 100644 hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/AbstractConvertorTest.java rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/GeometryCollectionConvertorTest.java (71%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/LineStringConvertorTest.java (89%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/MultiLineStringConvertorTest.java (78%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/MultiPointConvertorTest.java (77%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/MultiPolygonConvertorTest.java (78%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/PointConvertorTest.java (87%) rename hibernate-spatial/src/{test/java/org/hibernate/spatial/dialect => matrix/java/org/hibernate/spatial/integration/dialects}/sqlserver/convertors/PolygonConvertorTest.java (77%) create mode 100644 hibernate-spatial/src/matrix/resources/GeomEntity.hbm.xml create mode 100644 hibernate-spatial/src/matrix/resources/log4j.properties rename hibernate-spatial/src/test/java/org/hibernate/spatial/{test => }/TestCircle.java (99%) rename hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/{unittests => }/PostgisDialectTest.java (91%) delete mode 100644 hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/AbstractConvertorTest.java delete mode 100644 hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/ConvertorTestData.java delete mode 100644 hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/SpatialObjectGenerator.java rename hibernate-spatial/src/test/java/org/hibernate/spatial/{test => }/mgeom/MLineStringTest.java (98%) rename hibernate-spatial/src/test/java/org/hibernate/spatial/{test => }/mgeom/MultiMLineStringTest.java (95%) rename hibernate-spatial/src/test/java/org/hibernate/spatial/{test => }/mgeom/TestEventLocator.java (99%) rename hibernate-spatial/src/test/java/org/hibernate/spatial/{test => }/mgeom/TestMLineStringGetCoordinatesBetween.java (99%) diff --git a/hibernate-spatial/hibernate-spatial.gradle b/hibernate-spatial/hibernate-spatial.gradle index 20addb8c08..b944deee77 100644 --- a/hibernate-spatial/hibernate-spatial.gradle +++ b/hibernate-spatial/hibernate-spatial.gradle @@ -1,12 +1,13 @@ apply plugin: 'java' +apply plugin: org.hibernate.build.gradle.testing.matrix.MatrixTestingPlugin dependencies { compile( project( ':hibernate-core' ) ) compile( [group: 'com.vividsolutions', name: 'jts', version: '1.11'] ) { transitive = false } - compile( [group: 'org.postgis', name: 'postgis-jdbc', version: '1.1.6'] ) - compile( [group: 'postgresql', name: 'postgresql', version: '8.1-407.jdbc3'] ) + compile( [group: 'org.postgis', name: 'postgis-jdbc', version: '1.5.3'] ) + compile( [group: 'postgresql', name: 'postgresql', version: '8.4-701.jdbc4'] ) compile( libraries.dom4j ) { @@ -22,6 +23,8 @@ dependencies { testCompile( [group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4']) testCompile([group: 'com.oracle.jdbc', name:'ojdbc6', version:'11.1.0.7.0']) testCompile([group: 'com.microsoft', name: 'sqljdbc', version: '2.0']) + + matrixRuntime( 'jaxen:jaxen:1.1' ) } sourceSets { @@ -31,4 +34,13 @@ sourceSets { setSrcDirs( ['src/test/java','src/test/resources'] ) } } + matrix { + java { + srcDir 'src/matrix/java' + } + resources { + srcDir 'src/matrix/resources' + } + } } + diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/AbstractExpectationsFactory.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/AbstractExpectationsFactory.java similarity index 99% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/AbstractExpectationsFactory.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/AbstractExpectationsFactory.java index 1869dad46f..9231b04ab8 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/AbstractExpectationsFactory.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/AbstractExpectationsFactory.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import java.sql.Blob; import java.sql.Connection; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/DataSourceUtils.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/DataSourceUtils.java similarity index 96% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/DataSourceUtils.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/DataSourceUtils.java index d58cbbe07f..40622edd3a 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/DataSourceUtils.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/DataSourceUtils.java @@ -23,23 +23,7 @@ * For more information, visit: http://www.hibernate.spatial.org/ */ -package org.hibernate.spatial.test; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import javax.sql.DataSource; +package org.hibernate.spatial.integration; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.ParseException; @@ -47,6 +31,13 @@ import org.apache.commons.dbcp.BasicDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.sql.DataSource; +import java.io.*; +import java.sql.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + /** *

Unit testsuite-suite support class.

* diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/EWKTReader.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/EWKTReader.java similarity index 99% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/EWKTReader.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/EWKTReader.java index 278c5a9083..9ff1760238 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/EWKTReader.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/EWKTReader.java @@ -39,7 +39,7 @@ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import java.io.IOException; import java.io.Reader; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/GeomEntity.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/GeomEntity.java similarity index 98% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/GeomEntity.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/GeomEntity.java index 646fbd020f..abf711079b 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/GeomEntity.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/GeomEntity.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.ParseException; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/GeometryEquality.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/GeometryEquality.java similarity index 98% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/GeometryEquality.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/GeometryEquality.java index e452fd3f76..4636f63c5a 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/GeometryEquality.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/GeometryEquality.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/NativeSQLStatement.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/NativeSQLStatement.java similarity index 97% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/NativeSQLStatement.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/NativeSQLStatement.java index 8bd5764c41..d00abdbb44 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/NativeSQLStatement.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/NativeSQLStatement.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/SQLExpressionTemplate.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SQLExpressionTemplate.java similarity index 97% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/SQLExpressionTemplate.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SQLExpressionTemplate.java index 914abc93b6..6b3f952be9 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/SQLExpressionTemplate.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SQLExpressionTemplate.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; /** * SQLExpressoinTemplates generate database-specific diff --git a/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialDialectMatcher.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialDialectMatcher.java new file mode 100644 index 0000000000..750fecfc8c --- /dev/null +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialDialectMatcher.java @@ -0,0 +1,16 @@ +package org.hibernate.spatial.integration; + +import org.hibernate.dialect.Dialect; +import org.hibernate.spatial.SpatialDialect; +import org.hibernate.testing.Skip; + +/** + * @author Karel Maesen, Geovise BVBA + * creation-date: 1/13/12 + */ +public class SpatialDialectMatcher implements Skip.Matcher { + @Override + public boolean isMatch() { + return !(Dialect.getDialect() instanceof SpatialDialect); + } +} diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/SpatialFunctionalTestCase.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialFunctionalTestCase.java similarity index 91% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/SpatialFunctionalTestCase.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialFunctionalTestCase.java index f293e8db73..0f953600fe 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/SpatialFunctionalTestCase.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/SpatialFunctionalTestCase.java @@ -1,28 +1,21 @@ -package org.hibernate.spatial; +package org.hibernate.spatial.integration; + +import com.vividsolutions.jts.geom.Geometry; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; +import org.hibernate.spatial.SpatialDialect; +import org.hibernate.spatial.SpatialFunction; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.slf4j.Logger; import java.sql.Connection; import java.sql.SQLException; import java.util.List; import java.util.Map; -import com.vividsolutions.jts.geom.Geometry; -import org.slf4j.Logger; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.cfg.Configuration; -import org.hibernate.spatial.test.AbstractExpectationsFactory; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.GeometryEquality; -import org.hibernate.spatial.test.TestData; -import org.hibernate.spatial.test.TestSupport; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; /** * @author Karel Maesen, Geovise BVBA diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestData.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestData.java similarity index 98% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestData.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestData.java index 54b562e10b..771ea2c57f 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestData.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestData.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import java.io.InputStream; import java.util.Collection; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestDataElement.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestDataElement.java similarity index 97% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestDataElement.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestDataElement.java index 2a5274eed9..ae2642fbe8 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestDataElement.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestDataElement.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; /** * A TestDataElement captures the information necessary to build a testsuite-suite geometry. diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestDataReader.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestDataReader.java similarity index 98% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestDataReader.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestDataReader.java index b19e6d42b4..034a0e91ce 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestDataReader.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestDataReader.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import java.io.InputStream; import java.util.ArrayList; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestFeature.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestFeature.java similarity index 89% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestFeature.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestFeature.java index 138859ca52..3dab406bab 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestFeature.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestFeature.java @@ -1,4 +1,4 @@ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import com.vividsolutions.jts.geom.Geometry; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestSpatialFunctions.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSpatialFunctions.java similarity index 98% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/TestSpatialFunctions.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSpatialFunctions.java index 693f1d090c..cc34f4d076 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestSpatialFunctions.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSpatialFunctions.java @@ -23,24 +23,27 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial; +package org.hibernate.spatial.integration; + +import com.vividsolutions.jts.geom.Geometry; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.spatial.SpatialDialect; +import org.hibernate.spatial.SpatialFunction; +import org.hibernate.testing.Skip; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; -import com.vividsolutions.jts.geom.Geometry; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.Transaction; - /** * @author Karel Maesen, Geovise BVBA */ +@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect") public class TestSpatialFunctions extends SpatialFunctionalTestCase { private static Logger LOGGER = LoggerFactory.getLogger( TestSpatialFunctions.class ); @@ -57,6 +60,7 @@ public class TestSpatialFunctions extends SpatialFunctionalTestCase { @Test public void testSpatialFunctions() throws Exception { + if (! (getDialect() instanceof SpatialDialect)) return; dimension(); astext(); asbinary(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestSpatialRestrictions.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java similarity index 96% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/TestSpatialRestrictions.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java index 6041cdb8af..75187d3005 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestSpatialRestrictions.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java @@ -23,26 +23,28 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.hibernate.spatial.integration; import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.criterion.Criterion; +import org.hibernate.spatial.SpatialDialect; +import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.criterion.SpatialRestrictions; -import org.hibernate.spatial.test.GeomEntity; +import org.hibernate.testing.Skip; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.fail; +@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect") public class TestSpatialRestrictions extends SpatialFunctionalTestCase { private static Logger LOGGER = LoggerFactory.getLogger( TestSpatialRestrictions.class ); @@ -64,6 +66,7 @@ public class TestSpatialRestrictions extends SpatialFunctionalTestCase { @Test public void testRestrictions() throws Exception { + if (! (getDialect() instanceof SpatialDialect)) return; within(); filter(); contains(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestStoreRetrieve.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestStoreRetrieve.java similarity index 95% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/TestStoreRetrieve.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestStoreRetrieve.java index be4ec26557..deb6eb8bfd 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestStoreRetrieve.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestStoreRetrieve.java @@ -23,23 +23,22 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; +package org.hibernate.spatial.integration; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.ParseException; +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.spatial.SpatialDialect; +import org.hibernate.testing.Skip; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.spatial.test.GeomEntity; -import org.hibernate.spatial.test.TestDataElement; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -49,6 +48,7 @@ import static org.junit.Assert.assertTrue; * This testsuite-suite class verifies whether the Geometrys retrieved * are equal to the Geometrys stored. */ +@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect") public class TestStoreRetrieve extends SpatialFunctionalTestCase { private static Logger LOGGER = LoggerFactory.getLogger( TestStoreRetrieve.class ); @@ -61,6 +61,7 @@ public class TestStoreRetrieve extends SpatialFunctionalTestCase { @Test public void testStoreRetrieve() throws ParseException { + if (! (getDialect() instanceof SpatialDialect)) return; Map stored = new HashMap(); //check whether we retrieve exactly what we store storeTestObjects( stored ); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestSupport.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSupport.java similarity index 96% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestSupport.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSupport.java index 528530bdc1..5cb306fd95 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestSupport.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSupport.java @@ -1,4 +1,4 @@ -package org.hibernate.spatial.test; +package org.hibernate.spatial.integration; import org.hibernate.cfg.Configuration; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestSupportFactories.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSupportFactories.java similarity index 87% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/TestSupportFactories.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSupportFactories.java index 7f046b5879..6c40c3603b 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/TestSupportFactories.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/TestSupportFactories.java @@ -1,7 +1,6 @@ -package org.hibernate.spatial; +package org.hibernate.spatial.integration; import org.hibernate.dialect.Dialect; -import org.hibernate.spatial.test.TestSupport; /** @@ -44,20 +43,20 @@ public class TestSupportFactories { private static String getSupportFactoryClassName(Dialect dialect) { String canonicalName = dialect.getClass().getCanonicalName(); if ( "org.hibernate.spatial.dialect.postgis.PostgisDialect".equals( canonicalName ) ) { - return "org.hibernate.spatial.dialect.postgis.PostgisTestSupport"; + return "org.hibernate.spatial.integration.dialects.postgis.PostgisTestSupport"; } // if ("org.hibernate.spatial.geodb.GeoDBDialect".equals(canonicalName)) { // return "org.hibernate.spatial.geodb.GeoDBSupport"; // } if ("org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect".equals(canonicalName)) { - return "org.hibernate.spatial.dialect.sqlserver.SQLServerTestSupport"; + return "org.hibernate.spatial.integration.dialects.sqlserver.SQLServerTestSupport"; } // if ("org.hibernatespatial.mysql.MySQLSpatialDialect".equals(canonicalName) || // "org.hibernatespatial.mysql.MySQLSpatialInnoDBDialect".equals(canonicalName)) { // return "org.hibernatespatial.mysql.MySQLTestSupport"; // } if ( "org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect".equals( canonicalName ) ) { - return "org.hibernate.spatial.dialect.oracle.OracleSDOTestSupport"; + return "org.hibernate.spatial.integration.dialects.oracle.OracleSDOTestSupport"; } throw new IllegalArgumentException( "Dialect not known in test suite" ); } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/JDBCConnectionProxy.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/JDBCConnectionProxy.java similarity index 99% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/JDBCConnectionProxy.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/JDBCConnectionProxy.java index 6e59bca8ae..db0d2b7c00 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/JDBCConnectionProxy.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/JDBCConnectionProxy.java @@ -1,4 +1,4 @@ -package org.hibernatespatial.oracle; +package org.hibernate.spatial.integration.dialects.oracle; import java.sql.Array; import java.sql.Blob; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/OracleSDOTestSupport.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/OracleSDOTestSupport.java similarity index 72% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/OracleSDOTestSupport.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/OracleSDOTestSupport.java index e9ded59fd0..78e6c0ff89 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/OracleSDOTestSupport.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/OracleSDOTestSupport.java @@ -1,11 +1,11 @@ -package org.hibernate.spatial.dialect.oracle; +package org.hibernate.spatial.integration.dialects.oracle; import org.hibernate.cfg.Configuration; -import org.hibernate.spatial.test.AbstractExpectationsFactory; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.SQLExpressionTemplate; -import org.hibernate.spatial.test.TestData; -import org.hibernate.spatial.test.TestSupport; +import org.hibernate.spatial.integration.AbstractExpectationsFactory; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.SQLExpressionTemplate; +import org.hibernate.spatial.integration.TestData; +import org.hibernate.spatial.integration.TestSupport; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDODataSourceUtils.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDODataSourceUtils.java similarity index 92% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDODataSourceUtils.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDODataSourceUtils.java index 382415cd78..655cb77ed0 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDODataSourceUtils.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDODataSourceUtils.java @@ -23,12 +23,12 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.oracle; +package org.hibernate.spatial.integration.dialects.oracle; import java.sql.SQLException; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.SQLExpressionTemplate; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.SQLExpressionTemplate; public class SDODataSourceUtils extends DataSourceUtils { diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOGeometryExpectationsFactory.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOGeometryExpectationsFactory.java similarity index 97% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOGeometryExpectationsFactory.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOGeometryExpectationsFactory.java index 639ce98156..1a3b50a19a 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOGeometryExpectationsFactory.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOGeometryExpectationsFactory.java @@ -23,14 +23,15 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.oracle; +package org.hibernate.spatial.integration.dialects.oracle; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Point; -import org.hibernate.spatial.test.AbstractExpectationsFactory; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.NativeSQLStatement; +import org.hibernate.spatial.dialect.oracle.SDOGeometryValueExtractor; +import org.hibernate.spatial.integration.AbstractExpectationsFactory; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.NativeSQLStatement; /** * Expectations factory for Oracle 10g (SDOGeometry). diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOGeometryExpressionTemplate.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOGeometryExpressionTemplate.java similarity index 88% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOGeometryExpressionTemplate.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOGeometryExpressionTemplate.java index 2604b37842..c9008d96fa 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOGeometryExpressionTemplate.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOGeometryExpressionTemplate.java @@ -23,10 +23,10 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.oracle; +package org.hibernate.spatial.integration.dialects.oracle; -import org.hibernate.spatial.test.SQLExpressionTemplate; -import org.hibernate.spatial.test.TestDataElement; +import org.hibernate.spatial.integration.SQLExpressionTemplate; +import org.hibernate.spatial.integration.TestDataElement; public class SDOGeometryExpressionTemplate implements SQLExpressionTemplate { diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOTestDataElement.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOTestDataElement.java similarity index 92% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOTestDataElement.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOTestDataElement.java index dbead63dcb..a17c197afb 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOTestDataElement.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOTestDataElement.java @@ -23,10 +23,10 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.oracle; +package org.hibernate.spatial.integration.dialects.oracle; -import org.hibernate.spatial.test.TestDataElement; +import org.hibernate.spatial.integration.TestDataElement; /** * A specialised subclass for SDOGeometry test objects diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOTestDataReader.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOTestDataReader.java similarity index 90% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOTestDataReader.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOTestDataReader.java index e0a4eabe62..83fba01781 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/oracle/SDOTestDataReader.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/oracle/SDOTestDataReader.java @@ -23,14 +23,14 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.oracle; +package org.hibernate.spatial.integration.dialects.oracle; import java.util.List; import org.dom4j.Element; -import org.hibernate.spatial.test.TestDataElement; -import org.hibernate.spatial.test.TestDataReader; +import org.hibernate.spatial.integration.TestDataElement; +import org.hibernate.spatial.integration.TestDataReader; public class SDOTestDataReader extends TestDataReader { diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisExpectationsFactory.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisExpectationsFactory.java similarity index 96% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisExpectationsFactory.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisExpectationsFactory.java index 26f06200ba..ff3aff7555 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisExpectationsFactory.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisExpectationsFactory.java @@ -23,14 +23,15 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.postgis; +package org.hibernate.spatial.integration.dialects.postgis; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Point; -import org.hibernate.spatial.test.AbstractExpectationsFactory; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.NativeSQLStatement; +import org.hibernate.spatial.dialect.postgis.PGGeometryValueExtractor; +import org.hibernate.spatial.integration.AbstractExpectationsFactory; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.NativeSQLStatement; /** * This class provides the expected return values to the testsuite-suite classes in this package. diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisExpressionTemplate.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisExpressionTemplate.java similarity index 88% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisExpressionTemplate.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisExpressionTemplate.java index 4d40bce765..cf91d9fe41 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisExpressionTemplate.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisExpressionTemplate.java @@ -23,10 +23,10 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.postgis; +package org.hibernate.spatial.integration.dialects.postgis; -import org.hibernate.spatial.test.SQLExpressionTemplate; -import org.hibernate.spatial.test.TestDataElement; +import org.hibernate.spatial.integration.SQLExpressionTemplate; +import org.hibernate.spatial.integration.TestDataElement; /** * The template for postgis insert SQL diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisTestSupport.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisTestSupport.java similarity index 66% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisTestSupport.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisTestSupport.java index bb2263f7bf..26aeded9e1 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisTestSupport.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/postgis/PostgisTestSupport.java @@ -1,11 +1,11 @@ -package org.hibernate.spatial.dialect.postgis; +package org.hibernate.spatial.integration.dialects.postgis; -import org.hibernate.spatial.test.AbstractExpectationsFactory; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.SQLExpressionTemplate; -import org.hibernate.spatial.test.TestData; -import org.hibernate.spatial.test.TestSupport; +import org.hibernate.spatial.integration.AbstractExpectationsFactory; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.SQLExpressionTemplate; +import org.hibernate.spatial.integration.TestData; +import org.hibernate.spatial.integration.TestSupport; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** @@ -29,7 +29,7 @@ public class PostgisTestSupport extends TestSupport { @Override public SQLExpressionTemplate getSQLExpressionTemplate() { - return new org.hibernate.spatial.dialect.postgis.PostgisExpressionTemplate(); + return new PostgisExpressionTemplate(); } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SQLServerExpressionTemplate.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SQLServerExpressionTemplate.java similarity index 89% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SQLServerExpressionTemplate.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SQLServerExpressionTemplate.java index 8fe492766d..75f3c2f6b6 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SQLServerExpressionTemplate.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SQLServerExpressionTemplate.java @@ -23,10 +23,10 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver; +package org.hibernate.spatial.integration.dialects.sqlserver; -import org.hibernate.spatial.test.SQLExpressionTemplate; -import org.hibernate.spatial.test.TestDataElement; +import org.hibernate.spatial.integration.SQLExpressionTemplate; +import org.hibernate.spatial.integration.TestDataElement; /** * @author Karel Maesen, Geovise BVBA diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SQLServerTestSupport.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SQLServerTestSupport.java similarity index 68% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SQLServerTestSupport.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SQLServerTestSupport.java index fb50bf198f..22d1c9c28b 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SQLServerTestSupport.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SQLServerTestSupport.java @@ -1,9 +1,9 @@ -package org.hibernate.spatial.dialect.sqlserver; +package org.hibernate.spatial.integration.dialects.sqlserver; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.SQLExpressionTemplate; -import org.hibernate.spatial.test.TestData; -import org.hibernate.spatial.test.TestSupport; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.SQLExpressionTemplate; +import org.hibernate.spatial.integration.TestData; +import org.hibernate.spatial.integration.TestSupport; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SqlServerExpectationsFactory.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SqlServerExpectationsFactory.java similarity index 97% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SqlServerExpectationsFactory.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SqlServerExpectationsFactory.java index 8122aff3ce..0201e52720 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/SqlServerExpectationsFactory.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/SqlServerExpectationsFactory.java @@ -23,15 +23,15 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver; +package org.hibernate.spatial.integration.dialects.sqlserver; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Point; import org.hibernate.spatial.dialect.sqlserver.convertors.Decoders; -import org.hibernate.spatial.test.AbstractExpectationsFactory; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.NativeSQLStatement; +import org.hibernate.spatial.integration.AbstractExpectationsFactory; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.NativeSQLStatement; /** diff --git a/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/AbstractConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/AbstractConvertorTest.java new file mode 100644 index 0000000000..5137ac04d2 --- /dev/null +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/AbstractConvertorTest.java @@ -0,0 +1,139 @@ +/* + * $Id: AbstractConvertorTest.java 278 2010-12-18 14:03:32Z maesenka $ + * + * This file is part of Hibernate Spatial, an extension to the + * hibernate ORM solution for geographic data. + * + * Copyright © 2007-2010 Geovise BVBA + * + * 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; either + * version 2.1 of the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, visit: http://www.hibernatespatial.org/ + */ +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; + +/** + * @author Karel Maesen, Geovise BVBA. + * Date: Nov 2, 2009 + */ + +import com.vividsolutions.jts.geom.Geometry; +import org.hibernate.spatial.dialect.sqlserver.convertors.Decoders; +import org.hibernate.spatial.dialect.sqlserver.convertors.Encoders; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; +import org.hibernate.spatial.integration.DataSourceUtils; +import org.hibernate.spatial.integration.SpatialFunctionalTestCase; +import org.hibernate.spatial.integration.TestData; +import org.hibernate.spatial.integration.TestSupport; +import org.hibernate.spatial.integration.dialects.sqlserver.SQLServerExpressionTemplate; +import org.hibernate.spatial.integration.dialects.sqlserver.SQLServerTestSupport; +import org.slf4j.Logger; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertTrue; + +/** + * @author Karel Maesen, Geovise BVBA. + * Date: Nov 2, 2009 + */ +public abstract class AbstractConvertorTest extends SpatialFunctionalTestCase { + + private DataSourceUtils dataSourceUtils; + + private final static TestSupport support = new SQLServerTestSupport(); + + Map decodedGeoms; + Map rawResults; + Map encodedGeoms; + Map expectedGeoms; + + + public void beforeClass() { + dataSourceUtils = new DataSourceUtils( + "sqlserver/hibernate-spatial-sqlserver-test.properties", + new SQLServerExpressionTemplate() + ); + try { + String sql = dataSourceUtils.parseSqlIn("sqlserver/create-sqlserver-test-schema.sql"); + dataSourceUtils.executeStatement(sql); + TestData testData = support.createTestData(null); + dataSourceUtils.insertTestData(testData); + }catch(SQLException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void afterClass() { + try { + String sql = dataSourceUtils.parseSqlIn("sqlserver/drop-sqlserver-test-schema.sql"); + dataSourceUtils.executeStatement(sql); + } catch (SQLException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void doDecoding(OpenGisType type) { + rawResults = dataSourceUtils.rawDbObjects(type.toString()); + TestData testData = support.createTestData(null); + expectedGeoms = dataSourceUtils.expectedGeoms(type.toString(), testData); + decodedGeoms = new HashMap(); + + for (Integer id : rawResults.keySet()) { + Geometry geometry = Decoders.decode((byte[]) rawResults.get(id)); + decodedGeoms.put(id, geometry); + } + } + + public void doEncoding() { + encodedGeoms = new HashMap(); + for (Integer id : decodedGeoms.keySet()) { + Geometry geom = decodedGeoms.get(id); + byte[] bytes = Encoders.encode(geom); + encodedGeoms.put(id, bytes); + } + } + + public void test_encoding() { + for (Integer id : encodedGeoms.keySet()) { + assertTrue( + "Wrong encoding for case " + id, + Arrays.equals((byte[]) rawResults.get(id), encodedGeoms.get(id)) + ); + } + } + + public void test_decoding() { + for (Integer id : decodedGeoms.keySet()) { + Geometry expected = expectedGeoms.get(id); + Geometry received = decodedGeoms.get(id); + assertTrue("Wrong decoding for case " + id, expected.equalsExact(received)); + } + } + + //TODO -- add logger. + @Override + protected Logger getLogger() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/GeometryCollectionConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/GeometryCollectionConvertorTest.java similarity index 71% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/GeometryCollectionConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/GeometryCollectionConvertorTest.java index 39bc5bf44c..e9ed407f9f 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/GeometryCollectionConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/GeometryCollectionConvertorTest.java @@ -23,9 +23,13 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; -import org.junit.Before; +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; +import org.hibernate.testing.AfterClassOnce; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; import org.junit.Test; /** @@ -35,11 +39,13 @@ import org.junit.Test; * Time: 5:33:19 PM * To change this template use File | Settings | File Templates. */ +@RequiresDialect(value=SqlServer2008SpatialDialect.class) public class GeometryCollectionConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setUp() { - doDecoding( OpenGisType.GEOMETRYCOLLECTION ); + super.beforeClass(); + doDecoding(OpenGisType.GEOMETRYCOLLECTION); doEncoding(); } @@ -53,4 +59,9 @@ public class GeometryCollectionConvertorTest extends AbstractConvertorTest { super.test_decoding(); } + @AfterClassOnce + public void afterClass(){ + super.afterClass(); + } + } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/LineStringConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/LineStringConvertorTest.java similarity index 89% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/LineStringConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/LineStringConvertorTest.java index bb6be4cd21..96164d7984 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/LineStringConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/LineStringConvertorTest.java @@ -23,22 +23,25 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.LineString; -import org.junit.Before; -import org.junit.Test; - +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; import org.hibernate.spatial.mgeom.MCoordinate; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; +import org.junit.Test; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; +@RequiresDialect(SqlServer2008SpatialDialect.class) public class LineStringConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setUp() { doDecoding( OpenGisType.LINESTRING ); doEncoding(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiLineStringConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiLineStringConvertorTest.java similarity index 78% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiLineStringConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiLineStringConvertorTest.java index aae89eb67c..9164ded811 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiLineStringConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiLineStringConvertorTest.java @@ -23,14 +23,18 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; -import org.junit.Before; +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; import org.junit.Test; +@RequiresDialect(SqlServer2008SpatialDialect.class) public class MultiLineStringConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setUp() { doDecoding( OpenGisType.MULTILINESTRING ); doEncoding(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiPointConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiPointConvertorTest.java similarity index 77% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiPointConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiPointConvertorTest.java index ed82a1655e..ffd78b3f03 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiPointConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiPointConvertorTest.java @@ -23,14 +23,18 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; -import org.junit.Before; +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; import org.junit.Test; +@RequiresDialect(SqlServer2008SpatialDialect.class) public class MultiPointConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setUp() { doDecoding( OpenGisType.MULTIPOINT ); doEncoding(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiPolygonConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiPolygonConvertorTest.java similarity index 78% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiPolygonConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiPolygonConvertorTest.java index 45ebd7924e..18e3bc7668 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/MultiPolygonConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/MultiPolygonConvertorTest.java @@ -23,14 +23,18 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; -import org.junit.Before; +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; import org.junit.Test; +@RequiresDialect(SqlServer2008SpatialDialect.class) public class MultiPolygonConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setUp() { doDecoding( OpenGisType.MULTIPOLYGON ); doEncoding(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/PointConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/PointConvertorTest.java similarity index 87% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/PointConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/PointConvertorTest.java index fcc5172749..e2d559943e 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/PointConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/PointConvertorTest.java @@ -23,14 +23,16 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Point; -import org.junit.Before; -import org.junit.Test; - +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; import org.hibernate.spatial.mgeom.MCoordinate; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; +import org.junit.Test; import static junit.framework.Assert.assertEquals; @@ -38,9 +40,10 @@ import static junit.framework.Assert.assertEquals; * @author Karel Maesen, Geovise BVBA. * Date: Nov 2, 2009 */ +@RequiresDialect(SqlServer2008SpatialDialect.class) public class PointConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setup() { doDecoding( OpenGisType.POINT ); doEncoding(); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/PolygonConvertorTest.java b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/PolygonConvertorTest.java similarity index 77% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/PolygonConvertorTest.java rename to hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/PolygonConvertorTest.java index fbf0b53e6a..ec43ba172f 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/PolygonConvertorTest.java +++ b/hibernate-spatial/src/matrix/java/org/hibernate/spatial/integration/dialects/sqlserver/convertors/PolygonConvertorTest.java @@ -23,15 +23,19 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.dialect.sqlserver.convertors; +package org.hibernate.spatial.integration.dialects.sqlserver.convertors; -import org.junit.Before; +import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect; +import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType; +import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.RequiresDialect; import org.junit.Test; +@RequiresDialect(SqlServer2008SpatialDialect.class) public class PolygonConvertorTest extends AbstractConvertorTest { - @Before + @BeforeClassOnce public void setUp() { doDecoding( OpenGisType.POLYGON ); doEncoding(); diff --git a/hibernate-spatial/src/matrix/resources/GeomEntity.hbm.xml b/hibernate-spatial/src/matrix/resources/GeomEntity.hbm.xml new file mode 100644 index 0000000000..aae53c6cf9 --- /dev/null +++ b/hibernate-spatial/src/matrix/resources/GeomEntity.hbm.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + diff --git a/hibernate-spatial/src/matrix/resources/log4j.properties b/hibernate-spatial/src/matrix/resources/log4j.properties new file mode 100644 index 0000000000..3b9f13e13a --- /dev/null +++ b/hibernate-spatial/src/matrix/resources/log4j.properties @@ -0,0 +1,9 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + + +log4j.rootLogger=info, stdout + +log4j.logger.org.hibernate.spatial=debug diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestCircle.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/TestCircle.java similarity index 99% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestCircle.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/TestCircle.java index 6d7a0871a5..8b08c0e889 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/TestCircle.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/TestCircle.java @@ -26,7 +26,7 @@ * * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test; +package org.hibernate.spatial; import com.vividsolutions.jts.geom.Coordinate; import org.junit.Test; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/unittests/PostgisDialectTest.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisDialectTest.java similarity index 91% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/unittests/PostgisDialectTest.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisDialectTest.java index f728e7abb1..ce116ddfa4 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/unittests/PostgisDialectTest.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/postgis/PostgisDialectTest.java @@ -1,4 +1,4 @@ -package org.hibernate.spatial.dialect.postgis.unittests; +package org.hibernate.spatial.dialect.postgis; import junit.framework.TestCase; import org.junit.Test; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/AbstractConvertorTest.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/AbstractConvertorTest.java deleted file mode 100644 index a2bdcc09d2..0000000000 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/AbstractConvertorTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * $Id: AbstractConvertorTest.java 278 2010-12-18 14:03:32Z maesenka $ - * - * This file is part of Hibernate Spatial, an extension to the - * hibernate ORM solution for geographic data. - * - * Copyright © 2007-2010 Geovise BVBA - * - * 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; either - * version 2.1 of the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * For more information, visit: http://www.hibernatespatial.org/ - */ - -package org.hibernate.spatial.dialect.sqlserver.convertors; - -import com.vividsolutions.jts.geom.Geometry; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertTrue; - -/** - * @author Karel Maesen, Geovise BVBA. - * Date: Nov 2, 2009 - */ -public class AbstractConvertorTest { - - private final static String TEST_DATA = "sqlserver/sqlserver-2008-test-data.ser"; - - List testData = readTestData(); - Map decodedGeoms = new HashMap(); - Map rawResults; - Map encodedGeoms; - Map expectedGeoms; - - - - public List readTestData(){ - InputStream in = this.getClass().getClassLoader().getResourceAsStream(TEST_DATA); - if (in == null) { - throw new RuntimeException("Can't find file " + TEST_DATA); - } - try { - ObjectInputStream oin = new ObjectInputStream(in); - return (List)oin.readObject(); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } finally { - try { - in.close(); - } catch (IOException e) { - // nothing to do - } - } - } - - - public void doDecoding(OpenGisType type) { - List testData = readTestData(); - rawResults = toRawResults(testData, type.toString()); - expectedGeoms = toExpected(testData, type.toString()); - for ( Integer id : rawResults.keySet() ) { - Geometry geometry = Decoders.decode( (byte[]) rawResults.get( id ) ); - decodedGeoms.put( id, geometry ); - } - } - - private Map toExpected(List testData, String type) { - Map result = new HashMap(); - for (ConvertorTestData item : testData) { - if (! item.type.equals(type)) continue; - result.put(item.id, item.geometry); - } - return result; - } - - private Map toRawResults(List testData, String type) { - Map result = new HashMap(); - for (ConvertorTestData item : testData) { - if (! item.type.equals(type)) continue; - result.put(item.id, item.bytes); - } - return result; - } - - public void doEncoding() { - encodedGeoms = new HashMap(); - for ( Integer id : decodedGeoms.keySet() ) { - Geometry geom = decodedGeoms.get( id ); - byte[] bytes = Encoders.encode( geom ); - encodedGeoms.put( id, bytes ); - } - } - - public void test_encoding() { - for ( Integer id : encodedGeoms.keySet() ) { - assertTrue( - "Wrong encoding for case " + id, - Arrays.equals( (byte[]) rawResults.get( id ), encodedGeoms.get( id ) ) - ); - } - } - - public void test_decoding() { - for ( Integer id : decodedGeoms.keySet() ) { - Geometry expected = expectedGeoms.get( id ); - Geometry received = decodedGeoms.get( id ); - assertTrue( "Wrong decoding for case " + id, expected.equalsExact( received ) ); - } - } -} - diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/ConvertorTestData.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/ConvertorTestData.java deleted file mode 100644 index b935d1501c..0000000000 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/ConvertorTestData.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hibernate.spatial.dialect.sqlserver.convertors; - -import com.vividsolutions.jts.geom.Geometry; - -import java.io.Serializable; - -/** - * @author Karel Maesen, Geovise BVBA - * creation-date: 1/11/12 - */ -public class ConvertorTestData implements Serializable { - public Integer id; - public String type; - public Geometry geometry; - public byte[] bytes; -} diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/SpatialObjectGenerator.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/SpatialObjectGenerator.java deleted file mode 100644 index e98603cc87..0000000000 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/dialect/sqlserver/convertors/SpatialObjectGenerator.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.hibernate.spatial.dialect.sqlserver.convertors; - -import com.vividsolutions.jts.geom.Geometry; -import org.hibernate.spatial.dialect.sqlserver.SQLServerExpressionTemplate; -import org.hibernate.spatial.dialect.sqlserver.SQLServerTestSupport; -import org.hibernate.spatial.test.DataSourceUtils; -import org.hibernate.spatial.test.TestData; -import org.hibernate.spatial.test.TestSupport; - -import java.io.*; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * A simple utitlity to generate the binary geometry objects by inserting spatial objects into a SQL Server 2008 instance, - * and reading back the results. - * - * @author Karel Maesen, Geovise BVBA - * creation-date: 1/11/12 - */ -public class SpatialObjectGenerator { - - private final static String TEST_DATA = "sqlserver-2008-test-data.ser"; - - private final static DataSourceUtils dataSourceUtils = new DataSourceUtils( - "sqlserver/hibernate-spatial-sqlserver-test.properties", - new SQLServerExpressionTemplate() - ); - - private final static TestSupport support = new SQLServerTestSupport(); - - private final static String[] TYPES; - - static { - TYPES = new String[OpenGisType.values().length]; - int i = 0; - for (OpenGisType type : OpenGisType.values()) { - TYPES[i++] = type.toString(); - } - } - - private final TestData testData = support.createTestData(null); - - public static void main(String[] argv) { - File outFile = createOutputFile(argv); - SpatialObjectGenerator generator = new SpatialObjectGenerator(); - try { - generator.prepare(); - List result = generator.generateTestDataObjects(); - writeTo(outFile, result); - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (SQLException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } finally{ - try { - generator.discard(); - } catch (SQLException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - } - - } - - private static void writeTo(File outFile, List result) { - FileOutputStream fos = null; - ObjectOutputStream out = null; - - try { - fos = new FileOutputStream(outFile); - out = new ObjectOutputStream(fos); - out.writeObject(result); - out.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - - System.out.printf("Wrote %d objects to %s.", result.size(), outFile.getAbsolutePath()); - } - - private static File createOutputFile(String[] argv) { - String tmpDir = System.getProperty("java.io.tmpdir"); - File outFile = new File(tmpDir, TEST_DATA); - if (argv.length > 0) { - outFile = new File(argv[1]); - } - return outFile; - } - - - public void prepare() throws IOException, SQLException { - String sql = dataSourceUtils.parseSqlIn("sqlserver/create-sqlserver-test-schema.sql"); - dataSourceUtils.executeStatement(sql); - dataSourceUtils.insertTestData(testData); - } - - public List generateTestDataObjects() { - List result = new ArrayList(); - for (String type : TYPES) { - addTestObjectForType(type, result); - } - return result; - } - - private void addTestObjectForType(String type, List result) { - Map rawResults = dataSourceUtils.rawDbObjects(type.toString()); - Map geometries = dataSourceUtils.expectedGeoms(type.toString(), testData); - addToResult(type, result, rawResults, geometries); - } - - private void addToResult(String type, List result, Map rawResults, Map geometries) { - for (Integer id : rawResults.keySet()) { - ConvertorTestData data = new ConvertorTestData(); - data.id = id; - data.geometry = geometries.get(id); - data.type = type; - data.bytes = (byte[]) rawResults.get(id); - result.add(data); - } - } - - - public void discard() throws SQLException, IOException { - String sql = dataSourceUtils.parseSqlIn("sqlserver/drop-sqlserver-test-schema.sql"); - dataSourceUtils.executeStatement(sql); - } - -} diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/MLineStringTest.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/MLineStringTest.java similarity index 98% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/MLineStringTest.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/MLineStringTest.java index 9e0f685c5e..7d5d53028b 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/MLineStringTest.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/MLineStringTest.java @@ -26,7 +26,7 @@ * * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test.mgeom; +package org.hibernate.spatial.mgeom; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -34,14 +34,6 @@ import com.vividsolutions.jts.geom.CoordinateSequenceComparator; import com.vividsolutions.jts.geom.PrecisionModel; import junit.framework.TestCase; -import org.hibernate.spatial.mgeom.DoubleComparator; -import org.hibernate.spatial.mgeom.MCoordinate; -import org.hibernate.spatial.mgeom.MCoordinateSequenceFactory; -import org.hibernate.spatial.mgeom.MGeometry; -import org.hibernate.spatial.mgeom.MGeometryException; -import org.hibernate.spatial.mgeom.MGeometryFactory; -import org.hibernate.spatial.mgeom.MLineString; - /** * @author Karel Maesen */ diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/MultiMLineStringTest.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/MultiMLineStringTest.java similarity index 95% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/MultiMLineStringTest.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/MultiMLineStringTest.java index 46d5198d36..b4412c1e23 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/MultiMLineStringTest.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/MultiMLineStringTest.java @@ -26,18 +26,13 @@ * * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test.mgeom; +package org.hibernate.spatial.mgeom; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; import com.vividsolutions.jts.geom.GeometryFactory; import junit.framework.TestCase; -import org.hibernate.spatial.mgeom.MCoordinate; -import org.hibernate.spatial.mgeom.MCoordinateSequenceFactory; -import org.hibernate.spatial.mgeom.MLineString; -import org.hibernate.spatial.mgeom.MultiMLineString; - /** * @author Karel Maesen */ diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/TestEventLocator.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/TestEventLocator.java similarity index 99% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/TestEventLocator.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/TestEventLocator.java index 1bb3defb64..92ef567b65 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/TestEventLocator.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/TestEventLocator.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test.mgeom; +package org.hibernate.spatial.mgeom; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.PrecisionModel; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/TestMLineStringGetCoordinatesBetween.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/TestMLineStringGetCoordinatesBetween.java similarity index 99% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/TestMLineStringGetCoordinatesBetween.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/TestMLineStringGetCoordinatesBetween.java index eeda806a31..b1b0733de4 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/test/mgeom/TestMLineStringGetCoordinatesBetween.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/mgeom/TestMLineStringGetCoordinatesBetween.java @@ -23,7 +23,7 @@ * For more information, visit: http://www.hibernatespatial.org/ */ -package org.hibernate.spatial.test.mgeom; +package org.hibernate.spatial.mgeom; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; diff --git a/hibernate-spatial/src/test/resources/GeomEntity.hbm.xml b/hibernate-spatial/src/test/resources/GeomEntity.hbm.xml index 570cf86f38..aae53c6cf9 100644 --- a/hibernate-spatial/src/test/resources/GeomEntity.hbm.xml +++ b/hibernate-spatial/src/test/resources/GeomEntity.hbm.xml @@ -28,7 +28,7 @@ " http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - + diff --git a/hibernate-spatial/src/test/resources/hibernate.properties b/hibernate-spatial/src/test/resources/hibernate.properties index ee28b26921..50336a4dbc 100644 --- a/hibernate-spatial/src/test/resources/hibernate.properties +++ b/hibernate-spatial/src/test/resources/hibernate.properties @@ -22,6 +22,28 @@ # Boston, MA 02110-1301 USA # +# Default unit/integration test config. + +hibernate.dialect org.hibernate.dialect.H2Dialect +hibernate.connection.driver_class org.h2.Driver +hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE +hibernate.connection.username sa + +hibernate.connection.pool_size 5 + +hibernate.show_sql false + +hibernate.max_fetch_depth 5 + +hibernate.cache.region_prefix hibernate.test +hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory + +# NOTE: hibernate.jdbc.batch_versioned_data should be set to false when testing with Oracle +hibernate.jdbc.batch_versioned_data true + + +## Configs for spatial databases (used during testin on local dev environment). + #hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisDialect #hibernate.connection.driver_class org.postgresql.Driver #hibernate.connection.url jdbc:postgresql://localhost:5432:hibbrtru @@ -34,17 +56,17 @@ #hibernate.connection.username hbs #hibernate.connection.password hbs -hibernate.dialect org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect -hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver -hibernate.connection.url jdbc:sqlserver://192.168.122.67:1433;databaseName=HBS -hibernate.connection.username hbs -hibernate.connection.password hbs - -hibernate.connection.pool_size 5 - -hibernate.show_sql true - -hibernate.max_fetch_depth 5 - -hibernate.cache.region_prefix hibernate.test -hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory +#hibernate.dialect org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect +#hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver +#hibernate.connection.url jdbc:sqlserver://192.168.122.67:1433;databaseName=HBS +#hibernate.connection.username hbs +#hibernate.connection.password hbs +# +#hibernate.connection.pool_size 5 +# +#hibernate.show_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/src/test/resources/sqlserver/hibernate-spatial-sqlserver-test.properties b/hibernate-spatial/src/test/resources/sqlserver/hibernate-spatial-sqlserver-test.properties index 47d33b3dc2..2e899f5167 100644 --- a/hibernate-spatial/src/test/resources/sqlserver/hibernate-spatial-sqlserver-test.properties +++ b/hibernate-spatial/src/test/resources/sqlserver/hibernate-spatial-sqlserver-test.properties @@ -2,9 +2,9 @@ # $Id: hibernate-spatial-sqlserver-test.properties 182 2010-03-20 17:30:12Z maesenka $ # -jdbcUrl = jdbc:sqlserver://192.168.0.100:1433;databaseName=HBS -jdbcDriver = com.microsoft.sqlserver.jdbc.SQLServerDriver -jdbcUser = hbs -jdbcPass = hbs -dataset = test-data-set.xml +#jdbcUrl = jdbc:sqlserver://192.168.0.100:1433;databaseName=HBS +#jdbcDriver = com.microsoft.sqlserver.jdbc.SQLServerDriver +#jdbcUser = hbs +#jdbcPass = hbs +#dataset = test-data-set.xml