My test is just testing a StoredProcedure class, which i want to execute and rollback.
I pass a DataSource into the StoredProcedure....Code:
lt;bean id=quot;brokerTransactionAttemptquot; class=quot;payment.dao.storedprocedures.BrokerTransactionAttemptStoredProcedurequot;gt;
lt;constructor-arggt;lt;ref bean=quot;games3Datasourcequot; /gt; lt;/constructor-arggt;
lt;/beangt;
I also specify the transactionManager in my spring config:
Code:
lt;bean id=quot;transactionManagerquot; class=quot;org..jdbc.datasource.DataSourceTransactionManagerquot;gt;
lt;property name=quot;dataSourcequot; ref=quot;games3Datasourcequot;/gt;
lt;/beangt;
.... thats all i've read that im supposed to do. Shouldnt brokerTransactionAttempt be passed the transaction manager instead of the datasource?
My test loads brokerTransactionAttempt from the applicationContext and then executes it. But the data still ends up in the database - and i dont want it to.
Any thoughts?
Thanks
.... thats all i've read that im supposed to do. Shouldnt brokerTransactionAttempt be passed the transaction manager instead of the datasource?
No. You really need a datasource, how else would you connect to a database, your transactionmanager is useless for that.
Make sure that your test method is transactional else your normal transactional configuration applies.
Hi, i realise i need a datasource - maybe i wasnt clear.
Is just declaring it in the spring conf registering the datasource with the transaction manager?
So how to i make sure that my test method is transactional?
Reading the docs for AbstractTransactionalJUnit4SpringContextTests, it seems like it was going to do this for me.
Hi, it seems our db developer had put the commit instead the stored procedure, so i had no chance of this working from the start.
Thanks
Dave |