My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members

Overview

If you want locally test some TaskQueue and task was guicified you can use this project for this.

Status

There early beta release, bugreports are welcomed.

Limitations in current release:

  • tasks which failed with error just not removed from Queue, but no rescheduling were applied for them;
  • you can run only all tasks in queue at once.
  • MockHttpServletRequest and MockHttpServletResponse very primitive, so in some cases that maybe a problem(you can report if you get some). But in most(usual) cases they works fine.

Usage

You should add some GAE testing jars in your project:

  • appengine-testing.jar
  • apppengine-api-stubs.jar
  • apppengine-api-labs.jar
  • etc.

(read this: Local Unit Testing)

Look at LocalServiceTestHelper config example.

Typical usage looks like this:

public void SomeTest() {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();

...
Injector inj;
inj = Guice.createInjector(new AppConstsModule(), new MyServletModule());

AppConsts consts; 
consts  = injector.getInstance(AppConsts.class);

SomeTaskServlet someTaskServletInstance = inj.getInstance(SomeTaskServlet.class);

SomeCronServlet someCronServletInstance = inj.getInstance(SomeCronServlet.class);


request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
request.setMethod("GET");
request.setParameter("paramName", "paramValue");
ServletRunner.runMockServlet(someCronServletInstance, request, response);

int ti;
//this run all tasks in queue "SomeQueueName"
ti = TaskRunner.runTasksInQueue("SomeQueueName", someTaskServletInstance);

...
}

INSTALL

Run this:

svn checkout http://gaelocaltest.googlecode.com/svn/trunk/ gaelocaltest-read-only

Then just run ant and use /dist/lib/gaelocaltest.jar in your project.

In build.xml exist property "version" - this is version of GAE SDK which has been downloaded and used in building process. You can change it if you need other version.

Powered by Google Project Hosting