Actually, turned out you can follow the same GAE JUnit guidelines
(http://code.google.com/appengine/docs/java/howto/unittesting.html)
and create an environment - except, you need to do it on the server
side instead of in your test cases. I created an Environment class
using the code in the guidelines and added the below lines in my EMF
(EM factory) class, and all is well:

ApiProxy.setEnvironmentForCurrentThread(new Environment());
ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")){});

Also, FYI you can shut the DataNucleus logging up by turning them off
for the categories specified in 
http://www.datanucleus.org/products/accessplatform/logging.html.
They can really clutter up your Eclipse console.

Now, back to work.

On Dec 28, 9:09 am, Sekhar <[email protected]> wrote:
> Actually, any access on the local store (read or write) is failing
> with this "No API Environment" error. This must be a simple
> configuration issue (because I'm not doing anything fancy), and I'm
> sure there're lot of folks using JUnit with GWT/GAE... Please help,
> I'm stuck.
>
> On Dec 27, 8:44 pm, Sekhar <[email protected]> wrote:
>
>
>
> > I'm running a JUnit test that causes a persistent write (JPA) with GWT
> > and App Engine, and the test is failing with the below error. The "No
> > API environment is registered for this thread' error led me to the GAE
> > JUnit guidelines (http://code.google.com/appengine/docs/java/howto/
> > unittesting.html), but they apply for a pure GAE situation. How should
> > we run test cases with GWT when it involves persistent writes on the
> > local GAE? The tests that only read from the store are working fine,
> > as are direct access through the GWT front-end.
>
> > junit.framework.AssertionFailedError: Remote test failed at
> > 192.168.1.76 / Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> > 1.9.0.1) Gecko/2008070208 Firefox/3.0.1
> > com.google.gwt.user.client.rpc.SerializationException:
> > java.lang.NullPointerException: No API environment is registered for
> > this thread.
> >         at junit.framework.Assert.fail(Assert.java:197)
> >         at com.allurefx.herdspot.test.client.HerdspotServiceTest$3.onFailure
> > (HerdspotServiceTest.java:88)
> >         at
> > com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceiv 
> > ed
> > (RequestCallbackAdapter.java:218)
> >         at com.google.gwt.http.client.Request.fireOnResponseReceived
> > (Request.java:287)
> >         at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange
> > (RequestBuilder.java:396)
> >         at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >         at java.lang.reflect.Method.invoke(Unknown Source)
> >         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> > 103)
> >         at 
> > com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
> > 71)
> >         at com.google.gwt.dev.shell.OophmSessionHandler.invoke
> > (OophmSessionHandler.java:157)
> >         at
> > com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForRetur 
> > n
> > (BrowserChannel.java:1713)
> >         at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript
> > (BrowserChannelServer.java:165)
> >         at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke
> > (ModuleSpaceOOPHM.java:120)
> >         at 
> > com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
> > 507)
> >         at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject
> > (ModuleSpace.java:264)
> >         at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject
> > (JavaScriptHost.java:91)
> >         at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
> >         at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
> >         at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >         at java.lang.reflect.Method.invoke(Unknown Source)
> >         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> > 103)
> >         at 
> > com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
> > 71)
> >         at com.google.gwt.dev.shell.OophmSessionHandler.invoke
> > (OophmSessionHandler.java:157)
> >         at com.google.gwt.dev.shell.BrowserChannel.reactToMessages
> > (BrowserChannel.java:1668)
> >         at com.google.gwt.dev.shell.BrowserChannelServer.processConnection
> > (BrowserChannelServer.java:401)
> >         at com.google.gwt.dev.shell.BrowserChannelServer.run
> > (BrowserChannelServer.java:222)
> >         at java.lang.Thread.run(Unknown Source)

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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-web-toolkit?hl=en.


Reply via email to