diff --git a/lib/serviceruntime/runtimeversionprotocolclient.js b/lib/serviceruntime/runtimeversionprotocolclient.js
index 00989c3e6..f21147fec 100644
--- a/lib/serviceruntime/runtimeversionprotocolclient.js
+++ b/lib/serviceruntime/runtimeversionprotocolclient.js
@@ -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;
}
}
diff --git a/lib/serviceruntime/xmlcurrentstateserializer.js b/lib/serviceruntime/xmlcurrentstateserializer.js
index 2f2ae28d6..da69cfb7a 100644
--- a/lib/serviceruntime/xmlcurrentstateserializer.js
+++ b/lib/serviceruntime/xmlcurrentstateserializer.js
@@ -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) {
diff --git a/lib/serviceruntime/xmlroleenvironmentdatadeserializer.js b/lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
index f6c5d40d2..bac0bff19 100644
--- a/lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
+++ b/lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
@@ -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];
}
}
diff --git a/lib/services/table/models/entityresult.js b/lib/services/table/models/entityresult.js
index 46a4a1796..34334fa84 100644
--- a/lib/services/table/models/entityresult.js
+++ b/lib/services/table/models/entityresult.js
@@ -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];
diff --git a/lib/util/atomhandler.js b/lib/util/atomhandler.js
index 5ee0f97cf..36a6fe71d 100644
--- a/lib/util/atomhandler.js
+++ b/lib/util/atomhandler.js
@@ -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;
- }
-};
+};
\ No newline at end of file
diff --git a/lib/util/constants.js b/lib/util/constants.js
index b1125f2d8..3eb8cfa11 100644
--- a/lib/util/constants.js
+++ b/lib/util/constants.js
@@ -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.
diff --git a/lib/util/js2xml.js b/lib/util/js2xml.js
index 9d0b9031b..f7f5885bd 100644
--- a/lib/util/js2xml.js
+++ b/lib/util/js2xml.js
@@ -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]);
}
diff --git a/test/services/serviceBus/servicebusservice-tests.js b/test/services/serviceBus/servicebusservice-tests.js
index 78e4a506a..1f6ff56f2 100644
--- a/test/services/serviceBus/servicebusservice-tests.js
+++ b/test/services/serviceBus/servicebusservice-tests.js
@@ -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) {
diff --git a/test/util/atomhandler-tests.js b/test/util/atomhandler-tests.js
index 9c731cfdb..0f7cc68a7 100644
--- a/test/util/atomhandler-tests.js
+++ b/test/util/atomhandler-tests.js
@@ -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(
- ""
- + ""
- + ""
- + "") !== -1);
+ assert.equal(res,
+ '' +
+ '' +
+ '' +
+ '' + dateTime + '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ 'part1' +
+ 'row1' +
+ '10' +
+ 'my string' +
+ '' +
+ '' +
+ '' +
+ ''
+ );
- assert.ok(res.indexOf(
- ""
- + ""
- + ""
- + ""
- + ""
- + ""
- + ""
- + "part1"
- + "row1"
- + "10"
- + "my string"
- + ""
- + ""
- + "") !== -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,
+ '' +
+ '' +
+ '' +
+ '' + dateTime + '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ 'part1' +
+ 'row1' +
+ '10' +
+ 'my string' +
+ '' +
+ '' +
+ '' +
+ ''
+ );
+
+ 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();
});
diff --git a/test/util/servicebus-test-utils.js b/test/util/servicebus-test-utils.js
index 8d21cb95d..2a73148b5 100644
--- a/test/util/servicebus-test-utils.js
+++ b/test/util/servicebus-test-utils.js
@@ -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());
};
};