summaryrefslogtreecommitdiff
path: root/python/test
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-06-19 23:19:33 +0200
committerJose <jose@zeroc.com>2018-06-19 23:19:33 +0200
commitd0c97b66212a5f001ff9738dfc881fd1bbc666ca (patch)
tree8c2ef250bf35ce217bac6e713edbbb999c19bd1a /python/test
parentdefine test callbacks only with C++98 builds (diff)
downloadice-d0c97b66212a5f001ff9738dfc881fd1bbc666ca.tar.bz2
ice-d0c97b66212a5f001ff9738dfc881fd1bbc666ca.tar.xz
ice-d0c97b66212a5f001ff9738dfc881fd1bbc666ca.zip
Port Ice/scope test to scripting languages
Diffstat (limited to 'python/test')
-rw-r--r--python/test/Ice/scope/AllTests.py139
-rwxr-xr-xpython/test/Ice/scope/Client.py28
-rwxr-xr-xpython/test/Ice/scope/Server.py108
-rw-r--r--python/test/Ice/scope/Test.ice115
4 files changed, 390 insertions, 0 deletions
diff --git a/python/test/Ice/scope/AllTests.py b/python/test/Ice/scope/AllTests.py
new file mode 100644
index 00000000000..2eef2c349a3
--- /dev/null
+++ b/python/test/Ice/scope/AllTests.py
@@ -0,0 +1,139 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2018 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 sys, string, re, traceback, Ice, Test
+
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+
+def allTests(communicator):
+ sys.stdout.write("test same Slice type name in different scopes... ")
+ sys.stdout.flush()
+ i1 = Test.IPrx.checkedCast(communicator.stringToProxy("i1:default -p 12010"))
+
+ s1 = Test.S(0)
+
+ s2, s3 = i1.opS(s1)
+
+ test(s2 == s1)
+ test(s3 == s1)
+
+ sseq1 = [s1]
+
+ sseq2, sseq3 = i1.opSSeq(sseq1)
+
+ test(sseq2[0] == s1)
+ test(sseq3[0] == s1)
+
+ smap1 = {"a": s1}
+ smap2, smap3 = i1.opSMap(smap1)
+ test(smap2["a"] == s1)
+ test(smap3["a"] == s1)
+
+ c1 = Test.C(s1)
+
+ c2, c3 = i1.opC(c1)
+
+ test(c2.s == s1)
+ test(c3.s == s1)
+
+ cseq1 = [c1]
+ cseq2, cseq3 = i1.opCSeq(cseq1)
+
+ test(cseq2[0].s == s1)
+ test(cseq3[0].s == s1)
+
+ cmap1 = {"a": c1}
+ cmap2, cmap3 = i1.opCMap(cmap1)
+ test(cmap2["a"].s == s1)
+ test(cmap3["a"].s == s1)
+
+ i2 = Test.Inner.Inner2.IPrx.checkedCast(communicator.stringToProxy("i2:default -p 12010"))
+
+ s1 = Test.Inner.Inner2.S(0)
+
+ s2, s3 = i2.opS(s1)
+
+ test(s2 == s1)
+ test(s3 == s1)
+
+ sseq1 = [s1]
+
+ sseq2, sseq3 = i2.opSSeq(sseq1)
+
+ test(sseq2[0] == s1)
+ test(sseq3[0] == s1)
+
+ smap1 = {"a": s1}
+ smap2, smap3 = i2.opSMap(smap1)
+ test(smap2["a"] == s1)
+ test(smap3["a"] == s1)
+
+ c1 = Test.Inner.Inner2.C(s1)
+
+ c2, c3 = i2.opC(c1)
+
+ test(c2.s == s1)
+ test(c3.s == s1)
+
+ cseq1 = [c1]
+ cseq2, cseq3 = i2.opCSeq(cseq1)
+
+ test(cseq2[0].s == s1)
+ test(cseq3[0].s == s1)
+
+ cmap1 = {"a": c1}
+ cmap2, cmap3 = i2.opCMap(cmap1)
+ test(cmap2["a"].s == s1)
+ test(cmap3["a"].s == s1)
+
+ i3 = Test.Inner.IPrx.checkedCast(communicator.stringToProxy("i3:default -p 12010"))
+
+ s1 = Test.Inner.Inner2.S(0)
+
+ s2, s3 = i3.opS(s1)
+
+ test(s2 == s1)
+ test(s3 == s1)
+
+ sseq1 = [s1]
+
+ sseq2, sseq3 = i3.opSSeq(sseq1)
+
+ test(sseq2[0] == s1)
+ test(sseq3[0] == s1)
+
+ smap1 = {"a": s1}
+ smap2, smap3 = i3.opSMap(smap1)
+ test(smap2["a"] == s1)
+ test(smap3["a"] == s1)
+
+ c1 = Test.Inner.Inner2.C(s1)
+
+ c2, c3 = i3.opC(c1)
+
+ test(c2.s == s1)
+ test(c3.s == s1)
+
+ cseq1 = [c1]
+ cseq2, cseq3 = i3.opCSeq(cseq1)
+
+ test(cseq2[0].s == s1)
+ test(cseq3[0].s == s1)
+
+ cmap1 = {"a": c1}
+ cmap2, cmap3 = i3.opCMap(cmap1)
+ test(cmap2["a"].s == s1)
+ test(cmap3["a"].s == s1)
+
+ i1.shutdown()
+ print("ok")
diff --git a/python/test/Ice/scope/Client.py b/python/test/Ice/scope/Client.py
new file mode 100755
index 00000000000..c09de20efc6
--- /dev/null
+++ b/python/test/Ice/scope/Client.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2018 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, traceback
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test, AllTests
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ with Ice.initialize(sys.argv) as communicator:
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/scope/Server.py b/python/test/Ice/scope/Server.py
new file mode 100755
index 00000000000..895d26cf0bf
--- /dev/null
+++ b/python/test/Ice/scope/Server.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2018 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, traceback
+
+import Ice
+Ice.loadSlice('Test.ice')
+import Test
+
+
+class I1(Test.I):
+
+ def opS(self, s1, current=None):
+ return (s1, s1)
+
+ def opSSeq(self, sseq1, current=None):
+ return (sseq1, sseq1)
+
+ def opSMap(self, smap1, current=None):
+ return (smap1, smap1)
+
+ def opC(self, c1, current=None):
+ return (c1, c1)
+
+ def opCSeq(self, cseq1, current=None):
+ return (cseq1, cseq1)
+
+ def opCMap(self, cmap1, current=None):
+ return (cmap1, cmap1)
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+
+class I2(Test.Inner.Inner2.I):
+
+ def opS(self, s1, current=None):
+ return (s1, s1)
+
+ def opSSeq(self, sseq1, current=None):
+ return (sseq1, sseq1)
+
+ def opSMap(self, smap1, current=None):
+ return (smap1, smap1)
+
+ def opC(self, c1, current=None):
+ return (c1, c1)
+
+ def opCSeq(self, cseq1, current=None):
+ return (cseq1, cseq1)
+
+ def opCMap(self, cmap1, current=None):
+ return (cmap1, cmap1)
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+
+class I3(Test.Inner.I):
+
+ def opS(self, s1, current=None):
+ return (s1, s1)
+
+ def opSSeq(self, sseq1, current=None):
+ return (sseq1, sseq1)
+
+ def opSMap(self, smap1, current=None):
+ return (smap1, smap1)
+
+ def opC(self, c1, current=None):
+ return (c1, c1)
+
+ def opCSeq(self, cseq1, current=None):
+ return (cseq1, cseq1)
+
+ def opCMap(self, cmap1, current=None):
+ return (cmap1, cmap1)
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter.add(I1(), Ice.stringToIdentity("i1"))
+ adapter.add(I2(), Ice.stringToIdentity("i2"))
+ adapter.add(I3(), Ice.stringToIdentity("i3"))
+ adapter.activate()
+ communicator.waitForShutdown()
+ return True
+
+
+try:
+ with Ice.initialize(sys.argv) as communicator:
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/python/test/Ice/scope/Test.ice b/python/test/Ice/scope/Test.ice
new file mode 100644
index 00000000000..fbd505e2ee4
--- /dev/null
+++ b/python/test/Ice/scope/Test.ice
@@ -0,0 +1,115 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2018 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
+
+module Test
+{
+ struct S
+ {
+ int v;
+ }
+
+ dictionary<string, S> SMap;
+ sequence<S> SSeq;
+
+ class C
+ {
+ S s;
+ }
+
+ dictionary<string, C> CMap;
+ sequence<C> CSeq;
+
+ interface I
+ {
+ S opS(S s1, out S s2);
+ SSeq opSSeq(SSeq s1, out SSeq s2);
+ SMap opSMap(SMap s1, out SMap s2);
+
+ C opC(C c1, out C c2);
+ CSeq opCSeq(CSeq s1, out CSeq s2);
+ CMap opCMap(CMap c1, out CMap c2);
+
+ void shutdown();
+ }
+
+ dictionary<string, I*> IMap;
+ sequence<I*> ISeq;
+
+ module Inner
+ {
+ struct S
+ {
+ int v;
+ }
+
+ module Inner2
+ {
+ struct S
+ {
+ int v;
+ }
+
+ dictionary<string, S> SMap;
+ sequence<S> SSeq;
+
+ class C
+ {
+ S s;
+ }
+
+ dictionary<string, C> CMap;
+ sequence<C> CSeq;
+
+ interface I
+ {
+ S opS(S s1, out S s2);
+ SSeq opSSeq(SSeq s1, out SSeq s2);
+ SMap opSMap(SMap s1, out SMap s2);
+
+ C opC(C c1, out C c2);
+ CSeq opCSeq(CSeq c1, out CSeq c2);
+ CMap opCMap(CMap c1, out CMap c2);
+
+ void shutdown();
+ }
+
+ dictionary<string, I*> IMap;
+ sequence<I*> ISeq;
+ }
+
+ class C
+ {
+ S s;
+ }
+
+ sequence<Inner2::S> SSeq;
+ dictionary<string, Inner2::S> SMap;
+
+ dictionary<string, Inner2::C> CMap;
+ sequence<Inner2::C> CSeq;
+
+ interface I
+ {
+ Inner2::S opS(Inner2::S s1, out Inner2::S s2);
+ Inner2::SSeq opSSeq(Inner2::SSeq s1, out Inner2::SSeq s2);
+ Inner2::SMap opSMap(Inner2::SMap s1, out Inner2::SMap s2);
+
+ Inner2::C opC(Inner2::C c1, out Inner2::C c2);
+ Inner2::CSeq opCSeq(Inner2::CSeq c1, out Inner2::CSeq c2);
+ Inner2::CMap opCMap(Inner2::CMap c1, out Inner2::CMap c2);
+
+ void shutdown();
+ }
+
+ dictionary<string, I*> IMap;
+ sequence<I*> ISeq;
+ }
+}