use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testMultipleQueuesWithDefault.
@Test
public void testMultipleQueuesWithDefault() throws Exception {
QueueXml queueXml = makeQueueXml();
QueueXml.Entry tmpEntry = queueXml.addNewEntry();
tmpEntry.setBucketSize(1);
tmpEntry.setName(QueueXml.defaultEntry().getName());
tmpEntry.setRate("2/d");
queueXml.validateLastEntry();
localService.stop();
localService = LocalTaskQueueTestConfig.getLocalTaskQueue();
initLocalTaskQueue(Clock.DEFAULT);
localService.setQueueXml(queueXml);
localService.start();
Status status = new Status();
TaskQueueBulkAddResponse response = localService.bulkAdd(status, bulkAddRequest.build());
assertThat(response).isEqualTo(expectedBulkAddResponse.build());
Map<String, QueueStateInfo> queueInfo = localService.getQueueStateInfo();
assertThat(queueInfo).hasSize(queueXml.getEntries().size());
}
use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testQueryAndOwnTasks.
@Test
public void testQueryAndOwnTasks() throws Exception {
class MockClock implements Clock {
@Override
public long getCurrentTime() {
// Force nowMillis of QueryAndOwnTasks is guaranteed to be bigger than task eta.
return Clock.DEFAULT.getCurrentTime() + 1000;
}
}
initLocalTaskQueue(new MockClock());
TaskQueueBulkAddResponse sbresponse = localService.bulkAdd(new Status(), bulkAddPullRequest.build());
assertThat(sbresponse).isEqualTo(expectedBulkAddResponse.build());
TaskQueueQueryAndOwnTasksRequest request = TaskQueueQueryAndOwnTasksRequest.newBuilder().setQueueName(ByteString.copyFromUtf8("pull-queue")).setLeaseSeconds(10).setMaxTasks(5).build();
TaskQueueQueryAndOwnTasksResponse response = localService.queryAndOwnTasks(new Status(), request);
assertThat(response.getTaskCount()).isEqualTo(3);
for (int i = 0; i < response.getTaskCount(); ++i) {
assertThat(response.getTask(i).getTaskName().toStringUtf8()).isEqualTo("a-task-" + i);
assertThat(response.getTask(i).getBody().toStringUtf8()).isEqualTo("payload" + i);
}
}
use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testBulkAddPullTasks.
@Test
public void testBulkAddPullTasks() throws Exception {
TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddPullRequest.build());
assertThat(response).isEqualTo(expectedBulkAddResponse.build());
}
use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testMultipleQueuesNoDefault.
@Test
public void testMultipleQueuesNoDefault() throws Exception {
localService.stop();
localService = LocalTaskQueueTestConfig.getLocalTaskQueue();
initLocalTaskQueue(Clock.DEFAULT);
QueueXml queueXml = makeQueueXml();
localService.setQueueXml(queueXml);
localService.start();
// add an entry in the default queue, this makes sure that the default
// queue is automagically added.
Status status = new Status();
TaskQueueBulkAddResponse response = localService.bulkAdd(status, bulkAddRequest.build());
assertThat(response).isEqualTo(expectedBulkAddResponse.build());
Map<String, QueueStateInfo> queueInfo = localService.getQueueStateInfo();
assertThat(queueInfo).hasSize(queueXml.getEntries().size() + 1);
}
use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method assertValidationException.
private void assertValidationException(ErrorCode ec) {
expectedTaskResult1.setResult(ErrorCode.SKIPPED);
expectedTaskResult2.setResult(ec);
expectedTaskResult3.setResult(ErrorCode.SKIPPED);
TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddRequest.buildPartial());
assertThat(response).isEqualTo(expectedBulkAddResponse.buildPartial());
}
Aggregations