1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2007 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 Ice, Test, Twoways, TwowaysAMI
def test(b):
if not b:
raise RuntimeError('test assertion failed')
def allTests(communicator):
print "testing stringToProxy...",
ref = "test:default -p 12010 -t 10000"
base = communicator.stringToProxy(ref)
test(base)
print "ok"
print "testing ice_getCommunicator...",
test(base.ice_getCommunicator() == communicator)
print "ok"
print "testing proxy methods... ",
test(communicator.identityToString(base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()) == "other");
test(base.ice_facet("facet").ice_getFacet() == "facet");
test(base.ice_adapterId("id").ice_getAdapterId() == "id");
test(base.ice_twoway().ice_isTwoway());
test(base.ice_oneway().ice_isOneway());
test(base.ice_batchOneway().ice_isBatchOneway());
test(base.ice_datagram().ice_isDatagram());
test(base.ice_batchDatagram().ice_isBatchDatagram());
test(base.ice_secure(True).ice_isSecure());
test(not base.ice_secure(False).ice_isSecure());
print "ok"
print "testing checked cast...",
cl = Test.MyClassPrx.checkedCast(base)
test(cl)
derived = Test.MyDerivedClassPrx.checkedCast(cl)
test(derived)
test(cl == base)
test(derived == base)
test(cl == derived)
loc = Ice.LocatorPrx.checkedCast(base)
test(loc == None)
#
# Upcasting
#
cl2 = Test.MyClassPrx.checkedCast(derived)
obj = Ice.ObjectPrx.checkedCast(derived)
test(cl2)
test(obj)
test(cl2 == obj)
test(cl2 == derived)
print "ok"
print "testing checked cast with context...",
cref = "context:default -p 12010 -t 10000"
cbase = communicator.stringToProxy(cref)
test(cbase != None)
tccp = Test.TestCheckedCastPrx.checkedCast(cbase)
c = tccp.getContext()
test(c == None or len(c) == 0)
c = { }
c["one"] = "hello"
c["two"] = "world"
tccp = Test.TestCheckedCastPrx.checkedCast(cbase, c)
c2 = tccp.getContext()
test(c == c2)
print "ok"
print "testing twoway operations...",
Twoways.twoways(communicator, cl)
Twoways.twoways(communicator, derived)
derived.opDerived()
print "ok"
print "testing twoway operations with AMI...",
TwowaysAMI.twowaysAMI(communicator, cl)
TwowaysAMI.twowaysAMI(communicator, derived)
print "ok"
return cl
|