mercredi 27 février 2019

How to run queue task during local testing with Java Appengine

I'm having a hard time finding what I'm looking for in the documentation (under "Writing task queue tests").

What I'm trying to do is probably beyond a "unit" test. For my test, I call a function that runs an update to my local database and then queues a task to build out and send an email. I need to be able to actually fire my queue task to ensure the task itself functions properly based on the data it pulls from the database.

I am failing to understand from the documentation how to actually ensure my task is executed. Here is my config so far:

private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalTaskQueueTestConfig()
    .setQueueXmlPath("/full/path/to/queue.xml")
    .setDisableAutoTaskExecution(false));

Elsewhere, I add to the queue:

Queue someQueue = QueueFactory.getQueue(SOME_QUEUE.getQueueName());
someQueue.add(TaskOptions.Builder.withUrl("/some-url")
    .param("someParamName", "someParamValue"));

I don't get any errors, it's just not running my task. Is the issue that I'm running withUrl() and need to set some path for my web.xml? The queued task hits a Servlet.

Aucun commentaire:

Enregistrer un commentaire