Wednesday, April 8, 2015

Testing Google Task Queues

Google Task Queues are a great way to have snippets of code be executed at a later time. They can be used to spread application load, or to have some task executed at a programatically provided timestamp. The API is easy to understand and use, and Google provides an easy way to Unit test your code.

So far so good! This works perfectly when you use the default queue. If you want to use a non-default queue, however, there's a catch. The documentation prescribes that you just point your LocalTaskQueueTestConfig to the queue.xml file, and that's it. That is indeed all there is to it, but only if you have the XmlParser on your classpath (org.mortbay.xml.XmlParser). If it is not there, add this dependency to your POM:

<dependency>
  <groupid>com.google.appengine</groupid>
  <artifactid>appengine-tools-sdk</artifactid>
  <version>${appengine.target.version}</version>
</dependency>


This provides the XmlParser you need!

No comments:

Post a Comment