summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2015-07-09 14:03:40 -0230
committerDwayne Boone <dwayne@zeroc.com>2015-07-09 14:03:40 -0230
commit272471ae45a9470979d6e498bb04b19cd64c08ba (patch)
treefaf44da0170f4f585f8272ec16b98991831c1b71 /js
parentMinor change to prevent fixVersions from making unecessary change (diff)
downloadice-272471ae45a9470979d6e498bb04b19cd64c08ba.tar.bz2
ice-272471ae45a9470979d6e498bb04b19cd64c08ba.tar.xz
ice-272471ae45a9470979d6e498bb04b19cd64c08ba.zip
ICE-6472 Added info test to JavaScript
Diffstat (limited to 'js')
-rwxr-xr-xjs/allTests.py1
-rw-r--r--js/gulpfile.js1
-rw-r--r--js/src/Ice/browser/WSTransceiver.js2
-rw-r--r--js/test/Common/index.html4
-rw-r--r--js/test/Ice/info/.gitignore2
-rw-r--r--js/test/Ice/info/Client.js190
-rw-r--r--js/test/Ice/info/Test.ice26
-rw-r--r--js/test/Ice/info/run.js10
-rwxr-xr-xjs/test/Ice/info/run.py24
9 files changed, 259 insertions, 1 deletions
diff --git a/js/allTests.py b/js/allTests.py
index 940f797b41a..2dbafa66dfc 100755
--- a/js/allTests.py
+++ b/js/allTests.py
@@ -36,6 +36,7 @@ tests = [
("Ice/facetsBidir", ["core"]),
("Ice/hashmap", ["once"]),
("Ice/hold", ["core"]),
+ ("Ice/info", ["core"]),
("Ice/inheritance", ["once"]),
("Ice/inheritanceBidir", ["once"]),
("Ice/location", ["once"]),
diff --git a/js/gulpfile.js b/js/gulpfile.js
index b7ab5a86d02..99a05331363 100644
--- a/js/gulpfile.js
+++ b/js/gulpfile.js
@@ -56,6 +56,7 @@ var tests = [
"test/Ice/facets",
"test/Ice/facetsBidir",
"test/Ice/hold",
+ "test/Ice/info",
"test/Ice/inheritance",
"test/Ice/inheritanceBidir",
"test/Ice/location",
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js
index 3e57b41e8dd..781ce22d0cb 100644
--- a/js/src/Ice/browser/WSTransceiver.js
+++ b/js/src/Ice/browser/WSTransceiver.js
@@ -298,7 +298,7 @@ var WSTransceiver = Ice.Class({
checkSendSize: function(stream)
{
},
- setBUfferSze: function(rcvSize, sndSize)
+ setBufferSize: function(rcvSize, sndSize)
{
this._maxSendPacketSize = sndSize;
},
diff --git a/js/test/Common/index.html b/js/test/Common/index.html
index 16af6bcfb7a..ef2340ae875 100644
--- a/js/test/Common/index.html
+++ b/js/test/Common/index.html
@@ -182,6 +182,10 @@
{
files: ["Test.js", "Client.js"]
},
+ "Ice/info":
+ {
+ files: ["Test.js", "Client.js"]
+ },
"Ice/inheritance":
{
files: ["Test.js", "Client.js"]
diff --git a/js/test/Ice/info/.gitignore b/js/test/Ice/info/.gitignore
new file mode 100644
index 00000000000..d158d9308ba
--- /dev/null
+++ b/js/test/Ice/info/.gitignore
@@ -0,0 +1,2 @@
+Test.js
+index.html
diff --git a/js/test/Ice/info/Client.js b/js/test/Ice/info/Client.js
new file mode 100644
index 00000000000..cd866ca535b
--- /dev/null
+++ b/js/test/Ice/info/Client.js
@@ -0,0 +1,190 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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 IceSSL = require("ice").IceSSL;
+ var Test = require("Test").Test;
+ var Promise = Ice.Promise;
+
+ function allTests(communicator, out)
+ {
+ var p = new Ice.Promise();
+ var test = function(b)
+ {
+ if(!b)
+ {
+ try
+ {
+ throw new Error("test failed");
+ }
+ catch(err)
+ {
+ p.fail(err);
+ throw err;
+ }
+ }
+ };
+
+ var base, testIntf;
+
+ var defaultHost = communicator.getProperties().getPropertyWithDefault("Ice.Default.Host");
+
+ return Promise.try(
+ function()
+ {
+ out.write("testing proxy endpoint information... ");
+ var ref = "test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" +
+ "opaque -e 1.8 -t 100 -v ABCD";
+ var p1 = communicator.stringToProxy(ref);
+
+ var endps = p1.ice_getEndpoints();
+
+ var ipEndpoint = endps[0].getInfo();
+ test(ipEndpoint.host == "tcphost");
+ test(ipEndpoint.port == 10000);
+ test(ipEndpoint.timeout == 1200);
+ test(ipEndpoint.sourceAddress == "10.10.10.10");
+ test(ipEndpoint.compress);
+ test(!ipEndpoint.datagram());
+ test(ipEndpoint.type() == Ice.TCPEndpointType && !ipEndpoint.secure() ||
+ ipEndpoint.type() == Ice.WSEndpointType && !ipEndpoint.secure() ||
+ ipEndpoint.type() == Ice.WSSEndpointType && ipEndpoint.secure());
+
+ var opaqueEndpoint = endps[1].getInfo();
+ test(opaqueEndpoint.rawEncoding.equals(new Ice.EncodingVersion(1, 8)));
+ }
+ ).then(
+ function()
+ {
+ out.writeLine("ok");
+
+ out.write("testing connection endpoint information... ");
+ base = communicator.stringToProxy("test:default -p 12010");
+ testIntf = Test.TestIntfPrx.uncheckedCast(base);
+
+ var ipinfo;
+ return base.ice_getConnection().then(
+ function(conn)
+ {
+ ipinfo = conn.getEndpoint().getInfo();
+ test(ipinfo.port == 12010);
+ test(!ipinfo.compress);
+ test(ipinfo.host == defaultHost);
+
+ return testIntf.getEndpointInfoAsContext();
+ }
+ ).then(
+ function(ctx)
+ {
+ test(ctx.get("host") == ipinfo.host);
+ test(ctx.get("compress") == "false");
+ var port = parseInt(ctx.get("port"));
+ test(port > 0);
+ }
+ );
+ }
+ ).then(
+ function()
+ {
+ out.writeLine("ok");
+
+ out.write("testing connection information... ");
+
+ var info, ctx, connection;
+ return base.ice_getConnection().then(
+ function(conn)
+ {
+ connection = conn;
+ connection.setBufferSize(1024, 2048);
+
+ info = connection.getInfo();
+ test(!info.incoming);
+ test(info.adapterName.length == 0);
+ if(connection.type() != "ws" && connection.type() != "wss")
+ {
+ test(info.localPort > 0);
+ }
+ test(info.remotePort == 12010);
+ if(defaultHost == "127.0.0.1")
+ {
+ test(info.remoteAddress == defaultHost);
+ if(connection.type() != "ws" && connection.type() != "wss")
+ {
+ test(info.localAddress == defaultHost);
+ }
+ }
+ //test(info.rcvSize >= 1024);
+ test(info.sndSize >= 2048);
+
+ return testIntf.getConnectionInfoAsContext();
+ }
+ ).then(
+ function(c)
+ {
+ ctx = c;
+
+ test(ctx.get("incoming") == "true");
+ test(ctx.get("adapterName") == "TestAdapter");
+ if(connection.type() != "ws" && connection.type() != "wss")
+ {
+ test(ctx.get("remoteAddress") == info.localAddress);
+ test(ctx.get("localAddress") == info.remoteAddress);
+ test(parseInt(ctx.get("remotePort")) == info.localPort);
+ test(parseInt(ctx.get("localPort")) == info.remotePort);
+ }
+
+ if(connection.type() == "ws" || connection.type() == "wss")
+ {
+ //test(info.headers["Upgrade"] == "websocket");
+ //test(info.headers.get("Connection") == "Upgrade");
+ //test(info.headers.get("Sec-WebSocket-Protocol") == "ice.zeroc.com");
+ //test(info.headers.get("Sec-WebSocket-Accept") != null);
+
+ test(ctx.get("ws.Upgrade") == "websocket");
+ test(ctx.get("ws.Connection") == "Upgrade");
+ test(ctx.get("ws.Sec-WebSocket-Protocol") == "ice.zeroc.com");
+ test(ctx.get("ws.Sec-WebSocket-Version") == "13");
+ test(ctx.get("ws.Sec-WebSocket-Key") != null);
+ }
+ }
+ );
+ }
+ ).then(
+ function()
+ {
+ out.writeLine("ok");
+
+ return testIntf.shutdown();
+ }
+ );
+ }
+
+ var run = function(out, id)
+ {
+ var communicator = Ice.initialize(id);
+ return Promise.try(
+ function()
+ {
+ return allTests(communicator, out);
+ }
+ ).finally(
+ function()
+ {
+ communicator.destroy();
+ }
+ );
+ };
+ exports.__test__ = run;
+ exports.__runServer__ = true;
+}
+(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
+ typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : window.Ice.__require,
+ typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : window));
diff --git a/js/test/Ice/info/Test.ice b/js/test/Ice/info/Test.ice
new file mode 100644
index 00000000000..a71990ba3db
--- /dev/null
+++ b/js/test/Ice/info/Test.ice
@@ -0,0 +1,26 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Ice/Current.ice>
+
+module Test
+{
+
+interface TestIntf
+{
+ void shutdown();
+
+ Ice::Context getEndpointInfoAsContext();
+
+ Ice::Context getConnectionInfoAsContext();
+};
+
+};
diff --git a/js/test/Ice/info/run.js b/js/test/Ice/info/run.js
new file mode 100644
index 00000000000..7c2ffdcdd61
--- /dev/null
+++ b/js/test/Ice/info/run.js
@@ -0,0 +1,10 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+require("../../Common/Common").run(module);
diff --git a/js/test/Ice/info/run.py b/js/test/Ice/info/run.py
new file mode 100755
index 00000000000..1c21e886744
--- /dev/null
+++ b/js/test/Ice/info/run.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 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.
+#
+# **********************************************************************
+
+import os, sys
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()