tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: Externalize db access data for junit-testing
Date Wed, 13 Aug 2008 00:12:24 GMT
Hi Per,

On Aug 12, 2008, at 2:38 AM, Newgro wrote:

> first thanks to the openejb team for this great product. It helps  
> alot for
> ejb3. Wiki pages and forum support are great.

Thanks!  A very large percent of the docs come straight from the list,  
so a big thanks to all the people with questions/requests.  It's very  

> But i would like to "externalize" these parameters to an xml or  
> properties
> file.
> Is there a way to put my datasources to a place where openejb is  
> come along
> automatically? My tries to add them to openejb.xml failed.  
> Documentation
> point would help to (If this is already in the wiki - didn't found a  
> paper).

Sure, try this.  Create an openejb.xml file in any directory that gets  
added to your test classpath. For maven, something that winds up  
directly under "target/classes/" or "target/test-classes/" will work  
just fine.  Then in your test case do this:

     protected void setUp() throws Exception {
         Properties properties = new Properties();

         URL config =  

         initialContext = new InitialContext(properties);

The file itself doesn't have to be called "openejb.xml", you could  
have a few different files like that for different testing scenarios  
each with a name that describes the basic setup.


View raw message