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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2006 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, Ice, Test
def test(b):
if not b:
raise RuntimeError('test assertion failed')
def testExceptions(obj, collocated):
try:
obj.requestFailedException()
test(false)
except Ice.ObjectNotExistException, ex:
if not collocated:
test(ex.id == obj.ice_getIdentity())
test(ex.facet == obj.ice_getFacet())
test(ex.operation == "requestFailedException")
try:
obj.unknownUserException()
test(false)
except Ice.UnknownUserException, ex:
test(ex.unknown == "reason")
pass
try:
obj.unknownLocalException()
test(false)
except Ice.UnknownLocalException, ex:
test(ex.unknown == "reason")
pass
try:
obj.unknownException()
test(false)
except Ice.UnknownException, ex:
test(ex.unknown == "reason")
pass
try:
obj.userException()
test(false)
except Ice.UnknownUserException, ex:
#print ex.unknown
test(not collocated)
test(ex.unknown.find("Test.TestIntfUserException") >= 0)
except Test.TestIntfUserException:
test(collocated)
try:
obj.localException()
test(false)
except Ice.UnknownLocalException, ex:
#print ex.unknown
test(not collocated)
test(ex.unknown.find("Ice.SocketException") >= 0)
except SocketException:
test(collocated)
try:
obj.pythonException()
test(false)
except Ice.UnknownException, ex:
#print ex.unknown
test(not collocated)
test(ex.unknown.find("RuntimeError: message") >= 0)
except RuntimeError:
test(collocated)
def allTests(communicator, collocated):
print "testing stringToProxy... ",
sys.stdout.flush()
base = communicator.stringToProxy("asm:default -p 12010 -t 10000")
test(base)
print "ok"
print "testing checked cast... ",
sys.stdout.flush()
obj = Test.TestIntfPrx.checkedCast(base)
test(obj)
test(obj == base)
print "ok"
print "testing servant locator...",
sys.stdout.flush()
base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
try:
Test.TestIntfPrx.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010 -t 10000"))
except Ice.ObjectNotExistException:
pass
print "ok"
print "testing default servant locator...",
sys.stdout.flush()
base = communicator.stringToProxy("anothercat/locate:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
base = communicator.stringToProxy("locate:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
try:
Test.TestIntfPrx.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010 -t 10000"))
except Ice.ObjectNotExistException:
pass
try:
Test.TestIntfPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000"))
except Ice.ObjectNotExistException:
pass
print "ok"
print "testing locate exceptions... ",
sys.stdout.flush()
base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
testExceptions(obj, collocated)
print "ok"
print "testing finished exceptions... ",
sys.stdout.flush()
base = communicator.stringToProxy("category/finished:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
testExceptions(obj, collocated)
print "ok"
return obj
|