Search in sources :

Example 6 with TaskQueueAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class DevPullQueueTest method testDelete.

public void testDelete() throws Exception {
    TaskQueueAddRequest.Builder addRequest = newAddRequest(1000);
    TaskQueueAddResponse response = queue.add(addRequest);
    boolean deleted = queue.deleteTask(response.getChosenTaskName().toStringUtf8());
    assertTrue(deleted);
    deleted = queue.deleteTask(response.getChosenTaskName().toStringUtf8());
    assertEquals(false, deleted);
}
Also used : TaskQueueAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)

Example 7 with TaskQueueAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class DevQueueIntegrationTest method testAdd_UnnamedTask.

@Test
public void testAdd_UnnamedTask() throws Exception {
    // schedule way in the past
    TaskQueueAddRequest.Builder add = newAddRequest(1000);
    TaskQueueAddResponse response = queue.add(add);
    waitForJobExecution();
    assertThat(providedFetchReqs).hasSize(1);
    assertFetchReqEquals(providedFetchReqs.get(0), URLFetchRequest.RequestMethod.GET, "http://localhost:8080/my/url", false, 0, response.getChosenTaskName().toStringUtf8(), 0);
}
Also used : TaskQueueAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) Test(org.junit.Test)

Example 8 with TaskQueueAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class DevQueueIntegrationTest method testAddTaskIgnoresNonLocalhostHostHeader.

@Test
public void testAddTaskIgnoresNonLocalhostHostHeader() throws Exception {
    // schedule way in the past
    TaskQueueAddRequest.Builder add = newAddRequest(1000);
    Header header = TaskQueueAddRequest.Header.newBuilder().setKey(ByteString.copyFromUtf8("Host")).setValue(ByteString.copyFromUtf8("foo:8085")).build();
    add.addHeader(header);
    TaskQueueAddResponse response = queue.add(add);
    waitForJobExecution();
    assertThat(providedFetchReqs).hasSize(1);
    assertFetchReqEquals(providedFetchReqs.get(0), URLFetchRequest.RequestMethod.GET, "http://localhost:8080/my/url", false, 0, response.getChosenTaskName().toStringUtf8(), 0);
}
Also used : TaskQueueAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) Header(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest.Header) Test(org.junit.Test)

Example 9 with TaskQueueAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class DevQueueIntegrationTest method testAddTaskRespectsHostHeader.

@Test
public void testAddTaskRespectsHostHeader() throws Exception {
    // schedule way in the past
    TaskQueueAddRequest.Builder add = newAddRequest(1000);
    Header header = TaskQueueAddRequest.Header.newBuilder().setKey(ByteString.copyFromUtf8("Host")).setValue(ByteString.copyFromUtf8("localhost:24358")).build();
    add.addHeader(header);
    TaskQueueAddResponse response = queue.add(add);
    waitForJobExecution();
    assertThat(providedFetchReqs).hasSize(1);
    assertFetchReqEquals(providedFetchReqs.get(0), URLFetchRequest.RequestMethod.GET, "http://localhost:24358/my/url", false, 0, response.getChosenTaskName().toStringUtf8(), 0);
}
Also used : TaskQueueAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) Header(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest.Header) Test(org.junit.Test)

Example 10 with TaskQueueAddResponse

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse in project appengine-java-standard by GoogleCloudPlatform.

the class DevQueueTest method testAdd_UnnamedTask.

@Test
public void testAdd_UnnamedTask() throws Exception {
    TaskQueueAddRequest.Builder add = newAddRequest(1000);
    when(schedulerMock.getJobDetail(any(), eq("default"))).thenReturn(null);
    when(schedulerMock.scheduleJob(isA(JobDetail.class), isA(SimpleTrigger.class))).thenReturn(null);
    TaskQueueAddResponse resp = queue.add(add);
    ArgumentCaptor<String> taskName = ArgumentCaptor.forClass(String.class);
    verify(schedulerMock).getJobDetail(taskName.capture(), eq("default"));
    assertThat(resp.getChosenTaskName().toStringUtf8()).isEqualTo(taskName.getValue());
}
Also used : TaskQueueAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse) JobDetail(org.quartz.JobDetail) TaskQueueAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest) ByteString(com.google.protobuf.ByteString) SimpleTrigger(org.quartz.SimpleTrigger) Test(org.junit.Test)

Aggregations

TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)13 TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)10 Test (org.junit.Test)7 ByteString (com.google.protobuf.ByteString)3 Header (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest.Header)2 Status (com.google.appengine.tools.development.LocalRpcService.Status)2 JobDetail (org.quartz.JobDetail)2 SimpleTrigger (org.quartz.SimpleTrigger)2 InternalFailureException (com.google.appengine.api.taskqueue.InternalFailureException)1 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)1 TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)1 LatencyPercentiles (com.google.appengine.tools.development.LatencyPercentiles)1