Thanks for your reply, but I didn't find a solution in the test sources. The keyword "count" is only used to count the result entries.
Second, I can't use a mock datastoreService because the queries are made too deep in your classes with the entityManager. I cannot rewrite the complete sources for the test. I believe that there is a simple way to count the queries, because when I enable "appstats", I can see the number of RPCs (datastore queries). How does this work? On 19 Okt., 20:12, "Ikai Lan (Google)" <[email protected]> wrote: > 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/tru... > > 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/appengi... > > 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 <[email protected]> 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 > > [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<google-appengine-java%2B > > [email protected]> > > . > > 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 [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.
