*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/ \r
+*/\r
\r
package eu.etaxonomy.cdm.database;\r
\r
private static final Logger logger = Logger.getLogger(TestingTermInitializer.class);\r
\r
private DataSource dataSource;\r
- \r
+\r
private Resource termsDataSet;\r
- \r
+\r
private Resource termsDtd;\r
- \r
+\r
public void setTermsDataSet(Resource termsDataSet) {\r
this.termsDataSet = termsDataSet;\r
}\r
- \r
+\r
public void setTermsDtd(Resource termsDtd) {\r
this.termsDtd = termsDtd;\r
}\r
public void setDataSource(DataSource dataSource) {\r
this.dataSource = dataSource;\r
}\r
- \r
+\r
\r
@PostConstruct\r
@Override\r
public void initialize() {\r
super.initialize();\r
}\r
- \r
+\r
@Override\r
public void doInitialize(){\r
TransactionStatus txStatus = transactionManager.getTransaction(txDefinition);\r
try {\r
connection = getConnection();\r
IDataSet dataSet = new FlatXmlDataSet(new InputStreamReader(termsDataSet.getInputStream()),new InputStreamReader(termsDtd.getInputStream()));\r
- \r
+\r
DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);\r
} catch (Exception e) {\r
logger.error(e);\r
logger.error(sqle);\r
}\r
}\r
- \r
+\r
transactionManager.commit(txStatus);\r
- \r
+\r
+ txStatus = transactionManager.getTransaction(txDefinition);\r
for(VocabularyEnum vocabularyType : VocabularyEnum.values()) {\r
Class<? extends DefinedTermBase<?>> clazz = vocabularyType.getClazz();\r
UUID vocabularyUuid = vocabularyType.getUuid();\r
secondPass(clazz, vocabularyUuid,new HashMap<UUID,DefinedTermBase>());\r
}\r
+ transactionManager.commit(txStatus);\r
+ //txStatus = transactionManager.getTransaction(txDefinition);\r
}\r
\r
protected IDatabaseConnection getConnection() throws SQLException {\r
/**\r
* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
*\r
*/\r
public class DaoBaseTest extends CdmIntegrationTest {\r
- \r
- \r
- @SpringBeanByType\r
- private TaxonDaoHibernateImpl daoBaseTester;\r
- \r
+\r
+\r
+ @SpringBeanByType\r
+ private TaxonDaoHibernateImpl daoBaseTester;\r
+\r
/************ TESTS ********************************/\r
\r
- /**\r
- * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBase#getSession()}.\r
- */\r
- @Test\r
- public void testGetSession() {\r
- assertNotNull(daoBaseTester.getSession());\r
- }\r
+ /**\r
+ * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBase#getSession()}.\r
+ */\r
+ @Test\r
+ public void testGetSession() {\r
+ assertNotNull(daoBaseTester.getSession());\r
+ }\r
}\r
+#\r
+# NOTE:\r
+# additional hibernate properites are found in\r
+# /cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/applicationContext-test.xml\r
+#\r
hibernate.dialect=org.hibernate.dialect.HSQLCorrectedDialect\r
hibernate.connection.driver_class=org.hsqldb.jdbcDriver\r
hibernate.connection.url=jdbc:hsqldb:mem:cdm\r
<?xml version="1.0" encoding="UTF-8"?>\r
<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:context="http://www.springframework.org/schema/context"\r
- xmlns:tx="http://www.springframework.org/schema/tx"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans \r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xmlns:context="http://www.springframework.org/schema/context"\r
+ xmlns:tx="http://www.springframework.org/schema/tx"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/beans\r
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
http://www.springframework.org/schema/context\r
http://www.springframework.org/schema/context/spring-context-2.5.xsd\r
- http://www.springframework.org/schema/tx \r
+ http://www.springframework.org/schema/tx\r
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
\r
<!-- requires at least spring 2.5.4 <context:property-override location="classpath:eu/etaxonomy/cdm/persistence/override.properties"/>-->\r
+\r
+ <import resource="classpath:/eu/etaxonomy/cdm/persistence.xml" />\r
<bean id="dataSource" class="org.unitils.database.UnitilsDataSourceFactoryBean"/>\r
- \r
- <!-- exclude persistent term initializer as we want to use the TestingTermInitializer instead --> \r
+\r
+ <!-- exclude persistent term initializer as we want to use the TestingTermInitializer instead -->\r
<context:component-scan base-package="eu/etaxonomy/cdm">\r
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.database\.PersistentTermInitializer"/>\r
</context:component-scan>\r
- \r
+\r
<bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">\r
<property name="providers">\r
<list>\r
</list>\r
</property>\r
</bean>\r
- \r
+\r
<!-- enable the configuration of transactional behavior based on annotations -->\r
- <tx:annotation-driven transaction-manager="transactionManager"/> \r
- \r
+ <tx:annotation-driven transaction-manager="transactionManager"/>\r
+\r
<bean id="termInitializer" class="eu.etaxonomy.cdm.database.TestingTermInitializer">\r
<property name="termsDataSet" value="classpath:/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml"/>\r
<property name="termsDtd" value="classpath:/eu/etaxonomy/cdm/persistence/dao/hibernate/dataset.dtd"/>\r
</bean>\r
- \r
- <bean id="hibernateProperties" \r
+\r
+ <bean id="hibernateProperties"\r
class="org.springframework.beans.factory.config.PropertiesFactoryBean">\r
+ <!--\r
+ NOTE:\r
+ additional hibernate properites are found in\r
+ /cdmlib-persistence/src/test/resources/dbscripts/hibernate.properties\r
+ -->\r
<property name="properties">\r
<props>\r
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLCorrectedDialect</prop>\r
<prop key="hibernate.search.default.indexBase">./target/test-classes</prop>\r
</props>\r
</property>\r
- </bean> \r
- \r
- <bean id="taxonSpellingDirectory" class="org.springmodules.lucene.index.support.FSDirectoryFactoryBean">\r
+ </bean>\r
+\r
+ <bean id="taxonSpellingDirectory" class="org.springmodules.lucene.index.support.FSDirectoryFactoryBean">\r
<property name="location" value="file:./target/test-classes/eu.etaxonomy.cdm.model.taxon.TaxonBase_spelling"/>\r
<property name="create" value="false"/>\r
</bean>\r
\r
- \r
- <import resource="classpath:/eu/etaxonomy/cdm/persistence.xml" />\r
- \r
</beans>
\ No newline at end of file
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
-### log transaction activity
-#log4j.logger.org.hibernate.transaction=debug
+### log transaction management & binding
+log4j.logger.org.hibernate.transaction=debug
+log4j.logger.org.springframework.transaction.support.TransactionSynchronizationManager=trace
+#log4j.logger.org.springframework.orm.hibernate3.HibernateTransactionManager=trace
+log4j.logger.org.springframework.orm.hibernate3=trace
+
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=info
# NOTE: this is the unitils.properties file for the cdmlib-persitence module\r
# a separate unitils.properties exists for cdmlib-io\r
#\r
-\r
+#\r
+# the list of all properties is found in\r
+# http://unitils.org/unitils-default.properties\r
+#\r
+#######################################################################################\r
+#\r
# List of modules that is loaded. Overloading this list is normally not useful, unless you want to add a custom\r
# module. Disabling a module can be performed by setting unitils.module.<modulename>.enabled to false.\r
# If a module's specific dependencies are not found (e.g. hibernate is not in you classpath), this module is not loaded,\r
unitils.module.easymock.enabled=false\r
unitils.module.mock.enabled=false\r
\r
+\r
database.driverClassName=org.hsqldb.jdbcDriver\r
database.url=jdbc:hsqldb:mem:cdm\r
database.userName=sa\r
database.password=\r
database.dialect=hsqldb\r
database.schemaNames=PUBLIC\r
+\r
org.dbunit.dataset.datatype.IDataTypeFactory.implClassName.hsqldb=eu.etaxonomy.cdm.test.integration.HsqldbDataTypeFactory\r
\r
dbMaintainer.script.locations=src/test/resources/dbscripts\r
dbMaintainer.dbVersionSource.autoCreateVersionTable=true\r
dbMaintainer.autoCreateExecutedScriptsTable=true\r
\r
+# If set to commit, each test is run in a transaction, which is committed.\r
DatabaseModule.Transactional.value.default=commit\r
-transactionManager.type=spring\r
+\r
+# org.unitils.database.transaction.impl.DefaultUnitilsTransactionManager is used by default:\r
+#\r
+# Implements transactions for unit tests, by delegating to a spring PlatformTransactionManager.\r
+# The concrete implementation of PlatformTransactionManager that is used depends on the test class.\r
+# If a custom PlatformTransactionManager was configured in a spring ApplicationContext, this one is used.\r
+# If not, a suitable subclass of PlatformTransactionManager is created, depending on the configuration\r
+# of a test. E.g. if some ORM persistence unit was configured on the test, a PlatformTransactionManager\r
+# that can offer transactional behavior for such a persistence unit is used.\r
+# If no such configuration is found, a DataSourceTransactionManager is used.\r
+#\r
+# org.unitils.database.transaction.UnitilsTransactionManager.implClassName=org.unitils.database.transaction.impl.SpringTransactionManager\r
+\r
updateDataBaseSchema.enabled=true\r
\r
dataSetStructureGenerator.xsd.dirName=src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/\r