Коммит
bee77cbff7
|
@ -42,7 +42,7 @@ RuntimeVersionProtocolClient.prototype.getVersionMap = function (connectionPath,
|
|||
|
||||
for (var endpoint in endpoints) {
|
||||
var currentEndpoint = endpoints[endpoint];
|
||||
versions[currentEndpoint[Constants.METADATA_MARKER].version] = currentEndpoint[Constants.METADATA_MARKER].path;
|
||||
versions[currentEndpoint[Constants.XML_METADATA_MARKER].version] = currentEndpoint[Constants.XML_METADATA_MARKER].path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ XmlCurrentStateSerializer.prototype.serialize = function (currentState) {
|
|||
var currentStateXml = {};
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE] = {};
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE] = {};
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][Constants.METADATA_MARKER] = {};
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][Constants.METADATA_MARKER][ServiceRuntimeConstants.CLIENT_ID] = currentState.clientId;
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][Constants.XML_METADATA_MARKER] = {};
|
||||
currentStateXml[ServiceRuntimeConstants.CURRENT_STATE][ServiceRuntimeConstants.STATUS_LEASE][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.CLIENT_ID] = currentState.clientId;
|
||||
|
||||
// If it is a request for a change of status
|
||||
if (currentState.status) {
|
||||
|
|
|
@ -26,8 +26,8 @@ XmlRoleEnvironmentDataDeserializer.prototype.deserialize = function (xml) {
|
|||
var configurationSettings = this._translateConfigurationSettings(xml);
|
||||
var localResources = this._translateLocalResources(xml);
|
||||
var currentInstance = this._translateCurrentInstance(xml);
|
||||
var isEmulated = xml[ServiceRuntimeConstants.DEPLOYMENT][Constants.METADATA_MARKER][ServiceRuntimeConstants.EMULATED] === 'true';
|
||||
var deploymentId = xml[ServiceRuntimeConstants.DEPLOYMENT][Constants.METADATA_MARKER][ServiceRuntimeConstants.DEPLOYMENT_ID];
|
||||
var isEmulated = xml[ServiceRuntimeConstants.DEPLOYMENT][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.EMULATED] === 'true';
|
||||
var deploymentId = xml[ServiceRuntimeConstants.DEPLOYMENT][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.DEPLOYMENT_ID];
|
||||
var roles = this._translateRoles(xml, currentInstance, currentInstance.roleName);
|
||||
|
||||
var roleEnvironmentData = {
|
||||
|
@ -56,7 +56,7 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateConfigurationSettings = f
|
|||
|
||||
for (var configurationSetting in configurationSettings) {
|
||||
var currentConfigurationSetting = configurationSettings[configurationSetting];
|
||||
configurationSettingsMap[currentConfigurationSetting[Constants.METADATA_MARKER].name] = currentConfigurationSetting[Constants.METADATA_MARKER].value;
|
||||
configurationSettingsMap[currentConfigurationSetting[Constants.XML_METADATA_MARKER].name] = currentConfigurationSetting[Constants.XML_METADATA_MARKER].value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,9 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
|
|||
|
||||
for (var localResource in localResources) {
|
||||
var currentLocalResource = localResources[localResource];
|
||||
var currentLocalResourceName = currentLocalResource[Constants.METADATA_MARKER].name;
|
||||
var currentLocalResourceName = currentLocalResource[Constants.XML_METADATA_MARKER].name;
|
||||
|
||||
localResourcesMap[currentLocalResourceName] = currentLocalResource[Constants.METADATA_MARKER];
|
||||
localResourcesMap[currentLocalResourceName] = currentLocalResource[Constants.XML_METADATA_MARKER];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,10 +89,10 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
|
|||
XmlRoleEnvironmentDataDeserializer.prototype._translateCurrentInstance = function (xml) {
|
||||
var currentInstance = {};
|
||||
|
||||
currentInstance.id = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.METADATA_MARKER].id;
|
||||
currentInstance.roleName = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.METADATA_MARKER].roleName;
|
||||
currentInstance.faultDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.METADATA_MARKER].faultDomain;
|
||||
currentInstance.updateDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.METADATA_MARKER].updateDomain;
|
||||
currentInstance.id = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].id;
|
||||
currentInstance.roleName = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].roleName;
|
||||
currentInstance.faultDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].faultDomain;
|
||||
currentInstance.updateDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].updateDomain;
|
||||
|
||||
if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS]) {
|
||||
currentInstance.endpoints = this._translateRoleInstanceEndpoints(xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS]);
|
||||
|
@ -121,7 +121,7 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, cu
|
|||
|
||||
for (var role in roles) {
|
||||
var currentIterationRole = roles[role];
|
||||
var currentIterationRoleName = currentIterationRole[Constants.METADATA_MARKER].name;
|
||||
var currentIterationRoleName = currentIterationRole[Constants.XML_METADATA_MARKER].name;
|
||||
roleInstances = this._translateRoleInstances(currentIterationRole);
|
||||
|
||||
if (currentIterationRoleName === currentRole) {
|
||||
|
@ -165,7 +165,7 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstances = function
|
|||
|
||||
for (var instance in instances) {
|
||||
var currentIterationInstance = instances[instance];
|
||||
var currentIterationInstanceId = currentIterationInstance[Constants.METADATA_MARKER].id;
|
||||
var currentIterationInstanceId = currentIterationInstance[Constants.XML_METADATA_MARKER].id;
|
||||
|
||||
var endpoints = this._translateRoleInstanceEndpoints(currentIterationInstance[ServiceRuntimeConstants.ENDPOINTS]);
|
||||
|
||||
|
@ -173,9 +173,9 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstances = function
|
|||
endpoints[endpoint].roleInstanceId = currentIterationInstanceId;
|
||||
}
|
||||
|
||||
currentIterationInstance[Constants.METADATA_MARKER].endpoints = endpoints;
|
||||
currentIterationInstance[Constants.XML_METADATA_MARKER].endpoints = endpoints;
|
||||
|
||||
roleInstancesMap[currentIterationInstanceId] = currentIterationInstance[Constants.METADATA_MARKER];
|
||||
roleInstancesMap[currentIterationInstanceId] = currentIterationInstance[Constants.XML_METADATA_MARKER];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,9 +195,9 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstanceEndpoints = f
|
|||
|
||||
for (var endpoint in endpoints) {
|
||||
var currentEndpoint = endpoints[endpoint];
|
||||
var currentEndpointName = currentEndpoint[Constants.METADATA_MARKER].name;
|
||||
var currentEndpointName = currentEndpoint[Constants.XML_METADATA_MARKER].name;
|
||||
|
||||
endpointsMap[currentEndpointName] = currentEndpoint[Constants.METADATA_MARKER];
|
||||
endpointsMap[currentEndpointName] = currentEndpoint[Constants.XML_METADATA_MARKER];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,17 +37,17 @@ EntityResult.serialize = function (entity) {
|
|||
|
||||
if (entity[name] === null) {
|
||||
var newValue = {};
|
||||
newValue[Constants.METADATA_MARKER] = {};
|
||||
newValue[Constants.METADATA_MARKER][AtomHandler.NSMETA + ':null'] = 'true';
|
||||
newValue[Constants.XML_METADATA_MARKER] = {};
|
||||
newValue[Constants.XML_METADATA_MARKER][AtomHandler.NSMETA + ':null'] = 'true';
|
||||
|
||||
properties[AtomHandler.NSDATA + ':' + name] = newValue;
|
||||
} else if (entity[name][Constants.METADATA_MARKER] &&
|
||||
entity[name][Constants.METADATA_MARKER].type) {
|
||||
} else if (entity[name][Constants.XML_METADATA_MARKER] &&
|
||||
entity[name][Constants.XML_METADATA_MARKER].type) {
|
||||
|
||||
properties[AtomHandler.NSDATA + ':' + name] = entity[name];
|
||||
properties[AtomHandler.NSDATA + ':' + name][Constants.METADATA_MARKER][AtomHandler.NSMETA + ':type'] = properties[AtomHandler.NSDATA + ':' + name][Constants.METADATA_MARKER].type;
|
||||
properties[AtomHandler.NSDATA + ':' + name][Constants.XML_METADATA_MARKER][AtomHandler.NSMETA + ':type'] = properties[AtomHandler.NSDATA + ':' + name][Constants.XML_METADATA_MARKER].type;
|
||||
|
||||
delete properties[AtomHandler.NSDATA + ':' + name][Constants.METADATA_MARKER].type;
|
||||
delete properties[AtomHandler.NSDATA + ':' + name][Constants.XML_METADATA_MARKER].type;
|
||||
}
|
||||
else {
|
||||
properties[AtomHandler.NSDATA + ':' + name] = entity[name];
|
||||
|
|
|
@ -38,11 +38,7 @@ function AtomHandler(nsMeta, nsData) {
|
|||
}
|
||||
}
|
||||
|
||||
AtomHandler.prototype.parse = function (entityXml, innerTag, convertTypes) {
|
||||
if (convertTypes === undefined) {
|
||||
convertTypes = true;
|
||||
}
|
||||
|
||||
AtomHandler.prototype.parse = function (entityXml, innerTag) {
|
||||
if (!innerTag) {
|
||||
innerTag = Constants.ATOM_PROPERTIES_MARKER;
|
||||
}
|
||||
|
@ -54,53 +50,52 @@ AtomHandler.prototype.parse = function (entityXml, innerTag, convertTypes) {
|
|||
}
|
||||
|
||||
if (entityXml.link &&
|
||||
entityXml.link[Constants.METADATA_MARKER] &&
|
||||
entityXml.link[Constants.METADATA_MARKER].href) {
|
||||
entityXml.link[Constants.XML_METADATA_MARKER] &&
|
||||
entityXml.link[Constants.XML_METADATA_MARKER].href) {
|
||||
|
||||
entity.link = entityXml.link[Constants.METADATA_MARKER].href;
|
||||
entity.link = entityXml.link[Constants.XML_METADATA_MARKER].href;
|
||||
}
|
||||
|
||||
if (entityXml.updated) {
|
||||
entity.updated = entityXml.updated;
|
||||
}
|
||||
|
||||
if (entityXml[Constants.METADATA_MARKER] &&
|
||||
entityXml[Constants.METADATA_MARKER][this._xmlQualifyXmlTagName('etag', this.nsMeta)]) {
|
||||
if (entityXml[Constants.XML_METADATA_MARKER] &&
|
||||
entityXml[Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('etag', this.nsMeta)]) {
|
||||
|
||||
entity.etag = entityXml[Constants.METADATA_MARKER][this._xmlQualifyXmlTagName('etag', this.nsMeta)];
|
||||
entity.etag = entityXml[Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('etag', this.nsMeta)];
|
||||
}
|
||||
|
||||
var propertiesXmlTag = this._xmlQualifyXmlTagName(innerTag, this.nsMeta);
|
||||
|
||||
if (entityXml.content && entityXml.content[propertiesXmlTag]) {
|
||||
for (var property in entityXml.content[propertiesXmlTag]) {
|
||||
if (property !== Constants.METADATA_MARKER) {
|
||||
var propertyName = property;
|
||||
if (property.indexOf(this.nsData) !== -1) {
|
||||
propertyName = property.substr(2, property.length - 2);
|
||||
}
|
||||
var propertyName = property;
|
||||
if (azureutil.stringStartsWith(propertyName, this.nsData + ':')) {
|
||||
propertyName = property.substr(2, property.length - 2);
|
||||
}
|
||||
|
||||
if (property !== Constants.XML_METADATA_MARKER) {
|
||||
if (azureutil.objectIsEmpty(entityXml.content[propertiesXmlTag][property])) {
|
||||
// Empty properties are represented as an empty string.
|
||||
entity[propertyName] = '';
|
||||
} else if (entityXml.content[propertiesXmlTag][property][Constants.ATOM_VALUE_MARKER]) {
|
||||
} else if (entityXml.content[propertiesXmlTag][property][Constants.XML_METADATA_MARKER] !== undefined &&
|
||||
entityXml.content[propertiesXmlTag][property][Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('null', this.nsMeta)] &&
|
||||
entityXml.content[propertiesXmlTag][property][Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('null', this.nsMeta)] === 'true') {
|
||||
entity[propertyName] = null;
|
||||
} else if (entityXml.content[propertiesXmlTag][property][Constants.XML_VALUE_MARKER] !== undefined) {
|
||||
// Has an entry for value
|
||||
if (convertTypes) {
|
||||
if (entityXml.content[propertiesXmlTag][property][Constants.METADATA_MARKER] &&
|
||||
entityXml.content[propertiesXmlTag][property][Constants.METADATA_MARKER][this._xmlQualifyXmlTagName('type', this.nsMeta)]) {
|
||||
if (entityXml.content[propertiesXmlTag][property][Constants.XML_METADATA_MARKER] &&
|
||||
entityXml.content[propertiesXmlTag][property][Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('type', this.nsMeta)]) {
|
||||
// Has metadata for type
|
||||
this._setProperty(
|
||||
entity,
|
||||
propertyName,
|
||||
entityXml.content[propertiesXmlTag][property][Constants.ATOM_VALUE_MARKER],
|
||||
entityXml.content[propertiesXmlTag][property][Constants.METADATA_MARKER][this._xmlQualifyXmlTagName('type', this.nsMeta)]);
|
||||
} else {
|
||||
entity[propertyName] = this._propertyFromString(entityXml.content[propertiesXmlTag][property][Constants.ATOM_VALUE_MARKER]);
|
||||
}
|
||||
this._setProperty(
|
||||
entity,
|
||||
propertyName,
|
||||
entityXml.content[propertiesXmlTag][property][Constants.XML_VALUE_MARKER],
|
||||
entityXml.content[propertiesXmlTag][property][Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('type', this.nsMeta)]);
|
||||
} else {
|
||||
// The situation where a value marker exists and no type / null metadata marker exists shouldn't happen, but, just in case ...
|
||||
entity[propertyName] = entityXml.content[propertiesXmlTag][property][Constants.XML_VALUE_MARKER];
|
||||
}
|
||||
} else if (convertTypes) {
|
||||
// No metadata for type but try to infer the type
|
||||
entity[propertyName] = this._propertyFromString(entityXml.content[propertiesXmlTag][property]);
|
||||
} else {
|
||||
entity[propertyName] = entityXml.content[propertiesXmlTag][property];
|
||||
}
|
||||
|
@ -141,7 +136,7 @@ AtomHandler.prototype._setProperty = function (entity, propertyName, value, type
|
|||
entity[propertyName] = value;
|
||||
break;
|
||||
case "Edm.Boolean":
|
||||
entity[propertyName] = value === 'true';
|
||||
entity[propertyName] = value === 'true' || value === '1';
|
||||
break;
|
||||
case "Edm.Byte":
|
||||
entity[propertyName] = value;
|
||||
|
@ -212,14 +207,20 @@ AtomHandler.prototype._writeAtomEntryValue = function (parentElement, name, valu
|
|||
if (!azureutil.stringIsEmpty(value) &&
|
||||
typeof value === 'object') {
|
||||
|
||||
if (!azureutil.objectIsNull(value[Constants.ATOM_VALUE_MARKER]) &&
|
||||
!azureutil.objectIsNull(value[Constants.METADATA_MARKER]) &&
|
||||
!azureutil.objectIsNull(value[Constants.METADATA_MARKER][this._xmlQualifyXmlTagName('type', this.nsMeta)])) {
|
||||
if (!azureutil.objectIsNull(value[Constants.XML_VALUE_MARKER]) &&
|
||||
!azureutil.objectIsNull(value[Constants.XML_METADATA_MARKER]) &&
|
||||
!azureutil.objectIsNull(value[Constants.XML_METADATA_MARKER][this._xmlQualifyXmlTagName('type', this.nsMeta)])) {
|
||||
|
||||
// Primitive value + type
|
||||
var propertyType = value[Constants.METADATA_MARKER].type;
|
||||
parentElement = parentElement.ele(propertyTagName)
|
||||
.txt(this._convertToAtomPropertyText(value[Constants.ATOM_VALUE_MARKER], propertyType));
|
||||
var propertyType = value[Constants.XML_METADATA_MARKER].type;
|
||||
parentElement = parentElement.ele(propertyTagName);
|
||||
|
||||
if (!azureutil.stringIsEmpty(value[Constants.XML_VALUE_MARKER])) {
|
||||
parentElement = parentElement.txt(this._convertToAtomPropertyText(value[Constants.XML_VALUE_MARKER], propertyType));
|
||||
} else if (azureutil.stringStartsWith(propertyTagName, this.nsData + ':')) {
|
||||
// If the property is data, we may need to mark it as null
|
||||
parentElement.att(this._xmlQualifyXmlTagName('null', this.nsMeta), 'true');
|
||||
}
|
||||
} else if (this._isDate(value)) {
|
||||
parentElement = parentElement.ele(propertyTagName)
|
||||
.txt(this._convertToAtomPropertyText(value, "Edm.DateTime"));
|
||||
|
@ -233,7 +234,7 @@ AtomHandler.prototype._writeAtomEntryValue = function (parentElement, name, valu
|
|||
} else if (typeof value === 'object') {
|
||||
parentElement = parentElement.ele(propertyTagName);
|
||||
for (var propertyName in value) {
|
||||
if (propertyName !== Constants.METADATA_MARKER) {
|
||||
if (propertyName !== Constants.XML_METADATA_MARKER) {
|
||||
parentElement = this._writeAtomEntryValue(parentElement, propertyName, value[propertyName]);
|
||||
}
|
||||
}
|
||||
|
@ -244,13 +245,16 @@ AtomHandler.prototype._writeAtomEntryValue = function (parentElement, name, valu
|
|||
} else {
|
||||
parentElement = parentElement.ele(propertyTagName);
|
||||
if (!azureutil.stringIsEmpty(value)) {
|
||||
parentElement = parentElement.txt(this._convertToAtomPropertyText(value, "Edm.String"));
|
||||
parentElement = parentElement.txt(this._convertToAtomPropertyText(value, 'Edm.String'));
|
||||
} else if (azureutil.stringStartsWith(propertyTagName, this.nsData + ':')) {
|
||||
// If the property is data, we may need to mark it as null
|
||||
parentElement.att(this._xmlQualifyXmlTagName('null', this.nsMeta), 'true');
|
||||
}
|
||||
}
|
||||
|
||||
if (value && value[Constants.METADATA_MARKER]) {
|
||||
if (value && value[Constants.XML_METADATA_MARKER]) {
|
||||
// include the metadata
|
||||
var attributeList = value[Constants.METADATA_MARKER];
|
||||
var attributeList = value[Constants.XML_METADATA_MARKER];
|
||||
for (var attribute in attributeList) {
|
||||
parentElement = parentElement.att(attribute, attributeList[attribute]);
|
||||
}
|
||||
|
@ -316,24 +320,4 @@ var propertyTypeFormatters = {
|
|||
"Edm.Single": formatToString,
|
||||
"Edm.String": formatToString,
|
||||
"Edm.Time": formatToString
|
||||
};
|
||||
|
||||
AtomHandler.prototype._propertyFromString = function (value) {
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (value === 'true') {
|
||||
return true;
|
||||
} else if (value === 'false') {
|
||||
return false;
|
||||
} else if (azureutil.stringIsNumber(value)) {
|
||||
if (azureutil.stringIsInt(value)) {
|
||||
return parseInt(value, 10);
|
||||
} else {
|
||||
return parseFloat(value);
|
||||
}
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -727,7 +727,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
METADATA_MARKER: '@',
|
||||
XML_METADATA_MARKER: '@',
|
||||
|
||||
/**
|
||||
* Marker for atom value.
|
||||
|
@ -735,7 +735,7 @@ var Constants = {
|
|||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ATOM_VALUE_MARKER: '#',
|
||||
XML_VALUE_MARKER: '#',
|
||||
|
||||
/**
|
||||
* Marker for atom title tag.
|
||||
|
|
|
@ -32,9 +32,9 @@ exports.serialize = function (entity) {
|
|||
|
||||
doc = doc.begin(rootElementName, { version: '1.0', encoding: 'utf-8', standalone: 'yes' });
|
||||
|
||||
if (entity[rootElementName][Constants.METADATA_MARKER]) {
|
||||
for (var metadata in entity[rootElementName][Constants.METADATA_MARKER]) {
|
||||
doc.att(metadata, entity[rootElementName][Constants.METADATA_MARKER][metadata]);
|
||||
if (entity[rootElementName][Constants.XML_METADATA_MARKER]) {
|
||||
for (var metadata in entity[rootElementName][Constants.XML_METADATA_MARKER]) {
|
||||
doc.att(metadata, entity[rootElementName][Constants.XML_METADATA_MARKER][metadata]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ function _writeAtomEntryValue (parentElement, name, value) {
|
|||
} else if (typeof value === 'object') {
|
||||
parentElement = parentElement.ele(propertyTagName);
|
||||
for (var propertyName in value) {
|
||||
if (propertyName !== Constants.METADATA_MARKER) {
|
||||
if (propertyName !== Constants.XML_METADATA_MARKER) {
|
||||
parentElement = _writeAtomEntryValue(parentElement, propertyName, value[propertyName]);
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ function _writeAtomEntryValue (parentElement, name, value) {
|
|||
}
|
||||
}
|
||||
|
||||
if (value && value[Constants.METADATA_MARKER]) {
|
||||
if (value && value[Constants.XML_METADATA_MARKER]) {
|
||||
// include the metadata
|
||||
var attributeList = value[Constants.METADATA_MARKER];
|
||||
var attributeList = value[Constants.XML_METADATA_MARKER];
|
||||
for (var attribute in attributeList) {
|
||||
parentElement = parentElement.att(attribute, attributeList[attribute]);
|
||||
}
|
||||
|
|
|
@ -594,12 +594,12 @@ suite('servicebusservice-tests', function () {
|
|||
if (topic) {
|
||||
assert.equal(topic.TopicName, topicName);
|
||||
|
||||
assert.equal(topic.MaxSizeInMegabytes, topicOptions.MaxSizeInMegabytes);
|
||||
assert.equal(topic.RequiresDuplicateDetection, topicOptions.RequiresDuplicateDetection);
|
||||
assert.equal(topic.DefaultMessageTimeToLive, topicOptions.DefaultMessageTimeToLive);
|
||||
assert.equal(topic.DuplicateDetectionHistoryTimeWindow, topicOptions.DuplicateDetectionHistoryTimeWindow);
|
||||
assert.equal(topic.EnableBatchedOperations, topicOptions.EnableBatchedOperations);
|
||||
assert.equal(topic.SizeInBytes, topicOptions.SizeInBytes);
|
||||
assert.equal(topic.MaxSizeInMegabytes, topicOptions.MaxSizeInMegabytes.toString());
|
||||
assert.equal(topic.RequiresDuplicateDetection, topicOptions.RequiresDuplicateDetection.toString());
|
||||
assert.equal(topic.DefaultMessageTimeToLive, topicOptions.DefaultMessageTimeToLive.toString());
|
||||
assert.equal(topic.DuplicateDetectionHistoryTimeWindow, topicOptions.DuplicateDetectionHistoryTimeWindow.toString());
|
||||
assert.equal(topic.EnableBatchedOperations, topicOptions.EnableBatchedOperations.toString());
|
||||
assert.equal(topic.SizeInBytes, topicOptions.SizeInBytes.toString());
|
||||
}
|
||||
|
||||
servicebustestutil.checkNullParameter(function () {
|
||||
|
@ -900,11 +900,11 @@ suite('servicebusservice-tests', function () {
|
|||
assert.equal(createSubscriptionError2, null);
|
||||
assert.notEqual(subscription2, null);
|
||||
|
||||
assert.equal(subscription2.LockDuration, subscriptionOptions.LockDuration);
|
||||
assert.equal(subscription2.RequiresSession, subscriptionOptions.RequiresSession);
|
||||
assert.equal(subscription2.DefaultMessageTimeToLive, subscriptionOptions.DefaultMessageTimeToLive);
|
||||
assert.equal(subscription2.DeadLetteringOnMessageExpiration, subscriptionOptions.DeadLetteringOnMessageExpiration);
|
||||
assert.equal(subscription2.DeadLetteringOnFilterEvaluationExceptions, subscriptionOptions.DeadLetteringOnFilterEvaluationExceptions);
|
||||
assert.equal(subscription2.LockDuration, subscriptionOptions.LockDuration.toString());
|
||||
assert.equal(subscription2.RequiresSession, subscriptionOptions.RequiresSession.toString());
|
||||
assert.equal(subscription2.DefaultMessageTimeToLive, subscriptionOptions.DefaultMessageTimeToLive.toString());
|
||||
assert.equal(subscription2.DeadLetteringOnMessageExpiration, subscriptionOptions.DeadLetteringOnMessageExpiration.toString());
|
||||
assert.equal(subscription2.DeadLetteringOnFilterEvaluationExceptions, subscriptionOptions.DeadLetteringOnFilterEvaluationExceptions.toString());
|
||||
|
||||
// duplicate subscription
|
||||
serviceBusService.createSubscription(topicName, subscriptionName1, function (subscriptionError, duplicateSubscription) {
|
||||
|
|
|
@ -28,9 +28,11 @@ suite('atomhandler-tests', function () {
|
|||
test('Serialize', function (done) {
|
||||
var atomHandler = new AtomHandler('m', 'd');
|
||||
|
||||
var dateTime = ISO8061Date.format(new Date());
|
||||
|
||||
var entity = {
|
||||
title: '',
|
||||
updated: ISO8061Date.format(new Date()),
|
||||
updated: dateTime,
|
||||
author: {
|
||||
name: ''
|
||||
},
|
||||
|
@ -43,36 +45,201 @@ suite('atomhandler-tests', function () {
|
|||
'd:PartitionKey': 'part1',
|
||||
'd:RowKey': 'row1',
|
||||
'd:intValue': 10,
|
||||
'd:stringValue': 'my string'
|
||||
'd:stringValue': 'my string',
|
||||
'd:nullValue': null
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var res = atomHandler.serialize(entity);
|
||||
|
||||
assert.ok(res.indexOf(
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"
|
||||
+ "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
|
||||
+ "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" "
|
||||
+ "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\">"
|
||||
+ "<title/>"
|
||||
+ "<updated>") !== -1);
|
||||
assert.equal(res,
|
||||
'<?xml version="1.0" encoding="utf-8" standalone="yes"?>' +
|
||||
'<entry xmlns="http://www.w3.org/2005/Atom" ' +
|
||||
'xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" ' +
|
||||
'xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">' +
|
||||
'<title/>' +
|
||||
'<updated>' + dateTime + '</updated>' +
|
||||
'<author>' +
|
||||
'<name/>' +
|
||||
'</author>' +
|
||||
'<id/>' +
|
||||
'<content type="application/xml">' +
|
||||
'<m:properties>' +
|
||||
'<d:PartitionKey>part1</d:PartitionKey>' +
|
||||
'<d:RowKey>row1</d:RowKey>' +
|
||||
'<d:intValue>10</d:intValue>' +
|
||||
'<d:stringValue>my string</d:stringValue>' +
|
||||
'<d:nullValue m:null="true"/>' +
|
||||
'</m:properties>' +
|
||||
'</content>' +
|
||||
'</entry>'
|
||||
);
|
||||
|
||||
assert.ok(res.indexOf(
|
||||
"</updated>"
|
||||
+ "<author>"
|
||||
+ "<name/>"
|
||||
+ "</author>"
|
||||
+ "<id/>"
|
||||
+ "<content type=\"application/xml\">"
|
||||
+ "<m:properties>"
|
||||
+ "<d:PartitionKey>part1</d:PartitionKey>"
|
||||
+ "<d:RowKey>row1</d:RowKey>"
|
||||
+ "<d:intValue>10</d:intValue>"
|
||||
+ "<d:stringValue>my string</d:stringValue>"
|
||||
+ "</m:properties>"
|
||||
+ "</content>"
|
||||
+ "</entry>") !== -1);
|
||||
done();
|
||||
});
|
||||
|
||||
test('SerializeDataTypes', function (done) {
|
||||
var atomHandler = new AtomHandler('m', 'd');
|
||||
|
||||
var dateTime = ISO8061Date.format(new Date());
|
||||
|
||||
var entity = {
|
||||
title: '',
|
||||
updated: dateTime,
|
||||
author: {
|
||||
name: ''
|
||||
},
|
||||
id: '',
|
||||
content: {
|
||||
'@': {
|
||||
type: 'application/xml'
|
||||
},
|
||||
'm:properties': {
|
||||
'd:PartitionKey': {
|
||||
'#': 'part1',
|
||||
'@': { 'm:type': 'Edm.String' }
|
||||
},
|
||||
'd:RowKey': {
|
||||
'#': 'row1',
|
||||
'@': { 'm:type': 'Edm.String' }
|
||||
},
|
||||
'd:intValue': {
|
||||
'#': 10,
|
||||
'@': { 'm:type': 'Edm.Int32' }
|
||||
},
|
||||
'd:stringValue': {
|
||||
'#': 'my string',
|
||||
'@': { 'm:type': 'Edm.String' }
|
||||
},
|
||||
'd:nullValue': null
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var res = atomHandler.serialize(entity);
|
||||
|
||||
assert.equal(res,
|
||||
'<?xml version="1.0" encoding="utf-8" standalone="yes"?>' +
|
||||
'<entry xmlns="http://www.w3.org/2005/Atom" ' +
|
||||
'xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" ' +
|
||||
'xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">' +
|
||||
'<title/>' +
|
||||
'<updated>' + dateTime + '</updated>' +
|
||||
'<author>' +
|
||||
'<name/>' +
|
||||
'</author>' +
|
||||
'<id/>' +
|
||||
'<content type="application/xml">' +
|
||||
'<m:properties>' +
|
||||
'<d:PartitionKey m:type="Edm.String">part1</d:PartitionKey>' +
|
||||
'<d:RowKey m:type="Edm.String">row1</d:RowKey>' +
|
||||
'<d:intValue m:type="Edm.Int32">10</d:intValue>' +
|
||||
'<d:stringValue m:type="Edm.String">my string</d:stringValue>' +
|
||||
'<d:nullValue m:null="true"/>' +
|
||||
'</m:properties>' +
|
||||
'</content>' +
|
||||
'</entry>'
|
||||
);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('Parse', function (done) {
|
||||
var atomHandler = new AtomHandler('m', 'd');
|
||||
|
||||
var entityXmlJs = {
|
||||
title: '',
|
||||
updated: '',
|
||||
author: {
|
||||
name: ''
|
||||
},
|
||||
id: '',
|
||||
content: {
|
||||
'@': {
|
||||
type: 'application/xml'
|
||||
},
|
||||
'm:properties': {
|
||||
'd:PartitionKey': 'part1',
|
||||
'd:RowKey': 'row1',
|
||||
'd:intValue': '10',
|
||||
'd:stringValue': 'my string',
|
||||
'd:nullValue': '',
|
||||
'd:nullValue2': null
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var entityResult = atomHandler.parse(entityXmlJs);
|
||||
|
||||
var entity = {
|
||||
'PartitionKey': 'part1',
|
||||
'RowKey': 'row1',
|
||||
'intValue': '10',
|
||||
'stringValue': 'my string',
|
||||
'nullValue': '',
|
||||
'nullValue2': ''
|
||||
};
|
||||
|
||||
assert.deepEqual(entityResult, entity);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test('ParseDataTypes', function (done) {
|
||||
var atomHandler = new AtomHandler('m', 'd');
|
||||
|
||||
var entityXmlJs = {
|
||||
title: '',
|
||||
updated: '',
|
||||
author: {
|
||||
name: ''
|
||||
},
|
||||
id: '',
|
||||
content: {
|
||||
'@': {
|
||||
type: 'application/xml'
|
||||
},
|
||||
'm:properties': {
|
||||
'd:PartitionKey': {
|
||||
'#': 'part1',
|
||||
'@': { 'm:type': 'Edm.String' }
|
||||
},
|
||||
'd:RowKey': {
|
||||
'#': 'row1',
|
||||
'@': { 'm:type': 'Edm.String' }
|
||||
},
|
||||
'd:intValue': {
|
||||
'#': '10',
|
||||
'@': { 'm:type': 'Edm.Int32' }
|
||||
},
|
||||
'd:stringValue': {
|
||||
'#': 'my string',
|
||||
'@': { 'm:type': 'Edm.String' }
|
||||
},
|
||||
'd:nullValue': {
|
||||
'#': '',
|
||||
'@': { 'm:null': 'true' }
|
||||
},
|
||||
'd:nullValue2': {
|
||||
'@': { 'm:null': 'true' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var entityResult = atomHandler.parse(entityXmlJs);
|
||||
|
||||
var entity = {
|
||||
'PartitionKey': 'part1',
|
||||
'RowKey': 'row1',
|
||||
'intValue': 10,
|
||||
'stringValue': 'my string',
|
||||
'nullValue': null,
|
||||
'nullValue2': null
|
||||
};
|
||||
|
||||
assert.deepEqual(entityResult, entity);
|
||||
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -81,7 +81,7 @@ exports.tearDownTest = function (numberTests, serviceBusService, testPrefix, cal
|
|||
});
|
||||
};
|
||||
|
||||
var checkValue = function( test, value, optionValue) {
|
||||
var checkValue = function(test, value, optionValue) {
|
||||
if (optionValue) {
|
||||
assert.equal(value, optionValue);
|
||||
}
|
||||
|
@ -91,13 +91,13 @@ exports.validateQueue = function(testObject, queueName, queueOptions, queue) {
|
|||
testObject.notEqual(queue, null);
|
||||
if (queue) {
|
||||
testObject.equal(queue.QueueName, queueName);
|
||||
checkValue(testObject, queue.LockDuration, queueOptions.LockDuration);
|
||||
checkValue(testObject, queue.RequiresDuplicateDetection, queueOptions.RequiresDuplicateDetection);
|
||||
checkValue(testObject, queue.RequiresSession, queueOptions.RequiresSession);
|
||||
checkValue(testObject, queue.DefaultMessageTimeToLive, queueOptions.DefaultMessageTimeToLive);
|
||||
checkValue(testObject, queue.DeadLetteringOnMessageExpiration, queueOptions.DeadLetteringOnMessageExpiration);
|
||||
checkValue(testObject, queue.DuplicateDetectionHistoryTimeWindow, queueOptions.DuplicateDetectionHistoryTimeWindow);
|
||||
checkValue(testObject, queue.MaxSizeInMegabytes, queueOptions.MaxSizeInMegabytes);
|
||||
checkValue(testObject, queue.LockDuration, queueOptions.LockDuration.toString());
|
||||
checkValue(testObject, queue.RequiresDuplicateDetection, queueOptions.RequiresDuplicateDetection.toString());
|
||||
checkValue(testObject, queue.RequiresSession, queueOptions.RequiresSession.toString());
|
||||
checkValue(testObject, queue.DefaultMessageTimeToLive, queueOptions.DefaultMessageTimeToLive.toString());
|
||||
checkValue(testObject, queue.DeadLetteringOnMessageExpiration, queueOptions.DeadLetteringOnMessageExpiration.toString());
|
||||
checkValue(testObject, queue.DuplicateDetectionHistoryTimeWindow, queueOptions.DuplicateDetectionHistoryTimeWindow.toString());
|
||||
checkValue(testObject, queue.MaxSizeInMegabytes, queueOptions.MaxSizeInMegabytes.toString());
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче