Java Code Examples for com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig#getLocalTaskQueue()

The following examples show how to use com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig#getLocalTaskQueue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapreduceTestCase.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  taskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue();
  ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate();
  // Creating files is not allowed in some test execution environments, so don't.
  proxy.setProperty(LocalBlobstoreService.NO_STORAGE_PROPERTY, "true");
  appEngineServiceUtils = new AppEngineServiceUtilsImpl(modulesService);
  when(modulesService.getVersionHostname("backend", null))
      .thenReturn("version.backend.projectid.appspot.com");
}
 
Example 2
Source File: TaskQueueTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private void doTest() throws InterruptedException {
  QueueFactory.getDefaultQueue().add(TaskOptions.Builder.withTaskName("task29"));
  // Give the task time to execute if tasks are actually enabled (which they
  // aren't, but that's part of the test).
  Thread.sleep(1000);
  LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
  QueueStateInfo qsi = ltq.getQueueStateInfo().get(QueueFactory.getDefaultQueue().getQueueName());
  assertEquals(1, qsi.getTaskInfo().size());
  assertEquals("task29", qsi.getTaskInfo().get(0).getTaskName());
}
 
Example 3
Source File: TaskQueueConfigTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private void doTest() throws InterruptedException {
  // [START QueueFactory]
  QueueFactory.getQueue("my-queue-name").add(TaskOptions.Builder.withTaskName("task29"));
  // [END QueueFactory]
  // Give the task time to execute if tasks are actually enabled (which they
  // aren't, but that's part of the test).
  Thread.sleep(1000);
  LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
  QueueStateInfo qsi =
      ltq.getQueueStateInfo().get(QueueFactory.getQueue("my-queue-name").getQueueName());
  assertEquals(1, qsi.getTaskInfo().size());
  assertEquals("task29", qsi.getTaskInfo().get(0).getTaskName());
}
 
Example 4
Source File: PipelineTest.java    From appengine-pipelines with Apache License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
  super.setUp();
  traceBuffer = new StringBuffer();
  helper.setUp();
  apiProxyEnvironment = ApiProxy.getCurrentEnvironment();
  System.setProperty(USE_SIMPLE_GUIDS_FOR_DEBUGGING, "true");
  taskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue();
}
 
Example 5
Source File: ShardedCounterServiceDeleteTest.java    From appengine-counter with Apache License 2.0 5 votes vote down vote up
/**
 * Asserts that the {@code numExpectedTasksInQueue} matches the actual number of tasks in the queue.
 */
private void assertNumTasksInQueue(int numExpectedTasksInQueue)
{
	LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
	QueueStateInfo qsi = ltq.getQueueStateInfo()
		.get(QueueFactory.getQueue(DELETE_COUNTER_SHARD_QUEUE_NAME).getQueueName());
	assertEquals(numExpectedTasksInQueue, qsi.getTaskInfo().size());
}
 
Example 6
Source File: AsyncHelper.java    From yawp with MIT License 3 votes vote down vote up
private static int getCountTasks() {
    LocalTaskQueue localTaskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue();

    Map<String, QueueStateInfo> queueStateInfo = localTaskQueue.getQueueStateInfo();

    int count = 0;

    for (String key : queueStateInfo.keySet()) {
        count += queueStateInfo.get(key).getCountTasks();
    }

    return count;
}