Application Name: Platform
Version Number: 2.0.5
I have a suite of test cases in JUnit that call
BaseContextSensitiveTest.executeDataSet in an @Before annotated method in some tests, and others tests call
executeDataSet in the test method itself. In later tests after loading data for several tests beforehand, I get a SQL error saying I’m breaking a foreign key constraint. However, the foreign key error references a table that doesn’t have data loaded in the current test class, but that was loaded in previous test classes.
When I step through the code, I see that
BaseContextSensitiveTest.closeSessionAfterEachClass gets called at the correct time. After stepping into
getConnection(), an error occurs. Spring returns the correct bean for the session factory, but after calling
getCurrentSession(), a null value is returned and an error is thrown when trying to call
doReturningWork. I’ve checked and tried to call
getConnection() from within an method with an @After attribute and everything works. When I try to delete all data in the @Before method or at other times, I seemingly get an infinite loop.
Does anyone have any insight into why this is the case and the data isn’t being cleared? Is there a problem with calling
executeDataSet at the wrong time? @dkayiwa I see you first made the change to delete data in the @AfterClass method. Any thoughts?
For additional information, I have a module, OpenHMIS Cashier, running on platform 1.9.9 that I’m trying to update to 2.0.5.