Search in sources :

Example 6 with TaskQueueBulkAddResponse

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());
}
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 7 with TaskQueueBulkAddResponse

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);
    }
}
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 8 with TaskQueueBulkAddResponse

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

Example 9 with TaskQueueBulkAddResponse

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);
}
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 10 with TaskQueueBulkAddResponse

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

Aggregations

TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)21 Status (com.google.appengine.tools.development.LocalRpcService.Status)18 Test (org.junit.Test)16 ByteString (com.google.protobuf.ByteString)5 TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)4 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)4 TaskQueueQueryAndOwnTasksRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksRequest)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)3 LatencyPercentiles (com.google.appengine.tools.development.LatencyPercentiles)2 InternalFailureException (com.google.appengine.api.taskqueue.InternalFailureException)1 TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)1 TaskQueueModifyTaskLeaseRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseRequest)1 TaskQueueModifyTaskLeaseResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueModifyTaskLeaseResponse)1 ErrorCode (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueServiceError.ErrorCode)1 ApiProxy (com.google.apphosting.api.ApiProxy)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IdentityHashMap (java.util.IdentityHashMap)1