diff options
Diffstat (limited to 'py/test')
-rw-r--r-- | py/test/Ice/slicing/exceptions/AllTests.py | 303 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/Client.py | 31 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/Server.py | 127 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/ServerPrivate.ice | 35 | ||||
-rw-r--r-- | py/test/Ice/slicing/exceptions/Test.ice | 54 | ||||
-rwxr-xr-x | py/test/Ice/slicing/exceptions/run.py | 29 |
6 files changed, 579 insertions, 0 deletions
diff --git a/py/test/Ice/slicing/exceptions/AllTests.py b/py/test/Ice/slicing/exceptions/AllTests.py new file mode 100644 index 00000000000..696638a5dc7 --- /dev/null +++ b/py/test/Ice/slicing/exceptions/AllTests.py @@ -0,0 +1,303 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2004 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 Test, Ice, _Top, threading, sys + +def test(b): + if not b: + raise RuntimeError('test assertion failed') + +class CallbackBase: + def __init__(self): + self._called = False + self._cond = threading.Condition() + + def check(self): + self._cond.acquire() + try: + while not self._called: + self._cond.wait(5.0) + if self._called: + self._called = False + return True; + else: + return False + finally: + self._cond.release() + + def called(self): + self._cond.acquire() + _called = True + self._cond.notify() + self._cond.release() + +def allTests(communicator): + obj = communicator.stringToProxy("Test:default -p 12345") + t = _Top.TestPrx.checkedCast(obj) + + print "base... ", + gotException = False + try: + t.baseAsBase() + except _Top.Base, b: + test(b.b == "Base.b") + test(b.ice_id() == "::Base") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "base (AMI)... ", + #cb = new AMI_Test_baseAsBaseI + #t.baseAsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of unknown derived... ", + gotException = False + try: + t.unknownDerivedAsBase() + except _Top.Base, b: + test(b.b == "UnknownDerived.b") + test(b.ice_id() == "::Base") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of unknown derived (AMI)... ", + #cb = AMI_Test_unknownDerivedAsBaseI() + #t.unknownDerivedAsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "non-slicing of known derived as base... ", + gotException = False + try: + t.knownDerivedAsBase() + except _Top.KnownDerived, k: + test(k.b == "KnownDerived.b") + test(k.kd == "KnownDerived.kd") + test(k.ice_id() == "::KnownDerived") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "non-slicing of known derived as base (AMI)... ", + #cb = AMI_Test_knownDerivedAsBaseI() + #t.knownDerivedAsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "non-slicing of known derived as derived... ", + gotException = False + try: + t.knownDerivedAsKnownDerived() + except _Top.KnownDerived, k: + test(k.b == "KnownDerived.b") + test(k.kd == "KnownDerived.kd") + test(k.ice_id() == "::KnownDerived") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "non-slicing of known derived as derived (AMI)... ", + #cb = AMI_Test_knownDerivedAsKnownDerivedI() + #t.knownDerivedAsKnownDerived_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of unknown intermediate as base... ", + gotException = False + try: + t.unknownIntermediateAsBase() + except _Top.Base, b: + test(b.b == "UnknownIntermediate.b") + test(b.ice_id() == "::Base") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of unknown intermediate as base (AMI)... ", + #cb = AMI_Test_unknownIntermediateAsBaseI() + #t.unknownIntermediateAsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of known intermediate as base... ", + gotException = False + try: + t.knownIntermediateAsBase() + except _Top.KnownIntermediate, ki: + test(ki.b == "KnownIntermediate.b") + test(ki.ki == "KnownIntermediate.ki") + test(ki.ice_id() == "::KnownIntermediate") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of known intermediate as base (AMI)... ", + #cb = AMI_Test_knownIntermediateAsBaseI() + #t.knownIntermediateAsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of known most derived as base... ", + gotException = False + try: + t.knownMostDerivedAsBase() + except _Top.KnownMostDerived, kmd: + test(kmd.b == "KnownMostDerived.b") + test(kmd.ki == "KnownMostDerived.ki") + test(kmd.kmd == "KnownMostDerived.kmd") + test(kmd.ice_id() == "::KnownMostDerived") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of known most derived as base (AMI)... ", + #cb = AMI_Test_knownMostDerivedAsBaseI() + #t.knownMostDerivedAsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "non-slicing of known intermediate as intermediate... ", + gotException = False + try: + t.knownIntermediateAsKnownIntermediate() + except _Top.KnownIntermediate, ki: + test(ki.b == "KnownIntermediate.b") + test(ki.ki == "KnownIntermediate.ki") + test(ki.ice_id() == "::KnownIntermediate") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "non-slicing of known intermediate as intermediate (AMI)... ", + #cb = AMI_Test_knownIntermediateAsKnownIntermediateI() + #t.knownIntermediateAsKnownIntermediate_async(cb) + #test(cb.check()) + #print "ok" + + print "non-slicing of known most derived exception as intermediate... ", + gotException = False + try: + t.knownMostDerivedAsKnownIntermediate() + except _Top.KnownMostDerived, kmd: + test(kmd.b == "KnownMostDerived.b") + test(kmd.ki == "KnownMostDerived.ki") + test(kmd.kmd == "KnownMostDerived.kmd") + test(kmd.ice_id() == "::KnownMostDerived") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "non-slicing of known most derived as intermediate (AMI)... ", + #cb = AMI_Test_knownMostDerivedAsKnownIntermediateI() + #t.knownMostDerivedAsKnownIntermediate_async(cb) + #test(cb.check()) + #print "ok" + + print "non-slicing of known most derived as most derived... ", + gotException = False + try: + t.knownMostDerivedAsKnownMostDerived() + except _Top.KnownMostDerived, kmd: + test(kmd.b == "KnownMostDerived.b") + test(kmd.ki == "KnownMostDerived.ki") + test(kmd.kmd == "KnownMostDerived.kmd") + test(kmd.ice_id() == "::KnownMostDerived") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "non-slicing of known most derived as most derived (AMI)... ", + #cb = AMI_Test_knownMostDerivedAsKnownMostDerivedI() + #t.knownMostDerivedAsKnownMostDerived_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of unknown most derived, known intermediate as base... ", + gotException = False + try: + t.unknownMostDerived1AsBase() + except _Top.KnownIntermediate, ki: + test(ki.b == "UnknownMostDerived1.b") + test(ki.ki == "UnknownMostDerived1.ki") + test(ki.ice_id() == "::KnownIntermediate") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of unknown most derived, known intermediate as base (AMI)... ", + #cb = AMI_Test_unknownMostDerived1AsBaseI() + #t.unknownMostDerived1AsBase_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of unknown most derived, known intermediate as intermediate... ", + gotException = False + try: + t.unknownMostDerived1AsKnownIntermediate() + except _Top.KnownIntermediate, ki: + test(ki.b == "UnknownMostDerived1.b") + test(ki.ki == "UnknownMostDerived1.ki") + test(ki.ice_id() == "::KnownIntermediate") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of unknown most derived, known intermediate as intermediate (AMI)... ", + #cb = AMI_Test_unknownMostDerived1AsKnownIntermediateI() + #t.unknownMostDerived1AsKnownIntermediate_async(cb) + #test(cb.check()) + #print "ok" + + print "slicing of unknown most derived, unknown intermediate as base... ", + gotException = False + try: + t.unknownMostDerived2AsBase() + except _Top.Base, b: + test(b.b == "UnknownMostDerived2.b") + test(b.ice_id() == "::Base") + gotException = True + except: + test(False) + test(gotException) + print "ok" + + #print "slicing of unknown most derived, unknown intermediate as base (AMI)... ", + #cb = AMI_Test_unknownMostDerived2AsBaseI() + #t.unknownMostDerived2AsBase_async(cb) + #test(cb.check()) + #print "ok" + + return t diff --git a/py/test/Ice/slicing/exceptions/Client.py b/py/test/Ice/slicing/exceptions/Client.py new file mode 100644 index 00000000000..84df22c79fd --- /dev/null +++ b/py/test/Ice/slicing/exceptions/Client.py @@ -0,0 +1,31 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2004 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, AllTests + +def run(args, communicator): + Test = AllTests.allTests(communicator) + Test.shutdown() + return True + +try: + communicator = Ice.initialize(sys.argv) + status = run(sys.argv, communicator) +except Ice.Exception, ex: + print ex + status = False + +if communicator: + try: + communicator.destroy() + except Ice.Exception, ex: + print ex + status = False + +sys.exit(not status) diff --git a/py/test/Ice/slicing/exceptions/Server.py b/py/test/Ice/slicing/exceptions/Server.py new file mode 100644 index 00000000000..3d372a17b63 --- /dev/null +++ b/py/test/Ice/slicing/exceptions/Server.py @@ -0,0 +1,127 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2004 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, ServerPrivate, _Top + +class TestI(_Top.Test): + def __init__(self, adapter): + self._adapter = adapter + + def shutdown(self, current=None): + self._adapter.getCommunicator().shutdown() + + def baseAsBase(self, current=None): + b = _Top.Base() + b.b = "Base.b" + raise b + + def unknownDerivedAsBase(self, current=None): + d = _Top.UnknownDerived() + d.b = "UnknownDerived.b" + d.ud = "UnknownDerived.ud" + raise d + + def knownDerivedAsBase(self, current=None): + d = _Top.KnownDerived() + d.b = "KnownDerived.b" + d.kd = "KnownDerived.kd" + raise d + + def knownDerivedAsKnownDerived(self, current=None): + d = _Top.KnownDerived() + d.b = "KnownDerived.b" + d.kd = "KnownDerived.kd" + raise d + + def unknownIntermediateAsBase(self, current=None): + ui = _Top.UnknownIntermediate() + ui.b = "UnknownIntermediate.b" + ui.ui = "UnknownIntermediate.ui" + raise ui + + def knownIntermediateAsBase(self, current=None): + ki = _Top.KnownIntermediate() + ki.b = "KnownIntermediate.b" + ki.ki = "KnownIntermediate.ki" + raise ki + + def knownMostDerivedAsBase(self, current=None): + kmd = _Top.KnownMostDerived() + kmd.b = "KnownMostDerived.b" + kmd.ki = "KnownMostDerived.ki" + kmd.kmd = "KnownMostDerived.kmd" + raise kmd + + def knownIntermediateAsKnownIntermediate(self, current=None): + ki = _Top.KnownIntermediate() + ki.b = "KnownIntermediate.b" + ki.ki = "KnownIntermediate.ki" + raise ki + + def knownMostDerivedAsKnownIntermediate(self, current=None): + kmd = _Top.KnownMostDerived() + kmd.b = "KnownMostDerived.b" + kmd.ki = "KnownMostDerived.ki" + kmd.kmd = "KnownMostDerived.kmd" + raise kmd + + def knownMostDerivedAsKnownMostDerived(self, current=None): + kmd = _Top.KnownMostDerived() + kmd.b = "KnownMostDerived.b" + kmd.ki = "KnownMostDerived.ki" + kmd.kmd = "KnownMostDerived.kmd" + raise kmd + + def unknownMostDerived1AsBase(self, current=None): + umd1 = _Top.UnknownMostDerived1() + umd1.b = "UnknownMostDerived1.b" + umd1.ki = "UnknownMostDerived1.ki" + umd1.umd1 = "UnknownMostDerived1.umd1" + raise umd1 + + def unknownMostDerived1AsKnownIntermediate(self, current=None): + umd1 = _Top.UnknownMostDerived1() + umd1.b = "UnknownMostDerived1.b" + umd1.ki = "UnknownMostDerived1.ki" + umd1.umd1 = "UnknownMostDerived1.umd1" + raise umd1 + + def unknownMostDerived2AsBase(self, current=None): + umd2 = _Top.UnknownMostDerived2() + umd2.b = "UnknownMostDerived2.b" + umd2.ui = "UnknownMostDerived2.ui" + umd2.umd2 = "UnknownMostDerived2.umd2" + raise umd2 + +def run(args, communicator): + properties = communicator.getProperties() + properties.setProperty("Ice.Warn.Dispatch", "0") + properties.setProperty("TestAdapter.Endpoints", "default -p 12345 -t 10000") + adapter = communicator.createObjectAdapter("TestAdapter") + object = TestI(adapter) + adapter.add(object, Ice.stringToIdentity("Test")) + adapter.activate() + communicator.waitForShutdown() + return True + +try: + communicator = Ice.initialize(sys.argv) + status = run(sys.argv, communicator) +except Ice.Exception, ex: + print ex + status = False + +if communicator: + try: + communicator.destroy() + except Ice.Exception, ex: + print ex + status = False + +sys.exit(not status) diff --git a/py/test/Ice/slicing/exceptions/ServerPrivate.ice b/py/test/Ice/slicing/exceptions/ServerPrivate.ice new file mode 100644 index 00000000000..7fb5f592869 --- /dev/null +++ b/py/test/Ice/slicing/exceptions/ServerPrivate.ice @@ -0,0 +1,35 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +#ifndef SERVERPRIVATE_ICE +#define SERVERPRIVATE_ICE + +#include <Test.ice> + +exception UnknownDerived extends Base +{ + string ud; +}; + +exception UnknownIntermediate extends Base +{ + string ui; +}; + +exception UnknownMostDerived1 extends KnownIntermediate +{ + string umd1; +}; + +exception UnknownMostDerived2 extends UnknownIntermediate +{ + string umd2; +}; + +#endif diff --git a/py/test/Ice/slicing/exceptions/Test.ice b/py/test/Ice/slicing/exceptions/Test.ice new file mode 100644 index 00000000000..cc3e8b3f85f --- /dev/null +++ b/py/test/Ice/slicing/exceptions/Test.ice @@ -0,0 +1,54 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +exception Base +{ + string b; +}; + +exception KnownDerived extends Base +{ + string kd; +}; + +exception KnownIntermediate extends Base +{ + string ki; +}; + +exception KnownMostDerived extends KnownIntermediate +{ + string kmd; +}; + +["ami"] interface Test +{ + void baseAsBase() throws Base; + void unknownDerivedAsBase() throws Base; + void knownDerivedAsBase() throws Base; + void knownDerivedAsKnownDerived() throws KnownDerived; + + void unknownIntermediateAsBase() throws Base; + void knownIntermediateAsBase() throws Base; + void knownMostDerivedAsBase() throws Base; + void knownIntermediateAsKnownIntermediate() throws KnownIntermediate; + void knownMostDerivedAsKnownIntermediate() throws KnownIntermediate; + void knownMostDerivedAsKnownMostDerived() throws KnownMostDerived; + + void unknownMostDerived1AsBase() throws Base; + void unknownMostDerived1AsKnownIntermediate() throws KnownIntermediate; + void unknownMostDerived2AsBase() throws Base; + + void shutdown(); +}; + +#endif diff --git a/py/test/Ice/slicing/exceptions/run.py b/py/test/Ice/slicing/exceptions/run.py new file mode 100755 index 00000000000..ec319f83697 --- /dev/null +++ b/py/test/Ice/slicing/exceptions/run.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2004 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 + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +name = os.path.join("Ice", "slicing", "exceptions") + +print "tests with regular server." +TestUtil.clientServerTest(name) +#print "tests with AMD server." +#TestUtil.clientServerTestWithOptionsAndNames(name, "", "", "serveramd", "client") +sys.exit(0) |