use of com.google.appengine.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testBulkAddEmptyRequest.
@Test
public void testBulkAddEmptyRequest() throws Exception {
bulkAddRequest.clear();
expectedBulkAddResponse.clear();
TaskQueueBulkAddResponse response = localService.bulkAdd(new Status(), bulkAddRequest.build());
assertThat(response).isEqualTo(expectedBulkAddResponse.build());
}
use of com.google.appengine.tools.development.LocalRpcService.Status 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.tools.development.LocalRpcService.Status 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.tools.development.LocalRpcService.Status 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.tools.development.LocalRpcService.Status in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueTest method testDelete.
@Test
public void testDelete() throws Exception {
localService.bulkAdd(new Status(), bulkAddRequest.build());
TaskQueueDeleteRequest deleteRequest = TaskQueueDeleteRequest.newBuilder().setQueueName(ByteString.copyFromUtf8(entry.getName())).addTaskName(bulkAddRequest.getAddRequest(1).getTaskName()).build();
TaskQueueDeleteResponse deleteResponse = localService.delete(new Status(), deleteRequest);
assertThat(deleteResponse.getResultCount()).isEqualTo(1);
assertThat(deleteResponse.getResult(0)).isEqualTo(ErrorCode.OK);
QueueStateInfo queueInfo = localService.getQueueStateInfo().get(entry.getName());
assertThat(queueInfo.getCountTasks()).isEqualTo(2);
}
Aggregations