| /branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/PostgisExpectationsFactory.java |
|---|
| 27,6 → 27,7 |
| import com.vividsolutions.jts.geom.Geometry; |
| import org.hibernatespatial.test.AbstractExpectationsFactory; |
| import org.hibernatespatial.test.DataSourceUtils; |
| import org.hibernatespatial.test.NativeSQLStatement; |
| /** |
| 38,8 → 39,8 |
| private final PGGeometryUserType decoder = new PGGeometryUserType(); |
| public PostgisExpectationsFactory() { |
| super("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate()); |
| public PostgisExpectationsFactory(DataSourceUtils utils) { |
| super(utils, new PostgisExpressionTemplate()); |
| } |
| @Override |
| /branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/java/org/hibernatespatial/postgis/PostgisTestSupportFactory.java |
|---|
| 1,5 → 1,6 |
| package org.hibernatespatial.postgis; |
| import org.hibernate.cfg.Configuration; |
| import org.hibernate.testing.junit.functional.FunctionalTestCase; |
| import org.hibernatespatial.test.*; |
| 10,8 → 11,12 |
| public class PostgisTestSupportFactory implements TestSupportFactory { |
| public DataSourceUtils createDataSourceUtil(FunctionalTestCase testcase) { |
| return new DataSourceUtils("hibernate-spatial-postgis-test.properties", new PostgisExpressionTemplate()); |
| public DataSourceUtils createDataSourceUtil(Configuration configuration) { |
| String jdbcUrl = configuration.getProperty("hibernate.connection.url"); |
| String jdbcUser = configuration.getProperty("hibernate.connection.username"); |
| String jdbcPass = configuration.getProperty("hibernate.connection.password"); |
| String jdbcDriver = configuration.getProperty("hibernate.connection.driver_class"); |
| return new DataSourceUtils(jdbcDriver, jdbcUrl, jdbcUser, jdbcPass, new PostgisExpressionTemplate()); |
| } |
| public TestData createTestData(FunctionalTestCase testcase) { |
| 26,8 → 31,8 |
| return new GeometryEquality(); |
| } |
| public AbstractExpectationsFactory createExpectationsFactory() { |
| return new PostgisExpectationsFactory(); |
| public AbstractExpectationsFactory createExpectationsFactory(DataSourceUtils dataSourceUtils) { |
| return new PostgisExpectationsFactory(dataSourceUtils); |
| } |
| /branches/hibernate-3.6-integration/hibernate-spatial-postgis/src/test/resources/hibernate-spatial-postgis-test.properties |
|---|
| File deleted |
| /branches/hibernate-3.6-integration/hibernate-spatial-postgis/pom.xml |
|---|
| 53,27 → 53,6 |
| </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> |
| /branches/hibernate-3.6-integration/test-suite/src/test/java/org/hibernatespatial/testsuite/SpatialFunctionalTestCase.java |
|---|
| 1,5 → 1,6 |
| package org.hibernatespatial.testsuite; |
| import org.hibernate.cfg.Configuration; |
| import org.hibernate.testing.junit.functional.FunctionalTestCase; |
| import org.hibernatespatial.test.*; |
| 20,10 → 21,11 |
| public void prepareTest(){ |
| try { |
| TestSupportFactory tsFactory = TestSupportFactories.instance().getTestSupportFactory(getDialect()); |
| dataSourceUtils = tsFactory.createDataSourceUtil(this); |
| Configuration cfg = getEnvironment().getConfiguration(); |
| dataSourceUtils = tsFactory.createDataSourceUtil(cfg); |
| expectationsFactory = tsFactory.createExpectationsFactory(dataSourceUtils); |
| testData = tsFactory.createTestData(this); |
| geometryEquality = tsFactory.createGeometryEquality(); |
| expectationsFactory = tsFactory.createExpectationsFactory(); |
| } catch (Exception e) { |
| throw new RuntimeException(e); |
| /branches/hibernate-3.6-integration/hibernate-spatial/src/test/java/org/hibernatespatial/test/TestSupportFactory.java |
|---|
| 1,5 → 1,6 |
| package org.hibernatespatial.test; |
| import org.hibernate.cfg.Configuration; |
| import org.hibernate.testing.junit.functional.FunctionalTestCase; |
| 8,12 → 9,13 |
| * creation-date: Sep 30, 2010 |
| */ |
| public interface TestSupportFactory { |
| public DataSourceUtils createDataSourceUtil(FunctionalTestCase testcase); |
| public DataSourceUtils createDataSourceUtil(Configuration configuration); |
| public TestData createTestData(FunctionalTestCase testcase); |
| public GeometryEquality createGeometryEquality(); |
| public AbstractExpectationsFactory createExpectationsFactory(); |
| public AbstractExpectationsFactory createExpectationsFactory(DataSourceUtils dataSourceUtils); |
| } |
| /branches/hibernate-3.6-integration/hibernate-spatial/src/test/java/org/hibernatespatial/test/DataSourceUtils.java |
|---|
| 50,14 → 50,16 |
| private static Logger LOGGER = LoggerFactory.getLogger(DataSourceUtils.class); |
| private final String propertyFile; |
| private final SQLExpressionTemplate sqlExpressionTemplate; |
| private final String jdbcDriver; |
| private final String jdbcUrl; |
| private final String jdbcUser; |
| private final String jdbcPass; |
| private TestData testData; |
| private Properties properties; |
| private DataSource dataSource; |
| private static final String TEST_DATA_SET = "dataset"; |
| /** |
| * Constructor for the DataSourceUtils object. |
| * <p/> |
| 69,64 → 71,31 |
| * <li> driver: fully-qualified class name for the JDBC Driver</li> |
| * </il> |
| * |
| * @param propertyFile properties file for the database properties |
| * @param jdbcDriver |
| * @param jdbcUrl |
| * @param jdbcUser |
| * @param jdbcPass |
| * @param sqlExpressionTemplate SQLExpressionTemplate object that generates SQL statements for this database |
| */ |
| public DataSourceUtils(String propertyFile, SQLExpressionTemplate sqlExpressionTemplate) { |
| this.propertyFile = propertyFile; |
| public DataSourceUtils(String jdbcDriver, String jdbcUrl, String jdbcUser, String jdbcPass, SQLExpressionTemplate sqlExpressionTemplate) { |
| this.jdbcDriver = jdbcDriver; |
| this.jdbcUrl = jdbcUrl; |
| this.jdbcUser = jdbcUser; |
| this.jdbcPass = jdbcPass; |
| this.sqlExpressionTemplate = sqlExpressionTemplate; |
| readProperties(); |
| createBasicDataSource(); |
| loadTestObjects(); |
| } |
| private void readProperties() { |
| InputStream is = null; |
| try { |
| is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFile); |
| if (is == null) throw new RuntimeException(String.format("File %s not found on classpath.", propertyFile)); |
| properties = new Properties(); |
| properties.load(is); |
| } catch (IOException e) { |
| throw (new RuntimeException(e)); |
| } finally { |
| if (is != null) try { |
| is.close(); |
| } catch (IOException e) { |
| //nothing to do |
| } |
| } |
| } |
| private void createBasicDataSource() { |
| String url = properties.getProperty("jdbcUrl"); |
| String user = properties.getProperty("dbUsername"); |
| String pwd = properties.getProperty("dbPassword"); |
| String driverName = properties.getProperty("driver"); |
| BasicDataSource bds = new BasicDataSource(); |
| bds.setDriverClassName(driverName); |
| bds.setUrl(url); |
| bds.setUsername(user); |
| bds.setPassword(pwd); |
| bds.setDriverClassName(jdbcDriver); |
| bds.setUrl(jdbcUrl); |
| bds.setUsername(jdbcUser); |
| bds.setPassword(jdbcPass); |
| dataSource = bds; |
| } |
| /** |
| * loads the testsuite-suite objects |
| * <p/> |
| */ |
| private void loadTestObjects() { |
| testData = TestData.fromFile(properties.getProperty(TEST_DATA_SET)); |
| } |
| /** |
| * Return the testsuite-suite data set |
| */ |
| public TestData getTestData() { |
| return this.testData; |
| } |
| /** |
| * Returns a DataSource for the configured database. |
| * |
| * @return a DataSource |
| 173,15 → 142,6 |
| } |
| } |
| /** |
| * Insert all testsuite-suite data in the database |
| * |
| * @throws SQLException |
| */ |
| public void insertTestData() throws SQLException { |
| insertTestData(testData); |
| } |
| public void insertTestData(TestData testData) throws SQLException { |
| deleteTestData(); |
| Connection cn = null; |
| 275,7 → 235,7 |
| * @param type type of geometry |
| * @return map of identifier and JTS geometry |
| */ |
| public Map<Integer, Geometry> expectedGeoms(String type) { |
| public Map<Integer, Geometry> expectedGeoms(String type, TestData testData) { |
| Map<Integer, Geometry> result = new HashMap<Integer, Geometry>(); |
| EWKTReader parser = new EWKTReader(); |
| for (TestDataElement testDataElement : testData) { |
| /branches/hibernate-3.6-integration/hibernate-spatial/src/test/java/org/hibernatespatial/test/AbstractExpectationsFactory.java |
|---|
| 58,9 → 58,8 |
| private final DataSourceUtils dataSourceUtils; |
| private static final int MAX_BYTE_LEN = 1024; |
| public AbstractExpectationsFactory(String propertiesFile, SQLExpressionTemplate sqlExpressionTemplate) { |
| this.dataSourceUtils = new DataSourceUtils(propertiesFile, sqlExpressionTemplate); |
| public AbstractExpectationsFactory(DataSourceUtils dataSourceUtils, SQLExpressionTemplate sqlExpressionTemplate) { |
| this.dataSourceUtils = dataSourceUtils; |
| } |
| protected DataSourceUtils getDataSourceUtils() { |