Search in sources :

Example 1 with Header

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest.Header 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 2 with Header

use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest.Header 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)

Aggregations

TaskQueueAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest)2 Header (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddRequest.Header)2 TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)2 Test (org.junit.Test)2