users@glassfish.java.net

Re: Embedded testing woes

From: Gregory Gerard <ggerard_at_mac.com>
Date: Wed, 07 Apr 2010 14:11:02 -0700

Hi, Laird,

I ran into the same issue. I was able to get automagical container configuration by putting a domain.xml into the package org.glassfish.embed:
src/test/resources/org/glassfish/embed/domain.xml

With that I was able to get my JDBC DataSources to resolve okay.

There seem to be a lot of problems with embedded in general -- the recent thread on the db not being setup reliably for unit testing for instance.

I still have two outstanding issues:
1. logging doesn't work when set in persistence.xml under embedded -- same file in real GF works fine and I get all the messages.
2. <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> in my persistence.xml drops and creates the tables at the beginning and when I close the container, drops them all. Again, real GF works as expected and the tables remain.

greg

On Apr 7, 2010, at 13:12, glassfish_at_javadesktop.org wrote:

> So many articles about EJBContainer, so many that don't work!
>
> There's a great article here (http://www.adam-bien.com/roller/abien/entry/embedding_ejb_3_1_container) showing how to get an EJB 3.1 container running. It claims that no further configuration is necessary. This implies I don't have to set up a filesystem, or tell the testing machinery where to create the embedded EJB container, or anything. That's great; so I don't. I just say EJBContainer.createEJBContainer() and off I go.
>
> (It starts up, I should add, barfs out several SEVERE messages that look alarming concerning the fact that it doesn't know where its directory is, even though I'm told I don't have to supply one.)
>
> When I fire up a similar JUnit test under Maven, lo and behold Glassfish comes up, tells me no modules were found (!!), and then, understandably, fails when I attempt to do any lookup--any at all, including of "java:", "java:global", etc.--since nothing got installed in it. So much for no further configuration necessary!
>
> Another article here (http://blogs.sun.com/alexismp/entry/testing_ejb_3_1_s) implies that EJBs that are found at container startup time will be deployed. What does that mean? Do I have to package up an ejb-jar? Can't I leave my classes in their maven directories (target/classes, target/test-classes)? What's going on here? Isn't this configuration? Shouldn't my code get found, as described in the article? If not, where are the steps I need to perform so that Glassfish finds my stuff?
>
> So, having read these two articles and the product documentation, I still can't figure out how to test my EJB. What piece of documentation should I read next?
>
> Thanks,
> Laird
> [Message sent by forum member 'ljnelson']
>
> http://forums.java.net/jive/thread.jspa?messageID=395759
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>