[appengine-java] Re: How do I run DeferredTasks in a Unit Test

2012-02-02 Thread Riley Eynon-Lynch
Thanks for the question and answer, Brendan. Can you say what getQueue() is? -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit

[appengine-java] Re: How do I run DeferredTasks in a Unit Test

2012-02-02 Thread Riley Eynon-Lynch
private QueueStateInfo getQueue(String queueName) { return LocalTaskQueueTestConfig.getLocalTaskQueue().getQueueStateInfo().get(queueName); } will do. Thanks again! -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view

Re: [appengine-java] Re: How do I run DeferredTasks in a Unit Test

2012-02-02 Thread Jeff Schnitzer
This is a blast from the past. There are now official tools for unit testing deferred tasks: http://code.google.com/appengine/docs/java/tools/localunittesting.html#Writing_Deferred_Task_Tests However, ignore the latch stuff - it works erratically, and if you have an even slightly complicated

[appengine-java] Re: How do I run DeferredTasks in a Unit Test

2011-04-26 Thread Brendan Doherty
I've also tried the code below, however I get the following error on the line client.sendRequest(request); Perhaps I'm not encoding the task body correctly? com.google.apphosting.utils.servlet.DeferredTaskServlet: Deferred task failed exception:

Re: [appengine-java] Re: How do I run DeferredTasks in a Unit Test

2011-04-26 Thread Gianni Mariani
I'm not sure what this is not working (given that it worked previously). I'll take a look. The task is binary data. My first guess is this:- String queuedTask = taskInfo.getBody(); String is UTF-16 encoded while the body is a bunch of bytes. The process of decoding and re-encoding has a

Re: [appengine-java] Re: How do I run DeferredTasks in a Unit Test

2011-04-26 Thread Brendan Doherty
Thanks. I'll give that a try and report back. Do you know if the first approach I tried with LocalTaskQueueTestConfig.getLocalTaskQueue().runTask(queueName, taskName) should ever work from a JUnit test case, or will ServletUnit always be the way to go? It seems like something didn't work

Re: [appengine-java] Re: How do I run DeferredTasks in a Unit Test

2011-04-26 Thread Brendan Doherty
getBodyAsBytes() solves the problem. The following code will run each of the queued DeferredTasks from within a JUnit test. String queueName = QueueFactory.getDefaultQueue().getQueueName(); ServletRunner sr = new ServletRunner(); sr.registerServlet(