Last active
November 17, 2018 13:06
-
-
Save alejandrogr/fba129f0eadce6b13c1f to your computer and use it in GitHub Desktop.
Appengine JunitTest TaskLauncher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void executeTasksInQueue(String p_queue) throws InterruptedException, ServletException, IOException{ | |
LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue(); | |
QueueStateInfo qsi = ltq.getQueueStateInfo().get(QueueFactory.getQueue(p_queue).getQueueName()); | |
System.out.println("tasks in queue " + qsi.getTaskInfo().size()); | |
int i, I = qsi.getTaskInfo().size(); | |
for (i = 0; i < I; i++) { | |
QueueStateInfo.TaskStateInfo tsi = qsi.getTaskInfo().get(i); | |
String body = tsi.getBody(); | |
System.out.println("body -> " + body); | |
Map<String, String> queryMap = getQueryMap(body); | |
HttpServletRequest req = mock(HttpServletRequest.class); | |
HttpServletResponse res = mock(HttpServletResponse.class); | |
Set<String> keys = queryMap.keySet(); | |
for (String key : keys) { | |
Mockito.when(req.getParameter(key)).thenReturn(queryMap.get(key)); | |
} | |
Task task = new TaskFactory().getTask(tsi.getUrl()); | |
task.executeTask(req, res); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment