It try to use the rollback feature but it doesnt seems to work.
im using
<springframework.version>3.2.1.RELEASE</springframework.version>
<hibernate.version>4.2.1.Final</hibernate.version>
<spring-data-jpa.version>1.3.1.RELEASE</spring-data-jpa.version>
<spring-dbunit.version>1.1.12</spring-dbunit.version>
Here my log
https://gist.github.com/regis-leray/f5fbd8aa4f6e5e475057
In my junit test
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/applicationContext-int.xml")
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
TransactionalTestExecutionListener.class,
RollbackTransactionalDataSetTestExecutionListener.class })
@TransactionConfiguration(defaultRollback = true)
@Transactional
@DataSet(locations = {"dataset_configuration.xml"}, dbType = DBType.POSTGRESQL)
public class ITConfigurationServiceImplTest {
@Autowired
ConfigurationService configurationService;
@Test
public void shouldSaveConfiguration(){
ConfigurationTO to = new ConfigurationTO();
to.setKey("newKey");
to.setValue("newValue");
configurationService.saveConfiguration(to);
to = configurationService.getConfiguration("newKey");
assertNotNull(to);
assertEquals(to.getValue(), "newValue");
}
}
in My applicationContext-datasource xml file
<!-- Database configuration ==================================================================================== -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${app.db_hibernate_dialect}</prop>
<prop key="hibernate.show_sql">${app.showSql:false}</prop>
<prop key="hibernate.hbm2ddl.auto">${app.hbm2ddl:validate}</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache:true}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache:true}</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">ehcache-${app.ehcachemode}.xml</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
<property name="driverClassName" value="${app.db_driver}" />
<property name="url" value="${app.db_url}" />
<property name="username" value="${app.db_username}" />
<property name="password" value="${app.db_password}" />
<property name="maxWait" value="${datasource.maxWait:30000}" />
<!-- The initial number of connections that are created when the pool is started -->
<property name="initialSize" value="${datasource.initialSize:10}" />
<!-- The maximum number of active connections that can be allocated from this pool at the same time. -->
<property name="maxActive" value="${datasource.maxActive:20}" />
<!-- The maximum number of connections that should be kept in the pool at all times -->
<property name="maxIdle" value="${datasource.maxIdle:20}" />
</bean>
Also the transaction management is working well my test shouldSaveConfiguration() doesnt create a record in the database, but the dbunit dataset is not remove from the database table.
If i have time , l will run the unit test of spring dbunit with postgres 9 with the rollback feature
PS:
I find a way to resolve that with the dbunit feature
@DataSet(locations = {"dataset_configuration.xml"}, dbType = DBType.POSTGRESQL), tearDownOperation = DBOperation.DELETE_ALL)
It try to use the rollback feature but it doesnt seems to work.
im using
Here my log
https://gist.github.com/regis-leray/f5fbd8aa4f6e5e475057
In my junit test
in My applicationContext-datasource xml file
Also the transaction management is working well my test shouldSaveConfiguration() doesnt create a record in the database, but the dbunit dataset is not remove from the database table.
If i have time , l will run the unit test of spring dbunit with postgres 9 with the rollback feature
PS:
I find a way to resolve that with the dbunit feature