The ContextSensitiveTests fail on few machines with
TableNotFoundException when including
event-api tests jar. The
sessionFactory bean definition in TestingApplicationContext doesn’t include the
test-hibernate.cfg.xml configLocation. The tests fail if spring uses this definition of
sessionFactory bean because it cannot find the tables referred in
We are using
event-module in our project and we started writing
ContextSensitiveTests for the last few days back. Since the time we have added the
event-api-tests.jar we have seeing flaky test failure with errors as
NoSuchTableException for our local tables. It doesn’t fail on all machines but on some machines it fails. Our tables has been referred in
test-hibernate.cfg.xml in our local omod.
We started debugging this problem and figured out
sessionFactory#configLocations is populated with just one location(
classpath:hibernate.cfg.xml) in the scenarios the tests are failing. The scenarios where it passes the same is populated with two locations (
We started checking if there is a
sessionFactory bean getting defined with just one location in any of the
TestingApplicationContext.xml including our libraries. We found out the
event-api does that and we have started seeing the failure after including the
We suspected this might be happening because of which definition of
sessionFactory spring is useing in a test run. To fix this problem we added a blank
test-hibernate.cfg.xml in our
event-api fork and mentioned that in the
event-api, so if spring uses this definition of
sessionFactory it doesn’t ignore the
test-hibernate.cfg.xml present in our local module files.
- While we have tested with the fix above and it is working, is there another way of fixing this problem?
- Has anyone else used
event-api-testsjar and faced a similar problem?