tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikolaos Mpallas" <>
Subject RE: EJB testing with Hibernate + Maven + JUnit
Date Wed, 29 Jul 2009 06:07:06 GMT
I have setup exactly the same environment for regression testing and I use
Take into account that the openejb server in order to conform with the JSR
scans the directories
To find an orm.xml file which holds the mapping of entities/tables. If you
have an orm.xml and another
File which also contains the same mappings then u have problem. Now
regarding the issues:

1)In either case u can use an openejb.xml file in order to declare testing
and production datasources
And then inject them where exactly u want.That's an easy task if u read the
tutorial in site of openejb
Which explains how datasources are managed. I must pin point though that
Datasource in openejb can be declared
Programmatically  as JNDI Context and attributes. Again a read in the
tutorial will help you.
2)What is recommended for testing/production/regression testing is:
  a)You declare 2 different persistent units in your persistence xml file.
One for production where u declare
     a datasource and a persistence unit and another one for testing
declared for example in your case hsqldb stuff.
  b)Run regression tests and u use the testing pu for the testing purposes
along with the test datasource..;)
3)My design was a bit clear on that. I use OpenEJB + Hibernate + TestNG for
a framework I have created for regression
  Testing. I have created an abstract class say SomethingTestCase which has
2 annotations provided by the TestNG framework.
  @BeforeSuite @AfterSuite. This means that the application server is
started/destroyed after all tests have run(partially true
  Depends on how u have setup your projects).Take into account when using
JUnit that JUnit 4 was inspired after TestNG.
I think OpenEJB in embedded mode + TestNG offer a very nice environment to
perform EJB 3 tests.Currently I hope I will find time in
Order to integrate openejb with TestNG so that the two tools cooperate very
well. My vision is to create a small lib in TestNG which
Will integrate automatically openejb with TestNG using annotations...

Hope it helped.


p.s.:If questions in setup send me direct email.
p.s.1: To all of the community...I think is time to create a forum cause
searching mailing lists isn't the best practice nowdays :)

-----Original Message-----
From: Ilane [mailto:Ilane.Walberg@Sun.COM] 
Sent: Tuesday, July 28, 2009 10:03 PM
Subject: EJB testing with Hibernate + Maven + JUnit

I am setting up some tests for existing session EJBs, basically for
regression testing purposes, but also to run automatically during builds. 
These EJBs are essentially a CRUD interface for the persisent entities using
Hibernate.  I'm not really an EJB3 expert and am struggling somewhat in
finding an OpenEJB tutorial which addresses my situation.  I have the
following issues I'm trying to resolve:

Note: The current system uses both Hibernate mapping files, persistence.xml
to define the data source, and EJB annotations.  The test database is
HSQLDB, the production db is mysql.

 * What is the proper way to set up (i.e. tell the framework to use) the
.hbm.xml mapping files?  (I had <mapping-file> set up in persistence.xml but
was getting "duplicate mapping" errors until I commented it out.)
 * How can I verify that the tests are actually using the database type I
want (HSQLDB)?  (I'm a little paranoid!)
 * What is the most appropriate way to clear the database in the setUp()

Thanks for any hints, pointers, references, and support you can provide.


View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message