Subversion Repositories hibernate-spatial

Compare Revisions

Ignore whitespace Rev 184 → Rev 185

/trunk/hibernate-spatial-postgis/src/test/java/hibernate-spatial.cfg.xml
File deleted
\ No newline at end of file
/trunk/hibernate-spatial-postgis/src/test/java/log4j.properties
File deleted
/trunk/hibernate-spatial-postgis/src/test/java/hibernate.cfg.xml
File deleted
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/test/cfg/HSConfigurationTest.java
New file
0,0 → 1,38
package org.hibernatespatial.test.cfg;
 
import com.vividsolutions.jts.geom.PrecisionModel;
import org.hibernatespatial.HBSpatialExtension;
import org.hibernatespatial.cfg.HSConfiguration;
import org.junit.Test;
 
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
 
public class HSConfigurationTest {
 
@Test
public void testConfigureFailure() {
HSConfiguration config = new HSConfiguration();
config.configure("non-existing-file");
}
 
@Test
public void testHBSpatExtConfigure() {
HSConfiguration config = new HSConfiguration();
config.configure();
HBSpatialExtension.setConfiguration(config);
 
PrecisionModel pm = HBSpatialExtension.getDefaultGeomFactory()
.getPrecisionModel();
double scale = pm.getScale();
assertEquals(5.0, scale, 0.00001);
assertFalse(pm.isFloating());
}
 
private void testResults(HSConfiguration config) {
assertEquals("org.hibernatespatial.mysql.MySQLSpatialDialect", config
.getDefaultDialect());
assertEquals("FIXED", config.getPrecisionModel());
assertEquals("5", config.getPrecisionModelScale());
}
}
Property changes:
Added: svn:keywords
+ Id
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/test/pojo/reader/TestPostgisBasicFeatureReader.java
New file
0,0 → 1,65
package org.hibernatespatial.test.pojo.reader;
 
import org.hibernatespatial.cfg.HSConfiguration;
import org.hibernatespatial.helper.FinderException;
import org.junit.BeforeClass;
import org.junit.Test;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
 
public class TestPostgisBasicFeatureReader {
private static TestBasicFeatureReader delegate;
 
private static String dbUrl;
 
private static String DBNAME = "test";
 
private static HSConfiguration config;
 
private static Connection conn;
 
 
static {
 
config = new HSConfiguration();
config.configure();
 
dbUrl = "jdbc:postgresql://localhost:5432/" + DBNAME;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(dbUrl, "postgres", "");
 
} catch (Exception e) {
e.printStackTrace();
}
delegate = new TestBasicFeatureReader();
}
 
@BeforeClass
public static void setUpBeforeClass() throws Exception {
delegate.setUpBeforeClass(config, conn);
}
 
@Test
public void testReaderNoFilters() throws FinderException {
Statement stmt = null;
ResultSet rs = null;
 
try {
stmt = conn.createStatement();
rs = stmt.executeQuery("select count(*) from geomtest");
rs.next();
Integer expected = rs.getInt(1);
delegate.testReaderNoFilters(expected);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
 
}
}
 
}
Property changes:
Added: svn:keywords
+ Id
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/test/pojo/TestAutoMapper.java
New file
0,0 → 1,79
/**
*
*/
package org.hibernatespatial.test.pojo;
 
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernatespatial.cfg.HSConfiguration;
import org.hibernatespatial.pojo.AutoMapper;
import org.junit.BeforeClass;
import org.junit.Test;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.List;
 
import static org.junit.Assert.assertTrue;
 
/**
* @author Karel Maesen
*/
public class TestAutoMapper {
 
private static TestPojoUtility delegate;
 
private static String dbUrl;
 
private static String DBNAME = "test";
 
private static HSConfiguration config;
 
private static Connection conn;
 
static {
 
config = new HSConfiguration();
config.configure();
 
dbUrl = "jdbc:postgresql://localhost:5432/" + DBNAME;
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(dbUrl, "postgres", "");
 
} catch (Exception e) {
e.printStackTrace();
}
delegate = new TestPojoUtility();
}
 
@BeforeClass
public static void setUpBeforeClass() throws Exception {
delegate.setUpBeforeClass(config, conn);
}
 
 
@Test
public void testList() {
 
Session session = delegate.getSessionFactory().openSession();
try {
 
List<String[]> tables = AutoMapper.getMappedTables();
 
for (String[] tncomp : tables) {
Class entityClass = AutoMapper.getClass(tncomp[0], tncomp[1], tncomp[2]);
Criteria c = session.createCriteria(entityClass);
List results = c.list();
assertTrue(results.size() > 1);
}
 
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
session.close();
}
 
}
 
}
Property changes:
Added: svn:keywords
+ Id
Added: svn:mergeinfo
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/TestPostgisSpatialFunctions.java
New file
0,0 → 1,188
/*
* $Id:$
*
* 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.hibernatespatial.postgis;
 
import org.hibernatespatial.test.DataSourceUtils;
import org.hibernatespatial.test.TestData;
import org.hibernatespatial.test.TestSpatialFunctions;
import org.junit.BeforeClass;
import org.junit.Test;
 
import java.sql.SQLException;
 
/**
* Test class for the spatial functions added to HQL for postgis.
*
* @author Karel Maesen, Geovise BVBA
*/
public class TestPostgisSpatialFunctions {
 
private final static DataSourceUtils dataSourceUtils = new DataSourceUtils("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate());
 
private PostgisExpectationsFactory expected;
private TestSpatialFunctions delegate;
 
 
@BeforeClass
public static void beforeClass() throws Exception {
dataSourceUtils.deleteTestData();
TestData testData = TestData.fromFile("postgis-functions-test.xml");
dataSourceUtils.insertTestData(testData);
TestSpatialFunctions.setUpBeforeClass();
}
 
public TestPostgisSpatialFunctions() {
expected = new PostgisExpectationsFactory();
delegate = new TestSpatialFunctions(expected);
}
 
 
@Test
public void test_dimension() throws SQLException {
delegate.test_dimension();
}
 
@Test
public void test_astext() throws SQLException {
delegate.test_astext();
}
 
@Test
public void test_asbinary() throws SQLException {
delegate.test_asbinary();
}
 
@Test
public void test_geometrytype() throws SQLException {
delegate.test_geometrytype();
}
 
@Test
public void test_srid() throws SQLException {
delegate.test_srid();
}
 
@Test
public void test_issimple() throws SQLException {
delegate.test_issimple();
}
 
@Test
public void test_isempty() throws SQLException {
delegate.test_isempty();
}
 
@Test
public void test_boundary() throws SQLException {
delegate.test_boundary();
}
 
@Test
public void test_envelope() throws SQLException {
delegate.test_envelope();
}
 
@Test
public void test_within() throws SQLException {
delegate.test_within();
}
 
@Test
public void test_equals() throws SQLException {
delegate.test_equals();
}
 
@Test
public void test_crosses() throws SQLException {
delegate.test_crosses();
}
 
@Test
public void test_contains() throws SQLException {
delegate.test_contains();
}
 
@Test
public void test_disjoint() throws SQLException {
delegate.test_disjoint();
}
 
@Test
public void test_intersects() throws SQLException {
delegate.test_intersects();
}
 
@Test
public void test_overlaps() throws SQLException {
delegate.test_overlaps();
}
 
@Test
public void test_touches() throws SQLException {
delegate.test_touches();
}
 
@Test
public void test_relate() throws SQLException {
delegate.test_relate();
}
 
@Test
public void test_distance() throws SQLException {
delegate.test_distance();
}
 
@Test
public void test_buffer() throws SQLException {
delegate.test_buffer();
}
 
@Test
public void test_convexhull() throws SQLException {
delegate.test_convexhull();
}
 
@Test
public void test_intersection() throws SQLException {
delegate.test_intersection();
}
 
@Test
public void test_difference() throws SQLException {
delegate.test_difference();
}
 
@Test
public void test_symdifference() throws SQLException {
delegate.test_symdifference();
}
 
@Test
public void test_geomunion() throws SQLException {
delegate.test_geomunion();
}
 
}
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/TestPostgisSpatialRestrictions.java
New file
0,0 → 1,112
/*
* $Id:$
*
* 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.hibernatespatial.postgis;
 
import org.hibernatespatial.test.DataSourceUtils;
import org.hibernatespatial.test.TestData;
import org.hibernatespatial.test.TestSpatialRestrictions;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.sql.SQLException;
 
/**
* Test class for the spatial restrictions as applied to Postgis
*
* @author Karel Maesen, Geovise BVBA
*/
public class TestPostgisSpatialRestrictions {
 
private static Logger LOGGER = LoggerFactory.getLogger(TestPostgisSpatialRestrictions.class);
private final static DataSourceUtils dataSourceUtils = new DataSourceUtils("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate());
 
private PostgisExpectationsFactory expected;
private TestSpatialRestrictions delegate;
 
 
@BeforeClass
public static void beforeClass() throws Exception {
 
dataSourceUtils.deleteTestData();
//NO INVALID GEOMETRIES ALLOWED!!
TestData testData = TestData.fromFile("postgis-functions-test.xml");
dataSourceUtils.insertTestData(testData);
 
TestSpatialRestrictions.setUpBeforeClass();
}
 
public TestPostgisSpatialRestrictions() {
expected = new PostgisExpectationsFactory();
delegate = new TestSpatialRestrictions(expected);
}
 
@Test
public void test_within() throws SQLException {
delegate.test_within();
}
 
@Test
public void test_filter() throws SQLException {
delegate.test_filter();
}
 
@Test
public void test_contains() throws SQLException {
delegate.test_contains();
}
 
@Test
public void test_crosses() throws SQLException {
delegate.test_crosses();
}
 
@Test
public void test_touches() throws SQLException {
delegate.test_touches();
}
 
@Test
public void test_disjoint() throws SQLException {
delegate.test_disjoint();
}
 
@Test
public void test_eq() throws SQLException {
delegate.test_eq();
}
 
@Test
public void test_intersects() throws SQLException {
delegate.test_intersects();
}
 
@Test
public void test_overlaps() throws SQLException {
delegate.test_overlaps();
}
}
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/PostgisExpressionTemplate.java
New file
0,0 → 1,43
/*
* $Id:$
*
* 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.hibernatespatial.postgis;
 
import org.hibernatespatial.test.SQLExpressionTemplate;
import org.hibernatespatial.test.TestDataElement;
 
/**
* The template for postgis insert SQL
*
* @Author Karel Maesen, Geovise BVBA
*/
public class PostgisExpressionTemplate implements SQLExpressionTemplate {
 
final String SQL_TEMPLATE = "insert into geomtest values (%d, '%s', GeomFromText('%s', %d))";
 
public String toInsertSql(TestDataElement testDataElement) {
return String.format(SQL_TEMPLATE, testDataElement.id, testDataElement.type, testDataElement.wkt, testDataElement.srid);
}
}
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/PostgisExpectationsFactory.java
New file
0,0 → 1,211
/*
* $Id:$
*
* 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.hibernatespatial.postgis;
 
import com.vividsolutions.jts.geom.Geometry;
import org.hibernatespatial.test.AbstractExpectationsFactory;
import org.hibernatespatial.test.NativeSQLStatement;
 
/**
* This class provides the expected return values to the test classes in this package.
*
* @author Karel Maesen, Geovise BVBA
*/
public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
 
private final PGGeometryUserType decoder = new PGGeometryUserType();
 
public PostgisExpectationsFactory() {
super("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate());
}
 
@Override
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, touches(t.geom, GeomFromText(?, 4326)) from GeomTest t where touches(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, overlaps(t.geom, GeomFromText(?, 4326)) from GeomTest t where overlaps(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
String sql = "select t.id, relate(t.geom, GeomFromText(?, 4326), '" + matrix + "' ) from GeomTest t where relate(t.geom, GeomFromText(?, 4326), '" + matrix + "') = 'true' and srid(t.geom) = 4326";
return createNativeSQLStatementAllWKTParams(sql, geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, intersects(t.geom, GeomFromText(?, 4326)) from GeomTest t where intersects(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, t.geom && GeomFromText(?, 4326) from GeomTest t where intersects(t.geom, GeomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, distance(t.geom, GeomFromText(?, 4326)) from GeomTest t where srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement getNativeDimensionSQL() {
return createNativeSQLStatement("select id, dimension(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
return createNativeSQLStatement("select t.id, buffer(t.geom,?) from GeomTest t where srid(t.geom) = 4326", new Object[]{distance});
}
 
@Override
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, convexhull(geomunion(t.geom, GeomFromText(?, 4326))) from GeomTest t where srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, intersection(t.geom, GeomFromText(?, 4326)) from GeomTest t where srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, difference(t.geom, GeomFromText(?, 4326)) from GeomTest t where srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, symdifference(t.geom, GeomFromText(?, 4326)) from GeomTest t where srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, geomunion(t.geom, GeomFromText(?, 4326)) from GeomTest t where srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeAsTextStatement() {
return createNativeSQLStatement("select id, astext(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeSridStatement() {
return createNativeSQLStatement("select id, srid(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeIsSimpleStatement() {
return createNativeSQLStatement("select id, issimple(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeIsEmptyStatement() {
return createNativeSQLStatement("select id, isempty(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeBoundaryStatement() {
return createNativeSQLStatement("select id, boundary(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeEnvelopeStatement() {
return createNativeSQLStatement("select id, envelope(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeAsBinaryStatement() {
return createNativeSQLStatement("select id, asbinary(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeGeometryTypeStatement() {
return createNativeSQLStatement("select id, GeometryType(geom) from geomtest");
}
 
@Override
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, within(t.geom, GeomFromText(?, 4326)) from GeomTest t where within(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, equals(t.geom, GeomFromText(?, 4326)) from GeomTest t where equals(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, crosses(t.geom, GeomFromText(?, 4326)) from GeomTest t where crosses(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, contains(t.geom, GeomFromText(?, 4326)) from GeomTest t where contains(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
return createNativeSQLStatementAllWKTParams(
"select t.id, disjoint(t.geom, GeomFromText(?, 4326)) from GeomTest t where disjoint(t.geom, geomFromText(?, 4326)) = 'true' and srid(t.geom) = 4326",
geom.toText());
}
 
@Override
protected Geometry decode(Object o) {
return decoder.convert2JTS(o);
}
 
}
/trunk/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/TestPostgisStoreRetrieve.java
New file
0,0 → 1,61
/*
* $Id:$
*
* 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.hibernatespatial.postgis;
 
import com.vividsolutions.jts.io.ParseException;
import org.hibernatespatial.test.DataSourceUtils;
import org.hibernatespatial.test.TestData;
import org.hibernatespatial.test.TestStoreRetrieve;
import org.junit.Before;
import org.junit.Test;
 
import java.sql.SQLException;
 
/**
* This test class verifies whether the <code>Geometry</code>s retrieved are equal to the <code>Geometry</code>s stored.
*
* @Author Karel Maesen, Geovise BVBA
*/
public class TestPostgisStoreRetrieve {
 
private final TestStoreRetrieve delegate;
 
public TestPostgisStoreRetrieve() {
DataSourceUtils dataSourceUtils = new DataSourceUtils("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate());
TestData testData = dataSourceUtils.getTestData();
delegate = new TestStoreRetrieve(dataSourceUtils, testData);
}
 
@Before
public void setUp() throws SQLException {
delegate.setUp();
}
 
@Test
public void test_load_retrieve() throws ParseException {
delegate.test_load_retrieve();
}
}
/trunk/hibernate-spatial-postgis/src/test/resources/create-tables.sql
File deleted
\ No newline at end of file
/trunk/hibernate-spatial-postgis/src/test/resources/hibernate-spatial.cfg.xml
New file
0,0 → 1,6
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-spatial>
<default_dialect>org.hibernatespatial.postgis.PostgisDialect</default_dialect>
<precision_model>FIXED</precision_model>
<precision_model_scale>5</precision_model_scale>
</hibernate-spatial>
Property changes:
Added: svn:keywords
+ Id
/trunk/hibernate-spatial-postgis/src/test/resources/hibernate-spatial-postgis-test.properties
New file
0,0 → 1,5
jdbcUrl = jdbc:postgresql://localhost:5432/test
driver = org.postgresql.Driver
dbUsername = postgres
dbPassword = hbs
dataset = test-data-set.xml
/trunk/hibernate-spatial-postgis/src/test/resources/log4j.properties
New file
0,0 → 1,49
### direct log messages to stdout ###
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
 
### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
 
### set log levels - for more verbose logging change 'info' to 'debug' ###
 
log4j.rootLogger=debug, stdout
 
log4j.logger.org.hibernatespatial.test=debug
 
log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=debug
 
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
 
### log just the SQL
#log4j.logger.org.hibernate.SQL=debug
 
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug
 
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug
 
### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
 
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
 
### log transaction activity
#log4j.logger.org.hibernate.transaction=debug
 
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug
 
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
Property changes:
Added: svn:executable
+
Added: svn:keywords
+ Id
/trunk/hibernate-spatial-postgis/src/test/resources/postgis-functions-test.xml
New file
0,0 → 1,78
<TestData>
<!-- points -->
<Element>
<id>1</id>
<type>POINT</type>
<wkt>POINT(10 5)</wkt>
<srid>4326</srid>
</Element>
<Element>
<id>2</id>
<type>POINT</type>
<wkt>POINT(90 90)</wkt>
<srid>4326</srid>
</Element>
<Element>
<id>3</id>
<type>POINT</type>
<wkt>POINT(50 50)</wkt>
<srid>4326</srid>
</Element>
<Element>
<id>4</id>
<type>POINT</type>
<wkt>POINT(200 200)</wkt>
<srid>4326</srid>
</Element>
<Element>
<id>5</id>
<type>POINT</type>
<wkt>POINT(-4 -5)</wkt>
<srid>4326</srid>
</Element>
 
<Element>
<id>6</id>
<type>LINESTRING</type>
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
<srid>4326</srid>
</Element>
 
<Element>
<id>7</id>
<type>LINESTRING</type>
<wkt>LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
<srid>4326</srid>
</Element>
 
<Element>
<id>8</id>
<type>LINESTRING</type>
<wkt>LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
<srid>4326</srid>
</Element>
 
<Element>
<id>9</id>
<type>MULTILINESTRING</type>
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
</wkt>
<srid>4326</srid>
</Element>
 
<Element>
<id>10</id>
<type>POLYGON</type>
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
<srid>4326</srid>
</Element>
 
<Element>
<id>11</id>
<type>MULTIPOLYGON</type>
<wkt>MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
<srid>4326</srid>
</Element>
 
</TestData>
 
/trunk/hibernate-spatial-postgis/src/test/resources/create-table-geomtest.sql
New file
0,0 → 1,11
--
-- creates the test table
--
CREATE TABLE "geomtest"
(
id int PRIMARY KEY NOT NULL,
type varchar(50),
geom geometry
)
 
create index idx_geomentity_spatial on geomtest using gist(geom);
/trunk/hibernate-spatial-postgis/src/test/resources/hibernate.cfg.xml
New file
0,0 → 1,28
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/test</property>
<property name="hibernate.connection.username">postgres</property>
 
<property name="hibernate.dialect">org.hibernatespatial.postgis.PostgisDialect</property>
 
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
 
 
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
 
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
 
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
 
 
</session-factory>
</hibernate-configuration>
Property changes:
Added: svn:executable
+
Added: svn:keywords
+ Id