strange error when running all the tests

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

strange error when running all the tests

Sebaso
Hi All,

I have several tests that load data into a in memory derby with

    @BeforeClass
    public static void setUpClass() throws Exception {
        emf = Persistence.createEntityManagerFactory("testBase");
        em = emf.createEntityManager();

        // Initializes DBUnit
        connection = new DatabaseConnection(((EntityManagerImpl) (em.getDelegate())).getServerSession().getAccessor().getConnection());
        dataset = new FlatXmlDataSetBuilder().build(Thread.currentThread().getContextClassLoader().getResourceAsStream("dataset.xml"));
    }


    @Before
    public void setUp() throws Exception{
         tx = em.getTransaction();
         em.clear();
         DatabaseOperation.CLEAN_INSERT.execute(connection,dataset);
    }



they work great if run individually....

but If I run them via mvn test I get this kind of errors:

java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'POLICY' caused a violation of foreign key constraint 'BNDERBREACHPLICYID' for key (1).  The statement has been rolled back.

any ideas ?

Thanks

--
Sebastian E. Ovide





------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: strange error when running all the tests

Sebaso
I suspect that it is related to having a DB not clean after each test.

Is it possible to delete/drop a whole schema ?

On Thu, Jun 2, 2011 at 3:28 PM, Sebastian E. Ovide <[hidden email]> wrote:
Hi All,

I have several tests that load data into a in memory derby with

    @BeforeClass
    public static void setUpClass() throws Exception {
        emf = Persistence.createEntityManagerFactory("testBase");
        em = emf.createEntityManager();

        // Initializes DBUnit
        connection = new DatabaseConnection(((EntityManagerImpl) (em.getDelegate())).getServerSession().getAccessor().getConnection());
        dataset = new FlatXmlDataSetBuilder().build(Thread.currentThread().getContextClassLoader().getResourceAsStream("dataset.xml"));
    }


    @Before
    public void setUp() throws Exception{
         tx = em.getTransaction();
         em.clear();
         DatabaseOperation.CLEAN_INSERT.execute(connection,dataset);
    }



they work great if run individually....

but If I run them via mvn test I get this kind of errors:

java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'POLICY' caused a violation of foreign key constraint 'BNDERBREACHPLICYID' for key (1).  The statement has been rolled back.

any ideas ?

Thanks

--
Sebastian E. Ovide







--
Sebastian E. Ovide





------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today.
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user