diff options
Diffstat (limited to 'js/test/Ice/exceptions/Server.js')
-rw-r--r-- | js/test/Ice/exceptions/Server.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/js/test/Ice/exceptions/Server.js b/js/test/Ice/exceptions/Server.js new file mode 100644 index 00000000000..ffb45677831 --- /dev/null +++ b/js/test/Ice/exceptions/Server.js @@ -0,0 +1,56 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2017 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(module, require, exports) +{ + var Ice = require("ice").Ice; + var Test = require("Test").Test; + var ThrowerI = require("ThrowerI").ThrowerI; + + var run = function(out, id, ready) + { + id.properties.setProperty("Ice.MessageSizeMax", "10"); + id.properties.setProperty("Ice.Warn.Dispatch", "0"); + id.properties.setProperty("Ice.Warn.Connections", "0"); + var communicator = Ice.initialize(id); + var adapter; + var echo = Test.EchoPrx.uncheckedCast(communicator.stringToProxy("__echo:default -p 12010")); + return Ice.Promise.try(() => + { + return communicator.createObjectAdapter(""); + } + ).then(adpt => + { + adapter = adpt; + adapter.add(new ThrowerI(), Ice.stringToIdentity("thrower")); + return echo.setConnection(); + } + ).then(() => + { + var connection = echo.ice_getCachedConnection(); + connection.setCloseCallback((con) => { + // Re-establish connection if it fails (necessary for MemoryLimitException test) + echo.setConnection().then(() => echo.ice_getCachedConnection().setAdapter(adapter)) + }); + connection.setAdapter(adapter); + adapter.activate(); + ready.resolve(); + return communicator.waitForShutdown(); + } + ).then(() => + { + return echo.shutdown(); + } + ).finally(() => communicator.destroy()); + }; + exports._server = run; +} +(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)); |