Subversion Repositories hibernate-spatial

Compare Revisions

Ignore whitespace Rev 243 → Rev 244

/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/test/cfg/HSConfigurationTest.java
1,37 → 1,37
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());
//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());
//// }
//}
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/test/pojo/reader/TestPostgisBasicFeatureReader.java
1,65 → 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 {
 
}
}
 
}
//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 = "testsuite-suite";
//
// 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 {
//
// }
// }
//
//}
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/test/pojo/TestAutoMapper.java
1,254 → 1,254
/**
*
*/
package org.hibernatespatial.test.pojo;
 
import com.vividsolutions.jts.geom.Geometry;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernatespatial.HBSpatialExtension;
import org.hibernatespatial.cfg.HSConfiguration;
import org.hibernatespatial.pojo.*;
import org.hibernatespatial.postgis.PostgisExpressionTemplate;
import org.hibernatespatial.test.DataSourceUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
 
import java.sql.*;
import java.util.List;
 
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
 
/**
* @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;
 
 
@BeforeClass
public static void setUpBeforeClass() throws Exception {
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();
delegate.setUpBeforeClass(config, conn);
}
 
 
@Test
public void testList() throws SQLException {
DataSourceUtils dataSourceUtils = new DataSourceUtils("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate());
dataSourceUtils.insertTestData();
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();
dataSourceUtils.deleteTestData();
}
 
}
 
@Test
public void test_expose_attributes_of_mapped_class(){
List<String> attributes = AutoMapper.getAttributes(null, null, "geomtest");
assertTrue(attributes.contains("id"));
assertTrue(attributes.contains("type"));
assertTrue(attributes.contains("geom"));
assertEquals(3,attributes.size());
}
 
@Test
public void test_expose_id_attribute() throws MissingIdentifierException {
String identifier = AutoMapper.getIdAttribute(null, null, "geomtest");
assertEquals("id",identifier);
}
 
@Test
public void test_expose_geom_attribute() throws GeometryNotFoundException {
String geometryAttribute = AutoMapper.getGeometryAttribute(null, null, "geomtest");
assertEquals("geom",geometryAttribute);
}
 
@Test
public void test_expose_setter_for_attribute() throws GeometryNotFoundException {
String methodName = AutoMapper.getAttributeSetterName(null, null, "geomtest", "geom");
assertEquals("setGeom",methodName);
methodName = AutoMapper.getAttributeSetterName(null, null, "geomtest", "id");
assertEquals("setId",methodName);
methodName = AutoMapper.getAttributeSetterName(null, null, "geomtest", "type");
assertEquals("setType",methodName);
}
 
@Test
public void test_expose_getter_for_attribute() throws GeometryNotFoundException {
String methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "geom");
assertEquals("getGeom",methodName);
methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "id");
assertEquals("getId",methodName);
methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "type");
assertEquals("getType",methodName);
}
 
@Test
public void test_getter_for_non_existing_attribute_throws_illegal_argument_exception() throws GeometryNotFoundException {
 
try {
String methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "nonexisting");
fail();
}catch(IllegalArgumentException e){
 
}catch(Exception e){
fail();
}
 
try {
String methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", null);
fail();
}catch(IllegalArgumentException e){
 
}catch(Exception e){
fail();
}
}
 
@Test
public void test_fail_on_composite_primary_key() throws Exception {
try {
//prepare test table
PreparedStatement pstmt = conn.prepareStatement("create table mucomp (c1 int, c2 int, c3 char(10))");
pstmt.execute();
pstmt = conn.prepareStatement("alter table mucomp add primary key (c1, c2)");
pstmt.execute();
 
NamingStrategy naming = new SimpleNamingStrategy();
TypeMapper typeMapper = new TypeMapper(HBSpatialExtension.getDefaultSpatialDialect().getDbGeometryTypeName());
DatabaseMetaData dmd = conn.getMetaData();
FeatureMapper fMapper = new FeatureMapper(naming, typeMapper);
try {
ClassInfo cInfo = fMapper.createClassInfo(null, "public", "mucomp", dmd);
fail("Attempt to map class with multiple primary keys");
} catch (TableNotFoundException e) {
fail("TableNotFoundException thrown");
} catch (MissingIdentifierException e) {
//OK
} catch (Exception e) {
fail("MissingIdentifierException expected");
}
 
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
PreparedStatement delTabStmt = conn.prepareStatement("drop table mucomp");
delTabStmt.execute();
}
 
}
 
@Test
public void test_fail_on_no_primary_key() throws Exception {
try {
//prepare test table
PreparedStatement pstmt = conn.prepareStatement("create table nopkey (c1 int, c2 int, c3 char(10))");
pstmt.execute();
 
NamingStrategy naming = new SimpleNamingStrategy();
TypeMapper typeMapper = new TypeMapper(HBSpatialExtension.getDefaultSpatialDialect().getDbGeometryTypeName());
DatabaseMetaData dmd = conn.getMetaData();
FeatureMapper fMapper = new FeatureMapper(naming, typeMapper);
try {
ClassInfo cInfo = fMapper.createClassInfo(null, "public", "nopkey", dmd);
fail("Attempt to map class with no primary key");
} catch (TableNotFoundException e) {
fail("TableNotFoundException thrown");
} catch (MissingIdentifierException e) {
//OK
} catch (Exception e) {
fail("MissingIdentifierException expected");
}
 
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
PreparedStatement delTabStmt = conn.prepareStatement("drop table nopkey");
delTabStmt.execute();
}
 
}
 
 
@Test
public void test_unique_index_accepted_as_primary_key() throws Exception {
try {
//prepare test table
PreparedStatement pstmt = conn.prepareStatement("create table unik (c1 int, c2 int, c3 char(10))");
pstmt.execute();
pstmt = conn.prepareStatement("create unique index un_idx on unik(c1)");
pstmt.execute();
 
NamingStrategy naming = new SimpleNamingStrategy();
TypeMapper typeMapper = new TypeMapper(HBSpatialExtension.getDefaultSpatialDialect().getDbGeometryTypeName());
DatabaseMetaData dmd = conn.getMetaData();
FeatureMapper fMapper = new FeatureMapper(naming, typeMapper);
try {
ClassInfo cInfo = fMapper.createClassInfo(null, "public", "unik", dmd);
assertEquals("c1", cInfo.getIdAttribute().getColumnName());
 
} catch (TableNotFoundException e) {
fail("TableNotFoundException thrown");
} catch (MissingIdentifierException e) {
fail("Unique index not accepted as primary key");
} catch (Exception e) {
fail("MissingIdentifierException expected");
}
 
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
PreparedStatement delTabStmt = conn.prepareStatement("drop table unik");
delTabStmt.execute();
}
 
}
 
@AfterClass
public static void cleanUp() throws SQLException {
conn.close();
}
 
}
///**
// *
// */
//package org.hibernatespatial.testsuite-suite.pojo;
//
//import com.vividsolutions.jts.geom.Geometry;
//import org.hibernate.Criteria;
//import org.hibernate.Session;
//import org.hibernatespatial.HBSpatialExtension;
//import org.hibernatespatial.cfg.HSConfiguration;
//import org.hibernatespatial.pojo.*;
//import org.hibernatespatial.postgis.PostgisExpressionTemplate;
//import org.hibernatespatial.testsuite-suite.DataSourceUtils;
//import org.junit.AfterClass;
//import org.junit.BeforeClass;
//import org.junit.Test;
//
//import java.sql.*;
//import java.util.List;
//
//import static org.junit.Assert.assertEquals;
//import static org.junit.Assert.assertTrue;
//import static org.junit.Assert.fail;
//
///**
// * @author Karel Maesen
// */
//public class TestAutoMapper {
//
// private static TestPojoUtility delegate;
//
// private static String dbUrl;
//
// private static String DBNAME = "testsuite-suite";
//
// private static HSConfiguration config;
//
// private static Connection conn;
//
//
// @BeforeClass
// public static void setUpBeforeClass() throws Exception {
// 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();
// delegate.setUpBeforeClass(config, conn);
// }
//
//
// @Test
// public void testList() throws SQLException {
// DataSourceUtils dataSourceUtils = new DataSourceUtils("hibernate-spatial-postgis-testsuite-suite.properties", new PostgisExpressionTemplate());
// dataSourceUtils.insertTestData();
// 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();
// dataSourceUtils.deleteTestData();
// }
//
// }
//
// @Test
// public void test_expose_attributes_of_mapped_class(){
// List<String> attributes = AutoMapper.getAttributes(null, null, "geomtest");
// assertTrue(attributes.contains("id"));
// assertTrue(attributes.contains("type"));
// assertTrue(attributes.contains("geom"));
// assertEquals(3,attributes.size());
// }
//
// @Test
// public void test_expose_id_attribute() throws MissingIdentifierException {
// String identifier = AutoMapper.getIdAttribute(null, null, "geomtest");
// assertEquals("id",identifier);
// }
//
// @Test
// public void test_expose_geom_attribute() throws GeometryNotFoundException {
// String geometryAttribute = AutoMapper.getGeometryAttribute(null, null, "geomtest");
// assertEquals("geom",geometryAttribute);
// }
//
// @Test
// public void test_expose_setter_for_attribute() throws GeometryNotFoundException {
// String methodName = AutoMapper.getAttributeSetterName(null, null, "geomtest", "geom");
// assertEquals("setGeom",methodName);
// methodName = AutoMapper.getAttributeSetterName(null, null, "geomtest", "id");
// assertEquals("setId",methodName);
// methodName = AutoMapper.getAttributeSetterName(null, null, "geomtest", "type");
// assertEquals("setType",methodName);
// }
//
// @Test
// public void test_expose_getter_for_attribute() throws GeometryNotFoundException {
// String methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "geom");
// assertEquals("getGeom",methodName);
// methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "id");
// assertEquals("getId",methodName);
// methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "type");
// assertEquals("getType",methodName);
// }
//
// @Test
// public void test_getter_for_non_existing_attribute_throws_illegal_argument_exception() throws GeometryNotFoundException {
//
// try {
// String methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", "nonexisting");
// fail();
// }catch(IllegalArgumentException e){
//
// }catch(Exception e){
// fail();
// }
//
// try {
// String methodName = AutoMapper.getAttributeGetterName(null, null, "geomtest", null);
// fail();
// }catch(IllegalArgumentException e){
//
// }catch(Exception e){
// fail();
// }
// }
//
// @Test
// public void test_fail_on_composite_primary_key() throws Exception {
// try {
// //prepare testsuite-suite table
// PreparedStatement pstmt = conn.prepareStatement("create table mucomp (c1 int, c2 int, c3 char(10))");
// pstmt.execute();
// pstmt = conn.prepareStatement("alter table mucomp add primary key (c1, c2)");
// pstmt.execute();
//
// NamingStrategy naming = new SimpleNamingStrategy();
// TypeMapper typeMapper = new TypeMapper(HBSpatialExtension.getDefaultSpatialDialect().getDbGeometryTypeName());
// DatabaseMetaData dmd = conn.getMetaData();
// FeatureMapper fMapper = new FeatureMapper(naming, typeMapper);
// try {
// ClassInfo cInfo = fMapper.createClassInfo(null, "public", "mucomp", dmd);
// fail("Attempt to map class with multiple primary keys");
// } catch (TableNotFoundException e) {
// fail("TableNotFoundException thrown");
// } catch (MissingIdentifierException e) {
// //OK
// } catch (Exception e) {
// fail("MissingIdentifierException expected");
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// throw e;
// } finally {
// PreparedStatement delTabStmt = conn.prepareStatement("drop table mucomp");
// delTabStmt.execute();
// }
//
// }
//
// @Test
// public void test_fail_on_no_primary_key() throws Exception {
// try {
// //prepare testsuite-suite table
// PreparedStatement pstmt = conn.prepareStatement("create table nopkey (c1 int, c2 int, c3 char(10))");
// pstmt.execute();
//
// NamingStrategy naming = new SimpleNamingStrategy();
// TypeMapper typeMapper = new TypeMapper(HBSpatialExtension.getDefaultSpatialDialect().getDbGeometryTypeName());
// DatabaseMetaData dmd = conn.getMetaData();
// FeatureMapper fMapper = new FeatureMapper(naming, typeMapper);
// try {
// ClassInfo cInfo = fMapper.createClassInfo(null, "public", "nopkey", dmd);
// fail("Attempt to map class with no primary key");
// } catch (TableNotFoundException e) {
// fail("TableNotFoundException thrown");
// } catch (MissingIdentifierException e) {
// //OK
// } catch (Exception e) {
// fail("MissingIdentifierException expected");
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// throw e;
// } finally {
// PreparedStatement delTabStmt = conn.prepareStatement("drop table nopkey");
// delTabStmt.execute();
// }
//
// }
//
//
// @Test
// public void test_unique_index_accepted_as_primary_key() throws Exception {
// try {
// //prepare testsuite-suite table
// PreparedStatement pstmt = conn.prepareStatement("create table unik (c1 int, c2 int, c3 char(10))");
// pstmt.execute();
// pstmt = conn.prepareStatement("create unique index un_idx on unik(c1)");
// pstmt.execute();
//
// NamingStrategy naming = new SimpleNamingStrategy();
// TypeMapper typeMapper = new TypeMapper(HBSpatialExtension.getDefaultSpatialDialect().getDbGeometryTypeName());
// DatabaseMetaData dmd = conn.getMetaData();
// FeatureMapper fMapper = new FeatureMapper(naming, typeMapper);
// try {
// ClassInfo cInfo = fMapper.createClassInfo(null, "public", "unik", dmd);
// assertEquals("c1", cInfo.getIdAttribute().getColumnName());
//
// } catch (TableNotFoundException e) {
// fail("TableNotFoundException thrown");
// } catch (MissingIdentifierException e) {
// fail("Unique index not accepted as primary key");
// } catch (Exception e) {
// fail("MissingIdentifierException expected");
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// throw e;
// } finally {
// PreparedStatement delTabStmt = conn.prepareStatement("drop table unik");
// delTabStmt.execute();
// }
//
// }
//
// @AfterClass
// public static void cleanUp() throws SQLException {
// conn.close();
// }
//
//}
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/IntegrationTestPostgisStoreRetrieve.java
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/TestPostgisSpatialFunctions.java
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/TestPostgisSpatialRestrictions.java
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/TestPostgisStoreRetrieve.java
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/PostgisExpectationsFactory.java
30,7 → 30,7
import org.hibernatespatial.test.NativeSQLStatement;
 
/**
* This class provides the expected return values to the test classes in this package.
* This class provides the expected return values to the testsuite-suite classes in this package.
*
* @author Karel Maesen, Geovise BVBA
*/
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/PostgisTestSupportFactory.java
New file
0,0 → 1,34
package org.hibernatespatial.postgis;
 
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.hibernatespatial.test.*;
 
/**
* @author Karel Maesen, Geovise BVBA
* creation-date: Sep 30, 2010
*/
public class PostgisTestSupportFactory implements TestSupportFactory {
 
 
public DataSourceUtils createDataSourceUtil(FunctionalTestCase testcase) {
return new DataSourceUtils("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate());
}
 
public TestData createTestData(FunctionalTestCase testcase) {
if (testcase.getClass().getCanonicalName().contains("TestSpatialFunctions") ||
testcase.getClass().getCanonicalName().contains("TestSpatialRestrictions")){
return TestData.fromFile("postgis-functions-test.xml");
}
return TestData.fromFile("test-data-set.xml");
}
 
public GeometryEquality createGeometryEquality() {
return new GeometryEquality();
}
 
public AbstractExpectationsFactory createExpectationsFactory() {
return new PostgisExpectationsFactory();
}
 
 
}
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/resources/create-db.sh
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/resources/log4j.properties
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/resources/create-table-geomtest.sql
File deleted
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/resources/hibernate-spatial-postgis-test.properties
1,5 → 1,5
jdbcUrl = jdbc:postgresql://localhost:5432/test
jdbcUrl = jdbc:postgresql://localhost:5432/hibbrtru
driver = org.postgresql.Driver
dbUsername = postgres
dbPassword = hbs
dbUsername = hibbrtru
dbPassword = hibbrtru
dataset = test-data-set.xml
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/main/java/org/hibernatespatial/postgis/DialectProvider.java
28,8 → 28,6
*/
package org.hibernatespatial.postgis;
 
import java.util.Map;
 
import org.hibernatespatial.SpatialDialect;
import org.hibernatespatial.spi.SpatialDialectProvider;
 
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/main/java/org/hibernatespatial/postgis/PostgisDialect.java
28,10 → 28,12
*/
package org.hibernatespatial.postgis;
 
import org.hibernate.Hibernate;
 
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.CustomType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
import org.hibernate.usertype.UserType;
import org.hibernatespatial.SpatialAggregate;
import org.hibernatespatial.SpatialDialect;
45,6 → 47,8
*/
public class PostgisDialect extends PostgreSQLDialect implements SpatialDialect {
 
private static final Type geometryCustomType = new CustomType(new PGGeometryUserType(), new String[]{"postgis_geometry"});
 
public PostgisDialect() {
super();
registerColumnType(java.sql.Types.STRUCT, "geometry");
57,64 → 61,63
// first argument is the OGC standard functionname, second the name as
// it occurs in the spatial dialect
registerFunction("dimension", new StandardSQLFunction("dimension",
Hibernate.INTEGER));
StandardBasicTypes.INTEGER));
registerFunction("geometrytype", new StandardSQLFunction(
"geometrytype", Hibernate.STRING));
"geometrytype", StandardBasicTypes.STRING));
registerFunction("srid", new StandardSQLFunction("srid",
Hibernate.INTEGER));
StandardBasicTypes.INTEGER));
registerFunction("envelope", new StandardSQLFunction("envelope",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
registerFunction("astext", new StandardSQLFunction("astext",
Hibernate.STRING));
StandardBasicTypes.STRING));
registerFunction("asbinary", new StandardSQLFunction("asbinary",
Hibernate.BINARY));
StandardBasicTypes.BINARY));
registerFunction("isempty", new StandardSQLFunction("isempty",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("issimple", new StandardSQLFunction("issimple",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("boundary", new StandardSQLFunction("boundary",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
 
// Register functions for spatial relation constructs
registerFunction("overlaps", new StandardSQLFunction("overlaps",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("intersects", new StandardSQLFunction("intersects",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("equals", new StandardSQLFunction("equals",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("contains", new StandardSQLFunction("contains",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("crosses", new StandardSQLFunction("crosses",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("disjoint", new StandardSQLFunction("disjoint",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("touches", new StandardSQLFunction("touches",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("within", new StandardSQLFunction("within",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
registerFunction("relate", new StandardSQLFunction("relate",
Hibernate.BOOLEAN));
StandardBasicTypes.BOOLEAN));
 
// register the spatial analysis functions
registerFunction("distance", new StandardSQLFunction("distance",
Hibernate.DOUBLE));
StandardBasicTypes.DOUBLE));
registerFunction("buffer", new StandardSQLFunction("buffer",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
registerFunction("convexhull", new StandardSQLFunction("convexhull",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
registerFunction("difference", new StandardSQLFunction("difference",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
registerFunction("intersection", new StandardSQLFunction(
"intersection", new CustomType(PGGeometryUserType.class, null)));
"intersection", geometryCustomType));
registerFunction("symdifference",
new StandardSQLFunction("symdifference", new CustomType(
PGGeometryUserType.class, null)));
new StandardSQLFunction("symdifference",geometryCustomType));
registerFunction("geomunion", new StandardSQLFunction("geomunion",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
//register Spatial Aggregate funciton
registerFunction("extent", new StandardSQLFunction("extent",
new CustomType(PGGeometryUserType.class, null)));
geometryCustomType));
 
}
 
/branches/hibernate-3.6-integration/hibernate-spatial-postgis/pom.xml
42,17 → 42,38
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>provided</scope>
<version>[8.1-407.jdbc3,)</version>
<version>8.1-407.jdbc3</version>
</dependency>
 
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<version>3.6.0-SNAPSHOT</version>
<version>3.6.0-SNAPSHOT</version>
</dependency>
 
</dependencies>
 
<!--<profiles>-->
<!--<profile>-->
<!--<id>automated-unit-testsuite-suite</id>-->
<!--<build>-->
<!--<testResources>-->
<!--<testResource>-->
<!--<filtering>false</filtering>-->
<!--<directory>src/testsuite-suite/java</directory>-->
<!--<includes>-->
<!--<include>**/*.xml</include>-->
<!--</includes>-->
<!--</testResource>-->
<!--<testResource>-->
<!--<filtering>true</filtering>-->
<!--<directory>src/testsuite-suite/resources/automated</directory>-->
<!--</testResource>-->
<!--</testResources>-->
<!--</build>-->
<!--</profile>-->
<!--</profiles>-->
 
<distributionManagement>
<site>
<id>Hibernate Spatial site</id>