Search in sources :

Example 6 with QueueXml

use of com.google.apphosting.utils.config.QueueXml 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 7 with QueueXml

use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueConfigTest method testOnlyYaml_PromotingYaml.

@Test
public void testOnlyYaml_PromotingYaml() {
    System.setProperty("appengine.promoteYaml", "true");
    QueueXml queueConfig = getQueueConfigFromYaml("yaml-only");
    verifyIsYamlContent(queueConfig);
}
Also used : QueueXml(com.google.apphosting.utils.config.QueueXml) Test(org.junit.Test)

Example 8 with QueueXml

use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueConfigTest method testXmlWithYaml_PromotingYaml.

@Test
public void testXmlWithYaml_PromotingYaml() {
    System.setProperty("appengine.promoteYaml", "true");
    QueueXml queueConfig = getQueueConfigFromImplicitXmlAndYaml();
    verifyIsYamlContent(queueConfig);
}
Also used : QueueXml(com.google.apphosting.utils.config.QueueXml) Test(org.junit.Test)

Example 9 with QueueXml

use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueConfigTest method testOnlyXml_NotPromotingYaml.

@Test
public void testOnlyXml_NotPromotingYaml() {
    System.setProperty("appengine.promoteYaml", "false");
    QueueXml queueConfig = getQueueConfig("xml-only");
    verifyIsXmlContent(queueConfig);
}
Also used : QueueXml(com.google.apphosting.utils.config.QueueXml) Test(org.junit.Test)

Example 10 with QueueXml

use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueueTest method testTransactionalTasksWithAddActionsFailure.

@Test
public void testTransactionalTasksWithAddActionsFailure() throws Exception {
    DevQueue.taskNameGenerator = new AtomicInteger();
    final int tx = 321;
    final int error = 123;
    localService.stop();
    localService = LocalTaskQueueTestConfig.getLocalTaskQueue();
    initLocalTaskQueue(Clock.DEFAULT);
    QueueXml queueXml = makeQueueXml();
    localService.setQueueXml(queueXml);
    localService.start();
    addRequest1.getTransactionBuilder().setHandle(tx).setApp("foo");
    addRequest2.getTransactionBuilder().setHandle(tx).setApp("foo");
    addRequest3.getTransactionBuilder().setHandle(tx).setApp("foo");
    addRequest1.setTaskName(ByteString.copyFromUtf8(""));
    addRequest2.setTaskName(ByteString.copyFromUtf8(""));
    addRequest3.setTaskName(ByteString.copyFromUtf8(""));
    expectedTaskResult1.setChosenTaskName(ByteString.copyFromUtf8("task1"));
    expectedTaskResult2.setChosenTaskName(ByteString.copyFromUtf8("task2"));
    expectedTaskResult3.setChosenTaskName(ByteString.copyFromUtf8("task3"));
    Delegate<?> oldDelegate = ApiProxy.getDelegate();
    ApiProxy.setDelegate(mockDelegate);
    TaskQueueBulkAddRequest.Builder expectedAddActionsRequest = bulkAddRequest.clone();
    expectedAddActionsRequest.getAddRequestBuilder(0).setTaskName(ByteString.copyFromUtf8("task1"));
    expectedAddActionsRequest.getAddRequestBuilder(1).setTaskName(ByteString.copyFromUtf8("task2"));
    expectedAddActionsRequest.getAddRequestBuilder(2).setTaskName(ByteString.copyFromUtf8("task3"));
    when(mockDelegate.makeSyncCall(ApiProxy.getCurrentEnvironment(), "datastore_v3", "addActions", expectedAddActionsRequest.build().toByteArray())).thenThrow(new ApiProxy.ApplicationException(error, "mock"));
    ApiProxy.ApplicationException e = assertThrows(ApiProxy.ApplicationException.class, () -> localService.bulkAdd(new Status(), bulkAddRequest.build()));
    assertThat(e.getApplicationError()).isEqualTo(error + ErrorCode.DATASTORE_ERROR_VALUE);
    verify(mockDelegate).makeSyncCall(any(), any(), any(), any());
    Map<String, QueueStateInfo> queueInfo = localService.getQueueStateInfo();
    assertThat(queueInfo).hasSize(queueXml.getEntries().size() + 1);
    assertThat(queueInfo.get(addRequest1.getQueueName().toStringUtf8()).getCountTasks()).isEqualTo(0);
    // We have to restore the old delegate so that LocalServiceTestHelper won't break in tearDown
    ApiProxy.setDelegate(oldDelegate);
}
Also used : Status(com.google.appengine.tools.development.LocalRpcService.Status) TaskQueueBulkAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest) ApiProxy(com.google.apphosting.api.ApiProxy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueueXml(com.google.apphosting.utils.config.QueueXml) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

QueueXml (com.google.apphosting.utils.config.QueueXml)12 Test (org.junit.Test)10 ByteString (com.google.protobuf.ByteString)5 Status (com.google.appengine.tools.development.LocalRpcService.Status)4 TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)3 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ApiProxy (com.google.apphosting.api.ApiProxy)1 ConfigurationException (com.google.apphosting.utils.config.ConfigurationException)1 QueueXmlReader (com.google.apphosting.utils.config.QueueXmlReader)1 QueueYamlReader (com.google.apphosting.utils.config.QueueYamlReader)1