summaryrefslogtreecommitdiff
path: root/js/test/Ice/operations/Client.js
blob: 77093f5f18c403e547af944f6493c3015afb1e89 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// **********************************************************************
//
// Copyright (c) 2003-2014 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.
//
// **********************************************************************

(function(global){
    var require = typeof(module) !== "undefined" ? module.require : function(){};

    require("Ice/Ice");
    require("Test");
    require("Twoways");
    require("Oneways");
    require("BatchOneways");

    var Ice = global.Ice;
    var Promise = Ice.Promise;
    var Twoways = global.Twoways;
    var Oneways = global.Oneways;
    var BatchOneways = global.BatchOneways;

    var allTests = function(out, communicator, Test, bidir)
    {
        var ref, base, cl, derived;

        return Promise.try(
            function()
            {
                out.write("testing twoway operations... ");
                ref = "test:default -p 12010";
                base = communicator.stringToProxy(ref);
                return Test.MyClassPrx.checkedCast(base);
            }
        ).then(
            function(prx)
            {
                cl = prx;
                return Test.MyDerivedClassPrx.checkedCast(cl);
            }
        ).then(
            function(prx)
            {
                derived = prx;
                return Twoways.run(communicator, cl, Test, bidir);
            }
        ).then(
            function()
            {
                return Twoways.run(communicator, derived, Test, bidir);
            }
        ).then(
            function()
            {
                out.writeLine("ok");
                out.write("testing oneway operations... ");
                return Oneways.run(communicator, cl, Test, bidir);
            }
        ).then(
            function()
            {
                out.writeLine("ok");
                out.write("testing batch oneway operations... ");
                return BatchOneways.run(communicator, cl, Test, bidir);
            }
        ).then(
            function()
            {
                out.writeLine("ok");
                return cl;
            });
    };

    var run = function(out, id)
    {
        return Promise.try(
            function()
            {
                //
                // We must set MessageSizeMax to an explicit value,
                // because we run tests to check whether
                // Ice.MemoryLimitException is raised as expected.
                //
                id.properties.setProperty("Ice.MessageSizeMax", "100");
                var c = Ice.initialize(id);
                return allTests(out, c, global.Test, false).then(
                    function(cl)
                    {
                        return cl.shutdown();
                    }
                ).finally(
                    function()
                    {
                        if(c)
                        {
                            return c.destroy();
                        }
                    });
            });
    };
    global.__test__ = run
    global.__clientAllTests__ = allTests;
    global.__runServer__ = true;

}(typeof (global) === "undefined" ? window : global));