Hi Max, To be able cover my code with unit tests, I created a mock class for the App Engine environment (http://github.com/DomDerrien/two-tiers- utils/blob/master/src/Java/com/google/apphosting/api/ MockAppEngineEnvironment.java). As reported in my recent blog post (http://domderrien.blogspot.com/2009/11/unit-tests-mock-objects-and- app-engine.html), it's inspired from your documentation and from a post of App Engine fan.
FYI, it seems to me that the official SDK still requires the workaround. Thanks to your suggestion, the updated mock let the tests passing as before ;) private class MockApiProxyEnvironment implements ApiProxy.Environment { // ... public Map<String, Object> getAttributes() { Map<String, Object> out = new HashMap<String, Object>(); // Only necessary for tasks that are added when there is no "live" request // See: http://groups.google.com/group/google-appengine-java/msg/8f5872b052144c8d?pli=1 out.put("com.google.appengine.server_url_key", "http:// localhost:8080"); return out; } }; A+, Dom -- On Dec 3, 7:01 pm, "Max Ross (Google)" <maxr+appeng...@google.com> wrote: > Vince, > > We added a last minute fix for this in the SDK that just went out. Could > you please try your code with the official SDK download? > > Thanks, > Max > > On Thu, Dec 3, 2009 at 12:15 PM, Max Ross (Google) < > > maxr+appeng...@google.com <maxr%2bappeng...@google.com>> wrote: > > Sure, sorry for the trouble, and thanks for trying out the prerelease! > > > Max > > > On Thu, Dec 3, 2009 at 12:12 PM, Vince Bonfanti <vbonfa...@gmail.com>wrote: > > >> That fixed it. Thanks. > > >> Vince > > >> On Thu, Dec 3, 2009 at 2:24 PM, Max Ross (Google) < > >> maxr+appeng...@google.com <maxr%2bappeng...@google.com>> wrote: > > >>> Vince, > > >>> As a workaround, try setting the missing environment attribute explicitly > >>> before you add the task to the queue: > > >>> ApiProxy.getCurrentEnvironment().getAttributes().put("com.google.appengine.server_url_key", > >>> "http://localhost:8080"); > > >>> This should only be necessary for tasks that are added when there is no > >>> "live" request and it should have no impact in prod. > > >>> Sorry for the trouble, > >>> Max > > >>> On Thu, Dec 3, 2009 at 10:20 AM, Max Ross (Google) < > >>> maxr+appeng...@google.com <maxr%2bappeng...@google.com>> wrote: > > >>>> Hi Vince, > > >>>> That sounds like a bug in our code that was a side effect of the > >>>> automatic task execution that now happens in the dev environment. Let me > >>>> see if I can come up with a workaround for you. > > >>>> Max > > >>>> On Thu, Dec 3, 2009 at 10:06 AM, Vince Bonfanti > >>>> <vbonfa...@gmail.com>wrote: > > >>>>> I just started testing with the 1.2.8 prerelease, and I'm getting the > >>>>> following exception from Queue.add() in code that works in 1.2.6: > > >>>>> java.lang.IllegalStateException: Current enviornment must have the > >>>>> server url available via the com.google.appengine.server_url_key > >>>>> attribute. > > >>>>> This only happens when Queue.add() is invoked from the servlet init() > >>>>> method or from a static initializer; if Queue.add() is invoked from a > >>>>> "regular" request thread, then it works properly. > > >>>>> Vince > > >>>>> On Tue, Nov 24, 2009 at 9:00 PM, Ikai L (Google) > >>>>> <ika...@google.com>wrote: > > >>>>>> Hello App Engine Developers, > > >>>>>> As part of our ongoing efforts to improve release quality and > >>>>>> transparency, we will start prereleasing SDKs for early testing. We > >>>>>> hope this gives developers a chance to participate in our release > >>>>>> process by trying out new changes and sending feedback. As of this > >>>>>> morning, the prerelease SDK for our next release, 1.2.8, is available > >>>>>> in the familiar download location (note that the filename ends in > >>>>>> 'prerelease.zip'): > > >>>>>>http://code.google.com/p/googleappengine/downloads/list > > >>>>>> If you're interested, please download and give it a try locally with > >>>>>> your favorite App Engine code. Please note that, as a prerelease, this > >>>>>> SDK is not yet supported and still subject to change. Thus, please > >>>>>> don't take critical dependencies or make substantial changes to > >>>>>> production apps based on this SDK. > > >>>>>> Importantly, this prerelease is purely for the SDK and is intended for > >>>>>> local testing and development in dev_appserver. The server-side of App > >>>>>> Engine (our production environment) is not at 1.2.8, so deploying with > >>>>>> this SDK is not yet supported. In the future, we might enable a > >>>>>> complete SDK and server test environment for prereleases. > > >>>>>> A few notes on 1.2.8 in particular - this release is primarily for > >>>>>> servicing and updates in preparation for some exciting feature > >>>>>> launches we have in the pipeline. The current release notes (still > >>>>>> subject to change) are included below; these release notes do include > >>>>>> changes which will only be available on the server side Admin Console > >>>>>> (non-local) once 1.2.8 is formally released. > > >>>>>> Please try 1.2.8 for local development and send us your feedback! > > >>>>>> Thanks, > > >>>>>> App Engine Team > > >>>>>> Version 1.2.8 > >>>>>> ============= > >>>>>> - Support for JAXB. JAXB is included in JDK 1.6 (and App Engine's > >>>>>> production > >>>>>> servers). If you're using JDK 1.5 with your local dev_appserver, > >>>>>> you will > >>>>>> need to include the JAXB libraries with your application to use > >>>>>> it. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=1267 > >>>>>> - Added Quota API (com.google.appengine.api.quota) to match Python > >>>>>> API. > >>>>>> - Low-level Memcache API now supports grabTail() and batchIncrement > >>>>>> (). > >>>>>> - HTTPResponse object now has getFinalUrl() method for 302 > >>>>>> redirects. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=1464 > >>>>>> - Java Dev Appserver now automatically executes tasks. If you > >>>>>> prefer the old > >>>>>> behavior where tasks do not automatically execute you can use the > >>>>>> -Dtask_queue.disable_auto_task_execution flag when starting the > >>>>>> server. > >>>>>> - Additional file extensions permitted when sending mail. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=494 > >>>>>> - Fixed issue with Java mail handler not processing multipart > >>>>>> messages > >>>>>> correctly. > >>>>>> - Fixed agent code included in appengine-local-runtime.jar results > >>>>>> in > >>>>>> RuntimeException. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=2280 > >>>>>> - Fixed issue with sort orders defined on properties that allow > >>>>>> multiple > >>>>>> values. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=2349 > >>>>>> - Fixed problem with dropped query strings after requiring log-in. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=2225 > >>>>>> - Removed limitation preventing multiple parameters with the same > >>>>>> name. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=2090 > >>>>>> - Fixed issue with local datastore incorrectly sorting results of > >>>>>> ancestor queries. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=2177 > >>>>>> - New Index building status page in the Admin Console > >>>>>> - Task Queue now supports purging queues, and deleting tasks and > >>>>>> queues via > >>>>>> the Admin Console. > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=2159 > >>>>>> http://code.google.com/p/googleappengine/issues/detail?id=1740 > >>>>>> - Over Quota HTTP status code changed from 403 to 503, other to 500. > >>>>>> - Task Queue now considers all HTTP 2xx status codes to represent > >>>>>> success. > > >>>>>> ORM Changes > > >>>>>> - Explicitly disallow multiple relationships of the same type > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=154 > >>>>>> - Occasional ArrayOutOfBoundsIndexException > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=156 > >>>>>> - Support inheritance > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=25 > >>>>>> - Support != queries > >>>>>> - Support IN queries > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=39 > >>>>>> - Inheritance is working for simple fields and embedded fields. > >>>>>> Relationships > >>>>>> in base classes are completely untested and probably do not work. > >>>>>> - Cannot add child to existing one-to-many if parent has Long or > >>>>>> unencoded String pk > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=28 > >>>>>> - Can't query by embedded fields at depth > 1 > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=120 > >>>>>> - Positional parameters don't work (JPQL) > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=128 > >>>>>> - Throw JDOCanRetryException when ConcurrentMod hit during txn > >>>>>> commit > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=134 > >>>>>> - Respect JDOQL/JPQL case sensitivity for keywords, in particular > >>>>>> "count" > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=139 > >>>>>> - Put all native datastore types in the default fetch group > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=143 > >>>>>> - Empty Set gets loaded from datastore as null > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=145 > >>>>>> - Cannot remove element of one to many when parent has pk of type > >>>>>> Long or unencoded String > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=126 > >>>>>> - Severe problem when deleting a child object from an owned > >>>>>> relationship (JDO) > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=135 > >>>>>> - NPE resulting from corrupt JDOQL query > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=136 > >>>>>> - Embedded, multi-value fields don't work > > >>>>>>http://code.google.com/p/datanucleus-appengine/issues/detail?id=146 > > >>>>>> -- > > >>>>>> 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 > >>>>>> google-appengine-j...@googlegroups.com. > >>>>>> To unsubscribe from this group, send email to > >>>>>> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com> > >>>>>> . > >>>>>> For more options, visit this group at > >>>>>>http://groups.google.com/group/google-appengine-java?hl=en. > > >>>>> -- > >>>>> 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 > > ... > > read more » -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.