Thanks a bunch David, I'll give that a try right away. I suppose I
just didn't connect the dots in this case :)

On Mar 15, 8:23 pm, David Fuelling <[email protected]> wrote:
> Testing your JPA isn't much different than testing the low-level
> Datastore service.  Just create a JUnit test-case and add a "helper"
> object that gets initialized with every test, just like they show
> here:https://code.google.com/appengine/docs/java/tools/localunittesting.ht...
>
> In your test code (or in a DAO, or wherever), do the following to get
> ahold of the persistence manager:
>
> EMF.get().createEntityManager()
>
> The EMF class is detailed 
> here:https://code.google.com/appengine/docs/java/datastore/usingjpa.html#G...
>
> The magic glue that simulates the datastore in your JUnit test is what
> happens in the JUnit's "setup" function where you call
> "helper.setUp()".
>
> Hope that helps!
>
> david
>
> On Mar 13, 12:37 pm, hans <[email protected]> wrote:
>
> > Hi all,
>
> > I would like to test my JPA repository/dao components locally and I'm
> > running into a dead end. I'm on SDK 1.3.1.
>
> > I have read the documentation 
> > athttp://code.google.com/appengine/docs/java/tools/localunittesting.html.
>
> > This documentation deals with how to get access to the lower level
> > datastore API. I suppose I can compare that with a JDBC connection in
> > a conventional application. What I don't understand is how to write a
> > local unit test that talks to the JPA EntityManagerFactory. I found
> > some useful blog postings (http://objectuser.wordpress.com/2009/08/02/
> > google-app-engine-testing-with-spring/) but it seems the API version
> > used by the author of that posting is now outdated.
>
> > So my question is: how do I bridge the gap between the lower level
> > datastore factory and my JPA DAO implementation, e.g. how do I
> > configure JPA's EntityManagerFactory to use the local datastore
> > environment when running tests? I am aware my EntityManagerFactory
> > looks for persistence.xml on the classpath, which configures a
> > org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider, for
> > which I can not find the javadoc anywhere.
>
> > Also, I found a posting on this 
> > group,http://groups.google.com/group/google-appengine-java/browse_thread/th....
>
> > The solution there is to setup the environment *inside* the actual
> > test implementation. That will make testing kind of troublesome, and
> > it seems to use the ApiProxyLocalImpl that I can not get a hand of in
> > the current SDK version.
>
> > A side note: considering the fact that the vast majority of people
> > will be accessing the datastore through either JDO or JPA, shouldn't
> > the testing documentation provide examples for that (instead of the
> > lower level API which seems to me sort of a niche)
>
> > Regards,
> > Hans

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" 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-appengine-java?hl=en.

Reply via email to