2013-11-08 10:22:08 +04:00
|
|
|
|
//
|
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
//
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
2012-03-13 05:10:28 +04:00
|
|
|
|
|
|
|
|
|
var assert = require('assert');
|
2012-04-16 09:40:23 +04:00
|
|
|
|
var sinon = require('sinon');
|
2012-03-13 05:10:28 +04:00
|
|
|
|
|
2012-04-16 09:40:23 +04:00
|
|
|
|
// Test includes
|
|
|
|
|
var testutil = require('../util/util');
|
|
|
|
|
|
|
|
|
|
// Lib includes
|
|
|
|
|
var NamedPipeInputChannel = testutil.libRequire('serviceruntime/namedpipeinputchannel');
|
|
|
|
|
var RuntimeVersionProtocolClient = testutil.libRequire('serviceruntime/runtimeversionprotocolclient');
|
2012-03-13 05:10:28 +04:00
|
|
|
|
|
|
|
|
|
suite('runtimeversionprotocolclient-tests', function () {
|
2012-04-16 09:40:23 +04:00
|
|
|
|
test('getVersionMap single', function (done) {
|
|
|
|
|
var versionsEndpointPath = 'versionsEndpointPath';
|
|
|
|
|
|
2012-03-13 05:10:28 +04:00
|
|
|
|
var inputChannel = new NamedPipeInputChannel();
|
2012-04-16 09:40:23 +04:00
|
|
|
|
var stub = sinon.stub(inputChannel, '_readData');
|
|
|
|
|
|
|
|
|
|
stub.withArgs(versionsEndpointPath).callsArgWith(1, undefined,
|
2012-03-13 05:10:28 +04:00
|
|
|
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
2013-12-13 14:59:48 +04:00
|
|
|
|
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
2012-03-13 05:10:28 +04:00
|
|
|
|
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
|
|
|
|
"<RuntimeServerEndpoints>" +
|
|
|
|
|
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
|
|
|
|
"</RuntimeServerEndpoints>" +
|
2012-04-16 09:40:23 +04:00
|
|
|
|
"</RuntimeServerDiscovery>"
|
|
|
|
|
);
|
2012-03-13 05:10:28 +04:00
|
|
|
|
|
|
|
|
|
var runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(inputChannel);
|
2012-04-16 09:40:23 +04:00
|
|
|
|
runtimeVersionProtocolClient.getVersionMap(versionsEndpointPath, function (error, versions) {
|
2012-03-13 05:10:28 +04:00
|
|
|
|
assert.equal(error, null);
|
|
|
|
|
assert.notEqual(versions, null);
|
|
|
|
|
assert.equal(versions["2011-03-08"], "SomePath.GoalState");
|
|
|
|
|
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-16 09:40:23 +04:00
|
|
|
|
test('getVersionMap array', function (done) {
|
|
|
|
|
var versionsEndpointPath = 'versionsEndpointPath';
|
|
|
|
|
|
2012-03-13 05:10:28 +04:00
|
|
|
|
var inputChannel = new NamedPipeInputChannel();
|
2012-04-16 09:40:23 +04:00
|
|
|
|
var stub = sinon.stub(inputChannel, '_readData');
|
|
|
|
|
|
|
|
|
|
stub.withArgs(versionsEndpointPath).callsArgWith(1, undefined,
|
2012-03-13 05:10:28 +04:00
|
|
|
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
2013-12-13 14:59:48 +04:00
|
|
|
|
"<RuntimeServerDiscovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
2012-03-13 05:10:28 +04:00
|
|
|
|
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
|
|
|
|
|
"<RuntimeServerEndpoints>" +
|
|
|
|
|
"<RuntimeServerEndpoint version=\"2011-03-08\" path=\"SomePath.GoalState\" />" +
|
|
|
|
|
"<RuntimeServerEndpoint version=\"2011-08-08\" path=\"SomeOtherPath.GoalState\" />" +
|
|
|
|
|
"</RuntimeServerEndpoints>" +
|
2012-04-16 09:40:23 +04:00
|
|
|
|
"</RuntimeServerDiscovery>"
|
|
|
|
|
);
|
2012-03-13 05:10:28 +04:00
|
|
|
|
|
|
|
|
|
var runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(inputChannel);
|
2012-04-16 09:40:23 +04:00
|
|
|
|
runtimeVersionProtocolClient.getVersionMap(versionsEndpointPath, function (error, versions) {
|
2012-03-13 05:10:28 +04:00
|
|
|
|
assert.equal(error, null);
|
|
|
|
|
assert.notEqual(versions, null);
|
|
|
|
|
assert.equal(versions["2011-03-08"], "SomePath.GoalState");
|
|
|
|
|
assert.equal(versions["2011-08-08"], "SomeOtherPath.GoalState");
|
|
|
|
|
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
2012-04-16 09:40:23 +04:00
|
|
|
|
});
|