summaryrefslogtreecommitdiff
path: root/js/test/Ice/binding/Client.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/test/Ice/binding/Client.js')
-rw-r--r--js/test/Ice/binding/Client.js168
1 files changed, 64 insertions, 104 deletions
diff --git a/js/test/Ice/binding/Client.js b/js/test/Ice/binding/Client.js
index 30b0604fd59..075c5f491b8 100644
--- a/js/test/Ice/binding/Client.js
+++ b/js/test/Ice/binding/Client.js
@@ -19,13 +19,10 @@
{
if(array.length === 0)
{
- return new Promise.succeed();
+ return Promise.resolve();
}
var p = null;
- array.forEach(function(e)
- {
- p = p ? p.then(fn(e)) : fn(e);
- });
+ array.forEach(e => p = p ? p.then(fn(e)) : fn(e));
return p;
};
@@ -60,21 +57,17 @@
var createTestIntfPrx = function(adapters)
{
var endpoints = [];
- var closePromises = [];
var p = null;
return Promise.all(adapters.map(function(adapter){ return adapter.getTestIntf(); })).then(
- function()
+ function(results)
{
- var results = Array.prototype.slice.call(arguments);
results.forEach(
function(r)
{
- p = r[0];
- test(p);
+ p = r;
endpoints = endpoints.concat(p.ice_getEndpoints());
- }
- );
+ });
return Test.TestIntfPrx.uncheckedCast(p.ice_endpoints(endpoints));
});
};
@@ -89,7 +82,7 @@
{
if(adapters.length > 0)
{
- f1(adapters);
+ return (adapters);
}
}
);
@@ -108,7 +101,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -141,48 +134,44 @@
function(obj)
{
adapter = obj;
- return Promise.all(adapter.getTestIntf(), adapter.getTestIntf());
+ return Promise.all([adapter.getTestIntf(), adapter.getTestIntf()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- test1 = r1[0];
- test2 = r2[0];
-
- return Promise.all(test1.ice_getConnection(), test2.ice_getConnection());
+ [test1, test2] = r;
+ return Promise.all([test1.ice_getConnection(), test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- conn1 = r1[0];
- conn2 = r2[0];
+ [conn1, conn2] = r;
test(conn1 === conn2);
- return Promise.all(test1.ice_ping(), test2.ice_ping());
+ return Promise.all([test1.ice_ping(), test2.ice_ping()]);
}
).then(
- function(r1, r2)
+ function(r)
{
+ let [r1, r2] = r;
return com.deactivateObjectAdapter(adapter);
}
).then(
function()
{
test3 = Test.TestIntfPrx.uncheckedCast(test1);
- return Promise.all(test3.ice_getConnection(), test1.ice_getConnection());
+ return Promise.all([test3.ice_getConnection(), test1.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- conn3 = r1[0];
- conn1 = r2[0];
+ [conn3, conn1] = r;
test(conn3 === conn1);
- return Promise.all(test3.ice_getConnection(), test2.ice_getConnection());
+ return Promise.all([test3.ice_getConnection(), test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- conn3 = r1[0];
- conn2 = r2[0];
+ [conn3, conn2] = r;
test(conn3 === conn2);
return test3.ice_ping();
}
@@ -206,21 +195,19 @@
{
out.write("testing binding with multiple endpoints... ");
- return Promise.all(
+ return Promise.all([
com.createObjectAdapter("Adapter11", "default"),
com.createObjectAdapter("Adapter12", "default"),
- com.createObjectAdapter("Adapter13", "default"));
+ com.createObjectAdapter("Adapter13", "default")]);
}
).then(
//
// Ensure that when a connection is opened it's reused for new
// proxies and that all endpoints are eventually tried.
//
- function(r1, r2, r3)
+ function(r)
{
- adapters.push(r1[0]);
- adapters.push(r2[0]);
- adapters.push(r3[0]);
+ adapters.push(...r);
var f1 = function(names)
{
@@ -243,17 +230,19 @@
function(obj)
{
test3 = obj;
- return Promise.all(test1.ice_getConnection(), test2.ice_getConnection());
+ return Promise.all([test1.ice_getConnection(), test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
+ let [r1, r2] = r;
test(r1[0] === r2[0]);
- return Promise.all(test2.ice_getConnection(), test3.ice_getConnection());
+ return Promise.all([test2.ice_getConnection(), test3.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
+ let [r1, r2] = r;
test(r1[0] === r2[0]);
return test1.getAdapterName();
}
@@ -440,8 +429,7 @@
{
return f1(names);
}
- }
- );
+ });
};
return f1(ArrayUtil.clone(names));
}
@@ -498,9 +486,9 @@
return com.createObjectAdapter(name, "default");
})
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
var count = 20;
var adapterCount = adapters.length;
var proxies = new Array(10);
@@ -508,7 +496,7 @@
var f1 = function(count, adapterCount, proxies)
{
- var p1 = count === 10 ? com.deactivateObjectAdapter(adapters[2]) : new Promise().succeed();
+ var p1 = count === 10 ? com.deactivateObjectAdapter(adapters[2]) : Promise.resolve();
return p1.then(
function()
{
@@ -560,7 +548,7 @@
return forEach(proxies,
function(proxy)
{
- return proxy.ice_ping().exception(
+ return proxy.ice_ping().catch(
function(ex)
{
test(ex instanceof Ice.LocalException);
@@ -621,12 +609,7 @@
function()
{
out.writeLine("ok");
- },
- function(ex)
- {
- out.writeLine("failed! " + ex.stack);
- }
- );
+ });
}
).then(
function()
@@ -641,14 +624,14 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); }));
}
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
return createTestIntfPrx(adapters);
},
function(ex)
{
- console.log(ex.toString());
+ console.log(ex.stack);
test(false);
}
).then(
@@ -658,8 +641,7 @@
var f1 = function()
{
- return prx.getAdapterName().then(
- function(name)
+ return prx.getAdapterName().then(name =>
{
if(names.indexOf(name) !== -1)
{
@@ -667,24 +649,8 @@
}
return prx.ice_getConnection();
}
- ).then(
- function(conn)
- {
- return conn.close(false);
- }
- ).then(
- function()
- {
- if(names.length > 0)
- {
- return f1();
- }
- else
- {
- return prx;
- }
- }
- );
+ ).then(conn => conn.close(false)
+ ).then(() => names.length > 0 ? f1() : prx);
};
return f1();
@@ -751,9 +717,9 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); }));
}
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
return createTestIntfPrx(adapters);
}
).then(
@@ -883,14 +849,15 @@
test2 = Test.TestIntfPrx.uncheckedCast(obj.ice_connectionCached(false));
test(!test1.ice_isConnectionCached());
test(!test2.ice_isConnectionCached());
- return Promise.all(test1.ice_getConnection(),
- test2.ice_getConnection());
+ return Promise.all([test1.ice_getConnection(),
+ test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- test(r1[0] && r2[0]);
- test(r1[0] == r2[0]);
+ let [r1, r2] = r;
+ test(r1 && r2);
+ test(r1 == r2);
return test1.ice_ping();
}
).then(
@@ -902,8 +869,8 @@
function()
{
var test3 = Test.TestIntfPrx.uncheckedCast(test1);
- return Promise.all(test3.ice_getConnection(),
- test1.ice_getConnection());
+ return Promise.all([test3.ice_getConnection(),
+ test1.ice_getConnection()]);
}
).then(
function()
@@ -932,9 +899,9 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); }));
}
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
var f2 = function(prx)
{
@@ -1024,7 +991,7 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); })).then(
function(a)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = a;
return createTestIntfPrx(adapters);
}
).then(
@@ -1129,21 +1096,14 @@
{
return com.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.rejectr);
return p;
};
var run = function(out, id)
{
+ //id.properties.setProperty("Ice.Trace.Protocol", "1");
+ //id.properties.setProperty("Ice.Trace.Network", "2");
var p = new Ice.Promise();
setTimeout(
function()
@@ -1153,14 +1113,14 @@
allTests(out, id).then(function(){
return communicator.destroy();
}).then(function(){
- p.succeed();
- }).exception(function(ex){
- p.fail(ex);
+ p.resolve();
+ }).catch(function(ex){
+ p.reject(ex);
});
}
catch(ex)
{
- p.fail(ex);
+ p.reject(ex);
}
});
return p;