Search in sources :

Example 6 with Status

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());
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) Test(org.junit.Test)

Example 7 with Status

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());
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) QueueXml(com.google.apphosting.utils.config.QueueXml) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 8 with Status

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);
    }
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) TaskQueueQueryAndOwnTasksRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksRequest) Clock(com.google.appengine.tools.development.Clock) TaskQueueQueryAndOwnTasksResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksResponse) Test(org.junit.Test)

Example 9 with Status

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());
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) Test(org.junit.Test)

Example 10 with Status

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);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueDeleteRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest) TaskQueueDeleteResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse) Test(org.junit.Test)

Aggregations

Status (com.google.appengine.tools.development.LocalRpcService.Status)34 Test (org.junit.Test)31 TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)18 TaskQueueQueryAndOwnTasksRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksRequest)5 ApiProxy (com.google.apphosting.api.ApiProxy)5 ByteString (com.google.protobuf.ByteString)5 TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)4 TaskQueueModifyTaskLeaseRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)4 TaskQueueQueryAndOwnTasksResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksResponse)4 Clock (com.google.appengine.tools.development.Clock)4 QueueXml (com.google.apphosting.utils.config.QueueXml)4 TaskQueueDeleteRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteRequest)3 TaskQueueDeleteResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueDeleteResponse)3 TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)2 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ImageData (com.google.appengine.api.images.ImagesServicePb.ImageData)1 MIME_TYPE (com.google.appengine.api.images.ImagesServicePb.OutputSettings.MIME_TYPE)1 Transform (com.google.appengine.api.images.ImagesServicePb.Transform)1 TaskQueueFetchQueueStatsRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueFetchQueueStatsRequest)1