1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
%{
**********************************************************************
Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
This copy of Ice is licensed to you under the terms described in the
ICE_LICENSE file included in this distribution.
**********************************************************************
%}
classdef TestApp < handle
methods(Static)
function [initData, extraArgs] = createInitData(appName, args)
initData = Ice.InitializationData();
a = [appName, args]; % Insert appName as the first argument -- this becomes the value of Ice.ProgramName.
[initData.properties_, extraArgs] = Ice.createProperties(a);
extraArgs = initData.properties_.parseCommandLineOptions('Test', extraArgs);
end
end
methods
function obj = TestApp(communicator)
obj.communicator_ = communicator;
obj.properties_ = communicator.getProperties();
obj.appName_ = obj.properties_.getProperty('Ice.ProgramName');
end
function r = appName(obj)
r = obj.appName_;
end
function r = communicator(obj)
r = obj.communicator_;
end
function initData = cloneInitData(obj)
initData = Ice.InitializationData();
initData.properties_ = obj.properties_.clone();
end
function r = getTestEndpoint(obj, num, prot)
if nargin == 2
prot = '';
end
r = TestApp.getTestEndpointWithProperties(obj.properties_, num, prot);
end
function r = getTestHost(obj)
r = TestApp.getTestHostWithProperties(obj.properties_);
end
function r = getTestProtocol(obj)
r = TestApp.getTestProtocolWithProperties(obj.properties_);
end
function r = getTestPort(obj, num)
r = TestApp.getTestPortWithProperties(obj.properties_, num);
end
end
methods(Static, Access=private)
function r = getTestEndpointWithProperties(props, num, prot)
if length(prot) == 0
prot = props.getPropertyWithDefault('Ice.Default.Protocol', 'default');
end
basePort = props.getPropertyAsIntWithDefault('Test.BasePort', 12010);
r = sprintf('%s -p %d', prot, basePort + num);
end
function r = getTestHostWithProperties(props)
r = props.getPropertyWithDefault('Ice.Default.Host', '127.0.0.1');
end
function r = getTestProtocolWithProperties(props)
r = props.getPropertyWithDefault('Ice.Default.Protocol', 'tcp');
end
function r = getTestPortWithProperties(props, num)
r = props.getPropertyAsIntWithDefault('Test.BasePort', 12010) + num;
end
end
properties(Access=private)
appName_
communicator_
properties_
end
end
|