diff options
author | Jose <jose@zeroc.com> | 2016-08-19 21:25:18 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-08-19 21:25:18 +0200 |
commit | c8d32e04873be7938915c606027c84c8ab832f6b (patch) | |
tree | f862751cfaddcf5bb7b82a7c04a299d471f948d4 /js/test/Ice/timeout/Client.js | |
parent | Fix ICE-7278 (diff) | |
download | ice-c8d32e04873be7938915c606027c84c8ab832f6b.tar.bz2 ice-c8d32e04873be7938915c606027c84c8ab832f6b.tar.xz ice-c8d32e04873be7938915c606027c84c8ab832f6b.zip |
ES6 mapping updates
Diffstat (limited to 'js/test/Ice/timeout/Client.js')
-rw-r--r-- | js/test/Ice/timeout/Client.js | 227 |
1 files changed, 52 insertions, 175 deletions
diff --git a/js/test/Ice/timeout/Client.js b/js/test/Ice/timeout/Client.js index 533f52560d9..ec20772d85e 100644 --- a/js/test/Ice/timeout/Client.js +++ b/js/test/Ice/timeout/Client.js @@ -29,15 +29,14 @@ } catch(err) { - p.fail(err); + p.reject(err); throw err; } } }; var seq; - Promise.try( - function() + Promise.try(() => { ref = "timeout:default -p 12010"; obj = communicator.stringToProxy(ref); @@ -49,11 +48,9 @@ { mult = 4; } - return Test.TimeoutPrx.checkedCast(obj); } - ).then( - function(obj) + ).then(obj => { timeout = obj; test(timeout !== null); @@ -61,47 +58,23 @@ to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(100 * mult)); return timeout.holdAdapter(1000 * mult); } - ).then( - function() - { - return to.ice_getConnection(); - } - ).then( - function() - { - // - // Expect ConnectTimeoutException. - // - return to.op(); - } + ).then(() => to.ice_getConnection() + ).then(() => to.op() // Expect ConnectTimeoutException. ).then( failCB, - function(ex) + ex => { test(ex instanceof Ice.ConnectTimeoutException); return timeout.op(); // Ensure adapter is active. } - ).then( - function() + ).then(() => { to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(1000 * mult)); return timeout.holdAdapter(500 * mult); } - ).then( - function() - { - return to.ice_getConnection(); - } - ).then( - function() - { - // - // Expect success. - // - return to.op(); - } - ).then( - function() + ).then(() => to.ice_getConnection() + ).then(() => to.op() // Expect success. + ).then(() => { out.writeLine("ok"); out.write("testing connection timeout... "); @@ -109,99 +82,68 @@ seq = Ice.Buffer.createNative(new Array(10000000)); return timeout.holdAdapter(1000 * mult); } - ).then( - function() - { - // - // Expect TimeoutException. - // - return to.sendData(seq); - } - ).then( - function() - { - test(false); - }, - function(ex) + ).then(() => to.sendData(seq) // Expect TimeoutException + ).then(() => test(false), + ex => { test(ex instanceof Ice.TimeoutException); return timeout.op(); // Ensure adapter is active. } - ).then( - function() + ).then(() => { // NOTE: 30s timeout is necessary for Firefox/IE on Windows to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(30000 * mult)); return timeout.holdAdapter(500 * mult); } - ).then( - function() - { - // - // Expect success. - // - return to.sendData(Ice.Buffer.createNative(new Array(5 * 1024))); - } - ).then( - function() + ).then(() => to.sendData(Ice.Buffer.createNative(new Array(5 * 1024))) // Expect success. + ).then(() => { out.writeLine("ok"); out.write("testing invocation timeout... "); return obj.ice_getConnection(); } - ).then( - function(con) + ).then(con => { to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100)); return to.ice_getConnection(); } - ).then( - function(con) + ).then(con => { test(to.ice_getCachedConnection() === obj.ice_getCachedConnection()); return to.sleep(750); } ).then( failCB, - function(ex) + ex => { test(ex instanceof Ice.InvocationTimeoutException); return obj.ice_ping(); } - ).then( - function() + ).then(() => { to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500)); return to.ice_getConnection(); } - ).then( - function(con) + ).then(con => { test(to.ice_getCachedConnection() === obj.ice_getCachedConnection()); return to.sleep(250); } - ).then( - function() + ).then(() => { out.writeLine("ok"); out.write("testing close timeout... "); to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(500)); return to.ice_getConnection(); } - ).then( - function(con) + ).then(con => { connection = con; return timeout.holdAdapter(1500); } - ).then( - function() - { - return connection.close(false); - } - ).then( - function() + ).then(() => connection.close(false) + ).then(() => { try { @@ -212,8 +154,7 @@ test(false); } } - ).delay(1000).then( - function() + ).delay(1000).then(() => { try { @@ -226,8 +167,7 @@ } return timeout.op(); } - ).then( - function() + ).then(() => { out.writeLine("ok"); out.write("testing timeout overrides... "); @@ -248,58 +188,34 @@ comm = Ice.initialize(initData); return Test.TimeoutPrx.checkedCast(comm.stringToProxy(ref)); } - ).then( - function(obj) + ).then(obj => { to = obj; return timeout.holdAdapter(750 * 2 * mult); } - ).then( - function() - { - // - // Expect TimeoutException. - // - return to.sendData(seq); - } + ).then(() => to.sendData(seq) // Expect TimeoutException. ).then( failCB, - function(ex) + ex => { test(ex instanceof Ice.TimeoutException); return timeout.op(); // Ensure adapter is active. } - ).then( - function() - { - // - // Calling ice_timeout() should have no effect. - // - return Test.TimeoutPrx.checkedCast(to.ice_timeout(1000 * mult)); - } - ).then( - function(obj) + ).then(() => Test.TimeoutPrx.checkedCast(to.ice_timeout(1000 * mult)) // Calling ice_timeout() should have no effect. + ).then(obj => { to = obj; return timeout.holdAdapter(750 * 2 * mult); } - ).then( - function() - { - // - // Expect TimeoutException. - // - return to.sendData(seq); - } + ).then(() => to.sendData(seq) // Expect TimeoutException. ).then( failCB, - function(ex) + ex => { test(ex instanceof Ice.TimeoutException); return comm.destroy(); } - ).then( - function() + ).then(() => { // // Test Ice.Override.ConnectTimeout. @@ -318,25 +234,16 @@ to = Test.TimeoutPrx.uncheckedCast(comm.stringToProxy(ref)); return timeout.holdAdapter(750 * mult); } - ).then( - function() - { - return to.op(); - } + ).then(() => to.op() ).then( failCB, - function(ex) + ex => { test(ex instanceof Ice.ConnectTimeoutException); return timeout.op(); // Ensure adapter is active. } - ).then( - function() - { - return timeout.holdAdapter(750 * mult); - } - ).then( - function() + ).then(() => timeout.holdAdapter(750 * mult) + ).then(() => { // // Calling ice_timeout() should have no effect on the connect timeout. @@ -344,41 +251,27 @@ to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(1000 * mult)); return to.op(); } - ).then( - function() - { - test(false); - }, - function(ex) + ).then(() => test(false), + ex => { test(ex instanceof Ice.ConnectTimeoutException); return timeout.op(); // Ensure adapter is active. } - ).then( - function() + ).then(() => { to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(100 * mult)); return to.ice_getConnection(); // Force connection. } - ).then( - function(obj) - { - return timeout.holdAdapter(750 * mult); - } - ).then( - function() - { - return to.sendData(seq); - } + ).then(obj => timeout.holdAdapter(750 * mult) + ).then(() => to.sendData(seq) ).then( failCB, - function(ex) + ex => { test(ex instanceof Ice.TimeoutException); return comm.destroy(); } - ).then( - function() + ).then(() => { // // Test Ice.Override.CloseTimeout. @@ -389,30 +282,20 @@ comm = Ice.initialize(initData); return comm.stringToProxy(ref).ice_getConnection(); } - ).then( - function(con) - { - return timeout.holdAdapter(500); - } - ).then( - function() + ).then(() => timeout.holdAdapter(500) + ).then(() => { now = Date.now(); return comm.destroy(); } - ).then( - function() + ).then(() => { var t = Date.now(); test(t - now < 400); out.writeLine("ok"); return timeout.shutdown(); } - ).then( - function() - { - p.succeed(); - }); + ).then(p.resolve, p.reject); return p; }; @@ -435,8 +318,7 @@ id.properties.setProperty("Ice.MessageSizeMax", "10000"); var c = Ice.initialize(id); - return Promise.try( - function() + return Promise.try(() => { if(typeof(navigator) !== 'undefined' && isSafari() && isWorker()) { @@ -448,12 +330,7 @@ return allTests(out, c); } } - ).finally( - function() - { - return c.destroy(); - } - ); + ).finally(() => c.destroy()); }; exports.__test__ = run; exports.__runServer__ = true; |