diff options
author | Jose <jose@zeroc.com> | 2018-08-02 11:48:30 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-08-02 11:48:30 +0200 |
commit | 9417fad26a0ed34872df27b0e5b0b8737274ae21 (patch) | |
tree | c1d98c51149f899276cf5b628b51370f32ff582d /js/test/Ice/acm/Client.js | |
parent | Fix IcePHP sequences order (diff) | |
download | ice-9417fad26a0ed34872df27b0e5b0b8737274ae21.tar.bz2 ice-9417fad26a0ed34872df27b0e5b0b8737274ae21.tar.xz ice-9417fad26a0ed34872df27b0e5b0b8737274ae21.zip |
Update JavaScript tests to use TestHelper class
Diffstat (limited to 'js/test/Ice/acm/Client.js')
-rw-r--r-- | js/test/Ice/acm/Client.js | 121 |
1 files changed, 59 insertions, 62 deletions
diff --git a/js/test/Ice/acm/Client.js b/js/test/Ice/acm/Client.js index 31f3cce941d..a24d0b5ae88 100644 --- a/js/test/Ice/acm/Client.js +++ b/js/test/Ice/acm/Client.js @@ -10,15 +10,9 @@ (function(module, require, exports) { const Ice = require("ice").Ice; + const TestHelper = require("TestHelper").TestHelper; const Test = require("Test").Test; - - function test(value) - { - if(!value) - { - throw new Error("test failed"); - } - } + const test = TestHelper.test; class LoggerI { @@ -460,73 +454,76 @@ } } - async function allTests(out, communicator) + class Client extends TestHelper { - const ref = "communicator:default -p 12010"; - const com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref)); - - const tests = []; - // - // Skip some tests with IE it opens too many connections and - // IE doesn't allow more than 6 connections. - // - if(typeof navigator !== "undefined" && - ["MSIE", "Trident/7.0", "Edge/12", "Edge/13"].some(value => navigator.userAgent.indexOf(value) !== -1)) - { - tests.push(new HeartbeatOnIdleTest(com, out)); - tests.push(new SetACMTest(com, out)); - } - else + async allTests() { - tests.push(new InvocationHeartbeatTest(com, out)); - tests.push(new InvocationHeartbeatOnHoldTest(com, out)); - tests.push(new InvocationNoHeartbeatTest(com, out)); - tests.push(new InvocationHeartbeatCloseOnIdleTest(com, out)); + const communicator = this.communicator(); + const out = this.getWriter(); + const ref = "communicator:" + this.getTestEndpoint(); + const com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref)); - tests.push(new CloseOnIdleTest(com, out)); - tests.push(new CloseOnInvocationTest(com, out)); - tests.push(new CloseOnIdleAndInvocationTest(com, out)); - tests.push(new ForcefullCloseOnIdleAndInvocationTest(com, out)); + const tests = []; + // + // Skip some tests with IE it opens too many connections and + // IE doesn't allow more than 6 connections. + // + if(typeof navigator !== "undefined" && + ["MSIE", "Trident/7.0", "Edge/12", "Edge/13"].some(value => navigator.userAgent.indexOf(value) !== -1)) + { + tests.push(new HeartbeatOnIdleTest(com, out)); + tests.push(new SetACMTest(com, out)); + } + else + { + tests.push(new InvocationHeartbeatTest(com, out)); + tests.push(new InvocationHeartbeatOnHoldTest(com, out)); + tests.push(new InvocationNoHeartbeatTest(com, out)); + tests.push(new InvocationHeartbeatCloseOnIdleTest(com, out)); + + tests.push(new CloseOnIdleTest(com, out)); + tests.push(new CloseOnInvocationTest(com, out)); + tests.push(new CloseOnIdleAndInvocationTest(com, out)); + tests.push(new ForcefullCloseOnIdleAndInvocationTest(com, out)); + + tests.push(new HeartbeatOnIdleTest(com, out)); + tests.push(new HeartbeatAlwaysTest(com, out)); + tests.push(new HeartbeatManualTest(com, out)); + tests.push(new SetACMTest(com, out)); + } - tests.push(new HeartbeatOnIdleTest(com, out)); - tests.push(new HeartbeatAlwaysTest(com, out)); - tests.push(new HeartbeatManualTest(com, out)); - tests.push(new SetACMTest(com, out)); - } + await Promise.all(tests.map(test => test.init())); + await Promise.all(tests.map(test => test.start())); + for(const test of tests) + { + test.join(out); + } + await Promise.all(tests.map(test => test.destroy())); - await Promise.all(tests.map(test => test.init())); - await Promise.all(tests.map(test => test.start())); - for(const test of tests) - { - test.join(out); + out.write("shutting down... "); + await com.shutdown(); + out.writeLine("ok"); } - await Promise.all(tests.map(test => test.destroy())); - out.write("shutting down... "); - await com.shutdown(); - out.writeLine("ok"); - } - - async function run(out, initData) - { - let communicator; - try + async run(args) { - initData.properties.setProperty("Ice.Warn.Connections", "0"); - communicator = Ice.initialize(initData); - await allTests(out, communicator); - } - finally - { - if(communicator) + let communicator; + try { - await communicator.destroy(); + communicator = this.initialize(args); + await this.allTests(); + } + finally + { + if(communicator) + { + await communicator.destroy(); + } } } } + exports.Client = Client; - exports._test = run; - exports._runServer = true; }(typeof global !== "undefined" && typeof global.process !== "undefined" ? module : undefined, typeof global !== "undefined" && typeof global.process !== "undefined" ? require : this.Ice._require, typeof global !== "undefined" && typeof global.process !== "undefined" ? exports : this)); |