Enable/Disable a database trigger when running a dbunit test



Hi
I've created a testcase extending the
AbstractTransactionalDataSourceSpringContextTests. This testclass is
infact a dbunit test. I prepopulate the database with my own data,
perform a test and afterwords everything is rollbacked by the
TransactionalSpringTest (so original data in the db is preserved, my
own testdata should only exist in the test).
The dabase id's in this database are generated by a trigger. This
trigger calls the sequencer to create the next value. I don't want
this behaviour for my data I put in the table when running the test.
I want to define my own id's (so I can catchup the records after
calling te classToTest to check the changed values of this record)
To overcome this I ran an sql statement to disable the trigger. after
that I insert my own data and then I enable the trigger again. Than I
call the method I want to test on the classToTest. I've noticed that
the transaction is commited after enabling the trigger: the original
data in the database is lost, the testdata is now in place.

Is there a way to overcome this? (It's not an option to let our
sofware call the sequencer before inserting data so we don't need a
trigger anymore)

Normal flow dbunit test:
1) open transaction
2) insert testdata
3) perform test
4) verify test results
5) rollback transaction

--> gives normal behaviour

In my case:
1) open transaction
2) disable trigger
3) insert testdata
4) enable trigger
5) perform test
6) verify test
7) rollback transaction

--> original data is lost, testdata is commited to database.

Thanks for the advice/help!

Regards
.



Relevant Pages

  • Re: Enable/Disable a database trigger when running a dbunit test
    ... The dabase id's in this database are generated by a trigger. ... that the transaction is commited after enabling the trigger: ... original data in the database is lost, the testdata is now in place. ...
    (comp.lang.java.help)
  • Re: huge log file when inserting data
    ... Nothing else is running on the database. ... No trigger. ... The insert is in a transaction and it is committed. ... >space requirements. ...
    (microsoft.public.sqlserver.server)
  • Re: Auditing changes made to table design (syscolumns table)
    ... With out using profiler the only way I know of is to get this info from the ... Keep in mind I know the database and the tables I would ... I attempted to write a trigger to log when a change was made to the ... > certain criteria against every transaction. ...
    (microsoft.public.sqlserver.security)
  • Re: Enable/Disable a database trigger when running a dbunit test
    ... The dabase id's in this database are generated by a trigger. ... that the transaction is commited after enabling the trigger: ... rollback transaction ...
    (comp.lang.java.help)
  • Re: Transaction log and trigger
    ... You would have to "recover" the database to re-create the trigger. ... and then apply transaction log which was backed up for the next hour(by this ...
    (microsoft.public.sqlserver.server)