diff options
author | Michi Henning <michi@zeroc.com> | 2004-02-24 07:09:29 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-02-24 07:09:29 +0000 |
commit | 0802f5204cd7a50007b97e71aa8b58bfe9d03c95 (patch) | |
tree | a624d91c4848c2f5296a868f47bdd6bea161a881 /java/test/Ice/slicing/exceptions/csrc/AllTests.java | |
parent | *** empty log message *** (diff) | |
download | ice-0802f5204cd7a50007b97e71aa8b58bfe9d03c95.tar.bz2 ice-0802f5204cd7a50007b97e71aa8b58bfe9d03c95.tar.xz ice-0802f5204cd7a50007b97e71aa8b58bfe9d03c95.zip |
Added AMI and AMD tests for exception slicing. Removed a few redundant
semicolons from the source.
Diffstat (limited to 'java/test/Ice/slicing/exceptions/csrc/AllTests.java')
-rw-r--r-- | java/test/Ice/slicing/exceptions/csrc/AllTests.java | 750 |
1 files changed, 736 insertions, 14 deletions
diff --git a/java/test/Ice/slicing/exceptions/csrc/AllTests.java b/java/test/Ice/slicing/exceptions/csrc/AllTests.java index c35685e5a5e..db5758944cf 100644 --- a/java/test/Ice/slicing/exceptions/csrc/AllTests.java +++ b/java/test/Ice/slicing/exceptions/csrc/AllTests.java @@ -23,6 +23,610 @@ public class AllTests } } + private static class Callback + { + Callback() + { + _called = false; + } + + public synchronized boolean + check() + { + while(!_called) + { + try + { + wait(5000); + } + catch(InterruptedException ex) + { + continue; + } + + if(!_called) + { + return false; // Must be timeout. + } + } + + _called = false; + return true; + } + + public synchronized void + called() + { + assert(!_called); + _called = true; + notify(); + } + + private boolean _called; + } + + private static class AMI_Test_baseAsBaseI extends AMI_Test_baseAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(Base b) + { + test(b.b.equals("Base.b")); + test(b.ice_name().equals("Base")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_unknownDerivedAsBaseI extends AMI_Test_unknownDerivedAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(Base b) + { + test(b.b.equals("UnknownDerived.b")); + test(b.ice_name().equals("Base")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownDerivedAsBaseI extends AMI_Test_knownDerivedAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownDerived k) + { + test(k.b.equals("KnownDerived.b")); + test(k.kd.equals("KnownDerived.kd")); + test(k.ice_name().equals("KnownDerived")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownDerivedAsKnownDerivedI extends AMI_Test_knownDerivedAsKnownDerived + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownDerived k) + { + test(k.b.equals("KnownDerived.b")); + test(k.kd.equals("KnownDerived.kd")); + test(k.ice_name().equals("KnownDerived")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_unknownIntermediateAsBaseI extends AMI_Test_unknownIntermediateAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(Base b) + { + test(b.b.equals("UnknownIntermediate.b")); + test(b.ice_name().equals("Base")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownIntermediateAsBaseI extends AMI_Test_knownIntermediateAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownIntermediate ki) + { + test(ki.b.equals("KnownIntermediate.b")); + test(ki.ki.equals("KnownIntermediate.ki")); + test(ki.ice_name().equals("KnownIntermediate")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownMostDerivedAsBaseI extends AMI_Test_knownMostDerivedAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownMostDerived kmd) + { + test(kmd.b.equals("KnownMostDerived.b")); + test(kmd.ki.equals("KnownMostDerived.ki")); + test(kmd.kmd.equals("KnownMostDerived.kmd")); + test(kmd.ice_name().equals("KnownMostDerived")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownIntermediateAsKnownIntermediateI + extends AMI_Test_knownIntermediateAsKnownIntermediate + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownIntermediate ki) + { + test(ki.b.equals("KnownIntermediate.b")); + test(ki.ki.equals("KnownIntermediate.ki")); + test(ki.ice_name().equals("KnownIntermediate")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownMostDerivedAsKnownIntermediateI + extends AMI_Test_knownMostDerivedAsKnownIntermediate + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownMostDerived kmd) + { + test(kmd.b.equals("KnownMostDerived.b")); + test(kmd.ki.equals("KnownMostDerived.ki")); + test(kmd.kmd.equals("KnownMostDerived.kmd")); + test(kmd.ice_name().equals("KnownMostDerived")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_knownMostDerivedAsKnownMostDerivedI + extends AMI_Test_knownMostDerivedAsKnownMostDerived + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownMostDerived kmd) + { + test(kmd.b.equals("KnownMostDerived.b")); + test(kmd.ki.equals("KnownMostDerived.ki")); + test(kmd.kmd.equals("KnownMostDerived.kmd")); + test(kmd.ice_name().equals("KnownMostDerived")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_unknownMostDerived1AsBaseI extends AMI_Test_unknownMostDerived1AsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownIntermediate ki) + { + test(ki.b.equals("UnknownMostDerived1.b")); + test(ki.ki.equals("UnknownMostDerived1.ki")); + test(ki.ice_name().equals("KnownIntermediate")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_unknownMostDerived1AsKnownIntermediateI + extends AMI_Test_unknownMostDerived1AsKnownIntermediate + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(KnownIntermediate ki) + { + test(ki.b.equals("UnknownMostDerived1.b")); + test(ki.ki.equals("UnknownMostDerived1.ki")); + test(ki.ice_name().equals("KnownIntermediate")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_unknownMostDerived2AsBaseI extends AMI_Test_unknownMostDerived2AsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + throw exc; + } + catch(Base b) + { + test(b.b.equals("UnknownMostDerived2.b")); + test(b.ice_name().equals("Base")); + } + catch(Exception ex) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + public static TestPrx allTests(Ice.Communicator communicator, boolean collocated) { @@ -40,7 +644,7 @@ public class AllTests test(test.equals(base)); System.out.println("ok"); - System.out.print("testing throwing a base exception... "); + System.out.print("base... "); System.out.flush(); { boolean gotException = false; @@ -62,7 +666,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of unknown derived exception... "); + System.out.print("base (AMI)... "); + System.out.flush(); + { + AMI_Test_baseAsBaseI cb = new AMI_Test_baseAsBaseI(); + test.baseAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of unknown derived... "); System.out.flush(); { boolean gotException = false; @@ -84,7 +697,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing non-slicing of known derived exception thrown as base exception... "); + System.out.print("slicing of unknown derived (AMI)... "); + System.out.flush(); + { + AMI_Test_unknownDerivedAsBaseI cb = new AMI_Test_unknownDerivedAsBaseI(); + test.unknownDerivedAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("non-slicing of known derived as base... "); System.out.flush(); { boolean gotException = false; @@ -107,7 +729,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing non-slicing of known derived exception thrown as derived exception... "); + System.out.print("non-slicing of known derived as base (AMI)... "); + System.out.flush(); + { + AMI_Test_knownDerivedAsBaseI cb = new AMI_Test_knownDerivedAsBaseI(); + test.knownDerivedAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("non-slicing of known derived as derived... "); System.out.flush(); { boolean gotException = false; @@ -130,7 +761,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of unknown intermediate exception thrown as base exception... "); + System.out.print("non-slicing of known derived as derived (AMI)... "); + System.out.flush(); + { + AMI_Test_knownDerivedAsKnownDerivedI cb = new AMI_Test_knownDerivedAsKnownDerivedI(); + test.knownDerivedAsKnownDerived_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of unknown intermediate as base... "); System.out.flush(); { boolean gotException = false; @@ -152,7 +792,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of known intermediate exception thrown as base exception... "); + System.out.print("slicing of unknown intermediate as base (AMI)... "); + System.out.flush(); + { + AMI_Test_unknownIntermediateAsBaseI cb = new AMI_Test_unknownIntermediateAsBaseI(); + test.unknownIntermediateAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of known intermediate as base... "); System.out.flush(); { boolean gotException = false; @@ -175,7 +824,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of known most derived exception thrown as base exception... "); + System.out.print("slicing of known intermediate as base (AMI)... "); + System.out.flush(); + { + AMI_Test_knownIntermediateAsBaseI cb = new AMI_Test_knownIntermediateAsBaseI(); + test.knownIntermediateAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of known most derived as base... "); System.out.flush(); { boolean gotException = false; @@ -199,13 +857,22 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing non-slicing of known intermediate exception thrown as intermediate exception... "); + System.out.print("slicing of known most derived as base (AMI)... "); + System.out.flush(); + { + AMI_Test_knownMostDerivedAsBaseI cb = new AMI_Test_knownMostDerivedAsBaseI(); + test.knownMostDerivedAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("non-slicing of known intermediate as intermediate... "); System.out.flush(); { boolean gotException = false; try { - test.knownIntermediateAsknownIntermediate(); + test.knownIntermediateAsKnownIntermediate(); } catch(KnownIntermediate ki) { @@ -222,7 +889,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing non-slicing of known most derived thrown as intermediate exception... "); + System.out.print("non-slicing of known intermediate as intermediate (AMI)... "); + System.out.flush(); + { + AMI_Test_knownIntermediateAsKnownIntermediateI cb = new AMI_Test_knownIntermediateAsKnownIntermediateI(); + test.knownIntermediateAsKnownIntermediate_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("non-slicing of known most derived as intermediate... "); System.out.flush(); { boolean gotException = false; @@ -246,7 +922,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing non-slicing of known most derived thrown as most derived exception... "); + System.out.print("non-slicing of known most derived as intermediate (AMI)... "); + System.out.flush(); + { + AMI_Test_knownMostDerivedAsKnownIntermediateI cb = new AMI_Test_knownMostDerivedAsKnownIntermediateI(); + test.knownMostDerivedAsKnownIntermediate_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("non-slicing of known most derived as most derived... "); System.out.flush(); { boolean gotException = false; @@ -270,7 +955,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of unknown most derived with known intermediate thrown as base exception... "); + System.out.print("non-slicing of known most derived as most derived (AMI)... "); + System.out.flush(); + { + AMI_Test_knownMostDerivedAsKnownMostDerivedI cb = new AMI_Test_knownMostDerivedAsKnownMostDerivedI(); + test.knownMostDerivedAsKnownMostDerived_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of unknown most derived, known intermediate as base... "); System.out.flush(); { boolean gotException = false; @@ -293,7 +987,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of unknown most derived with known intermediate thrown as intermediate exception... "); + System.out.print("slicing of unknown most derived, known intermediate as base (AMI)... "); + System.out.flush(); + { + AMI_Test_unknownMostDerived1AsBaseI cb = new AMI_Test_unknownMostDerived1AsBaseI(); + test.unknownMostDerived1AsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of unknown most derived, known intermediate as intermediate... "); System.out.flush(); { boolean gotException = false; @@ -316,7 +1019,17 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing slicing of unknown most derived with unknown intermediate thrown as base exception... "); + System.out.print("slicing of unknown most derived, known intermediate as intermediate (AMI)... "); + System.out.flush(); + { + AMI_Test_unknownMostDerived1AsKnownIntermediateI cb = + new AMI_Test_unknownMostDerived1AsKnownIntermediateI(); + test.unknownMostDerived1AsKnownIntermediate_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("slicing of unknown most derived, unknown intermediate thrown as base... "); System.out.flush(); { boolean gotException = false; @@ -338,6 +1051,15 @@ public class AllTests } System.out.println("ok"); + System.out.print("slicing of unknown most derived, unknown intermediate thrown as base (AMI)... "); + System.out.flush(); + { + AMI_Test_unknownMostDerived2AsBaseI cb = new AMI_Test_unknownMostDerived2AsBaseI(); + test.unknownMostDerived2AsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + return test; } } |