Closed hwaastad closed 8 years ago
Hi @hwaastad,
I didn't tried but looks like a nice idea!
Do you know if ApplicationComposer runner can treat the test class as a CDI bean? this is needed so dbunit interceptor can intercept test methods in order to seed database.
Another option is to use Dbunit Rule, in this case the test class doesn't need to be a cdi bean.
I'll have a look over the weekend, thank you for the feedback!
Hi, I think both appcomposer and dbunit rules can be chained.
I've done some initial testing and hav an issue with getting the PU correctly.
/hw
Hi, great!
About the pu issue you may be having trouble to get the jdbc connection, right?
this project comes with a utility to look up PU, ex:
@Rule
public EntityManagerProvider emProvider = EntityManagerProvider.instance("rules-it");
with this emProvider you can retrieve the jdbc connection to use DBUnit rule BUT it only works for resource_local units and I think app copmposer uses managed ones
If that's the case then you can get jdbc connection from entity manager, look here for an example.
Hi @hwaastad , I've added an example of dbunit and application composer rules integration here: https://github.com/rmpestano/tomee/blob/master/examples/application-composer-dbunit/src/test/java/org/superbiz/composed/MoviesTest.java#L71
Let me know If it solves your case.
Hi, great work! I've been following the discussion with Romain and I'm pleased that you got it working.
a couple of comments:
Not sure if I need to care about this one, but just wanted to check with you :-)
br hw
Hi,
About 1 there is no need to use RESOURCE_LOCAL entity manager, dbunit rule just needs a JDBC connection. The utility component which comes with this rule, EntityManagerProvider, is the one which only works with RESOUCE_LOCAL em.
About 2 I've created an issue (#34).
Thank you very much for your feedback.
Hi, not really an issue, but have you tried to integrate the cdi module with TomEE ApplicationComposer?
btw, great job :-)