use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueue method parseQueueConfiguration.
/**
* Parse the queue configuration from application directory, either from xml or yaml configuration
*
* @param appDir the application war directory.
* @param queueXmlPath a user provided path that overrides the default path of queue.xml. This is
* used by local unit tests.
* @param queueYamlPath a user provided path that overrides the default path of queue.yaml. This
* is used by local unit tests.
* @return the parsed queue configuration.
* @throws ConfigurationException if both yaml and xml path are not null.
*/
QueueXml parseQueueConfiguration(String appDir, @Nullable final String queueXmlPath, @Nullable final String queueYamlPath) {
if (queueXmlPath != null && queueYamlPath != null) {
throw new ConfigurationException("Found both queue.xml and queue.yaml. Please use queue.yaml and remove queue.xml. " + "For more information: " + DOC_LINK);
}
QueueXml resultFromXml = null;
QueueXml resultFromYaml = null;
if (queueXmlPath != null) {
// user wants a custom queue.xml loaded
QueueXmlReader xmlReader = new QueueXmlReader(appDir) {
@Override
public String getFilename() {
return queueXmlPath;
}
};
resultFromXml = xmlReader.readQueueXml();
} else if (queueYamlPath != null) {
// user wants a custom queue.yaml loaded
QueueYamlReader yamlReader = new QueueYamlReader(appDir) {
@Override
public String getFilename() {
return queueYamlPath;
}
};
resultFromYaml = yamlReader.parse();
} else {
// Tries default path for xml or yaml configuration.
QueueXmlReader xmlReader = new QueueXmlReader(appDir);
// TODO Consider reloading queue.xml if changed.
// resultFromXml would be null iff the xml file does not exist.
resultFromXml = xmlReader.readQueueXml();
QueueYamlReader yamlReader = new QueueYamlReader(Paths.get(appDir, "WEB-INF").toString());
resultFromYaml = yamlReader.parse();
}
if (!ApiUtils.isPromotingYaml()) {
return (resultFromXml != null) ? resultFromXml : resultFromYaml;
}
// When promoting yaml, given proper messages if queue.xml is present.
if (resultFromXml != null && resultFromYaml == null) {
logger.warning("Using queue.xml. Please migrate to queue.yaml. For more information: " + DOC_LINK);
}
return (resultFromYaml != null) ? resultFromYaml : resultFromXml;
}
use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueConfigTest method testOnlyXml_PromotingYaml.
@Test
public void testOnlyXml_PromotingYaml() {
System.setProperty("appengine.promoteYaml", "true");
QueueXml queueConfig = getQueueConfig("xml-only");
verifyIsXmlContent(queueConfig);
}
use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueConfigTest method testXmlWithYaml_NotPromotingYaml.
@Test
public void testXmlWithYaml_NotPromotingYaml() {
System.setProperty("appengine.promoteYaml", "false");
QueueXml queueConfig = getQueueConfigFromImplicitXmlAndYaml();
verifyIsXmlContent(queueConfig);
}
use of com.google.apphosting.utils.config.QueueXml in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueueConfigTest method testOnlyYaml_NotPromotingYaml.
@Test
public void testOnlyYaml_NotPromotingYaml() {
System.setProperty("appengine.promoteYaml", "false");
QueueXml queueConfig = getQueueConfigFromYaml("yaml-only");
verifyIsYamlContent(queueConfig);
}
use of com.google.apphosting.utils.config.QueueXml 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());
}
Aggregations