first test OK, but then I get an exception

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

first test OK, but then I get an exception

Vincent F.
Hi,

I have a problem and I understand it, but I don't see any solution to it for the moment, so I hope you can help me.

I am using Derby Embedded driver, and my dataset looks like this:

        <APP.partner name="partnertest" />

        <APP.promotion code="promoCode1"
                              partner="1" />

I am using a FlatXmlDataSetBuilder and my setup/teardown operations are as follow:


         protected DatabaseOperation getSetUpOperation()
    {
                return DatabaseOperation.CLEAN_INSERT;
    }


        protected DatabaseOperation getTearDownOperation()
    {
        return DatabaseOperation.NONE;
    }


It works fine if I have only one test in my testCase: Partner is inserted and is assigned the ID "1", then Promotion is inserted and the link to Partner is done. Now when I add another test, it is failing because DbUnit is trying to insert a Promotion with a link to a Partner that doesn't exist.

I have tried to do the same with a FilteredDataset:

        protected IDataSet getDataSet() throws Exception {

                 FlatXmlDataSetBuilder builder=new FlatXmlDataSetBuilder();
                 IDataSet dataset=builder.build(new ClassPathResource(dataSetFile).getInputStream());
                 return new FilteredDataSet(new DatabaseSequenceFilter(getConnection()), dataset);
        }

But I get a CyclicTablesDependencyException because somewhere in my database I have a table user and a table billing info, and they are referencing each other (a user has a billing info, and a billing info has a user).So it looks like I can't use the DatabaseSequenceFilter..

Is there a solution to my problem ?  a workaround, something ?

Thanks in advance for your help.

--
Vincent
Reply | Threaded
Open this post in threaded view
|

Re: first test OK, but then I get an exception

Evguen
Vincent F. wrote
Hi,

I have a problem and I understand it, but I don't see any solution to it for the moment, so I hope you can help me.

[...]

But I get a CyclicTablesDependencyException because somewhere in my database I have a table user and a table billing info, and they are referencing each other (a user has a billing info, and a billing info has a user).So it looks like I can't use the DatabaseSequenceFilter..

Is there a solution to my problem ?  a workaround, something ?
Hello, I have exactly the same trouble. I glanced all over the web finding only javadoc for this class...
Did you find a solution ?

Best Regards

Evguen
Reply | Threaded
Open this post in threaded view
|

Re: first test OK, but then I get an exception

Vincent F.
sorry, I don't remember ever finding a solution for that. I think I gave up at some point.
Reply | Threaded
Open this post in threaded view
|

Re: first test OK, but then I get an exception

boly38
Hi
 i got this org.dbunit.database.CyclicTablesDependencyException too..

 seems like there is a related feature request (sourceforge / dbunit) feature-requests 169 (pending state)

 I'm interested if there is a workaround.

  Maybe there is a way to export a subset of table or exclude some table (instead of full export as in demoimportexport sample )

 does exist another sample to do this ??

Thanks