summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-09-11 14:07:13 +0000
committerMark Spruiell <mes@zeroc.com>2004-09-11 14:07:13 +0000
commit25f819cc504929b009965d33bda2b234a6ba4b5c (patch)
tree0921ba62bee6ad788b0bfc74b213c51fb818c0af
parentenabling AMI (diff)
downloadice-25f819cc504929b009965d33bda2b234a6ba4b5c.tar.bz2
ice-25f819cc504929b009965d33bda2b234a6ba4b5c.tar.xz
ice-25f819cc504929b009965d33bda2b234a6ba4b5c.zip
adding AMI tests
-rw-r--r--py/test/Ice/exceptions/AllTests.py340
1 files changed, 338 insertions, 2 deletions
diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py
index bec4c2461b4..261167ec4bd 100644
--- a/py/test/Ice/exceptions/AllTests.py
+++ b/py/test/Ice/exceptions/AllTests.py
@@ -47,7 +47,7 @@ class CallbackBase:
while not self._called:
self._cond.wait(5.0)
if self._called:
- self._called = false
+ self._called = False
return True;
else:
return False
@@ -56,10 +56,235 @@ class CallbackBase:
def called(self):
self._cond.acquire()
- _called = True
+ self._called = True
self._cond.notify()
self._cond.release()
+class AMI_Thrower_throwAasAI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.A, ex:
+ test(ex.aMem == 1)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwAasAObjectNotExistI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.ObjectNotExistException, ex:
+ id = Ice.stringToIdentity("does not exist")
+ test(ex.id == id)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwAasAFacetNotExistI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.FacetNotExistException, ex:
+ test(ex.facet == "no such facet")
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwAorDasAorDI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.A, ex:
+ test(ex.aMem == 1)
+ except Test.D, ex:
+ test(ex.dMem == -1)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwBasAI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.B, ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwCasAI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.C, ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwBasBI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.B, ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwCasBI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.C, ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwCasCI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.C, ex:
+ test(ex.aMem == 1)
+ test(ex.bMem == 2)
+ test(ex.cMem == 3)
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwModAI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Test.Mod.A, ex:
+ test(ex.aMem == 1)
+ test(ex.a2Mem == 2)
+ except Ice.OperationNotExistException:
+ #
+ # This operation is not supported in Java.
+ #
+ pass
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwUndeclaredAI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownUserException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwUndeclaredBI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownUserException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwUndeclaredCI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownUserException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwLocalExceptionI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownLocalException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+class AMI_Thrower_throwNonIceExceptionI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.UnknownException:
+ pass
+ except:
+ test(False)
+ self.called()
+
+class AMI_WrongOperation_noSuchOperationI(CallbackBase):
+ def ice_response(self):
+ test(False)
+
+ def ice_exception(self, ex):
+ try:
+ raise ex
+ except Ice.OperationNotExistException, ex:
+ test(ex.operation == "noSuchOperation")
+ except:
+ test(False)
+ self.called()
+
def allTests(communicator):
print "testing servant registration exceptions... ",
adapter = communicator.createObjectAdapter("TestAdapter1")
@@ -391,4 +616,115 @@ def allTests(communicator):
print "ok"
+ print "catching exact types with AMI... ",
+
+ cb = AMI_Thrower_throwAasAI()
+ thrower.throwAasA_async(cb, 1)
+ test(cb.check())
+ # Let's check if we can reuse the same callback object for another call.
+ thrower.throwAasA_async(cb, 1)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwAorDasAorDI()
+ thrower.throwAorDasAorD_async(cb, 1)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwAorDasAorDI()
+ thrower.throwAorDasAorD_async(cb, -1)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwBasBI()
+ thrower.throwBasB_async(cb, 1, 2)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwCasCI()
+ thrower.throwCasC_async(cb, 1, 2, 3)
+ test(cb.check())
+ # Let's check if we can reuse the same callback object for another call.
+ thrower.throwCasC_async(cb, 1, 2, 3)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwModAI()
+ thrower.throwModA_async(cb, 1, 2)
+ test(cb.check())
+
+ print "ok"
+
+ print "catching derived types... ",
+
+ cb = AMI_Thrower_throwBasAI()
+ thrower.throwBasA_async(cb, 1, 2)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwCasAI()
+ thrower.throwCasA_async(cb, 1, 2, 3)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwCasBI()
+ thrower.throwCasB_async(cb, 1, 2, 3)
+ test(cb.check())
+
+ print "ok"
+
+ if thrower.supportsUndeclaredExceptions():
+ print "catching unknown user exception with AMI... ",
+
+ cb = AMI_Thrower_throwUndeclaredAI()
+ thrower.throwUndeclaredA_async(cb, 1)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwUndeclaredBI()
+ thrower.throwUndeclaredB_async(cb, 1, 2)
+ test(cb.check())
+
+ cb = AMI_Thrower_throwUndeclaredCI()
+ thrower.throwUndeclaredC_async(cb, 1, 2, 3)
+ test(cb.check())
+
+ print "ok"
+
+ print "catching object not exist exception with AMI... ",
+
+ id = Ice.stringToIdentity("does not exist")
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_newIdentity(id))
+ cb = AMI_Thrower_throwAasAObjectNotExistI()
+ thrower2.throwAasA_async(cb, 1)
+ test(cb.check())
+
+ print "ok"
+
+ print "catching facet not exist exception with AMI... ",
+
+ thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet")
+ cb = AMI_Thrower_throwAasAFacetNotExistI()
+ thrower2.throwAasA_async(cb, 1)
+ test(cb.check())
+
+ print "ok"
+
+ print "catching operation not exist exception with AMI... ",
+
+ cb = AMI_WrongOperation_noSuchOperationI()
+ thrower4 = Test.WrongOperationPrx.uncheckedCast(thrower)
+ thrower4.noSuchOperation_async(cb)
+ test(cb.check())
+
+ print "ok"
+
+ print "catching unknown local exception with AMI... ",
+
+ cb = AMI_Thrower_throwLocalExceptionI()
+ thrower.throwLocalException_async(cb)
+ test(cb.check())
+
+ print "ok"
+
+ print "catching unknown non-Ice exception with AMI... ",
+
+ cb = AMI_Thrower_throwNonIceExceptionI()
+ thrower.throwNonIceException_async(cb)
+ test(cb.check())
+
+ print "ok"
+
return thrower