diff options
author | Michi Henning <michi@zeroc.com> | 2004-02-25 06:31:17 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-02-25 06:31:17 +0000 |
commit | 6eaba1e723912c8dbb895b39b6e1435801808372 (patch) | |
tree | 648e2e7259e60920ed4fe23e7dc596d4678ebde9 /java | |
parent | HP fixes again (diff) | |
download | ice-6eaba1e723912c8dbb895b39b6e1435801808372.tar.bz2 ice-6eaba1e723912c8dbb895b39b6e1435801808372.tar.xz ice-6eaba1e723912c8dbb895b39b6e1435801808372.zip |
Added AMI/AMD tests.
Diffstat (limited to 'java')
-rw-r--r-- | java/test/Ice/slicing/build.xml | 2 | ||||
-rw-r--r-- | java/test/Ice/slicing/objects/csrc/AllTests.java | 1522 | ||||
-rwxr-xr-x | java/test/Ice/slicing/objects/run.py | 24 | ||||
-rw-r--r-- | java/test/Ice/slicing/objectsAMD/Forward.ice | 30 | ||||
-rw-r--r-- | java/test/Ice/slicing/objectsAMD/Server.java | 63 | ||||
-rw-r--r-- | java/test/Ice/slicing/objectsAMD/ServerPrivateAMD.ice | 48 | ||||
-rw-r--r-- | java/test/Ice/slicing/objectsAMD/TestAMD.ice | 114 | ||||
-rw-r--r-- | java/test/Ice/slicing/objectsAMD/TestI.java | 377 | ||||
-rw-r--r-- | java/test/Ice/slicing/objectsAMD/build.xml | 62 |
9 files changed, 2212 insertions, 30 deletions
diff --git a/java/test/Ice/slicing/build.xml b/java/test/Ice/slicing/build.xml index 7c8b1e9eb41..892c9a7d1ce 100644 --- a/java/test/Ice/slicing/build.xml +++ b/java/test/Ice/slicing/build.xml @@ -17,12 +17,14 @@ the Free Software Foundation. <ant dir="exceptions"/> <ant dir="exceptionsAMD"/> <ant dir="objects"/> + <ant dir="objectsAMD"/> </target> <target name="clean"> <ant dir="exceptions" target="clean"/> <ant dir="exceptionsAMD" target="clean"/> <ant dir="objects" target="clean"/> + <ant dir="objectsAMD" target="clean"/> </target> </project> diff --git a/java/test/Ice/slicing/objects/csrc/AllTests.java b/java/test/Ice/slicing/objects/csrc/AllTests.java index 9a30600bbeb..1e481761720 100644 --- a/java/test/Ice/slicing/objects/csrc/AllTests.java +++ b/java/test/Ice/slicing/objects/csrc/AllTests.java @@ -23,6 +23,973 @@ 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_SBaseAsObjectI extends AMI_Test_SBaseAsObject + { + public void + ice_response(Ice.Object o) + { + test(o != null); + test(o.ice_id(null).equals("::SBase")); + SBase sb = (SBase)o; + test(sb != null); + test(sb.sb.equals("SBase.sb")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_SBaseAsSBaseI extends AMI_Test_SBaseAsSBase + { + public void + ice_response(SBase sb) + { + test(sb.sb.equals("SBase.sb")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_SBSKnownDerivedAsSBaseI extends AMI_Test_SBSKnownDerivedAsSBase + { + public void + ice_response(SBase sb) + { + test(sb.sb.equals("SBSKnownDerived.sb")); + SBSKnownDerived sbskd = (SBSKnownDerived)sb; + test(sbskd != null); + test(sbskd.sbskd.equals("SBSKnownDerived.sbskd")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_SBSKnownDerivedAsSBSKnownDerivedI extends AMI_Test_SBSKnownDerivedAsSBSKnownDerived + { + public void + ice_response(SBSKnownDerived sbskd) + { + test(sbskd.sbskd.equals("SBSKnownDerived.sbskd")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_SBSUnknownDerivedAsSBaseI extends AMI_Test_SBSUnknownDerivedAsSBase + { + public void + ice_response(SBase sb) + { + test(sb.sb.equals("SBSUnknownDerived.sb")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_SUnknownAsObjectI extends AMI_Test_SUnknownAsObject + { + public void + ice_response(Ice.Object o) + { + test(o.ice_id(null).equals("::Ice::Object")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_oneElementCycleI extends AMI_Test_oneElementCycle + { + public void + ice_response(B b) + { + test(b != null); + test(b.ice_id(null).equals("::B")); + test(b.sb.equals("B1.sb")); + test(b.pb == b); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_twoElementCycleI extends AMI_Test_twoElementCycle + { + public void + ice_response(B b1) + { + test(b1 != null); + test(b1.ice_id(null).equals("::B")); + test(b1.sb.equals("B1.sb")); + + B b2 = b1.pb; + test(b2 != null); + test(b2.ice_id(null).equals("::B")); + test(b2.sb.equals("B2.sb")); + test(b2.pb == b1); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_D1AsBI extends AMI_Test_D1AsB + { + public void + ice_response(B b1) + { + test(b1 != null); + test(b1.ice_id(null).equals("::D1")); + test(b1.sb.equals("D1.sb")); + test(b1.pb != null); + test(b1.pb != b1); + D1 d1 = (D1)b1; + test(d1 != null); + test(d1.sd1.equals("D1.sd1")); + test(d1.pd1 != null); + test(d1.pd1 != b1); + test(b1.pb == d1.pd1); + + B b2 = b1.pb; + test(b2 != null); + test(b2.pb == b1); + test(b2.sb.equals("D2.sb")); + test(b2.ice_id(null).equals("::B")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_D1AsD1I extends AMI_Test_D1AsD1 + { + public void + ice_response(D1 d1) + { + test(d1 != null); + test(d1.ice_id(null).equals("::D1")); + test(d1.sb.equals("D1.sb")); + test(d1.pb != null); + test(d1.pb != d1); + + B b2 = d1.pb; + test(b2 != null); + test(b2.ice_id(null).equals("::B")); + test(b2.sb.equals("D2.sb")); + test(b2.pb == d1); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_D2AsBI extends AMI_Test_D2AsB + { + public void + ice_response(B b2) + { + test(b2 != null); + test(b2.ice_id(null).equals("::B")); + test(b2.sb.equals("D2.sb")); + test(b2.pb != null); + test(b2.pb != b2); + + B b1 = b2.pb; + test(b1 != null); + test(b1.ice_id(null).equals("::D1")); + test(b1.sb.equals("D1.sb")); + test(b1.pb == b2); + D1 d1 = (D1)b1; + test(d1 != null); + test(d1.sd1.equals("D1.sd1")); + test(d1.pd1 == b2); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_paramTest1I extends AMI_Test_paramTest1 + { + public void + ice_response(B b1, B b2) + { + test(b1 != null); + test(b1.ice_id(null).equals("::D1")); + test(b1.sb.equals("D1.sb")); + test(b1.pb == b2); + D1 d1 = (D1)b1; + test(d1 != null); + test(d1.sd1.equals("D1.sd1")); + test(d1.pd1 == b2); + + test(b2 != null); + test(b2.ice_id(null).equals("::B")); // No factory, must be sliced + test(b2.sb.equals("D2.sb")); + test(b2.pb == b1); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_paramTest2I extends AMI_Test_paramTest2 + { + public void + ice_response(B b2, B b1) + { + test(b1 != null); + test(b1.ice_id(null).equals("::D1")); + test(b1.sb.equals("D1.sb")); + test(b1.pb == b2); + D1 d1 = (D1)b1; + test(d1 != null); + test(d1.sd1.equals("D1.sd1")); + test(d1.pd1 == b2); + + test(b2 != null); + test(b2.ice_id(null).equals("::B")); // No factory, must be sliced + test(b2.sb.equals("D2.sb")); + test(b2.pb == b1); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_returnTest1I extends AMI_Test_returnTest1 + { + public void + ice_response(B r, B p1, B p2) + { + test(r == p1); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_returnTest2I extends AMI_Test_returnTest2 + { + public void + ice_response(B r, B p1, B p2) + { + test(r == p1); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_returnTest3I extends AMI_Test_returnTest3 + { + public void + ice_response(B b) + { + r = b; + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + + public B r; + } + + private static class AMI_Test_paramTest3I extends AMI_Test_paramTest3 + { + public void + ice_response(B ret, B p1, B p2) + { + test(p1 != null); + test(p1.sb.equals("D2.sb (p1 1)")); + test(p1.pb == null); + test(p1.ice_id(null).equals("::B")); + + test(p2 != null); + test(p2.sb.equals("D2.sb (p2 1)")); + test(p2.pb == null); + test(p2.ice_id(null).equals("::B")); + + test(ret != null); + test(ret.sb.equals("D1.sb (p2 2)")); + test(ret.pb == null); + test(ret.ice_id(null).equals("::D1")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + + public B r; + } + + private static class AMI_Test_paramTest4I extends AMI_Test_paramTest4 + { + public void + ice_response(B ret, B b) + { + test(b != null); + test(b.sb.equals("D4.sb (1)")); + test(b.pb == null); + test(b.ice_id(null).equals("::B")); + + test(ret != null); + test(ret.sb.equals("B.sb (2)")); + test(ret.pb == null); + test(ret.ice_id(null).equals("::B")); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + + public B r; + } + + private static class AMI_Test_sequenceTestI extends AMI_Test_sequenceTest + { + public void + ice_response(SS ss) + { + r = ss; + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + + public SS r; + } + + private static class AMI_Test_dictionaryTestI extends AMI_Test_dictionaryTest + { + public void + ice_response(java.util.Map r, java.util.Map bout) + { + this.r = r; + this.bout = bout; + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + + public java.util.Map r; + public java.util.Map bout; + } + + private static class AMI_Test_throwBaseAsBaseI extends AMI_Test_throwBaseAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + BaseException e = (BaseException)exc; + test(e.ice_name().equals("BaseException")); + test(e.sbe.equals("sbe")); + test(e.pb != null); + test(e.pb.sb.equals("sb")); + test(e.pb.pb == e.pb); + } + catch(Exception e) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_throwDerivedAsBaseI extends AMI_Test_throwDerivedAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + DerivedException e = (DerivedException)exc; + test(e.ice_name().equals("DerivedException")); + test(e.sbe.equals("sbe")); + test(e.pb != null); + test(e.pb.sb.equals("sb1")); + test(e.pb.pb == e.pb); + test(e.sde.equals("sde1")); + test(e.pd1 != null); + test(e.pd1.sb.equals("sb2")); + test(e.pd1.pb == e.pd1); + test(e.pd1.sd1.equals("sd2")); + test(e.pd1.pd1 == e.pd1); + } + catch(Exception e) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_throwDerivedAsDerivedI extends AMI_Test_throwDerivedAsDerived + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + DerivedException e = (DerivedException)exc; + test(e.ice_name().equals("DerivedException")); + test(e.sbe.equals("sbe")); + test(e.pb != null); + test(e.pb.sb.equals("sb1")); + test(e.pb.pb == e.pb); + test(e.sde.equals("sde1")); + test(e.pd1 != null); + test(e.pd1.sb.equals("sb2")); + test(e.pd1.pb == e.pd1); + test(e.pd1.sd1.equals("sd2")); + test(e.pd1.pd1 == e.pd1); + } + catch(Exception e) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_throwUnknownDerivedAsBaseI extends AMI_Test_throwUnknownDerivedAsBase + { + public void + ice_response() + { + test(false); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + try + { + BaseException e = (BaseException)exc; + test(e.ice_name().equals("BaseException")); + test(e.sbe.equals("sbe")); + test(e.pb != null); + test(e.pb.sb.equals("sb d2")); + test(e.pb.pb == e.pb); + } + catch(Exception e) + { + test(false); + } + callback.called(); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + + private static class AMI_Test_useForwardI extends AMI_Test_useForward + { + public void + ice_response(Forward f) + { + test(f != null); + callback.called(); + } + + public void + ice_exception(Ice.LocalException exc) + { + test(false); + } + + public void + ice_exception(Ice.UserException exc) + { + test(false); + } + + public boolean + check() + { + return callback.check(); + } + + private Callback callback = new Callback(); + } + public static TestPrx allTests(Ice.Communicator communicator, boolean collocated) { @@ -40,7 +1007,7 @@ public class AllTests test(test.equals(base)); System.out.println("ok"); - System.out.print("testing base as Object... "); + System.out.print("base as Object... "); System.out.flush(); { Ice.Object o; @@ -61,7 +1028,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing base as base... "); + System.out.print("base as Object (AMI)... "); + System.out.flush(); + { + AMI_Test_SBaseAsObjectI cb = new AMI_Test_SBaseAsObjectI(); + test.SBaseAsObject_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("base as base... "); System.out.flush(); { SBase sb; @@ -77,7 +1053,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing base with known derived as base... "); + System.out.print("base as base (AMI)... "); + System.out.flush(); + { + AMI_Test_SBaseAsSBaseI cb = new AMI_Test_SBaseAsSBaseI(); + test.SBaseAsSBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("base with known derived as base... "); System.out.flush(); { SBase sb; @@ -97,7 +1082,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing base with known derived as known derived... "); + System.out.print("base with known derived as base (AMI)... "); + System.out.flush(); + { + AMI_Test_SBSKnownDerivedAsSBaseI cb = new AMI_Test_SBSKnownDerivedAsSBaseI(); + test.SBSKnownDerivedAsSBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("base with known derived as known derived... "); System.out.flush(); { SBSKnownDerived sbskd; @@ -113,7 +1107,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing base with unknown derived as base... "); + System.out.print("base with known derived as known derived (AMI)... "); + System.out.flush(); + { + AMI_Test_SBSKnownDerivedAsSBSKnownDerivedI cb = new AMI_Test_SBSKnownDerivedAsSBSKnownDerivedI(); + test.SBSKnownDerivedAsSBSKnownDerived_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("base with unknown derived as base... "); System.out.flush(); { SBase sb; @@ -129,7 +1132,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing unknown with Object as Object... "); + System.out.print("base with unknown derived as base (AMI)... "); + System.out.flush(); + { + AMI_Test_SBSUnknownDerivedAsSBaseI cb = new AMI_Test_SBSUnknownDerivedAsSBaseI(); + test.SBSUnknownDerivedAsSBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("unknown with Object as Object... "); System.out.flush(); { Ice.Object o; @@ -145,7 +1157,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing one-element cycle... "); + System.out.print("unknown with Object as Object (AMI)... "); + System.out.flush(); + { + AMI_Test_SUnknownAsObjectI cb = new AMI_Test_SUnknownAsObjectI(); + test.SUnknownAsObject_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("one-element cycle... "); System.out.flush(); { try @@ -163,7 +1184,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing two-element cycle... "); + System.out.print("one-element cycle (AMI)... "); + System.out.flush(); + { + AMI_Test_oneElementCycleI cb = new AMI_Test_oneElementCycleI(); + test.oneElementCycle_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("two-element cycle... "); System.out.flush(); { try @@ -186,7 +1216,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing known derived pointer slicing as base... "); + System.out.print("two-element cycle (AMI)... "); + System.out.flush(); + { + AMI_Test_twoElementCycleI cb = new AMI_Test_twoElementCycleI(); + test.twoElementCycle_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("known derived pointer slicing as base... "); System.out.flush(); { try @@ -218,7 +1257,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing known derived pointer slicing as derived... "); + System.out.print("known derived pointer slicing as base (AMI)... "); + System.out.flush(); + { + AMI_Test_D1AsBI cb = new AMI_Test_D1AsBI(); + test.D1AsB_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("known derived pointer slicing as derived... "); System.out.flush(); { try @@ -244,7 +1292,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing unknown derived pointer slicing as base... "); + System.out.print("known derived pointer slicing as derived (AMI)... "); + System.out.flush(); + { + AMI_Test_D1AsD1I cb = new AMI_Test_D1AsD1I(); + test.D1AsD1_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("unknown derived pointer slicing as base... "); System.out.flush(); { try @@ -274,7 +1331,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing parameter pointer slicing with known first... "); + System.out.print("unknown derived pointer slicing as base (AMI)... "); + System.out.flush(); + { + AMI_Test_D2AsBI cb = new AMI_Test_D2AsBI(); + test.D2AsB_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("param ptr slicing with known first... "); System.out.flush(); { try @@ -304,7 +1370,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing parameter pointer slicing with unknown first... "); + System.out.print("param ptr slicing with known first (AMI)... "); + System.out.flush(); + { + AMI_Test_paramTest1I cb = new AMI_Test_paramTest1I(); + test.paramTest1_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("param ptr slicing with unknown first... "); System.out.flush(); { try @@ -334,7 +1409,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing return value identity with known first... "); + System.out.print("param ptr slicing with unknown first (AMI)... "); + System.out.flush(); + { + AMI_Test_paramTest2I cb = new AMI_Test_paramTest2I(); + test.paramTest2_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("return value identity with known first... "); System.out.flush(); { try @@ -351,7 +1435,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing return value identity with unknown first... "); + System.out.print("return value identity with known first (AMI)... "); + System.out.flush(); + { + AMI_Test_returnTest1I cb = new AMI_Test_returnTest1I(); + test.returnTest1_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("return value identity with unknown first... "); System.out.flush(); { try @@ -368,7 +1461,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing return value identity for input params known first... "); + System.out.print("return value identity with unknown first (AMI)... "); + System.out.flush(); + { + AMI_Test_returnTest2I cb = new AMI_Test_returnTest2I(); + test.returnTest2_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("return value identity for input params known first... "); System.out.flush(); { try @@ -422,7 +1524,57 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing return value identity for input params unknown first... "); + System.out.print("return value identity for input params known first (AMI)... "); + System.out.flush(); + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D3 d3 = new D3(); + d3.pb = d1; + d3.sb = "D3.sb"; + d3.sd3 = "D3.sd3"; + d3.pd3 = d1; + d1.pb = d3; + d1.pd1 = d3; + + AMI_Test_returnTest3I cb = new AMI_Test_returnTest3I(); + test.returnTest3_async(cb, d1, d3); + test(cb.check()); + B b1 = cb.r; + + test(b1 != null); + test(b1.sb.equals("D1.sb")); + test(b1.ice_id(null).equals("::D1")); + D1 p1 = (D1)b1; + test(p1 != null); + test(p1.sd1.equals("D1.sd1")); + test(p1.pd1 == b1.pb); + + B b2 = b1.pb; + test(b2 != null); + test(b2.sb.equals("D3.sb")); + test(b2.ice_id(null).equals("::B")); // Sliced by server + test(b2.pb == b1); + boolean gotException = false; + try + { + D3 p3 = (D3)b2; + } + catch(ClassCastException ex) + { + gotException = true; + } + test(gotException); + + test(b1 != d1); + test(b1 != d3); + test(b2 != d1); + test(b2 != d3); + } + System.out.println("ok"); + + System.out.print("return value identity for input params unknown first... "); System.out.flush(); { try @@ -477,7 +1629,58 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing remainder unmarshaling (3 instances)... "); + System.out.print("return value identity for input params unknown first (AMI)... "); + System.out.flush(); + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D3 d3 = new D3(); + d3.pb = d1; + d3.sb = "D3.sb"; + d3.sd3 = "D3.sd3"; + d3.pd3 = d1; + d1.pb = d3; + d1.pd1 = d3; + + AMI_Test_returnTest3I cb = new AMI_Test_returnTest3I(); + test.returnTest3_async(cb, d3, d1); + test(cb.check()); + B b1 = cb.r; + + test(b1 != null); + test(b1.sb.equals("D3.sb")); + test(b1.ice_id(null).equals("::B")); // Sliced by server + + boolean gotException = false; + try + { + D3 p1 = (D3)b1; + } + catch(ClassCastException ex) + { + gotException = true; + } + test(gotException); + + B b2 = b1.pb; + test(b2 != null); + test(b2.sb.equals("D1.sb")); + test(b2.ice_id(null).equals("::D1")); + test(b2.pb == b1); + D1 p3 = (D1)b2; + test(p3 != null); + test(p3.sd1.equals("D1.sd1")); + test(p3.pd1 == b1); + + test(b1 != d1); + test(b1 != d3); + test(b2 != d1); + test(b2 != d3); + } + System.out.println("ok"); + + System.out.print("remainder unmarshaling (3 instances)... "); System.out.flush(); { try @@ -508,7 +1711,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing remainder unmarshaling (4 instances)... "); + System.out.print("remainder unmarshaling (3 instances) (AMI)... "); + System.out.flush(); + { + AMI_Test_paramTest3I cb = new AMI_Test_paramTest3I(); + test.paramTest3_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("remainder unmarshaling (4 instances)... "); System.out.flush(); { try @@ -533,8 +1745,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing parameter pointer slicing with first instance marshaled in" - + " unknown derived as base... "); + System.out.print("remainder unmarshaling (4 instances) (AMI)... "); + System.out.flush(); + { + AMI_Test_paramTest4I cb = new AMI_Test_paramTest4I(); + test.paramTest4_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("param ptr slicing, instance marshaled in unknown derived as base... "); System.out.flush(); { try @@ -567,8 +1787,36 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing parameter pointer slicing with first instance marshaled in" - + " unknown derived as derived... "); + System.out.print("param ptr slicing, instance marshaled in unknown derived as base (AMI)... "); + System.out.flush(); + { + B b1 = new B(); + b1.sb = "B.sb(1)"; + b1.pb = b1; + + D3 d3 = new D3(); + d3.sb = "D3.sb"; + d3.pb = d3; + d3.sd3 = "D3.sd3"; + d3.pd3 = b1; + + B b2 = new B(); + b2.sb = "B.sb(2)"; + b2.pb = b1; + + AMI_Test_returnTest3I cb = new AMI_Test_returnTest3I(); + test.returnTest3_async(cb, d3, b2); + test(cb.check()); + B r = cb.r; + + test(r != null); + test(r.ice_id(null).equals("::B")); + test(r.sb.equals("D3.sb")); + test(r.pb == r); + } + System.out.println("ok"); + + System.out.print("param ptr slicing, instance marshaled in unknown derived as derived... "); System.out.flush(); { try @@ -603,7 +1851,39 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing sequence slicing... "); + System.out.print("param ptr slicing, instance marshaled in unknown derived as derived (AMI)... "); + System.out.flush(); + { + D1 d11 = new D1(); + d11.sb = "D1.sb(1)"; + d11.pb = d11; + d11.sd1 = "D1.sd1(1)"; + + D3 d3 = new D3(); + d3.sb = "D3.sb"; + d3.pb = d3; + d3.sd3 = "D3.sd3"; + d3.pd3 = d11; + + D1 d12 = new D1(); + d12.sb = "D1.sb(2)"; + d12.pb = d12; + d12.sd1 = "D1.sd1(2)"; + d12.pd1 = d11; + + AMI_Test_returnTest3I cb = new AMI_Test_returnTest3I(); + test.returnTest3_async(cb, d3, d12); + test(cb.check()); + B r = cb.r; + + test(r != null); + test(r.ice_id(null).equals("::B")); + test(r.sb.equals("D3.sb")); + test(r.pb == r); + } + System.out.println("ok"); + + System.out.print("sequence slicing... "); System.out.flush(); { try @@ -693,7 +1973,92 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing dictionary slicing... "); + System.out.print("sequence slicing (AMI)... "); + System.out.flush(); + { + SS ss; + { + B ss1b = new B(); + ss1b.sb = "B.sb"; + ss1b.pb = ss1b; + + D1 ss1d1 = new D1(); + ss1d1.sb = "D1.sb"; + ss1d1.sd1 = "D1.sd1"; + ss1d1.pb = ss1b; + + D3 ss1d3 = new D3(); + ss1d3.sb = "D3.sb"; + ss1d3.sd3 = "D3.sd3"; + ss1d3.pb = ss1b; + + B ss2b = new B(); + ss2b.sb = "B.sb"; + ss2b.pb = ss1b; + + D1 ss2d1 = new D1(); + ss2d1.sb = "D1.sb"; + ss2d1.sd1 = "D1.sd1"; + ss2d1.pb = ss2b; + + D3 ss2d3 = new D3(); + ss2d3.sb = "D3.sb"; + ss2d3.sd3 = "D3.sd3"; + ss2d3.pb = ss2b; + + ss1d1.pd1 = ss2b; + ss1d3.pd3 = ss2d1; + + ss2d1.pd1 = ss1d3; + ss2d3.pd3 = ss1d1; + + SS1 ss1 = new SS1(); + ss1.s = new B[3]; + ss1.s[0] = ss1b; + ss1.s[1] = ss1d1; + ss1.s[2] = ss1d3; + + SS2 ss2 = new SS2(); + ss2.s = new B[3]; + ss2.s[0] = ss2b; + ss2.s[1] = ss2d1; + ss2.s[2] = ss2d3; + + AMI_Test_sequenceTestI cb = new AMI_Test_sequenceTestI(); + test.sequenceTest_async(cb, ss1, ss2); + test(cb.check()); + ss = cb.r; + } + test(ss.c1 != null); + B ss1b = ss.c1.s[0]; + B ss1d1 = ss.c1.s[1]; + test(ss.c2 != null); + B ss1d3 = ss.c1.s[2]; + + test(ss.c2 != null); + B ss2b = ss.c2.s[0]; + B ss2d1 = ss.c2.s[1]; + B ss2d3 = ss.c2.s[2]; + + test(ss1b.pb == ss1b); + test(ss1d1.pb == ss1b); + test(ss1d3.pb == ss1b); + + test(ss2b.pb == ss1b); + test(ss2d1.pb == ss2b); + test(ss2d3.pb == ss2b); + + test(ss1b.ice_id(null).equals("::B")); + test(ss1d1.ice_id(null).equals("::D1")); + test(ss1d3.ice_id(null).equals("::B")); + + test(ss2b.ice_id(null).equals("::B")); + test(ss2d1.ice_id(null).equals("::D1")); + test(ss2d3.ice_id(null).equals("::B")); + } + System.out.println("ok"); + + System.out.print("dictionary slicing... "); System.out.flush(); { try @@ -748,7 +2113,59 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing base exception thrown as base exception... "); + System.out.print("dictionary slicing (AMI)... "); + System.out.flush(); + { + java.util.Map bin = new java.util.HashMap(); + java.util.Map bout; + java.util.Map r; + int i; + for(i = 0; i < 10; ++i) + { + String s = "D1." + new Integer(i).toString(); + D1 d1 = new D1(); + d1.sb = s; + d1.pb = d1; + d1.sd1 = s; + bin.put(new Integer(i), d1); + } + + AMI_Test_dictionaryTestI cb = new AMI_Test_dictionaryTestI(); + test.dictionaryTest_async(cb, bin); + test(cb.check()); + bout = cb.bout; + r = cb.r; + + test(bout.size() == 10); + for(i = 0; i < 10; ++i) + { + B b = (B)bout.get(new Integer(i * 10)); + test(b != null); + String s = "D1." + new Integer(i).toString(); + test(b.sb.equals(s)); + test(b.pb != null); + test(b.pb != b); + test(b.pb.sb.equals(s)); + test(b.pb.pb == b.pb); + } + + test(r.size() == 10); + for(i = 0; i < 10; ++i) + { + B b = (B)r.get(new Integer(i * 20)); + test(b != null); + String s = "D1." + new Integer(i * 20).toString(); + test(b.sb.equals(s)); + test(b.pb == (i == 0 ? (B)null : (B)r.get(new Integer((i - 1) * 20)))); + D1 d1 = (D1)b; + test(d1 != null); + test(d1.sd1.equals(s)); + test(d1.pd1 == d1); + } + } + System.out.println("ok"); + + System.out.print("base exception thrown as base exception... "); System.out.flush(); { try @@ -771,7 +2188,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing derived exception thrown as base exception... "); + System.out.print("base exception thrown as base exception (AMI)... "); + System.out.flush(); + { + AMI_Test_throwBaseAsBaseI cb = new AMI_Test_throwBaseAsBaseI(); + test.throwBaseAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("derived exception thrown as base exception... "); System.out.flush(); { try @@ -800,7 +2226,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing derived exception thrown as derived exception... "); + System.out.print("derived exception thrown as base exception (AMI)... "); + System.out.flush(); + { + AMI_Test_throwDerivedAsBaseI cb = new AMI_Test_throwDerivedAsBaseI(); + test.throwDerivedAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("derived exception thrown as derived exception... "); System.out.flush(); { try @@ -829,7 +2264,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing unknown derived exception thrown as base exception... "); + System.out.print("derived exception thrown as derived exception (AMI)... "); + System.out.flush(); + { + AMI_Test_throwDerivedAsDerivedI cb = new AMI_Test_throwDerivedAsDerivedI(); + test.throwDerivedAsDerived_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("unknown derived exception thrown as base exception... "); System.out.flush(); { try @@ -852,7 +2296,16 @@ public class AllTests } System.out.println("ok"); - System.out.print("testing forward-declared class... "); + System.out.print("unknown derived exception thrown as base exception (AMI)... "); + System.out.flush(); + { + AMI_Test_throwUnknownDerivedAsBaseI cb = new AMI_Test_throwUnknownDerivedAsBaseI(); + test.throwUnknownDerivedAsBase_async(cb); + test(cb.check()); + } + System.out.println("ok"); + + System.out.print("forward-declared class... "); System.out.flush(); { try @@ -868,6 +2321,15 @@ public class AllTests } System.out.println("ok"); + System.out.print("forward-declared class (AMI)... "); + System.out.flush(); + { + AMI_Test_useForwardI cb = new AMI_Test_useForwardI(); + test.useForward_async(cb); + test(cb.check()); + } + System.out.println("ok"); + return test; } } diff --git a/java/test/Ice/slicing/objects/run.py b/java/test/Ice/slicing/objects/run.py index 6f6b8f7bfb7..dac109bdc8b 100755 --- a/java/test/Ice/slicing/objects/run.py +++ b/java/test/Ice/slicing/objects/run.py @@ -27,7 +27,31 @@ import TestUtil name = os.path.join("Ice", "slicing", "objects") testdir = os.path.join(toplevel, "test", name) +nameAMD = os.path.join("Ice", "slicing", "objectsAMD") +testdirAMD = os.path.join(toplevel, "test", nameAMD) +print "tests with regular server." TestUtil.clientServerTestWithClasspath(os.path.join(testdir, "sclasses"), os.path.join(testdir, "cclasses")) +print "tests with AMD server." +server = "java -ea Server --Ice.ProgramName=Server " +client = "java -ea Client --Ice.ProgramName=Client " +print "starting server...", +cp = os.getenv("CLASSPATH", "") +os.environ["CLASSPATH"] = os.path.join(testdirAMD, "classes") + TestUtil.sep + cp +serverPipe = os.popen(server + TestUtil.serverOptions) +TestUtil.getAdapterReady(serverPipe) +print "ok" +print "starting client...", +os.environ["CLASSPATH"] = cp +os.environ["CLASSPATH"] = os.path.join(testdir, "cclasses") + TestUtil.sep + cp +clientPipe = os.popen(client + TestUtil.clientOptions) +print "ok" +TestUtil.printOutputFromPipe(clientPipe) +clientStatus = clientPipe.close() +serverStatus = serverPipe.close() +if clientStatus or serverStatus: + TestUtil.killServers() + sys.exit(1) + sys.exit(0) diff --git a/java/test/Ice/slicing/objectsAMD/Forward.ice b/java/test/Ice/slicing/objectsAMD/Forward.ice new file mode 100644 index 00000000000..bcf3c459f62 --- /dev/null +++ b/java/test/Ice/slicing/objectsAMD/Forward.ice @@ -0,0 +1,30 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +#ifndef FORWARD_ICE +#define FORWARD_ICE + +class Forward; + +class Hidden +{ + Forward f; +}; + +class Forward +{ + Hidden h; +}; + +#endif diff --git a/java/test/Ice/slicing/objectsAMD/Server.java b/java/test/Ice/slicing/objectsAMD/Server.java new file mode 100644 index 00000000000..6402c74685f --- /dev/null +++ b/java/test/Ice/slicing/objectsAMD/Server.java @@ -0,0 +1,63 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +public class Server +{ + private static int + run(String[] args, Ice.Communicator communicator) + { + Ice.Properties properties = communicator.getProperties(); + properties.setProperty("Ice.Warn.Dispatch", "0"); + properties.setProperty("TestAdapter.Endpoints", "default -p 12345 -t 2000"); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + Ice.Object object = new TestI(adapter); + adapter.add(object, Ice.Util.stringToIdentity("Test")); + adapter.activate(); + communicator.waitForShutdown(); + return 0; + } + + public static void + main(String[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + communicator = Ice.Util.initialize(args); + status = run(args, communicator); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + } + + System.exit(status); + } +} diff --git a/java/test/Ice/slicing/objectsAMD/ServerPrivateAMD.ice b/java/test/Ice/slicing/objectsAMD/ServerPrivateAMD.ice new file mode 100644 index 00000000000..b59df25fa0e --- /dev/null +++ b/java/test/Ice/slicing/objectsAMD/ServerPrivateAMD.ice @@ -0,0 +1,48 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +#ifndef SERVERPRIVATE_AMD_ICE +#define SERVERPRIVATE_AMD_ICE + +#include <TestAMD.ice> + +class SBSUnknownDerived extends SBase +{ + string sbsud; +}; + +class SUnknown +{ + string su; +}; + +class D2 extends B +{ + string sd2; + B pd2; +}; + +class D4 extends B +{ + B p1; + B p2; +}; + +exception UnknownDerivedException extends BaseException +{ + string sude; + D2 pd2; +}; + +#endif diff --git a/java/test/Ice/slicing/objectsAMD/TestAMD.ice b/java/test/Ice/slicing/objectsAMD/TestAMD.ice new file mode 100644 index 00000000000..999b3cf7d04 --- /dev/null +++ b/java/test/Ice/slicing/objectsAMD/TestAMD.ice @@ -0,0 +1,114 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +#ifndef TEST_AMD_ICE +#define TEST_AMD_ICE + +class SBase +{ + string sb; +}; + +class SBSKnownDerived extends SBase +{ + string sbskd; +}; + +class B +{ + string sb; + B pb; +}; + +class D1 extends B +{ + string sd1; + B pd1; +}; + +sequence<B> BSeq; + +class SS1 +{ + BSeq s; +}; + +class SS2 +{ + BSeq s; +}; + +struct SS +{ + SS1 c1; + SS2 c2; +}; + +dictionary<int, B> BDict; + +exception BaseException +{ + string sbe; + B pb; +}; + +exception DerivedException extends BaseException +{ + string sde; + D1 pd1; +}; + +class Forward; // Forward-declared class defined in another compilation unit + +["ami", "amd"] interface Test +{ + Object SBaseAsObject(); + SBase SBaseAsSBase(); + SBase SBSKnownDerivedAsSBase(); + SBSKnownDerived SBSKnownDerivedAsSBSKnownDerived(); + + SBase SBSUnknownDerivedAsSBase(); + + Object SUnknownAsObject(); + + B oneElementCycle(); + B twoElementCycle(); + B D1AsB(); + D1 D1AsD1(); + B D2AsB(); + + void paramTest1(out B p1, out B p2); + void paramTest2(out B p2, out B p1); + B paramTest3(out B p1, out B p2); + B paramTest4(out B p); + + B returnTest1(out B p1, out B p2); + B returnTest2(out B p2, out B p1); + B returnTest3(B p1, B p2); + + SS sequenceTest(SS1 p1, SS2 p2); + + BDict dictionaryTest(BDict bin, out BDict bout); + + void throwBaseAsBase() throws BaseException; + void throwDerivedAsBase() throws BaseException; + void throwDerivedAsDerived() throws DerivedException; + void throwUnknownDerivedAsBase() throws BaseException; + + void useForward(out Forward f); // Use of forward-declared class to verify that code is generated correctly. + + void shutdown(); +}; + +#endif diff --git a/java/test/Ice/slicing/objectsAMD/TestI.java b/java/test/Ice/slicing/objectsAMD/TestI.java new file mode 100644 index 00000000000..c56abf90dd3 --- /dev/null +++ b/java/test/Ice/slicing/objectsAMD/TestI.java @@ -0,0 +1,377 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +public final class TestI extends _TestDisp +{ + public + TestI(Ice.ObjectAdapter adapter) + { + _adapter = adapter; + } + + public void + shutdown_async(AMD_Test_shutdown cb, Ice.Current current) + { + _adapter.getCommunicator().shutdown(); + cb.ice_response(); + } + + public void + SBaseAsObject_async(AMD_Test_SBaseAsObject cb, Ice.Current current) + { + SBase sb = new SBase(); + sb.sb = "SBase.sb"; + cb.ice_response(sb); + } + + public void + SBaseAsSBase_async(AMD_Test_SBaseAsSBase cb, Ice.Current current) + { + SBase sb = new SBase(); + sb.sb = "SBase.sb"; + cb.ice_response(sb); + } + + public void + SBSKnownDerivedAsSBase_async(AMD_Test_SBSKnownDerivedAsSBase cb, Ice.Current current) + { + SBSKnownDerived sbskd = new SBSKnownDerived(); + sbskd.sb = "SBSKnownDerived.sb"; + sbskd.sbskd = "SBSKnownDerived.sbskd"; + cb.ice_response(sbskd); + } + + public void + SBSKnownDerivedAsSBSKnownDerived_async(AMD_Test_SBSKnownDerivedAsSBSKnownDerived cb, Ice.Current current) + { + SBSKnownDerived sbskd = new SBSKnownDerived(); + sbskd.sb = "SBSKnownDerived.sb"; + sbskd.sbskd = "SBSKnownDerived.sbskd"; + cb.ice_response(sbskd); + } + + public void + SBSUnknownDerivedAsSBase_async(AMD_Test_SBSUnknownDerivedAsSBase cb, Ice.Current current) + { + SBSUnknownDerived sbsud = new SBSUnknownDerived(); + sbsud.sb = "SBSUnknownDerived.sb"; + sbsud.sbsud = "SBSUnknownDerived.sbsud"; + cb.ice_response(sbsud); + } + + public void + SUnknownAsObject_async(AMD_Test_SUnknownAsObject cb, Ice.Current current) + { + SUnknown su = new SUnknown(); + su.su = "SUnknown.su"; + cb.ice_response(su); + } + + public void + oneElementCycle_async(AMD_Test_oneElementCycle cb, Ice.Current current) + { + B b = new B(); + b.sb = "B1.sb"; + b.pb = b; + cb.ice_response(b); + } + + public void + twoElementCycle_async(AMD_Test_twoElementCycle cb, Ice.Current current) + { + B b1 = new B(); + b1.sb = "B1.sb"; + B b2 = new B(); + b2.sb = "B2.sb"; + b2.pb = b1; + b1.pb = b2; + cb.ice_response(b1); + } + + public void + D1AsB_async(AMD_Test_D1AsB cb, Ice.Current current) + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D2 d2 = new D2(); + d2.pb = d1; + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + d2.pd2 = d1; + d1.pb = d2; + d1.pd1 = d2; + cb.ice_response(d1); + } + + public void + D1AsD1_async(AMD_Test_D1AsD1 cb, Ice.Current current) + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D2 d2 = new D2(); + d2.pb = d1; + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + d2.pd2 = d1; + d1.pb = d2; + d1.pd1 = d2; + cb.ice_response(d1); + } + + public void + D2AsB_async(AMD_Test_D2AsB cb, Ice.Current current) + { + D2 d2 = new D2(); + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + D1 d1 = new D1(); + d1.pb = d2; + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + d1.pd1 = d2; + d2.pb = d1; + d2.pd2 = d1; + cb.ice_response(d2); + } + + public void + paramTest1_async(AMD_Test_paramTest1 cb, Ice.Current current) + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D2 d2 = new D2(); + d2.pb = d1; + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + d2.pd2 = d1; + d1.pb = d2; + d1.pd1 = d2; + cb.ice_response(d1, d2); + } + + public void + paramTest2_async(AMD_Test_paramTest2 cb, Ice.Current current) + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D2 d2 = new D2(); + d2.pb = d1; + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + d2.pd2 = d1; + d1.pb = d2; + d1.pd1 = d2; + cb.ice_response(d2, d1); + } + + public void + paramTest3_async(AMD_Test_paramTest3 cb, Ice.Current current) + { + D2 d2 = new D2(); + d2.sb = "D2.sb (p1 1)"; + d2.pb = null; + d2.sd2 = "D2.sd2 (p1 1)"; + + D1 d1 = new D1(); + d1.sb = "D1.sb (p1 2)"; + d1.pb = null; + d1.sd1 = "D1.sd2 (p1 2)"; + d1.pd1 = null; + d2.pd2 = d1; + + D2 d4 = new D2(); + d4.sb = "D2.sb (p2 1)"; + d4.pb = null; + d4.sd2 = "D2.sd2 (p2 1)"; + + D1 d3 = new D1(); + d3.sb = "D1.sb (p2 2)"; + d3.pb = null; + d3.sd1 = "D1.sd2 (p2 2)"; + d3.pd1 = null; + d4.pd2 = d3; + cb.ice_response(d3, d2, d4); + } + + public void + paramTest4_async(AMD_Test_paramTest4 cb, Ice.Current current) + { + D4 d4 = new D4(); + d4.sb = "D4.sb (1)"; + d4.pb = null; + d4.p1 = new B(); + d4.p1.sb = "B.sb (1)"; + d4.p2 = new B(); + d4.p2.sb = "B.sb (2)"; + cb.ice_response(d4.p2, d4); + } + + public void + returnTest1_async(AMD_Test_returnTest1 cb, Ice.Current current) + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D2 d2 = new D2(); + d2.pb = d1; + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + d2.pd2 = d1; + d1.pb = d2; + d1.pd1 = d2; + cb.ice_response(d2, d2, d1); + } + + public void + returnTest2_async(AMD_Test_returnTest2 cb, Ice.Current current) + { + D1 d1 = new D1(); + d1.sb = "D1.sb"; + d1.sd1 = "D1.sd1"; + D2 d2 = new D2(); + d2.pb = d1; + d2.sb = "D2.sb"; + d2.sd2 = "D2.sd2"; + d2.pd2 = d1; + d1.pb = d2; + d1.pd1 = d2; + cb.ice_response(d1, d1, d2); + } + + public void + returnTest3_async(AMD_Test_returnTest3 cb, B p1, B p2, Ice.Current current) + { + cb.ice_response(p1); + } + + public void + sequenceTest_async(AMD_Test_sequenceTest cb, SS1 p1, SS2 p2, Ice.Current current) + { + SS ss = new SS(); + ss.c1 = p1; + ss.c2 = p2; + cb.ice_response(ss); + } + + public void + dictionaryTest_async(AMD_Test_dictionaryTest cb, java.util.Map bin, Ice.Current current) + { + java.util.Map bout = new java.util.HashMap(); + int i; + for(i = 0; i < 10; ++i) + { + B b = (B)bin.get(new Integer(i)); + D2 d2 = new D2(); + d2.sb = b.sb; + d2.pb = b.pb; + d2.sd2 = "D2"; + d2.pd2 = d2; + bout.put(new Integer(i * 10), d2); + } + java.util.Map r = new java.util.HashMap(); + for(i = 0; i < 10; ++i) + { + String s = "D1." + new Integer(i * 20).toString(); + D1 d1 = new D1(); + d1.sb = s; + d1.pb = (i == 0 ? (B)null : (B)r.get(new Integer((i - 1) * 20))); + d1.sd1 = s; + d1.pd1 = d1; + r.put(new Integer(i * 20), d1); + } + cb.ice_response(r, bout); + } + + public void + throwBaseAsBase_async(AMD_Test_throwBaseAsBase cb, Ice.Current current) + throws BaseException + { + BaseException be = new BaseException(); + be.sbe = "sbe"; + be.pb = new B(); + be.pb.sb = "sb"; + be.pb.pb = be.pb; + cb.ice_exception(be); + } + + public void + throwDerivedAsBase_async(AMD_Test_throwDerivedAsBase cb, Ice.Current current) + throws BaseException + { + DerivedException de = new DerivedException(); + de.sbe = "sbe"; + de.pb = new B(); + de.pb.sb = "sb1"; + de.pb.pb = de.pb; + de.sde = "sde1"; + de.pd1 = new D1(); + de.pd1.sb = "sb2"; + de.pd1.pb = de.pd1; + de.pd1.sd1 = "sd2"; + de.pd1.pd1 = de.pd1; + cb.ice_exception(de); + } + + public void + throwDerivedAsDerived_async(AMD_Test_throwDerivedAsDerived cb, Ice.Current current) + throws DerivedException + { + DerivedException de = new DerivedException(); + de.sbe = "sbe"; + de.pb = new B(); + de.pb.sb = "sb1"; + de.pb.pb = de.pb; + de.sde = "sde1"; + de.pd1 = new D1(); + de.pd1.sb = "sb2"; + de.pd1.pb = de.pd1; + de.pd1.sd1 = "sd2"; + de.pd1.pd1 = de.pd1; + cb.ice_exception(de); + } + + public void + throwUnknownDerivedAsBase_async(AMD_Test_throwUnknownDerivedAsBase cb, Ice.Current current) + throws BaseException + { + D2 d2 = new D2(); + d2.sb = "sb d2"; + d2.pb = d2; + d2.sd2 = "sd2 d2"; + d2.pd2 = d2; + + UnknownDerivedException ude = new UnknownDerivedException(); + ude.sbe = "sbe"; + ude.pb = d2; + ude.sude = "sude"; + ude.pd2 = d2; + cb.ice_exception(ude); + } + + public void + useForward_async(AMD_Test_useForward cb, Ice.Current current) + { + Forward f = new Forward(); + f = new Forward(); + f.h = new Hidden(); + f.h.f = f; + cb.ice_response(f); + } + + private Ice.ObjectAdapter _adapter; +} diff --git a/java/test/Ice/slicing/objectsAMD/build.xml b/java/test/Ice/slicing/objectsAMD/build.xml new file mode 100644 index 00000000000..77187c6ff0e --- /dev/null +++ b/java/test/Ice/slicing/objectsAMD/build.xml @@ -0,0 +1,62 @@ +<!-- + +Copyright (c) 2003 +ZeroC, Inc. +Billerica, MA, USA + +All Rights Reserved. + +Ice is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License version 2 as published by +the Free Software Foundation. + +--> +<project name="test_Ice_slicing_exceptionsAMD" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../../.."/> + <property name="lib.dir" value="${top.dir}/lib"/> + <property name="class.dir" value="classes"/> + <property name="generated.dir" value="generated"/> + + <!-- set common build properties for this build --> + <property file="${top.dir}/config/build.properties"/> + + <!-- install slice2java task --> + <taskdef name="slice2java" classpath="${top.dir}/ant" + classname="Slice2JavaTask" /> + + <target name="init"> + <!-- Create the time stamp --> + <tstamp/> + </target> + + <target name="generate" depends="init"> + <!-- Create the output directory for generated code --> + <mkdir dir="${generated.dir}"/> + <slice2java outputdir="${generated.dir}"> + <includepath> + <pathelement path="."/> + </includepath> + <fileset dir="." includes="TestAMD.ice"/> + <fileset dir="." includes="ServerPrivateAMD.ice"/> + <fileset dir="." includes="Forward.ice"/> + </slice2java> + </target> + + <target name="compile" depends="generate"> + <mkdir dir="${class.dir}"/> + <javac srcdir="${generated.dir}" destdir="${class.dir}" + source="1.4" classpath="${lib.dir}" debug="${debug}"/> + <javac srcdir="." destdir="${class.dir}" source="1.4" + classpath="${lib.dir}" excludes="generated/**" debug="${debug}"/> + </target> + + <target name="all" depends="compile"/> + + <target name="clean"> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> |