I recall seeing something in test utils that did this. Check out the tests in this package for details:
http://code.google.com/p/datanucleus-appengine/source/browse/#svn/trunk/tests/org/datanucleus/store/appengine/query%3Fstate%3Dclosed There might be a better way to approach the test, however. Since you don't care if the query actually executes (this is a unit test, after all), why don't you mock out DatastoreService? http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html It's an interface, so you should be able to use EasyMock to create a mock DatastoreService object and record call counts: http://easymock.org/EasyMock3_0_Documentation.html -- Ikai Lan Developer Programs Engineer, Google App Engine Blogger: http://googleappengine.blogspot.com Reddit: http://www.reddit.com/r/appengine Twitter: http://twitter.com/app_engine On Mon, Oct 18, 2010 at 12:57 AM, Jonas Gehring <gehr...@egotec.com> wrote: > Hello. > > I have implemented a method that does a few datastore queries. For > performance I decided to cache the results of the queries and use the > cache on every next method call. > > Now I would like to test whether my cache works within a JUnit test. > But for this I must count the datastore queries and compare them. Is > there a way to do this? > > I think about such solution: > > int countBefore = ds.countQueries() > doSomething(); // 1st time without cache > assertEquals(10, ds.countQueries() - countBefore); > doSomething(); // 2nd time with cache > assertEquals(10, ds.countQueries() - countBefore); > > Thanks. > > -- > 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 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.