1 # **********************************************************************
3 # Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 # This copy of Ice is licensed to you under the terms described in the
6 # ICE_LICENSE file included in this distribution.
8 # **********************************************************************
14 raise RuntimeError('test assertion failed')
16 def testExceptions(obj
, collocated
):
19 obj
.requestFailedException()
21 except Ice
.ObjectNotExistException
, ex
:
23 test(ex
.id == obj
.ice_getIdentity())
24 test(ex
.facet
== obj
.ice_getFacet())
25 test(ex
.operation
== "requestFailedException")
30 obj
.unknownUserException()
32 except Ice
.UnknownUserException
, ex
:
33 test(ex
.unknown
== "reason")
38 obj
.unknownLocalException()
40 except Ice
.UnknownLocalException
, ex
:
41 test(ex
.unknown
== "reason")
46 obj
.unknownException()
48 except Ice
.UnknownException
, ex
:
49 test(ex
.unknown
== "reason")
55 except Ice
.UnknownUserException
, ex
:
56 test(ex
.unknown
.find("Test::TestIntfUserException") >= 0)
63 except Ice
.UnknownLocalException
, ex
:
65 test(ex
.unknown
.find("Ice.SocketException") >= 0)
66 except SocketException
:
74 except Ice
.UnknownException
, ex
:
75 test(ex
.unknown
.find("RuntimeError: message") >= 0)
80 obj
.unknownExceptionWithServantException()
82 except Ice
.UnknownException
, ex
:
83 test(ex
.unknown
== "reason")
88 obj
.impossibleException(False)
90 except Ice
.UnknownUserException
:
91 # Operation doesn't throw, but locate() and finished() throw TestIntfUserException.
97 obj
.impossibleException(True)
99 except Ice
.UnknownUserException
:
100 # Operation doesn't throw, but locate() and finished() throw TestIntfUserException.
106 obj
.intfUserException(False)
108 except Test
.TestImpossibleException
:
109 # Operation doesn't throw, but locate() and finished() throw TestImpossibleException.
115 obj
.intfUserException(True)
117 except Test
.TestImpossibleException
:
118 # Operation throws TestIntfUserException, but locate() and finished() throw TestImpossibleException.
123 def allTests(communicator
, collocated
):
124 print "testing stringToProxy...",
126 base
= communicator
.stringToProxy("asm:default -p 12010")
130 print "testing checked cast...",
132 obj
= Test
.TestIntfPrx
.checkedCast(base
)
137 print "testing ice_ids...",
140 obj
= communicator
.stringToProxy("category/locate:default -p 12010")
143 except Ice
.UnknownUserException
, ex
:
144 test(ex
.unknown
== "Test::TestIntfUserException")
149 obj
= communicator
.stringToProxy("category/finished:default -p 12010")
152 except Ice
.UnknownUserException
, ex
:
153 test(ex
.unknown
== "Test::TestIntfUserException")
158 print "testing servant locator...",
160 base
= communicator
.stringToProxy("category/locate:default -p 12010")
161 obj
= Test
.TestIntfPrx
.checkedCast(base
)
163 Test
.TestIntfPrx
.checkedCast(communicator
.stringToProxy("category/unknown:default -p 12010"))
164 except Ice
.ObjectNotExistException
:
168 print "testing default servant locator...",
170 base
= communicator
.stringToProxy("anothercat/locate:default -p 12010")
171 obj
= Test
.TestIntfPrx
.checkedCast(base
)
172 base
= communicator
.stringToProxy("locate:default -p 12010")
173 obj
= Test
.TestIntfPrx
.checkedCast(base
)
175 Test
.TestIntfPrx
.checkedCast(communicator
.stringToProxy("anothercat/unknown:default -p 12010"))
176 except Ice
.ObjectNotExistException
:
179 Test
.TestIntfPrx
.checkedCast(communicator
.stringToProxy("unknown:default -p 12010"))
180 except Ice
.ObjectNotExistException
:
184 print "testing locate exceptions...",
186 base
= communicator
.stringToProxy("category/locate:default -p 12010")
187 obj
= Test
.TestIntfPrx
.checkedCast(base
)
188 testExceptions(obj
, collocated
)
191 print "testing finished exceptions...",
193 base
= communicator
.stringToProxy("category/finished:default -p 12010")
194 obj
= Test
.TestIntfPrx
.checkedCast(base
)
195 testExceptions(obj
, collocated
)
198 print "testing servant locator removal...",
200 base
= communicator
.stringToProxy("test/activation:default -p 12010")
201 activation
= Test
.TestActivationPrx
.checkedCast(base
)
202 activation
.activateServantLocator(False)
206 except Ice
.ObjectNotExistException
:
210 print "testing servant locator addition...",
212 activation
.activateServantLocator(True)