You can check out warp-persist which is meant to do just that. http://code.google.com/p/warp-persist
Dhanji. On Fri, Jan 1, 2010 at 5:54 AM, Sam Halliday <[email protected]> wrote: > Dear all, > > I'm a big fan of the J2EE Container-managed injection of the Java > Persistence API (JPA) into private fields, such as > > @PersistenceUnit > private EntityManagerFactory emf; > > However, when writing JUnit tests, there is no container management* > and one has to manually call Persistence.createEntityManagerFactory. > It is also necessary to programmatically set some properties such as > the test database connection, because again there is no container > management and JDNI JDBC connections are not available. > > Is it possible to use Guice in the JUnit environment to provide > injected 'EntityManagerFactory's? I seen the following post > > > http://cowwoc.blogspot.com/2008/10/integrating-google-guice-into-junit4.html > > and I am wondering if this is still the recommended way to do things. > Guice 2 has been released since this post was made in 2008. And the > following looks like it is doing much more than I need - for a start, > the EntityManagerFactory is never going to be the test subject. > > http://code.google.com/p/atunit/ > > Thanks in advance. > > * unless someone knows of a painless way to get JUnit suites and > individual tests to run inside Glassfish from NetBeans. > > -- > > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
