-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: EJB3 - unitTest only entity managers...
PostPosted: Sat Jul 05, 2008 10:54 am 
Newbie

Joined: Tue Jan 11, 2005 6:48 am
Posts: 7
Hello,

I have a bit of a problem here with JPA, more specifically with the "persistence.xml" configuration file.

As I understand, each and every PersistenceUnit has to be declared in the "persistence.xml" file.
What I want is to declare 2 different Persistence units: one for production environment using a specific database and another one for testing purposes only (for this one, I'd use an in-memory Hypersonic DB).

What I would like is to have my unitTest-only-PersistenceUnit to be accessible directly in unittests (=> not in a JBoss managed environment) but I certainly DON'T want to have it even seen when deployed under JBoss.

In order to do so, my first idea would be to:
1: Declare my "production" PersistenceUnits in a file called "persistence.xml". This file would be automatically found by my application server.
2: Declare my test PersistenceUnit in another file (let's say persistence-test.xml". This file would not be seen by my appServer but could be specified manually in my J2SE unittest code (like this, for example: Persistence.createEntityManagerFactory(PERSISTENCE_XML_CONFIG_FILE_NAME, PERSISTENCE_UNIT_NAME);)

Problem is that I have to specify all the PersistenceUnits in the same single "persistence.xml" file... I can't just create 2 different persistence config files

Wouldn't it be easier for everybody if it was possible to give the name of a file playing the role of the "persistence.xml" file without forcibly being this file? That would help me a lot for my unit tests...

Don't know if that is clear enough. Anyway, thank you in advance for your responses.

Jer


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 19, 2008 6:33 am 
Newbie

Joined: Tue Jan 11, 2005 6:48 am
Posts: 7
Hello again,

I still haven't found any solution to that problem. I am currently writing tests in a dummy client application calling the beans to test from a deployed server...

I would really be grateful if somebody could at least give me pointers about how to make it possible to load a specific, test-only persistence.xml configuration file when running in test mode...

Your help would be greatly appreciated.

Thank you in advance,

Jérôme


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.