On May 8, 2008, at 1:11 PM, Gegas wrote:
Gegas wrote:
It's especially the persistence.xml that's my concern.
1. The src/main/resources/persistence.xml is mapped to my
production data
source
2. The src/test/resources/persistence.xml is mapped to a in-memory
database (HSQLDB)
The production ejb-jar.xml might contain security constraints etc.
not in
focus when testing etc.
What do yoy think? Is it possible to have different persistence.xml?
Kind regards, Andreas
I'm stupid... of course the persistence.xml in src/main/resources is
good
enough for both production and test!!!
Sorry for my stupid mistake :-(
Heh :) It's not so stupid as we did put some fancy code for mapping
the datasources to your persistence.xml without which you might
actually need to have separate persistence.xmls. But we work hard to
adapt things to the environment you setup so these kinds of issues are
avoided. And then of course we went the extra mile to make sure you
could setup your entire environment right in your test case, config
file free, which is nice icing on the cake. That also allows you to
shut off things like transaction or security processing, which can be
nice. Well, technically you're turning *on* the mock transaction
manager and/or security service we provide, but you get the idea :)
The one thing that you really might want a different persistence.xml
for is maybe there is some JPA provider specific property you use in
production that you don't want enabled in test (or vice versa). I
suspect that'll be a rare case, but it's certainly something to keep
an eye out for.
But(!), I still think it would be interesting to be able to split
test from
production using the "Maven" best practices.
Yea, it's definitely an idea to keep on the radar. We already do
allow you to supplement your testing with a separate set of test ejbs
which live in src/test/java and are configured via a src/test/
resources/META-INF/ejb-jar.xml, so we'd probably have to find a
different way to have a "test" ejb-jar.xml for the production ejbs in
src/main/java. Maybe something as simple as looking for a test.ejb-
jar.xml file which we'd prefer over the ejb-jar.xml for testing
purposes.
If the need comes up, definitely let us know.
-David