summaryrefslogtreecommitdiff
path: root/matlab/test/Ice/operations/BatchOnewaysAMI.m
blob: b12e31a9f0fb261afc2ebdbe461dbca05f2b6c5c (plain)
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
%
% Copyright (c) ZeroC, Inc. All rights reserved.
%

classdef BatchOnewaysAMI
    methods(Static)
        function batchOneways(p)
            bs1 = zeros(1, 10  * 1024);

            batch = p.ice_batchOneway();
            future = batch.ice_flushBatchRequestsAsync(); % Empty flush
            future.wait();
            assert(strcmp(future.State, 'finished'));

            futures = {};
            for i = 1:30
                futures{i} = batch.opByteSOnewayAsync(bs1);
            end
            for i = 1:30
                assert(futures{i}.wait());
            end

            count = 0;
            while count < 27 % 3 * 9 requests auto-flushed.
                count = count + p.opByteSOnewayCallCount();
                pause(0.1);
            end

            if ~isempty(batch.ice_getConnection())
                batch2 = p.ice_batchOneway();

                batch.ice_pingAsync();
                batch2.ice_pingAsync();
                assert(batch.ice_flushBatchRequestsAsync().wait());
                batch.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                batch.ice_pingAsync();
                batch2.ice_pingAsync();

                batch.ice_getConnection();
                batch2.ice_getConnection();

                batch.ice_pingAsync();
                batch.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                assert(batch.ice_pingAsync().wait());
                assert(batch2.ice_pingAsync().wait());
            end

            identity = Ice.Identity();
            identity.name = 'invalid';
            batch3 = batch.ice_identity(identity);
            batch3.ice_pingAsync();
            assert(batch3.ice_flushBatchRequestsAsync().wait());

            % Make sure that a bogus batch request doesn't cause troubles to other ones.
            batch3.ice_pingAsync();
            batch.ice_pingAsync();
            assert(batch.ice_flushBatchRequestsAsync().wait());
            batch.ice_pingAsync();
        end
    end
end