ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <erlend.bjo...@aftenposten.no>
Subject Automatic rollback with Spring for junit tests ?
Date Tue, 03 Oct 2006 14:07:53 GMT
Hi there!

 

I'm trying to set up some junit tests and want to take automatically a rollback for each test,
in a Spring context.

 

Any clues how to set this property transactionManager (see below for the error) correctly
in Spring ? 

 

I have tried to use the AbstractTransactionalSpringContextTests feature from Spring without
any luck so far.

With the AbstractSpringContextTests it works fine.

 

 

Thanks,

Erlend

 

--

 

I get this error:

 

..

..

2006-10-03 15:53:01,734 [INFO      ] [main      ] org.springframework.context.support.ClassPathXmlApplicationContext
- Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@19836ed]

2006-10-03 15:53:01,734 [INFO      ] [main      ] org.springframework.context.support.ClassPathXmlApplicationContext
- Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using
default [org.springframework.context.event.SimpleApplicationEventMulticaster@1afae45]

2006-10-03 15:53:01,734 [INFO      ] [main      ] org.springframework.beans.factory.support.DefaultListableBeanFactory
- Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [configurator,sqlMapClient,sqlMapClientTemplate,contactDao,dataSource]; root
of BeanFactory hierarchy]

 

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with
name 'no.aftenposten.contactinfo.dao.ibatis.ContactDaoTest': Unsatisfied dependency expressed
through bean property 'transactionManager': set this property value or disable dependency
checking for this bean

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.checkDependencies(AbstractAutowireCapableBeanFactory.java:995)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:856)

            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:227)

            at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:187)

            at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

            at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

--

 

My spring-dao.xml ...

 

     <!-- Section 4 -->

    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">

        <property name="configLocation">

            <value>classpath:sql/SqlMap-config.xml</value>

        </property>

        <property name="useTransactionAwareDataSource">

            <value>false</value>

        </property>

        <property name="dataSource">

            <ref bean="dataSource"/>

        </property>

    </bean>

 

    <!-- Section 5 -->

    <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">

        <property name="sqlMapClient">

            <ref bean="sqlMapClient"/>

        </property>

    </bean>

 

    <!-- Section 6 -->

    <bean id="contactDao" class="no.aftenposten.contactinfo.dao.ibatis.ContactDaoImpl">

        <property name="sqlMapClient">

            <ref bean="sqlMapClient"/>

        </property>

    </bean>

 

    <!-- javax.sql.DataSource supplied by Jakarta Commons Connection Pooling -->

    <bean id="dataSource" lazy-init="true" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">

        <property name="driverClassName">

            <value>${application.db.driver}</value>

        </property>

        <property name="url">

            <value>${application.db.url}</value>

        </property>

        <property name="username">

            <value>${application.db.username}</value>

        </property>

        <property name="password">

            <value>${application.db.password}</value>

        </property>

    </bean>


Mime
View raw message