summaryrefslogtreecommitdiff
path: root/matlab/test
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2017-10-03 15:15:31 -0700
committerMark Spruiell <mes@zeroc.com>2017-10-03 15:15:31 -0700
commit3c1ed6f3c56943fa7938042f72dc20dc79f6ae2a (patch)
tree5af66030548c3250946ee68f786e60fa5bfee9c7 /matlab/test
parentAdding inheritance test (diff)
downloadice-3c1ed6f3c56943fa7938042f72dc20dc79f6ae2a.tar.bz2
ice-3c1ed6f3c56943fa7938042f72dc20dc79f6ae2a.tar.xz
ice-3c1ed6f3c56943fa7938042f72dc20dc79f6ae2a.zip
Adding more tests; checksum support
Diffstat (limited to 'matlab/test')
-rw-r--r--matlab/test/Ice/acm/AllTests.m99
-rw-r--r--matlab/test/Ice/acm/Application.m143
-rw-r--r--matlab/test/Ice/acm/Client.m37
-rw-r--r--matlab/test/Ice/acm/Test.ice39
-rw-r--r--matlab/test/Ice/acm/generated/.gitignore1
-rw-r--r--matlab/test/Ice/acm/runTest.m4
-rw-r--r--matlab/test/Ice/ami/Client.m2
-rw-r--r--matlab/test/Ice/ami/runTest.m4
-rw-r--r--matlab/test/Ice/checksum/AllTests.m70
-rw-r--r--matlab/test/Ice/checksum/Application.m143
-rw-r--r--matlab/test/Ice/checksum/Client.m37
-rw-r--r--matlab/test/Ice/checksum/Test.ice25
-rw-r--r--matlab/test/Ice/checksum/Types.ice615
-rw-r--r--matlab/test/Ice/checksum/generated/.gitignore1
-rw-r--r--matlab/test/Ice/checksum/runTest.m4
-rw-r--r--matlab/test/Ice/defaultValue/AllTests.m181
-rw-r--r--matlab/test/Ice/defaultValue/Application.m143
-rw-r--r--matlab/test/Ice/defaultValue/Client.m29
-rw-r--r--matlab/test/Ice/defaultValue/Test.ice211
-rw-r--r--matlab/test/Ice/defaultValue/generated/.gitignore1
-rw-r--r--matlab/test/Ice/defaultValue/runTest.m4
-rw-r--r--matlab/test/Ice/enums/Client.m2
-rw-r--r--matlab/test/Ice/enums/runTest.m4
-rw-r--r--matlab/test/Ice/exceptions/Client.m2
-rw-r--r--matlab/test/Ice/exceptions/runTest.m4
-rw-r--r--matlab/test/Ice/facets/Client.m2
-rw-r--r--matlab/test/Ice/facets/runTest.m4
-rw-r--r--matlab/test/Ice/info/Client.m2
-rw-r--r--matlab/test/Ice/info/runTest.m4
-rw-r--r--matlab/test/Ice/inheritance/Client.m2
-rw-r--r--matlab/test/Ice/inheritance/runTest.m4
-rw-r--r--matlab/test/Ice/objects/Client.m2
-rw-r--r--matlab/test/Ice/objects/runTest.m4
-rw-r--r--matlab/test/Ice/operations/Client.m2
-rw-r--r--matlab/test/Ice/operations/runTest.m4
-rw-r--r--matlab/test/Ice/optional/Client.m2
-rw-r--r--matlab/test/Ice/optional/runTest.m4
-rw-r--r--matlab/test/Ice/proxy/Client.m2
-rw-r--r--matlab/test/Ice/proxy/runTest.m4
-rw-r--r--matlab/test/Ice/slicing/exceptions/Client.m2
-rw-r--r--matlab/test/Ice/slicing/exceptions/runTest.m4
-rw-r--r--matlab/test/Ice/slicing/objects/Client.m2
-rw-r--r--matlab/test/Ice/slicing/objects/runTest.m4
-rw-r--r--matlab/test/Ice/timeout/AllTests.m340
-rw-r--r--matlab/test/Ice/timeout/Application.m143
-rw-r--r--matlab/test/Ice/timeout/Client.m54
-rw-r--r--matlab/test/Ice/timeout/Test.ice29
-rw-r--r--matlab/test/Ice/timeout/generated/.gitignore1
-rw-r--r--matlab/test/Ice/timeout/runTest.m4
49 files changed, 2394 insertions, 36 deletions
diff --git a/matlab/test/Ice/acm/AllTests.m b/matlab/test/Ice/acm/AllTests.m
new file mode 100644
index 00000000000..44085259f7f
--- /dev/null
+++ b/matlab/test/Ice/acm/AllTests.m
@@ -0,0 +1,99 @@
+%{
+**********************************************************************
+
+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 AllTests
+ methods(Static)
+ function allTests(app)
+ import test.Ice.acm.Test.*;
+
+ communicator = app.communicator();
+
+ ref = 'communicator:default -p 12010';
+ com = RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref));
+
+ AllTests.testSetACM(communicator, com);
+ AllTests.testHeartbeatManual(communicator, com);
+
+ com.shutdown();
+ end
+ function testSetACM(communicator, com)
+ import test.Ice.acm.Test.*;
+
+ fprintf('testing setACM/getACM... ');
+
+ adapter = com.createObjectAdapter(-1, -1, -1);
+
+ initData = Ice.InitializationData();
+ initData.properties_ = communicator.getProperties().clone();
+ initData.properties_.setProperty('Ice.ACM.Timeout', '1');
+ initData.properties_.setProperty('Ice.ACM.Client.Timeout', '15');
+ initData.properties_.setProperty('Ice.ACM.Client.Close', '4');
+ initData.properties_.setProperty('Ice.ACM.Client.Heartbeat', '2');
+ testCommunicator = Ice.initialize(initData);
+ proxy = TestIntfPrx.uncheckedCast(testCommunicator.stringToProxy(adapter.getTestIntf().ice_toString()));
+ proxy.ice_getConnection();
+
+ acm = proxy.ice_getCachedConnection().getACM();
+ assert(acm.timeout == 15);
+ assert(acm.close == Ice.ACMClose.CloseOnIdleForceful);
+ assert(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnIdle);
+
+ proxy.ice_getCachedConnection().setACM(Ice.Unset, Ice.Unset, Ice.Unset);
+ acm = proxy.ice_getCachedConnection().getACM();
+ assert(acm.timeout == 15);
+ assert(acm.close == Ice.ACMClose.CloseOnIdleForceful);
+ assert(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnIdle);
+
+ proxy.ice_getCachedConnection().setACM(1, Ice.ACMClose.CloseOnInvocationAndIdle, ...
+ Ice.ACMHeartbeat.HeartbeatAlways);
+ acm = proxy.ice_getCachedConnection().getACM();
+ assert(acm.timeout == 1);
+ assert(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle);
+ assert(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways);
+
+ proxy.startHeartbeatCount();
+ proxy.waitForHeartbeatCount(2);
+
+ adapter.deactivate();
+ testCommunicator.destroy();
+ fprintf('ok\n');
+ end
+ function testHeartbeatManual(communicator, com)
+ import test.Ice.acm.Test.*;
+
+ fprintf('testing manual heartbeats... ');
+
+ adapter = com.createObjectAdapter(10, -1, 0);
+
+ initData = Ice.InitializationData();
+ initData.properties_ = communicator.getProperties().clone();
+ initData.properties_.setProperty('Ice.ACM.Timeout', '10');
+ initData.properties_.setProperty('Ice.ACM.Client.Timeout', '10');
+ initData.properties_.setProperty('Ice.ACM.Client.Close', '0');
+ initData.properties_.setProperty('Ice.ACM.Client.Heartbeat', '0');
+ testCommunicator = Ice.initialize(initData);
+ proxy = TestIntfPrx.uncheckedCast(testCommunicator.stringToProxy(adapter.getTestIntf().ice_toString()));
+ con = proxy.ice_getConnection();
+
+ proxy.startHeartbeatCount();
+ con.heartbeat();
+ con.heartbeat();
+ con.heartbeat();
+ con.heartbeat();
+ con.heartbeat();
+ proxy.waitForHeartbeatCount(5);
+
+ adapter.deactivate();
+ testCommunicator.destroy();
+ fprintf('ok\n');
+ end
+ end
+end
diff --git a/matlab/test/Ice/acm/Application.m b/matlab/test/Ice/acm/Application.m
new file mode 100644
index 00000000000..4735c1cd057
--- /dev/null
+++ b/matlab/test/Ice/acm/Application.m
@@ -0,0 +1,143 @@
+%{
+**********************************************************************
+
+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 (Abstract) Application < handle
+ methods(Sealed)
+ %
+ % main() initializes the Communicator, calls run(), and destroys
+ % the Communicator upon return from run(). It thereby handles
+ % all exceptions properly, i.e., error messages are printed
+ % if exceptions propagate to main(), and the Communicator is
+ % always destroyed, regardless of exceptions.
+ %
+ function r = main(obj, appName, varargin)
+ if ~isempty(obj.communicator_)
+ printf('%s: only one instance of the Application class can be used', appName);
+ r = 1;
+ return;
+ end
+
+ obj.testName_ = appName;
+
+ args = {};
+ initializationData = [];
+
+ if length(varargin) >= 1
+ args = varargin{1};
+ end
+ if length(varargin) >= 2
+ initializationData = varargin{2};
+ end
+
+ %
+ % We parse the properties here to extract Ice.ProgramName.
+ %
+ if isempty(initializationData)
+ [initializationData, args] = obj.getInitData(args);
+ end
+
+ if ~isempty(initializationData)
+ initData = initializationData.clone();
+ else
+ initData = Ice.InitializationData();
+ end
+
+ [initData.properties_, args] = Ice.createProperties(args, initData.properties_);
+
+ status = 0;
+
+ try
+ [communicator, args] = Ice.initialize(args, initData);
+ obj.communicator_ = communicator;
+
+ status = obj.run(args);
+ catch ex
+ fprintf('%s: caught %s', obj.testName_, ex.identifier);
+ disp(getReport(ex, 'extended'));
+ status = 1;
+ end
+ obj.communicator_.destroy();
+ obj.communicator_ = [];
+
+ r = status;
+ end
+ function r = initialize(obj, varargin)
+ assert(length(varargin) <= 1);
+ if length(varargin) == 0
+ r = Ice.initialize();
+ else
+ r = Ice.initialize(varargin{1});
+ end
+ end
+ function r = appName(obj)
+ r = obj.testName_;
+ end
+ function r = communicator(obj)
+ r = obj.communicator_;
+ end
+ function r = createInitializationData(obj)
+ initData = Ice.InitializationData();
+ r = initData;
+ end
+ function r = getTestEndpoint(obj, num, prot)
+ r = Application.getTestEndpointWithProperties(obj.communicator_.getProperties(), num, prot);
+ end
+ function r = getTestHost(obj)
+ r = Application.getTestHostWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestProtocol(obj)
+ r = Application.getTestProtocolWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestPort(obj, num)
+ r = Application.getTestPortWithProperties(obj.communicator_.getProperties(), num);
+ end
+ end
+ methods(Static)
+ function r = getTestEndpointWithProperties(props, num, prot)
+ protocol = prot;
+ if length(protocol) == 0
+ protocol = props.getPropertyWithDefault('Ice.Default.Protocol', 'default');
+ end
+
+ basePort = props.getPropertyAsIntWithDefault('Test.BasePort', 12010);
+
+ r = sprintf('%s -p %d', protocol, 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
+ methods(Abstract)
+ r = run(obj, args)
+ end
+ methods(Access=protected)
+ %
+ % Hook to override the initialization data. This hook is
+ % necessary because some properties must be set prior to
+ % communicator initialization.
+ %
+ function [initData, remArgs] = getInitData(obj, args)
+ initData = obj.createInitializationData();
+ [initData.properties_, remArgs] = Ice.createProperties(args);
+ remArgs = initData.properties_.parseCommandLineOptions('Test', remArgs);
+ end
+ end
+ properties(Access=private)
+ testName_
+ communicator_
+ end
+end
diff --git a/matlab/test/Ice/acm/Client.m b/matlab/test/Ice/acm/Client.m
new file mode 100644
index 00000000000..7cde23db42b
--- /dev/null
+++ b/matlab/test/Ice/acm/Client.m
@@ -0,0 +1,37 @@
+%{
+**********************************************************************
+
+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 Client < Application
+ methods
+ function r = run(obj, args)
+ AllTests.allTests(obj);
+ r = 0;
+ end
+ end
+ methods(Access=protected)
+ function [r, remArgs] = getInitData(obj, args)
+ [initData, remArgs] = getInitData@Application(obj, args);
+ initData.properties_.setProperty('Ice.Package.Test', 'test.Ice.acm');
+ initData.properties_.setProperty('Ice.Warn.Connections', '0');
+ r = initData;
+ end
+ end
+ methods(Static)
+ function status = start(args)
+ addpath('generated');
+ if ~libisloaded('icematlab')
+ loadlibrary('icematlab')
+ end
+ c = Client();
+ status = c.main('Client', args);
+ end
+ end
+end
diff --git a/matlab/test/Ice/acm/Test.ice b/matlab/test/Ice/acm/Test.ice
new file mode 100644
index 00000000000..71fd1163244
--- /dev/null
+++ b/matlab/test/Ice/acm/Test.ice
@@ -0,0 +1,39 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#pragma once
+
+[["matlab:package:test.Ice.acm"]]
+module Test
+{
+
+interface TestIntf
+{
+ void sleep(int seconds);
+ void sleepAndHold(int seconds);
+ void interruptSleep();
+ void startHeartbeatCount();
+ void waitForHeartbeatCount(int count);
+}
+
+interface RemoteObjectAdapter
+{
+ TestIntf* getTestIntf();
+ void activate();
+ void hold();
+ void deactivate();
+}
+
+interface RemoteCommunicator
+{
+ RemoteObjectAdapter* createObjectAdapter(int acmTimeout, int close, int heartbeat);
+ void shutdown();
+}
+
+}
diff --git a/matlab/test/Ice/acm/generated/.gitignore b/matlab/test/Ice/acm/generated/.gitignore
new file mode 100644
index 00000000000..39af5887579
--- /dev/null
+++ b/matlab/test/Ice/acm/generated/.gitignore
@@ -0,0 +1 @@
+# Dummy file, so that git retains this otherwise empty directory.
diff --git a/matlab/test/Ice/acm/runTest.m b/matlab/test/Ice/acm/runTest.m
new file mode 100644
index 00000000000..66a1e8dda5e
--- /dev/null
+++ b/matlab/test/Ice/acm/runTest.m
@@ -0,0 +1,4 @@
+function runTest(varargin)
+ status = Client.start(varargin);
+ exit(status);
+end
diff --git a/matlab/test/Ice/ami/Client.m b/matlab/test/Ice/ami/Client.m
index 10d1c635a21..2d1475a67d4 100644
--- a/matlab/test/Ice/ami/Client.m
+++ b/matlab/test/Ice/ami/Client.m
@@ -32,7 +32,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/ami/runTest.m b/matlab/test/Ice/ami/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/ami/runTest.m
+++ b/matlab/test/Ice/ami/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/checksum/AllTests.m b/matlab/test/Ice/checksum/AllTests.m
new file mode 100644
index 00000000000..16eaf366f6e
--- /dev/null
+++ b/matlab/test/Ice/checksum/AllTests.m
@@ -0,0 +1,70 @@
+%{
+**********************************************************************
+
+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 AllTests
+ methods(Static)
+ function r = allTests(app)
+ import test.Ice.checksum.Test.*;
+
+ communicator = app.communicator();
+
+ ref = ['test:', app.getTestEndpoint(0, '')];
+ base = communicator.stringToProxy(ref);
+ assert(~isempty(base));
+
+ checksum = ChecksumPrx.checkedCast(base);
+ assert(~isempty(checksum));
+
+ %
+ % Verify that no checksums are present for local types.
+ %
+ fprintf('testing checksums... ');
+ map = SliceChecksums();
+ keys = map.keys();
+ for i = 1:length(keys)
+ key = keys{i};
+ assert(isempty(strfind(key, 'Local')));
+ end
+
+ %
+ % Get server's Slice checksums.
+ %
+ d = checksum.getSliceChecksums();
+
+ %
+ % Compare the checksums. For a type FooN whose name ends in an integer N,
+ % we assume that the server's type does not change for N = 1, and does
+ % change for N > 1.
+ %
+ skeys = d.keys();
+ for i = 1:length(skeys)
+ n = 0;
+ key = skeys{i};
+ pos = regexp(key, '\d+');
+ if ~isempty(pos)
+ n = str2num(key(pos:end));
+ end
+
+ assert(map.isKey(key));
+ value = map(key);
+
+ if n <= 1
+ assert(strcmp(value, d(key)));
+ else
+ assert(~strcmp(value, d(key)));
+ end
+ end
+ fprintf('ok\n');
+
+ r = checksum;
+ end
+ end
+end
diff --git a/matlab/test/Ice/checksum/Application.m b/matlab/test/Ice/checksum/Application.m
new file mode 100644
index 00000000000..4735c1cd057
--- /dev/null
+++ b/matlab/test/Ice/checksum/Application.m
@@ -0,0 +1,143 @@
+%{
+**********************************************************************
+
+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 (Abstract) Application < handle
+ methods(Sealed)
+ %
+ % main() initializes the Communicator, calls run(), and destroys
+ % the Communicator upon return from run(). It thereby handles
+ % all exceptions properly, i.e., error messages are printed
+ % if exceptions propagate to main(), and the Communicator is
+ % always destroyed, regardless of exceptions.
+ %
+ function r = main(obj, appName, varargin)
+ if ~isempty(obj.communicator_)
+ printf('%s: only one instance of the Application class can be used', appName);
+ r = 1;
+ return;
+ end
+
+ obj.testName_ = appName;
+
+ args = {};
+ initializationData = [];
+
+ if length(varargin) >= 1
+ args = varargin{1};
+ end
+ if length(varargin) >= 2
+ initializationData = varargin{2};
+ end
+
+ %
+ % We parse the properties here to extract Ice.ProgramName.
+ %
+ if isempty(initializationData)
+ [initializationData, args] = obj.getInitData(args);
+ end
+
+ if ~isempty(initializationData)
+ initData = initializationData.clone();
+ else
+ initData = Ice.InitializationData();
+ end
+
+ [initData.properties_, args] = Ice.createProperties(args, initData.properties_);
+
+ status = 0;
+
+ try
+ [communicator, args] = Ice.initialize(args, initData);
+ obj.communicator_ = communicator;
+
+ status = obj.run(args);
+ catch ex
+ fprintf('%s: caught %s', obj.testName_, ex.identifier);
+ disp(getReport(ex, 'extended'));
+ status = 1;
+ end
+ obj.communicator_.destroy();
+ obj.communicator_ = [];
+
+ r = status;
+ end
+ function r = initialize(obj, varargin)
+ assert(length(varargin) <= 1);
+ if length(varargin) == 0
+ r = Ice.initialize();
+ else
+ r = Ice.initialize(varargin{1});
+ end
+ end
+ function r = appName(obj)
+ r = obj.testName_;
+ end
+ function r = communicator(obj)
+ r = obj.communicator_;
+ end
+ function r = createInitializationData(obj)
+ initData = Ice.InitializationData();
+ r = initData;
+ end
+ function r = getTestEndpoint(obj, num, prot)
+ r = Application.getTestEndpointWithProperties(obj.communicator_.getProperties(), num, prot);
+ end
+ function r = getTestHost(obj)
+ r = Application.getTestHostWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestProtocol(obj)
+ r = Application.getTestProtocolWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestPort(obj, num)
+ r = Application.getTestPortWithProperties(obj.communicator_.getProperties(), num);
+ end
+ end
+ methods(Static)
+ function r = getTestEndpointWithProperties(props, num, prot)
+ protocol = prot;
+ if length(protocol) == 0
+ protocol = props.getPropertyWithDefault('Ice.Default.Protocol', 'default');
+ end
+
+ basePort = props.getPropertyAsIntWithDefault('Test.BasePort', 12010);
+
+ r = sprintf('%s -p %d', protocol, 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
+ methods(Abstract)
+ r = run(obj, args)
+ end
+ methods(Access=protected)
+ %
+ % Hook to override the initialization data. This hook is
+ % necessary because some properties must be set prior to
+ % communicator initialization.
+ %
+ function [initData, remArgs] = getInitData(obj, args)
+ initData = obj.createInitializationData();
+ [initData.properties_, remArgs] = Ice.createProperties(args);
+ remArgs = initData.properties_.parseCommandLineOptions('Test', remArgs);
+ end
+ end
+ properties(Access=private)
+ testName_
+ communicator_
+ end
+end
diff --git a/matlab/test/Ice/checksum/Client.m b/matlab/test/Ice/checksum/Client.m
new file mode 100644
index 00000000000..55bcb87448b
--- /dev/null
+++ b/matlab/test/Ice/checksum/Client.m
@@ -0,0 +1,37 @@
+%{
+**********************************************************************
+
+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 Client < Application
+ methods
+ function r = run(obj, args)
+ checksum = AllTests.allTests(obj);
+ checksum.shutdown();
+ r = 0;
+ end
+ end
+ methods(Access=protected)
+ function [r, remArgs] = getInitData(obj, args)
+ [initData, remArgs] = getInitData@Application(obj, args);
+ initData.properties_.setProperty('Ice.Package.Test', 'test.Ice.checksum');
+ r = initData;
+ end
+ end
+ methods(Static)
+ function status = start(args)
+ addpath('generated');
+ if ~libisloaded('icematlab')
+ loadlibrary('icematlab')
+ end
+ c = Client();
+ status = c.main('Client', args);
+ end
+ end
+end
diff --git a/matlab/test/Ice/checksum/Test.ice b/matlab/test/Ice/checksum/Test.ice
new file mode 100644
index 00000000000..0b8f9722063
--- /dev/null
+++ b/matlab/test/Ice/checksum/Test.ice
@@ -0,0 +1,25 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/SliceChecksumDict.ice>
+
+[["matlab:package:test.Ice.checksum"]]
+module Test
+{
+
+interface Checksum
+{
+ idempotent Ice::SliceChecksumDict getSliceChecksums();
+
+ void shutdown();
+}
+
+}
diff --git a/matlab/test/Ice/checksum/Types.ice b/matlab/test/Ice/checksum/Types.ice
new file mode 100644
index 00000000000..485330caf42
--- /dev/null
+++ b/matlab/test/Ice/checksum/Types.ice
@@ -0,0 +1,615 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#pragma once
+
+[["matlab:package:test.Ice.checksum"]]
+module Test
+{
+
+//
+// TEST: Same
+//
+const int IntConst1 = 100;
+
+//
+// TEST: Value changed
+//
+const int IntConst2 = 100;
+
+//
+// TEST: Type changed
+//
+const int IntConst3 = 100;
+
+//
+// TEST: Same
+//
+enum Enum1 { Enum11, Enum12, Enum13 }
+
+//
+// TEST: Add enumerator
+//
+enum Enum2 { Enum21, Enum22, Enum23 }
+
+//
+// TEST: Remove enumerator
+//
+enum Enum3 { Enum31, Enum32, Enum33 }
+
+//
+// TEST: Change to a different type
+//
+enum Enum4 { Enum41, Enum42, Enum43 }
+
+//
+// TEST: Enum with explicit values.
+//
+enum EnumExplicit0 { EnumExplicit01 = 1, EnumExplicit02 = 2, EnumExplicit03 = 3 }
+
+//
+// TEST: Enum with same explicit values, different order.
+//
+enum EnumExplicit1 { EnumExplicit11 = 1, EnumExplicit12 = 2, EnumExplicit13 = 3 }
+
+//
+// TEST: Enum with different explicit values.
+//
+enum EnumExplicit2 { EnumExplicit21 = 1, EnumExplicit22 = 2, EnumExplicit23 = 3}
+
+//
+// TEST: Enum with explicit values, removed enumerator.
+//
+enum EnumExplicit3 { EnumExplicit31 = 1, EnumExplicit32 = 2, EnumExplicit33 = 3}
+
+//
+// TEST: Same
+//
+sequence<int> Sequence1;
+
+//
+// TEST: Change sequence type
+//
+sequence<int> Sequence2;
+
+//
+// TEST: Change to a different type
+//
+sequence<int> Sequence3;
+
+//
+// TEST: Same
+//
+dictionary<string, int> Dictionary1;
+
+//
+// TEST: Change key type
+//
+dictionary<string, int> Dictionary2;
+
+//
+// TEST: Change value type
+//
+dictionary<string, int> Dictionary3;
+
+//
+// TEST: Change to a different type
+//
+dictionary<string, int> Dictionary4;
+
+//
+// TEST: Same
+//
+struct Struct1
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Add member
+//
+struct Struct2
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Change member type
+//
+struct Struct3
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Remove member
+//
+struct Struct4
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Change to a different type
+//
+struct Struct5
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Same
+//
+interface Interface1
+{
+}
+
+//
+// TEST: Change interface to class
+//
+interface Interface2
+{
+}
+
+//
+// TEST: Add base interface
+//
+interface Interface3
+{
+}
+
+//
+// TEST: Add operation
+//
+interface Interface4
+{
+}
+
+//
+// TEST: Same
+//
+class EmptyClass1
+{
+}
+
+//
+// TEST: Add data member
+//
+class EmptyClass2
+{
+}
+
+//
+// TEST: Add operation
+//
+class EmptyClass3
+{
+}
+
+//
+// TEST: Add base class
+//
+class EmptyClass4
+{
+}
+
+//
+// TEST: Add interface
+//
+class EmptyClass5
+{
+}
+
+//
+// TEST: Same
+//
+class SimpleClass1
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Add operation
+//
+class SimpleClass2
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Rename member
+//
+class SimpleClass3
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Add member
+//
+class SimpleClass4
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Remove member
+//
+class SimpleClass5
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Reorder members
+//
+class SimpleClass6
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Change member type
+//
+class SimpleClass7
+{
+ string str;
+ float f;
+}
+
+//
+// TEST: Same
+//
+exception Exception1
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Add member
+//
+exception Exception2
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Change member type
+//
+exception Exception3
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Remove member
+//
+exception Exception4
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Add base exception
+//
+exception Exception5
+{
+}
+
+//
+// TEST: Change to a different type
+//
+exception Exception6
+{
+ string str;
+ bool b;
+}
+
+//
+// TEST: Exception with optional members.
+//
+exception OptionalEx0
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Exception with optional members, different order, same tags.
+//
+exception OptionalEx1
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Exception with different optional members.
+//
+exception OptionalEx2
+{
+ string firstName;
+ string secondName;
+ optional(1) string emailAddress;
+}
+
+//
+// TEST: Exception with different optional members.
+//
+exception OptionalEx3
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Exception with optional members using different tags.
+//
+exception OptionalEx4
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Same
+//
+interface BaseInterface1
+{
+ void baseOp1();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Change return type
+//
+interface BaseInterface2
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Add parameter
+//
+interface BaseInterface3
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Add exception
+//
+interface BaseInterface4
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Change out parameter to in parameter
+//
+interface BaseInterface5
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Remove parameter
+//
+interface BaseInterface6
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Remove exception
+//
+interface BaseInterface7
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Remove operation
+//
+interface BaseInterface8
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Add base interface
+//
+interface BaseInterface9
+{
+ void baseOp();
+ void baseOp2(int i, out string s) throws Exception1;
+}
+
+//
+// TEST: Class with compact id
+//
+class Compact1(1)
+{
+ int id;
+}
+
+//
+// TEST: Derived from class with compact id
+//
+class Derived1 extends Compact1
+{
+}
+
+//
+// TEST: Same class names but different compact id
+//
+class Compact2(2)
+{
+ int id;
+}
+
+//
+// TEST: Class with optional members.
+//
+class Optional0
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Class with optional members, different order, same tags.
+//
+class Optional1
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Class with different optional members.
+//
+class Optional2
+{
+ string firstName;
+ string secondName;
+ optional(1) string emailAddress;
+}
+
+//
+// TEST: Class with different optional members.
+//
+class Optional3
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Class with optional members using different tags.
+//
+class Optional4
+{
+ string firstName;
+ optional(1) string secondName;
+ optional(2) string emailAddress;
+}
+
+//
+// TEST: Interface with optional parameters.
+//
+interface OptionalParameters0
+{
+ void op1(string firstName, optional(1) string secondName,
+ optional(2) string emailAddress);
+}
+
+//
+// TEST: Interface with optional parameters, different order.
+//
+interface OptionalParameters1
+{
+ void op1(string firstName, optional(1) string secondName,
+ optional(2) string emailAddress);
+}
+
+//
+// TEST: Interface with optional parameters, different tags.
+//
+interface OptionalParameters2
+{
+ void op1(string firstName, optional(1) string emailAddress,
+ optional(2) string secondName);
+}
+
+//
+// TEST: Interface with different optional parameters.
+//
+interface OptionalParameters3
+{
+ void op1(string firstName, optional(1) string emailAddress,
+ string secondName);
+}
+
+//
+// TEST: Interface with optional return type.
+//
+interface OptionalReturn0
+{
+ optional(1) int op();
+}
+
+//
+// TEST: Interface that changes optional return type.
+//
+interface OptionalReturn2
+{
+ optional(1) int op();
+}
+
+//
+// TEST: Local
+//
+local enum LocalEnum { LocalEnum1, LocalEnum2, LocalEnum3 }
+
+//
+// TEST: Local
+//
+local sequence<string> LocalSequence;
+
+//
+// TEST: Local
+//
+local dictionary<string, string> LocalDictionary;
+
+//
+// TEST: Local
+//
+local struct LocalStruct
+{
+ string str;
+}
+
+//
+// TEST: Local
+//
+local class LocalClass
+{
+}
+
+}
diff --git a/matlab/test/Ice/checksum/generated/.gitignore b/matlab/test/Ice/checksum/generated/.gitignore
new file mode 100644
index 00000000000..39af5887579
--- /dev/null
+++ b/matlab/test/Ice/checksum/generated/.gitignore
@@ -0,0 +1 @@
+# Dummy file, so that git retains this otherwise empty directory.
diff --git a/matlab/test/Ice/checksum/runTest.m b/matlab/test/Ice/checksum/runTest.m
new file mode 100644
index 00000000000..66a1e8dda5e
--- /dev/null
+++ b/matlab/test/Ice/checksum/runTest.m
@@ -0,0 +1,4 @@
+function runTest(varargin)
+ status = Client.start(varargin);
+ exit(status);
+end
diff --git a/matlab/test/Ice/defaultValue/AllTests.m b/matlab/test/Ice/defaultValue/AllTests.m
new file mode 100644
index 00000000000..499604924fd
--- /dev/null
+++ b/matlab/test/Ice/defaultValue/AllTests.m
@@ -0,0 +1,181 @@
+%{
+**********************************************************************
+
+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 AllTests
+ methods(Static)
+ function allTests(app)
+ import test.Ice.defaultValue.Test.*;
+
+ communicator = app.communicator();
+
+ fprintf('testing default values... ');
+
+ v = Struct1();
+ assert(~v.boolFalse);
+ assert(v.boolTrue);
+ assert(v.b == 254);
+ assert(v.s == 16000);
+ assert(v.i == 3);
+ assert(v.l == 4);
+ assert(v.f == single(5.1));
+ assert(v.d == 6.2);
+ assert(strcmp(v.str, sprintf('foo \\ "bar\n \r\n\t\v\f\a\b? \a \a')));
+ assert(v.c1 == Color.red);
+ assert(v.c2 == Color.green);
+ assert(v.c3 == Color.blue);
+ assert(v.nc1 == test.Ice.defaultValue.Test.Nested.Color.red);
+ assert(v.nc2 == test.Ice.defaultValue.Test.Nested.Color.green);
+ assert(v.nc3 == test.Ice.defaultValue.Test.Nested.Color.blue);
+ assert(strcmp(v.noDefault, ''));
+ assert(v.zeroI == 0);
+ assert(v.zeroL == 0);
+ assert(v.zeroF == 0);
+ assert(v.zeroDotF == 0);
+ assert(v.zeroD == 0);
+ assert(v.zeroDotD == 0);
+
+ v = Struct2();
+ assert(v.boolTrue == ConstBool.value);
+ assert(v.b == ConstByte.value);
+ assert(v.s == ConstShort.value);
+ assert(v.i == ConstInt.value);
+ assert(v.l == ConstLong.value);
+ assert(v.f == ConstFloat.value);
+ assert(v.d == ConstDouble.value);
+ assert(strcmp(v.str, ConstString.value));
+ assert(v.c1 == ConstColor1.value);
+ assert(v.c2 == ConstColor2.value);
+ assert(v.c3 == ConstColor3.value);
+ assert(v.nc1 == ConstNestedColor1.value);
+ assert(v.nc2 == ConstNestedColor2.value);
+ assert(v.nc3 == ConstNestedColor3.value);
+
+ v = Base();
+ assert(~v.boolFalse);
+ assert(v.boolTrue);
+ assert(v.b == 1);
+ assert(v.s == 2);
+ assert(v.i == 3);
+ assert(v.l == 4);
+ assert(v.f == single(5.1));
+ assert(v.d == 6.2);
+ assert(strcmp(v.str, sprintf('foo \\ "bar\n \r\n\t\v\f\a\b? \a \a')));
+ assert(strcmp(v.noDefault, ''));
+ assert(v.zeroI == 0);
+ assert(v.zeroL == 0);
+ assert(v.zeroF == 0);
+ assert(v.zeroDotF == 0);
+ assert(v.zeroD == 0);
+ assert(v.zeroDotD == 0);
+
+ v = Derived();
+ assert(~v.boolFalse);
+ assert(v.boolTrue);
+ assert(v.b == 1);
+ assert(v.s == 2);
+ assert(v.i == 3);
+ assert(v.l == 4);
+ assert(v.f == single(5.1));
+ assert(v.d == 6.2);
+ assert(strcmp(v.str, sprintf('foo \\ "bar\n \r\n\t\v\f\a\b? \a \a')));
+ assert(v.c1 == Color.red);
+ assert(v.c2 == Color.green);
+ assert(v.c3 == Color.blue);
+ assert(v.nc1 == test.Ice.defaultValue.Test.Nested.Color.red);
+ assert(v.nc2 == test.Ice.defaultValue.Test.Nested.Color.green);
+ assert(v.nc3 == test.Ice.defaultValue.Test.Nested.Color.blue);
+ assert(strcmp(v.noDefault, ''));
+ assert(v.zeroI == 0);
+ assert(v.zeroL == 0);
+ assert(v.zeroF == 0);
+ assert(v.zeroDotF == 0);
+ assert(v.zeroD == 0);
+ assert(v.zeroDotD == 0);
+
+ v = BaseEx();
+ assert(~v.boolFalse);
+ assert(v.boolTrue);
+ assert(v.b == 1);
+ assert(v.s == 2);
+ assert(v.i == 3);
+ assert(v.l == 4);
+ assert(v.f == single(5.1));
+ assert(v.d == 6.2);
+ assert(strcmp(v.str, sprintf('foo \\ "bar\n \r\n\t\v\f\a\b? \a \a')));
+ assert(strcmp(v.noDefault, ''));
+ assert(v.zeroI == 0);
+ assert(v.zeroL == 0);
+ assert(v.zeroF == 0);
+ assert(v.zeroDotF == 0);
+ assert(v.zeroD == 0);
+ assert(v.zeroDotD == 0);
+
+ v = DerivedEx();
+ assert(~v.boolFalse);
+ assert(v.boolTrue);
+ assert(v.b == 1);
+ assert(v.s == 2);
+ assert(v.i == 3);
+ assert(v.l == 4);
+ assert(v.f == single(5.1));
+ assert(v.d == 6.2);
+ assert(strcmp(v.str, sprintf('foo \\ "bar\n \r\n\t\v\f\a\b? \a \a')));
+ assert(strcmp(v.noDefault, ''));
+ assert(v.c1 == Color.red);
+ assert(v.c2 == Color.green);
+ assert(v.c3 == Color.blue);
+ assert(v.nc1 == test.Ice.defaultValue.Test.Nested.Color.red);
+ assert(v.nc2 == test.Ice.defaultValue.Test.Nested.Color.green);
+ assert(v.nc3 == test.Ice.defaultValue.Test.Nested.Color.blue);
+ assert(v.zeroI == 0);
+ assert(v.zeroL == 0);
+ assert(v.zeroF == 0);
+ assert(v.zeroDotF == 0);
+ assert(v.zeroD == 0);
+ assert(v.zeroDotD == 0);
+
+ fprintf('ok\n');
+
+ fprintf('testing default constructor... ');
+
+ v = test.Ice.defaultValue.Test.StructNoDefaults();
+ assert(v.bo == false);
+ assert(v.b == 0);
+ assert(v.s == 0);
+ assert(v.i == 0);
+ assert(v.l == 0);
+ assert(v.f == 0.0);
+ assert(v.d == 0.0);
+ assert(strcmp(v.str, ''));
+ assert(v.c1 == test.Ice.defaultValue.Test.Color.red);
+ assert(isempty(v.bs));
+ assert(isempty(v.is));
+ assert(~isempty(v.st));
+ assert(isempty(v.dict));
+
+ e = test.Ice.defaultValue.Test.ExceptionNoDefaults();
+ assert(strcmp(e.str, ''));
+ assert(e.c1 == test.Ice.defaultValue.Test.Color.red);
+ assert(isempty(e.bs));
+ assert(~isempty(e.st));
+ assert(isempty(e.dict));
+
+ cl = test.Ice.defaultValue.Test.ClassNoDefaults();
+ assert(strcmp(cl.str, ''));
+ assert(cl.c1 == test.Ice.defaultValue.Test.Color.red);
+ assert(isempty(cl.bs));
+ assert(~isempty(cl.st));
+ assert(isempty(cl.dict));
+
+ fprintf('ok\n');
+ end
+ end
+end
diff --git a/matlab/test/Ice/defaultValue/Application.m b/matlab/test/Ice/defaultValue/Application.m
new file mode 100644
index 00000000000..4735c1cd057
--- /dev/null
+++ b/matlab/test/Ice/defaultValue/Application.m
@@ -0,0 +1,143 @@
+%{
+**********************************************************************
+
+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 (Abstract) Application < handle
+ methods(Sealed)
+ %
+ % main() initializes the Communicator, calls run(), and destroys
+ % the Communicator upon return from run(). It thereby handles
+ % all exceptions properly, i.e., error messages are printed
+ % if exceptions propagate to main(), and the Communicator is
+ % always destroyed, regardless of exceptions.
+ %
+ function r = main(obj, appName, varargin)
+ if ~isempty(obj.communicator_)
+ printf('%s: only one instance of the Application class can be used', appName);
+ r = 1;
+ return;
+ end
+
+ obj.testName_ = appName;
+
+ args = {};
+ initializationData = [];
+
+ if length(varargin) >= 1
+ args = varargin{1};
+ end
+ if length(varargin) >= 2
+ initializationData = varargin{2};
+ end
+
+ %
+ % We parse the properties here to extract Ice.ProgramName.
+ %
+ if isempty(initializationData)
+ [initializationData, args] = obj.getInitData(args);
+ end
+
+ if ~isempty(initializationData)
+ initData = initializationData.clone();
+ else
+ initData = Ice.InitializationData();
+ end
+
+ [initData.properties_, args] = Ice.createProperties(args, initData.properties_);
+
+ status = 0;
+
+ try
+ [communicator, args] = Ice.initialize(args, initData);
+ obj.communicator_ = communicator;
+
+ status = obj.run(args);
+ catch ex
+ fprintf('%s: caught %s', obj.testName_, ex.identifier);
+ disp(getReport(ex, 'extended'));
+ status = 1;
+ end
+ obj.communicator_.destroy();
+ obj.communicator_ = [];
+
+ r = status;
+ end
+ function r = initialize(obj, varargin)
+ assert(length(varargin) <= 1);
+ if length(varargin) == 0
+ r = Ice.initialize();
+ else
+ r = Ice.initialize(varargin{1});
+ end
+ end
+ function r = appName(obj)
+ r = obj.testName_;
+ end
+ function r = communicator(obj)
+ r = obj.communicator_;
+ end
+ function r = createInitializationData(obj)
+ initData = Ice.InitializationData();
+ r = initData;
+ end
+ function r = getTestEndpoint(obj, num, prot)
+ r = Application.getTestEndpointWithProperties(obj.communicator_.getProperties(), num, prot);
+ end
+ function r = getTestHost(obj)
+ r = Application.getTestHostWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestProtocol(obj)
+ r = Application.getTestProtocolWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestPort(obj, num)
+ r = Application.getTestPortWithProperties(obj.communicator_.getProperties(), num);
+ end
+ end
+ methods(Static)
+ function r = getTestEndpointWithProperties(props, num, prot)
+ protocol = prot;
+ if length(protocol) == 0
+ protocol = props.getPropertyWithDefault('Ice.Default.Protocol', 'default');
+ end
+
+ basePort = props.getPropertyAsIntWithDefault('Test.BasePort', 12010);
+
+ r = sprintf('%s -p %d', protocol, 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
+ methods(Abstract)
+ r = run(obj, args)
+ end
+ methods(Access=protected)
+ %
+ % Hook to override the initialization data. This hook is
+ % necessary because some properties must be set prior to
+ % communicator initialization.
+ %
+ function [initData, remArgs] = getInitData(obj, args)
+ initData = obj.createInitializationData();
+ [initData.properties_, remArgs] = Ice.createProperties(args);
+ remArgs = initData.properties_.parseCommandLineOptions('Test', remArgs);
+ end
+ end
+ properties(Access=private)
+ testName_
+ communicator_
+ end
+end
diff --git a/matlab/test/Ice/defaultValue/Client.m b/matlab/test/Ice/defaultValue/Client.m
new file mode 100644
index 00000000000..98e0a2e29cc
--- /dev/null
+++ b/matlab/test/Ice/defaultValue/Client.m
@@ -0,0 +1,29 @@
+%{
+**********************************************************************
+
+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 Client < Application
+ methods
+ function r = run(obj, args)
+ AllTests.allTests(obj);
+ r = 0;
+ end
+ end
+ methods(Static)
+ function status = start(args)
+ addpath('generated');
+ if ~libisloaded('icematlab')
+ loadlibrary('icematlab')
+ end
+ c = Client();
+ status = c.main('Client', args);
+ end
+ end
+end
diff --git a/matlab/test/Ice/defaultValue/Test.ice b/matlab/test/Ice/defaultValue/Test.ice
new file mode 100644
index 00000000000..3b474aeeb23
--- /dev/null
+++ b/matlab/test/Ice/defaultValue/Test.ice
@@ -0,0 +1,211 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#pragma once
+
+[["matlab:package:test.Ice.defaultValue"]]
+
+[["suppress-warning:deprecated"]] // For enumerator references
+
+module Test
+{
+
+enum Color { red, green, blue }
+
+module Nested
+{
+
+enum Color { red, green, blue }
+
+}
+
+struct Struct1
+{
+ bool boolFalse = false;
+ bool boolTrue = true;
+ byte b = 254;
+ short s = 16000;
+ int i = 3;
+ long l = 4;
+ float f = 5.1;
+ double d = 6.2;
+ string str = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+ Color c1 = ::Test::Color::red;
+ Color c2 = Test::green;
+ Color c3 = blue;
+ Nested::Color nc1 = Test::Nested::Color::red;
+ Nested::Color nc2 = Nested::green;
+ Nested::Color nc3 = blue;
+ string noDefault;
+ int zeroI = 0;
+ long zeroL = 0;
+ float zeroF = 0;
+ float zeroDotF = 0.0;
+ double zeroD = 0;
+ double zeroDotD = 0;
+}
+
+const bool ConstBool = true;
+const byte ConstByte = 254;
+const short ConstShort = 16000;
+const int ConstInt = 3;
+const long ConstLong = 4;
+const float ConstFloat = 5.1;
+const double ConstDouble = 6.2;
+const string ConstString = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+const Color ConstColor1 = ::Test::Color::red;
+const Color ConstColor2 = Test::green;
+const Color ConstColor3 = blue;
+const Nested::Color ConstNestedColor1 = Test::Nested::Color::red;
+const Nested::Color ConstNestedColor2 = Test::Nested::green;
+const Nested::Color ConstNestedColor3 = blue;
+const int ConstZeroI = 0;
+const long ConstZeroL = 0;
+const float ConstZeroF = 0;
+const float ConstZeroDotF = 0.0;
+const double ConstZeroD = 0;
+const double ConstZeroDotD = 0;
+
+struct Struct2
+{
+ bool boolTrue = ConstBool;
+ byte b = ConstByte;
+ short s = ConstShort;
+ int i = ConstInt;
+ long l = ConstLong;
+ float f = ConstFloat;
+ double d = ConstDouble;
+ string str = ConstString;
+ Color c1 = ConstColor1;
+ Color c2 = ConstColor2;
+ Color c3 = ConstColor3;
+ Nested::Color nc1 = ConstNestedColor1;
+ Nested::Color nc2 = ConstNestedColor2;
+ Nested::Color nc3 = ConstNestedColor3;
+ int zeroI = ConstZeroI;
+ long zeroL = ConstZeroL;
+ float zeroF = ConstZeroF;
+ float zeroDotF = ConstZeroDotF;
+ double zeroD = ConstZeroD;
+ double zeroDotD = ConstZeroDotD;
+}
+
+class Base
+{
+ bool boolFalse = false;
+ bool boolTrue = true;
+ byte b = 1;
+ short s = 2;
+ int i = 3;
+ long l = 4;
+ float f = 5.1;
+ double d = 6.2;
+ string str = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+ string noDefault;
+ int zeroI = 0;
+ long zeroL = 0;
+ float zeroF = 0;
+ float zeroDotF = 0.0;
+ double zeroD = 0;
+ double zeroDotD = 0;
+}
+
+class Derived extends Base
+{
+ Color c1 = ::Test::Color::red;
+ Color c2 = Test::green;
+ Color c3 = blue;
+ Nested::Color nc1 = ::Test::Nested::Color::red;
+ Nested::Color nc2 = Nested::green;
+ Nested::Color nc3 = blue;
+}
+
+exception BaseEx
+{
+ bool boolFalse = false;
+ bool boolTrue = true;
+ byte b = 1;
+ short s = 2;
+ int i = 3;
+ long l = 4;
+ float f = 5.1;
+ double d = 6.2;
+ string str = "foo \\ \"bar\n \r\n\t\v\f\a\b\? \007 \x07";
+ string noDefault;
+ int zeroI = 0;
+ long zeroL = 0;
+ float zeroF = 0;
+ float zeroDotF = 0.0;
+ double zeroD = 0;
+ double zeroDotD = 0;
+}
+
+exception DerivedEx extends BaseEx
+{
+ Color c1 = ConstColor1;
+ Color c2 = ConstColor2;
+ Color c3 = ConstColor3;
+ Nested::Color nc1 = ConstNestedColor1;
+ Nested::Color nc2 = ConstNestedColor2;
+ Nested::Color nc3 = ConstNestedColor3;
+}
+
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+}
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq is;
+ InnerStruct st;
+ IntStringDict dict;
+}
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+}
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+}
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+}
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+}
+
+}
diff --git a/matlab/test/Ice/defaultValue/generated/.gitignore b/matlab/test/Ice/defaultValue/generated/.gitignore
new file mode 100644
index 00000000000..39af5887579
--- /dev/null
+++ b/matlab/test/Ice/defaultValue/generated/.gitignore
@@ -0,0 +1 @@
+# Dummy file, so that git retains this otherwise empty directory.
diff --git a/matlab/test/Ice/defaultValue/runTest.m b/matlab/test/Ice/defaultValue/runTest.m
new file mode 100644
index 00000000000..66a1e8dda5e
--- /dev/null
+++ b/matlab/test/Ice/defaultValue/runTest.m
@@ -0,0 +1,4 @@
+function runTest(varargin)
+ status = Client.start(varargin);
+ exit(status);
+end
diff --git a/matlab/test/Ice/enums/Client.m b/matlab/test/Ice/enums/Client.m
index 697bf720a22..2bb55598b28 100644
--- a/matlab/test/Ice/enums/Client.m
+++ b/matlab/test/Ice/enums/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/enums/runTest.m b/matlab/test/Ice/enums/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/enums/runTest.m
+++ b/matlab/test/Ice/enums/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/exceptions/Client.m b/matlab/test/Ice/exceptions/Client.m
index f5ca5baf8ed..fac92f81d4a 100644
--- a/matlab/test/Ice/exceptions/Client.m
+++ b/matlab/test/Ice/exceptions/Client.m
@@ -27,7 +27,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/exceptions/runTest.m b/matlab/test/Ice/exceptions/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/exceptions/runTest.m
+++ b/matlab/test/Ice/exceptions/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/facets/Client.m b/matlab/test/Ice/facets/Client.m
index 7cc32e939bf..7282d7cf92e 100644
--- a/matlab/test/Ice/facets/Client.m
+++ b/matlab/test/Ice/facets/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/facets/runTest.m b/matlab/test/Ice/facets/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/facets/runTest.m
+++ b/matlab/test/Ice/facets/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/info/Client.m b/matlab/test/Ice/info/Client.m
index a46732415fe..fd6d9189671 100644
--- a/matlab/test/Ice/info/Client.m
+++ b/matlab/test/Ice/info/Client.m
@@ -24,7 +24,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/info/runTest.m b/matlab/test/Ice/info/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/info/runTest.m
+++ b/matlab/test/Ice/info/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/inheritance/Client.m b/matlab/test/Ice/inheritance/Client.m
index 00b8798d2b8..7e2fa5ab6d1 100644
--- a/matlab/test/Ice/inheritance/Client.m
+++ b/matlab/test/Ice/inheritance/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/inheritance/runTest.m b/matlab/test/Ice/inheritance/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/inheritance/runTest.m
+++ b/matlab/test/Ice/inheritance/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/objects/Client.m b/matlab/test/Ice/objects/Client.m
index 124911de4f9..7fb48de6576 100644
--- a/matlab/test/Ice/objects/Client.m
+++ b/matlab/test/Ice/objects/Client.m
@@ -55,7 +55,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/objects/runTest.m b/matlab/test/Ice/objects/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/objects/runTest.m
+++ b/matlab/test/Ice/objects/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/operations/Client.m b/matlab/test/Ice/operations/Client.m
index 4d898e22ef2..81493fa543f 100644
--- a/matlab/test/Ice/operations/Client.m
+++ b/matlab/test/Ice/operations/Client.m
@@ -41,7 +41,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/operations/runTest.m b/matlab/test/Ice/operations/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/operations/runTest.m
+++ b/matlab/test/Ice/operations/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/optional/Client.m b/matlab/test/Ice/optional/Client.m
index 23d3a9957b4..5357b276707 100644
--- a/matlab/test/Ice/optional/Client.m
+++ b/matlab/test/Ice/optional/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/optional/runTest.m b/matlab/test/Ice/optional/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/optional/runTest.m
+++ b/matlab/test/Ice/optional/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/proxy/Client.m b/matlab/test/Ice/proxy/Client.m
index d6fde0f2068..3a44ad592df 100644
--- a/matlab/test/Ice/proxy/Client.m
+++ b/matlab/test/Ice/proxy/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/proxy/runTest.m b/matlab/test/Ice/proxy/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/proxy/runTest.m
+++ b/matlab/test/Ice/proxy/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/slicing/exceptions/Client.m b/matlab/test/Ice/slicing/exceptions/Client.m
index 7937df88aa1..ddc1dbd0601 100644
--- a/matlab/test/Ice/slicing/exceptions/Client.m
+++ b/matlab/test/Ice/slicing/exceptions/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/slicing/exceptions/runTest.m b/matlab/test/Ice/slicing/exceptions/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/slicing/exceptions/runTest.m
+++ b/matlab/test/Ice/slicing/exceptions/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/slicing/objects/Client.m b/matlab/test/Ice/slicing/objects/Client.m
index 19549675263..8b93685d66a 100644
--- a/matlab/test/Ice/slicing/objects/Client.m
+++ b/matlab/test/Ice/slicing/objects/Client.m
@@ -25,7 +25,7 @@ classdef Client < Application
end
end
methods(Static)
- function start(args)
+ function status = start(args)
addpath('generated');
if ~libisloaded('icematlab')
loadlibrary('icematlab')
diff --git a/matlab/test/Ice/slicing/objects/runTest.m b/matlab/test/Ice/slicing/objects/runTest.m
index ca3eaa751c8..66a1e8dda5e 100644
--- a/matlab/test/Ice/slicing/objects/runTest.m
+++ b/matlab/test/Ice/slicing/objects/runTest.m
@@ -1,4 +1,4 @@
function runTest(varargin)
- Client.start(varargin);
- quit
+ status = Client.start(varargin);
+ exit(status);
end
diff --git a/matlab/test/Ice/timeout/AllTests.m b/matlab/test/Ice/timeout/AllTests.m
new file mode 100644
index 00000000000..5e01cfe9547
--- /dev/null
+++ b/matlab/test/Ice/timeout/AllTests.m
@@ -0,0 +1,340 @@
+%{
+**********************************************************************
+
+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 AllTests
+ methods(Static)
+ function r = connect(prx)
+ nRetry = 10;
+ while nRetry > 0
+ nRetry = nRetry - 1;
+ try
+ prx.ice_getConnection();
+ break;
+ catch ex
+ if isa(ex, 'Ice.ConnectTimeoutException')
+ % Can sporadically occur with slow machines
+ else
+ rethrow(ex);
+ end
+ end
+ end
+ r = prx.ice_getConnection(); % Establish connection
+ end
+ function r = allTests(app)
+ import test.Ice.timeout.Test.*;
+
+ communicator = app.communicator();
+
+ sref = ['timeout:', app.getTestEndpoint(0, '')];
+ obj = communicator.stringToProxy(sref);
+ assert(~isempty(obj));
+
+ mult = 1;
+ if ~strcmp(communicator.getProperties().getPropertyWithDefault('Ice.Default.Protocol', 'tcp'), 'tcp')
+ mult = 4;
+ end
+
+ timeout = TimeoutPrx.checkedCast(obj);
+ assert(~isempty(timeout));
+
+ fprintf('testing connect timeout... ');
+
+ %
+ % Expect ConnectTimeoutException.
+ %
+ to = timeout.ice_timeout(100 * mult);
+ timeout.holdAdapter(500 * mult);
+ try
+ to.op();
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.ConnectTimeoutException'));
+ end
+
+ %
+ % Expect success.
+ %
+ timeout.op(); % Ensure adapter is active.
+ to = timeout.ice_timeout(1000 * mult);
+ timeout.holdAdapter(500 * mult);
+ try
+ to.op();
+ catch ex
+ if isa(ex, 'Ice.ConnectTimeoutException')
+ assert(false);
+ else
+ rethrow(ex);
+ end
+ end
+
+ fprintf('ok\n');
+
+ % The sequence needs to be large enough to fill the write/recv buffers
+ bufSize = 2000000;
+ seq = zeros(1, bufSize, 'uint8');
+
+ fprintf('testing connection timeout... ');
+
+ %
+ % Expect TimeoutException.
+ %
+ to = timeout.ice_timeout(250);
+ AllTests.connect(to);
+ timeout.holdAdapter(750 * mult);
+ try
+ to.sendData(seq);
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.TimeoutException'));
+ end
+
+ %
+ % Expect success.
+ %
+ timeout.op(); % Ensure adapter is active.
+ to = timeout.ice_timeout(1000 * mult);
+ timeout.holdAdapter(500 * mult);
+ try
+ to.sendData(zeros(1, 1000000, 'uint8'));
+ catch ex
+ if isa(ex, 'Ice.TimeoutException')
+ assert(false);
+ else
+ rethrow(ex);
+ end
+ end
+
+ fprintf('ok\n');
+
+ fprintf('testing invocation timeout... ');
+
+ connection = obj.ice_getConnection();
+ to = timeout.ice_invocationTimeout(100);
+ assert(connection == to.ice_getConnection());
+ try
+ to.sleep(750 * mult);
+ assert(false);
+ catch ex
+ assert(isa(ex, 'Ice.InvocationTimeoutException'));
+ end
+ obj.ice_ping();
+ to = TimeoutPrx.checkedCast(obj.ice_invocationTimeout(500 * mult));
+ assert(connection == to.ice_getConnection());
+ try
+ to.sleep(100 * mult);
+ catch ex
+ if isa(ex, 'Ice.InvocationTimeoutException')
+ assert(false);
+ else
+ rethrow(ex);
+ end
+ end
+ assert(connection == to.ice_getConnection());
+
+ %
+ % Expect InvocationTimeoutException.
+ %
+ to = timeout.ice_invocationTimeout(100);
+ f = to.sleepAsync(750 * mult);
+ try
+ f.fetchOutputs();
+ catch ex
+ assert(isa(ex, 'Ice.TimeoutException'));
+ end
+ obj.ice_ping();
+
+ %
+ % Expect success.
+ %
+ to = timeout.ice_invocationTimeout(500 * mult);
+ f = to.sleepAsync(100 * mult);
+ f.fetchOutputs();
+
+ %
+ % Backward compatible connection timeouts
+ %
+ to = timeout.ice_invocationTimeout(-2).ice_timeout(250);
+ con = AllTests.connect(to);
+ try
+ to.sleep(750);
+ assert(false);
+ catch ex
+ if isa(ex, 'Ice.TimeoutException')
+ assert(~isempty(con));
+ try
+ con.getInfo();
+ assert(false);
+ catch ex
+ if isa(ex, 'Ice.TimeoutException')
+ % Connection got closed as well.
+ else
+ rethrow(ex);
+ end
+ end
+ end
+ end
+ obj.ice_ping();
+
+ try
+ con = AllTests.connect(to);
+ to.sleepAsync(750).fetchOutputs();
+ assert(false);
+ catch ex
+ assert(isa(ex, 'Ice.TimeoutException'));
+ assert(~isempty(con));
+ try
+ con.getInfo();
+ assert(false);
+ catch ex
+ if isa(ex, 'Ice.TimeoutException')
+ % Connection got closed as well.
+ else
+ rethrow(ex);
+ end
+ end
+ end
+ obj.ice_ping();
+
+ fprintf('ok\n');
+
+ fprintf('testing close timeout... ');
+
+ to = TimeoutPrx.uncheckedCast(obj.ice_timeout(250 * mult));
+ connection = AllTests.connect(to);
+ timeout.holdAdapter(600);
+ connection.close(Ice.ConnectionClose.GracefullyWithWait);
+ try
+ connection.getInfo(); % getInfo() doesn't throw in the closing state.
+ catch ex
+ assert(false);
+ end
+
+ pause(.650 * mult);
+
+ try
+ connection.getInfo();
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.ConnectionManuallyClosedException'));
+ assert(ex.graceful);
+ end
+ timeout.op(); % Ensure adapter is active.
+
+ fprintf('ok\n');
+
+ fprintf('testing timeout overrides... ');
+
+ %
+ % Test Ice.Override.Timeout. This property overrides all
+ % endpoint timeouts.
+ %
+ initData = app.createInitializationData();
+ initData.properties_ = communicator.getProperties().clone();
+ initData.properties_.setProperty('Ice.Override.ConnectTimeout', '250');
+ initData.properties_.setProperty('Ice.Override.Timeout', '100');
+ comm = app.initialize(initData);
+ to = TimeoutPrx.uncheckedCast(comm.stringToProxy(sref));
+ AllTests.connect(to);
+ timeout.holdAdapter(500 * mult);
+ try
+ to.sendData(seq);
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.TimeoutException'));
+ end
+ %
+ % Calling ice_timeout() should have no effect.
+ %
+ timeout.op(); % Ensure adapter is active.
+ to = TimeoutPrx.uncheckedCast(to.ice_timeout(1000 * mult));
+ AllTests.connect(to);
+ timeout.holdAdapter(500 * mult);
+ try
+ to.sendData(seq);
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.TimeoutException'));
+ end
+ comm.destroy();
+
+ %
+ % Test Ice.Override.ConnectTimeout.
+ %
+ initData = app.createInitializationData();
+ initData.properties_ = communicator.getProperties().clone();
+ if mult == 1
+ initData.properties_.setProperty('Ice.Override.ConnectTimeout', '250');
+ else
+ initData.properties_.setProperty('Ice.Override.ConnectTimeout', '2500');
+ end
+
+ comm = app.initialize(initData);
+ to = TimeoutPrx.uncheckedCast(comm.stringToProxy(sref));
+ timeout.holdAdapter(750 * mult);
+ try
+ to.op();
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.ConnectTimeoutException'));
+ end
+ %
+ % Calling ice_timeout() should have no effect on the connect timeout.
+ %
+ timeout.op(); % Ensure adapter is active.
+ timeout.holdAdapter(750 * mult);
+ to = to.ice_timeout(1000 * mult);
+ try
+ to.op();
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.ConnectTimeoutException'));
+ end
+ %
+ % Verify that timeout set via ice_timeout() is still used for requests.
+ %
+ timeout.op(); % Ensure adapter is active.
+ to = to.ice_timeout(250);
+ AllTests.connect(to);
+ timeout.holdAdapter(750 * mult);
+ try
+ to.sendData(seq);
+ assert(false);
+ catch ex
+ % Expected.
+ assert(isa(ex, 'Ice.TimeoutException'));
+ end
+ comm.destroy();
+ %
+ % Test Ice.Override.CloseTimeout.
+ %
+ initData = app.createInitializationData();
+ initData.properties_ = communicator.getProperties().clone();
+ initData.properties_.setProperty('Ice.Override.CloseTimeout', '100');
+ comm = app.initialize(initData);
+ comm.stringToProxy(sref).ice_getConnection();
+ timeout.holdAdapter(800);
+ tic();
+ comm.destroy();
+ assert(toc() < .7);
+
+ fprintf('ok\n');
+
+ r = timeout;
+ end
+ end
+end
diff --git a/matlab/test/Ice/timeout/Application.m b/matlab/test/Ice/timeout/Application.m
new file mode 100644
index 00000000000..4735c1cd057
--- /dev/null
+++ b/matlab/test/Ice/timeout/Application.m
@@ -0,0 +1,143 @@
+%{
+**********************************************************************
+
+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 (Abstract) Application < handle
+ methods(Sealed)
+ %
+ % main() initializes the Communicator, calls run(), and destroys
+ % the Communicator upon return from run(). It thereby handles
+ % all exceptions properly, i.e., error messages are printed
+ % if exceptions propagate to main(), and the Communicator is
+ % always destroyed, regardless of exceptions.
+ %
+ function r = main(obj, appName, varargin)
+ if ~isempty(obj.communicator_)
+ printf('%s: only one instance of the Application class can be used', appName);
+ r = 1;
+ return;
+ end
+
+ obj.testName_ = appName;
+
+ args = {};
+ initializationData = [];
+
+ if length(varargin) >= 1
+ args = varargin{1};
+ end
+ if length(varargin) >= 2
+ initializationData = varargin{2};
+ end
+
+ %
+ % We parse the properties here to extract Ice.ProgramName.
+ %
+ if isempty(initializationData)
+ [initializationData, args] = obj.getInitData(args);
+ end
+
+ if ~isempty(initializationData)
+ initData = initializationData.clone();
+ else
+ initData = Ice.InitializationData();
+ end
+
+ [initData.properties_, args] = Ice.createProperties(args, initData.properties_);
+
+ status = 0;
+
+ try
+ [communicator, args] = Ice.initialize(args, initData);
+ obj.communicator_ = communicator;
+
+ status = obj.run(args);
+ catch ex
+ fprintf('%s: caught %s', obj.testName_, ex.identifier);
+ disp(getReport(ex, 'extended'));
+ status = 1;
+ end
+ obj.communicator_.destroy();
+ obj.communicator_ = [];
+
+ r = status;
+ end
+ function r = initialize(obj, varargin)
+ assert(length(varargin) <= 1);
+ if length(varargin) == 0
+ r = Ice.initialize();
+ else
+ r = Ice.initialize(varargin{1});
+ end
+ end
+ function r = appName(obj)
+ r = obj.testName_;
+ end
+ function r = communicator(obj)
+ r = obj.communicator_;
+ end
+ function r = createInitializationData(obj)
+ initData = Ice.InitializationData();
+ r = initData;
+ end
+ function r = getTestEndpoint(obj, num, prot)
+ r = Application.getTestEndpointWithProperties(obj.communicator_.getProperties(), num, prot);
+ end
+ function r = getTestHost(obj)
+ r = Application.getTestHostWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestProtocol(obj)
+ r = Application.getTestProtocolWithProperties(obj.communicator_.getProperties());
+ end
+ function r = getTestPort(obj, num)
+ r = Application.getTestPortWithProperties(obj.communicator_.getProperties(), num);
+ end
+ end
+ methods(Static)
+ function r = getTestEndpointWithProperties(props, num, prot)
+ protocol = prot;
+ if length(protocol) == 0
+ protocol = props.getPropertyWithDefault('Ice.Default.Protocol', 'default');
+ end
+
+ basePort = props.getPropertyAsIntWithDefault('Test.BasePort', 12010);
+
+ r = sprintf('%s -p %d', protocol, 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
+ methods(Abstract)
+ r = run(obj, args)
+ end
+ methods(Access=protected)
+ %
+ % Hook to override the initialization data. This hook is
+ % necessary because some properties must be set prior to
+ % communicator initialization.
+ %
+ function [initData, remArgs] = getInitData(obj, args)
+ initData = obj.createInitializationData();
+ [initData.properties_, remArgs] = Ice.createProperties(args);
+ remArgs = initData.properties_.parseCommandLineOptions('Test', remArgs);
+ end
+ end
+ properties(Access=private)
+ testName_
+ communicator_
+ end
+end
diff --git a/matlab/test/Ice/timeout/Client.m b/matlab/test/Ice/timeout/Client.m
new file mode 100644
index 00000000000..fcdcdef26b8
--- /dev/null
+++ b/matlab/test/Ice/timeout/Client.m
@@ -0,0 +1,54 @@
+%{
+**********************************************************************
+
+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 Client < Application
+ methods
+ function r = run(obj, args)
+ timeout = AllTests.allTests(obj);
+ timeout.shutdown();
+ r = 0;
+ end
+ end
+ methods(Access=protected)
+ function [r, remArgs] = getInitData(obj, args)
+ [initData, remArgs] = getInitData@Application(obj, args);
+ initData.properties_.setProperty('Ice.Package.Test', 'test.Ice.timeout');
+
+ %
+ % For this test, we want to disable retries.
+ %
+ initData.properties_.setProperty('Ice.RetryIntervals', '-1');
+
+ %
+ % This test kills connections, so we don't want warnings.
+ %
+ initData.properties_.setProperty('Ice.Warn.Connections', '0');
+
+ %
+ % Limit the send buffer size, this test relies on the socket
+ % send() blocking after sending a given amount of data.
+ %
+ initData.properties_.setProperty('Ice.TCP.SndSize', '50000');
+
+ r = initData;
+ end
+ end
+ methods(Static)
+ function status = start(args)
+ addpath('generated');
+ if ~libisloaded('icematlab')
+ loadlibrary('icematlab')
+ end
+ c = Client();
+ status = c.main('Client', args);
+ end
+ end
+end
diff --git a/matlab/test/Ice/timeout/Test.ice b/matlab/test/Ice/timeout/Test.ice
new file mode 100644
index 00000000000..cbe4d4a7258
--- /dev/null
+++ b/matlab/test/Ice/timeout/Test.ice
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#pragma once
+
+[["matlab:package:test.Ice.timeout"]]
+module Test
+{
+
+sequence<byte> ByteSeq;
+
+interface Timeout
+{
+ void op();
+ void sendData(ByteSeq seq);
+ void sleep(int to);
+
+ void holdAdapter(int to);
+
+ void shutdown();
+}
+
+}
diff --git a/matlab/test/Ice/timeout/generated/.gitignore b/matlab/test/Ice/timeout/generated/.gitignore
new file mode 100644
index 00000000000..39af5887579
--- /dev/null
+++ b/matlab/test/Ice/timeout/generated/.gitignore
@@ -0,0 +1 @@
+# Dummy file, so that git retains this otherwise empty directory.
diff --git a/matlab/test/Ice/timeout/runTest.m b/matlab/test/Ice/timeout/runTest.m
new file mode 100644
index 00000000000..66a1e8dda5e
--- /dev/null
+++ b/matlab/test/Ice/timeout/runTest.m
@@ -0,0 +1,4 @@
+function runTest(varargin)
+ status = Client.start(varargin);
+ exit(status);
+end