public Test.StringSS opStringSS(Test.StringSS p1, Test.StringSS p2, out Test.StringSS p3, Ice.Current current) { p3 = new Test.StringSS(); p3.AddRange(p1); p3.AddRange(p2); Test.StringSS r = new Test.StringSS(); for (int i = 0; i < p2.Count; i++) { r.Add(p2[p2.Count - (i + 1)]); } return(r); }
public Test.StringSS[] opStringSSS(Test.StringSS[] p1, Test.StringSS[] p2, out Test.StringSS[] p3, Ice.Current current) { p3 = new Test.StringSS[p1.Length + p2.Length]; p1.CopyTo(p3, 0); p2.CopyTo(p3, p1.Length); Test.StringSS[] r = new Test.StringSS[p2.Length]; for (int i = 0; i < p2.Length; i++) { r[i] = p2[p2.Length - (i + 1)]; } return(r); }
public void opStringSS_async(Test.AMD_MyClass_opStringSS cb, Test.StringSS p1, Test.StringSS p2, Ice.Current current) { Test.StringSS p3 = new Test.StringSS(); p3.AddRange(p1); p3.AddRange(p2); Test.StringSS r = new Test.StringSS(); for (int i = 0; i < p2.Count; i++) { r.Add(p2[p2.Count - (i + 1)]); } cb.ice_response(r, p3); }
public void opStringSSS_async(Test.AMD_MyClass_opStringSSS cb, Test.StringSS[] p1, Test.StringSS[] p2, Ice.Current current) { Test.StringSS[] p3 = new Test.StringSS[p1.Length + p2.Length]; Array.Copy(p1, 0, p3, 0, p1.Length); Array.Copy(p2, 0, p3, p1.Length, p2.Length); Test.StringSS[] r = new Test.StringSS[p2.Length]; for (int i = 0; i < p2.Length; i++) { r[i] = p2[p2.Length - (i + 1)]; } cb.ice_response(r, p3); }
public void opStringSS(Test.StringSS rso, Test.StringSS sso) { test(sso.Count == 5); test(sso[0].Count == 1); test(sso[0][0].Equals("abc")); test(sso[1].Count == 2); test(sso[1][0].Equals("de")); test(sso[1][1].Equals("fghi")); test(sso[2].Count == 0); test(sso[3].Count == 0); test(sso[4].Count == 1); test(sso[4][0].Equals("xyz")); test(rso.Count == 3); test(rso[0].Count == 1); test(rso[0][0].Equals("xyz")); test(rso[1].Count == 0); test(rso[2].Count == 0); called(); }
public override void ice_response(Test.StringSS rso, Test.StringSS sso) { test(sso.Count == 5); test(sso[0].Count == 1); test(sso[0][0].Equals("abc")); test(sso[1].Count == 2); test(sso[1][0].Equals("de")); test(sso[1][1].Equals("fghi")); test(sso[2].Count == 0); test(sso[3].Count == 0); test(sso[4].Count == 1); test(sso[4][0].Equals("xyz")); test(rso.Count == 3); test(rso[0].Count == 1); test(rso[0][0].Equals("xyz")); test(rso[1].Count == 0); test(rso[2].Count == 0); callback.called(); }
internal static void twoways(Ice.Communicator communicator, Test.MyClassPrx p) { p.ice_ping(); test(p.ice_isA(Test.MyClass.ice_staticId())); test(p.ice_id().Equals(Test.MyDerivedClass.ice_staticId())); { string[] ids = p.ice_ids(); test(ids.Length == 3); test(ids[0].Equals("::Ice::Object")); test(ids[1].Equals("::Test::MyClass")); test(ids[2].Equals("::Test::MyDerivedClass")); } { p.opVoid(); } { byte b; byte r; r = p.opByte(0xff, 0x0f, out b); test(b == 0xf0); test(r == 0xff); } { bool b; bool r; r = p.opBool(true, false, out b); test(b); test(!r); } { short s; int i; long l; long r; r = p.opShortIntLong(10, 11, 12L, out s, out i, out l); test(s == 10); test(i == 11); test(l == 12); test(r == 12L); r = p.opShortIntLong(Int16.MinValue, Int32.MinValue, Int64.MinValue, out s, out i, out l); test(s == Int16.MinValue); test(i == Int32.MinValue); test(l == Int64.MinValue); test(r == Int64.MinValue); r = p.opShortIntLong(Int16.MaxValue, Int32.MaxValue, Int64.MaxValue, out s, out i, out l); test(s == Int16.MaxValue); test(i == Int32.MaxValue); test(l == Int64.MaxValue); test(r == Int64.MaxValue); } { float f; double d; double r; r = p.opFloatDouble(3.14f, 1.1e10, out f, out d); test(f == 3.14f); test(d == 1.1e10); test(r == 1.1e10); r = p.opFloatDouble(Single.Epsilon, Double.MinValue, out f, out d); test(f == Single.Epsilon); test(d == Double.MinValue); test(r == Double.MinValue); r = p.opFloatDouble(Single.MaxValue, Double.MaxValue, out f, out d); test(f == Single.MaxValue); test(d == Double.MaxValue); test(r == Double.MaxValue); } { string s; string r; r = p.opString("hello", "world", out s); test(s.Equals("world hello")); test(r.Equals("hello world")); } { Test.MyEnum e; Test.MyEnum r; r = p.opMyEnum(Test.MyEnum.enum2, out e); test(e == Test.MyEnum.enum2); test(r == Test.MyEnum.enum3); } { Test.MyClassPrx c1; Test.MyClassPrx c2; Test.MyClassPrx r; r = p.opMyClass(p, out c1, out c2); test(Ice.Util.proxyIdentityAndFacetCompare(c1, p) == 0); test(Ice.Util.proxyIdentityAndFacetCompare(c2, p) != 0); test(Ice.Util.proxyIdentityAndFacetCompare(r, p) == 0); test(c1.ice_getIdentity().Equals(communicator.stringToIdentity("test"))); test(c2.ice_getIdentity().Equals(communicator.stringToIdentity("noSuchIdentity"))); test(r.ice_getIdentity().Equals(communicator.stringToIdentity("test"))); r.opVoid(); c1.opVoid(); try { c2.opVoid(); test(false); } catch(Ice.ObjectNotExistException) { } r = p.opMyClass(null, out c1, out c2); test(c1 == null); test(c2 != null); test(Ice.Util.proxyIdentityAndFacetCompare(r, p) == 0); r.opVoid(); } { Test.Structure si1 = new Test.Structure(); si1.p = p; si1.e = Test.MyEnum.enum3; si1.s = new Test.AnotherStruct(); si1.s.s = "abc"; Test.Structure si2 = new Test.Structure(); si2.p = null; si2.e = Test.MyEnum.enum2; si2.s = new Test.AnotherStruct(); si2.s.s = "def"; Test.Structure so; Test.Structure rso = p.opStruct(si1, si2, out so); test(rso.p == null); test(rso.e == Test.MyEnum.enum2); test(rso.s.s.Equals("def")); test(so.p.Equals(p)); test(so.e == Test.MyEnum.enum3); test(so.s.s.Equals("a new string")); so.p.opVoid(); } { byte[] tbsi1 = new byte[] { 0x01, 0x11, 0x12, 0x22 }; Test.ByteS bsi1 = new Test.ByteS(tbsi1); byte[] tbsi2 = new byte[] { 0xf1, 0xf2, 0xf3, 0xf4 }; Test.ByteS bsi2 = new Test.ByteS(tbsi2); Test.ByteS bso; Test.ByteS rso; rso = p.opByteS(bsi1, bsi2, out bso); test(bso.Count == 4); test(bso[0] == 0x22); test(bso[1] == 0x12); test(bso[2] == 0x11); test(bso[3] == 0x01); test(rso.Count == 8); test(rso[0] == 0x01); test(rso[1] == 0x11); test(rso[2] == 0x12); test(rso[3] == 0x22); test(rso[4] == 0xf1); test(rso[5] == 0xf2); test(rso[6] == 0xf3); test(rso[7] == 0xf4); } { bool[] tbsi1 = new bool[] { true, true, false }; Test.BoolS bsi1 = new Test.BoolS(tbsi1); bool[] tbsi2 = new bool[] { false }; Test.BoolS bsi2 = new Test.BoolS(tbsi2); Test.BoolS bso; Test.BoolS rso; rso = p.opBoolS(bsi1, bsi2, out bso); test(bso.Count == 4); test(bso[0]); test(bso[1]); test(!bso[2]); test(!bso[3]); test(rso.Count == 3); test(!rso[0]); test(rso[1]); test(rso[2]); } { short[] tssi = new short[] { 1, 2, 3 }; Test.ShortS ssi = new Test.ShortS(tssi); int[] tisi = new int[] { 5, 6, 7, 8 }; Test.IntS isi = new Test.IntS(tisi); long[] tlsi = new long[] { 10, 30, 20 }; Test.LongS lsi = new Test.LongS(tlsi); Test.ShortS sso; Test.IntS iso; Test.LongS lso; Test.LongS rso; rso = p.opShortIntLongS(ssi, isi, lsi, out sso, out iso, out lso); test(sso.Count == 3); test(sso[0] == 1); test(sso[1] == 2); test(sso[2] == 3); test(iso.Count == 4); test(iso[0] == 8); test(iso[1] == 7); test(iso[2] == 6); test(iso[3] == 5); test(lso.Count == 6); test(lso[0] == 10); test(lso[1] == 30); test(lso[2] == 20); test(lso[3] == 10); test(lso[4] == 30); test(lso[5] == 20); test(rso.Count == 3); test(rso[0] == 10); test(rso[1] == 30); test(rso[2] == 20); } { float[] tfsi = new float[] { 3.14f, 1.11f }; Test.FloatS fsi = new Test.FloatS(tfsi); double[] tdsi = new double[] { 1.1e10, 1.2e10, 1.3e10 }; Test.DoubleS dsi = new Test.DoubleS(tdsi); Test.FloatS fso; Test.DoubleS dso; Test.DoubleS rso; rso = p.opFloatDoubleS(fsi, dsi, out fso, out dso); test(fso.Count == 2); test(fso[0] == 3.14f); test(fso[1] == 1.11f); test(dso.Count == 3); test(dso[0] == 1.3e10); test(dso[1] == 1.2e10); test(dso[2] == 1.1e10); test(rso.Count == 5); test(rso[0] == 1.1e10); test(rso[1] == 1.2e10); test(rso[2] == 1.3e10); test((float)rso[3] == 3.14f); test((float)rso[4] == 1.11f); } { string[] tssi1 = new string[] { "abc", "de", "fghi" }; Test.StringS ssi1 = new Test.StringS(tssi1); string[] tssi2 = new string[] { "xyz" }; Test.StringS ssi2 = new Test.StringS(tssi2); Test.StringS sso; Test.StringS rso; rso = p.opStringS(ssi1, ssi2, out sso); test(sso.Count == 4); test(sso[0].Equals("abc")); test(sso[1].Equals("de")); test(sso[2].Equals("fghi")); test(sso[3].Equals("xyz")); test(rso.Count == 3); test(rso[0].Equals("fghi")); test(rso[1].Equals("de")); test(rso[2].Equals("abc")); } { Test.ByteS s11 = new Test.ByteS(new byte[] { 0x01, 0x11, 0x12 }); Test.ByteS s12 = new Test.ByteS(new byte[] { 0xff }); Test.ByteSS bsi1 = new Test.ByteSS(new Test.ByteS[] { s11, s12 }); Test.ByteS s21 = new Test.ByteS(new byte[] { 0x0e }); Test.ByteS s22 = new Test.ByteS(new byte[] { 0xf2, 0xf1 }); Test.ByteSS bsi2 = new Test.ByteSS(new Test.ByteS[] { s21, s22 }); Test.ByteSS bso; Test.ByteSS rso; rso = p.opByteSS(bsi1, bsi2, out bso); test(bso.Count == 2); test(bso[0].Count == 1); test(bso[0][0] == 0xff); test(bso[1].Count == 3); test(bso[1][0] == 0x01); test(bso[1][1] == 0x11); test(bso[1][2] == 0x12); test(rso.Count == 4); test(rso[0].Count == 3); test(rso[0][0] == 0x01); test(rso[0][1] == 0x11); test(rso[0][2] == 0x12); test(rso[1].Count == 1); test(rso[1][0] == 0xff); test(rso[2].Count == 1); test(rso[2][0] == 0x0e); test(rso[3].Count == 2); test(rso[3][0] == 0xf2); test(rso[3][1] == 0xf1); } { Test.FloatS f11 = new Test.FloatS(new float[] { 3.14f }); Test.FloatS f12 = new Test.FloatS(new float[] { 1.11f }); Test.FloatS f13 = new Test.FloatS(new float[] { }); Test.FloatSS fsi = new Test.FloatSS(new Test.FloatS[] { f11, f12, f13 }); Test.DoubleS d11 = new Test.DoubleS(new double[] { 1.1e10, 1.2e10, 1.3e10 }); Test.DoubleSS dsi = new Test.DoubleSS(new Test.DoubleS[] { d11 }); Test.FloatSS fso; Test.DoubleSS dso; Test.DoubleSS rso; rso = p.opFloatDoubleSS(fsi, dsi, out fso, out dso); test(fso.Count == 3); test(fso[0].Count == 1); test(fso[0][0] == 3.14f); test(fso[1].Count == 1); test(fso[1][0] == 1.11f); test(fso[2].Count == 0); test(dso.Count == 1); test(dso[0].Count == 3); test(dso[0][0] == 1.1e10); test(dso[0][1] == 1.2e10); test(dso[0][2] == 1.3e10); test(rso.Count == 2); test(rso[0].Count == 3); test(rso[0][0] == 1.1e10); test(rso[0][1] == 1.2e10); test(rso[0][2] == 1.3e10); test(rso[1].Count == 3); test(rso[1][0] == 1.1e10); test(rso[1][1] == 1.2e10); test(rso[1][2] == 1.3e10); } { Test.StringS s11 = new Test.StringS(); s11.Add("abc"); Test.StringS s12 = new Test.StringS(); s12.Add("de"); s12.Add("fghi"); Test.StringSS ssi1 = new Test.StringSS(); ssi1.Add(s11); ssi1.Add(s12); Test.StringS s21 = new Test.StringS(); Test.StringS s22 = new Test.StringS(); Test.StringS s23 = new Test.StringS(); s23.Add("xyz"); Test.StringSS ssi2 = new Test.StringSS(); ssi2.Add(s21); ssi2.Add(s22); ssi2.Add(s23); Test.StringSS sso; Test.StringSS rso; rso = p.opStringSS(ssi1, ssi2, out sso); test(sso.Count == 5); test(sso[0].Count == 1); test(sso[0][0].Equals("abc")); test(sso[1].Count == 2); test(sso[1][0].Equals("de")); test(sso[1][1].Equals("fghi")); test(sso[2].Count == 0); test(sso[3].Count == 0); test(sso[4].Count == 1); test(sso[4][0].Equals("xyz")); test(rso.Count == 3); test(rso[0].Count == 1); test(rso[0][0].Equals("xyz")); test(rso[1].Count == 0); test(rso[2].Count == 0); } { Test.StringSS[] sssi1 = { new Test.StringSS(), new Test.StringSS() }; sssi1[0].Add(new Test.StringS()); sssi1[0].Add(new Test.StringS()); sssi1[0][0].Add("abc"); sssi1[0][0].Add("de"); sssi1[0][1].Add("xyz"); sssi1[1].Add(new Test.StringS()); sssi1[1][0].Add("hello"); Test.StringSS[] sssi2 = { new Test.StringSS(), new Test.StringSS(), new Test.StringSS() }; sssi2[0].Add(new Test.StringS()); sssi2[0].Add(new Test.StringS()); sssi2[0][0].Add(""); sssi2[0][0].Add(""); sssi2[0][1].Add("abcd"); sssi2[1].Add(new Test.StringS()); sssi2[1][0].Add(""); Test.StringSS[] ssso; Test.StringSS[] rsso = p.opStringSSS(sssi1, sssi2, out ssso); test(ssso.Length == 5); test(ssso[0].Count == 2); test(ssso[0][0].Count == 2); test(ssso[0][1].Count == 1); test(ssso[1].Count == 1); test(ssso[1][0].Count == 1); test(ssso[2].Count == 2); test(ssso[2][0].Count == 2); test(ssso[2][1].Count == 1); test(ssso[3].Count == 1); test(ssso[3][0].Count == 1); test(ssso[4].Count == 0); test(ssso[0][0][0].Equals("abc")); test(ssso[0][0][1].Equals("de")); test(ssso[0][1][0].Equals("xyz")); test(ssso[1][0][0].Equals("hello")); test(ssso[2][0][0].Equals("")); test(ssso[2][0][1].Equals("")); test(ssso[2][1][0].Equals("abcd")); test(ssso[3][0][0].Equals("")); test(rsso.Length == 3); test(rsso[0].Count == 0); test(rsso[1].Count == 1); test(rsso[1][0].Count == 1); test(rsso[2].Count == 2); test(rsso[2][0].Count == 2); test(rsso[2][1].Count == 1); test(rsso[1][0][0].Equals("")); test(rsso[2][0][0].Equals("")); test(rsso[2][0][1].Equals("")); test(rsso[2][1][0].Equals("abcd")); } { Dictionary<byte, bool> di1 = new Dictionary<byte, bool>(); di1[10] = true; di1[100] = false; Dictionary<byte, bool> di2 = new Dictionary<byte, bool>(); di2[10] = true; di2[11] = false; di2[101] = true; Dictionary<byte, bool> _do; Dictionary<byte, bool> ro = p.opByteBoolD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[10] == true); test(ro[11] == false); test(ro[100] == false); test(ro[101] == true); } { Dictionary<short, int> di1 = new Dictionary<short, int>(); di1[110] = -1; di1[1100] = 123123; Dictionary<short, int> di2 = new Dictionary<short, int>(); di2[110] = -1; di2[111] = -100; di2[1101] = 0; Dictionary<short, int> _do; Dictionary<short, int> ro = p.opShortIntD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[110] == -1); test(ro[111] == -100); test(ro[1100] == 123123); test(ro[1101] == 0); } { Dictionary<long, float> di1 = new Dictionary<long, float>(); di1[999999110L] = -1.1f; di1[999999111L] = 123123.2f; Dictionary<long, float> di2 = new Dictionary<long, float>(); di2[999999110L] = -1.1f; di2[999999120L] = -100.4f; di2[999999130L] = 0.5f; Dictionary<long, float> _do; Dictionary<long, float> ro = p.opLongFloatD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[999999110L] == -1.1f); test(ro[999999120L] == -100.4f); test(ro[999999111L] == 123123.2f); test(ro[999999130L] == 0.5f); } { Dictionary<string, string> di1 = new Dictionary<string, string>(); di1["foo"] = "abc -1.1"; di1["bar"] = "abc 123123.2"; Dictionary<string, string> di2 = new Dictionary<string, string>(); di2["foo"] = "abc -1.1"; di2["FOO"] = "abc -100.4"; di2["BAR"] = "abc 0.5"; Dictionary<string, string> _do; Dictionary<string, string> ro = p.opStringStringD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro["foo"].Equals("abc -1.1")); test(ro["FOO"].Equals("abc -100.4")); test(ro["bar"].Equals("abc 123123.2")); test(ro["BAR"].Equals("abc 0.5")); } { Dictionary<string, Test.MyEnum> di1 = new Dictionary<string, Test.MyEnum>(); di1["abc"] = Test.MyEnum.enum1; di1[""] = Test.MyEnum.enum2; Dictionary<string, Test.MyEnum> di2 = new Dictionary<string, Test.MyEnum>(); di2["abc"] = Test.MyEnum.enum1; di2["qwerty"] = Test.MyEnum.enum3; di2["Hello!!"] = Test.MyEnum.enum2; Dictionary<string, Test.MyEnum> _do; Dictionary<string, Test.MyEnum> ro = p.opStringMyEnumD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro["abc"] == Test.MyEnum.enum1); test(ro["qwerty"] == Test.MyEnum.enum3); test(ro[""] == Test.MyEnum.enum2); test(ro["Hello!!"] == Test.MyEnum.enum2); } { Dictionary<Test.MyEnum, string> di1 = new Dictionary<Test.MyEnum, string>(); di1[Test.MyEnum.enum1] = "abc"; Dictionary<Test.MyEnum, string> di2 = new Dictionary<Test.MyEnum, string>(); di2[Test.MyEnum.enum2] = "Hello!!"; di2[Test.MyEnum.enum3] = "qwerty"; Dictionary<Test.MyEnum, string> _do; Dictionary<Test.MyEnum, string> ro = p.opMyEnumStringD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 3); test(ro[Test.MyEnum.enum1].Equals("abc")); test(ro[Test.MyEnum.enum2].Equals("Hello!!")); test(ro[Test.MyEnum.enum3].Equals("qwerty")); } { Test.MyStruct s11 = new Test.MyStruct(1, 1); Test.MyStruct s12 = new Test.MyStruct(1, 2); Dictionary<Test.MyStruct, Test.MyEnum> di1 = new Dictionary<Test.MyStruct, Test.MyEnum>(); di1[s11] = Test.MyEnum.enum1; di1[s12] = Test.MyEnum.enum2; Test.MyStruct s22 = new Test.MyStruct(2, 2); Test.MyStruct s23 = new Test.MyStruct(2, 3); Dictionary<Test.MyStruct, Test.MyEnum> di2 = new Dictionary<Test.MyStruct, Test.MyEnum>(); di2[s11] = Test.MyEnum.enum1; di2[s22] = Test.MyEnum.enum3; di2[s23] = Test.MyEnum.enum2; Dictionary<Test.MyStruct, Test.MyEnum> _do; Dictionary<Test.MyStruct, Test.MyEnum> ro = p.opMyStructMyEnumD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[s11] == Test.MyEnum.enum1); test(ro[s12] == Test.MyEnum.enum2); test(ro[s22] == Test.MyEnum.enum3); test(ro[s23] == Test.MyEnum.enum2); } { int[] lengths = new int[] { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; for(int l = 0; l < lengths.Length; ++l) { Test.IntS s = new Test.IntS(); for(int i = 0; i < lengths[l]; ++i) { s.Add(i); } Test.IntS r = p.opIntS(s); test(r.Count == lengths[l]); for(int j = 0; j < r.Count; ++j) { test(r[j] == -j); } } } { Dictionary<string, string> ctx = new Dictionary<string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; { test(p.ice_getContext().Count == 0); Dictionary<string, string> r = p.opContext(); test(!r.Equals(ctx)); } { Dictionary<string, string> r = p.opContext(ctx); test(p.ice_getContext().Count == 0); test(Ice.CollectionComparer.Equals(r, ctx)); } { Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); test(Ice.CollectionComparer.Equals(p2.ice_getContext(), ctx)); Dictionary<string, string> r = p2.opContext(); test(Ice.CollectionComparer.Equals(r, ctx)); r = p2.opContext(ctx); test(Ice.CollectionComparer.Equals(r, ctx)); } } { // // Test implicit context propagation // String[] impls = {"Shared", "PerThread"}; for(int i = 0; i < 2; i++) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.ImplicitContext", impls[i]); Ice.Communicator ic = Ice.Util.initialize(initData); Dictionary<string, string> ctx = new Dictionary<string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; Test.MyClassPrx p3 = Test.MyClassPrxHelper.uncheckedCast( ic.stringToProxy("test:default -p 12010")); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(ic.getImplicitContext().getContext(), ctx)); test(Ice.CollectionComparer.Equals(p3.opContext(), ctx)); test(ic.getImplicitContext().containsKey("zero") == false); String r = ic.getImplicitContext().put("zero", "ZERO"); test(r.Equals("")); test(ic.getImplicitContext().get("zero").Equals("ZERO")); ctx = ic.getImplicitContext().getContext(); test(Ice.CollectionComparer.Equals(p3.opContext(), ctx)); Dictionary<string, string> prxContext = new Dictionary<string, string>(); prxContext["one"] = "UN"; prxContext["four"] = "QUATRE"; Dictionary<string, string> combined = new Dictionary<string, string>(prxContext); foreach(KeyValuePair<string, string> e in ctx) { try { combined.Add(e.Key, e.Value); } catch(System.ArgumentException) { // Ignore. } } test(combined["one"].Equals("UN")); p3 = Test.MyClassPrxHelper.uncheckedCast(p3.ice_context(prxContext)); ic.getImplicitContext().setContext(null); test(Ice.CollectionComparer.Equals(p3.opContext(), prxContext)); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(p3.opContext(), combined)); test(ic.getImplicitContext().remove("one").Equals("ONE")); if(impls[i].Equals("PerThread")) { PerThreadContextInvokeThread thread = new PerThreadContextInvokeThread( Test.MyClassPrxHelper.uncheckedCast(p3.ice_context(null))); thread.Start(); thread.Join(); } ic.destroy(); } } { p.opIdempotent(); } { p.opNonmutating(); } }
internal static void twowaysNewAMI(Ice.Communicator communicator, Test.MyClassPrx p) { { Ice.AsyncResult r = p.begin_ice_ping(); p.end_ice_ping(r); } { Callback cb = new Callback(); p.begin_ice_ping().whenCompleted(cb.ice_ping, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_ice_isA(Test.MyClass.ice_staticId()); test(p.end_ice_isA(r)); } { Callback cb = new Callback(); p.begin_ice_isA(Test.MyClass.ice_staticId()).whenCompleted(cb.ice_isA, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_ice_ids(); test(p.end_ice_ids(r).Length == 3); } { Callback cb = new Callback(); p.begin_ice_ids().whenCompleted(cb.ice_ids, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_ice_id(); test(p.end_ice_id(r).Equals(Test.MyDerivedClass.ice_staticId())); } { Callback cb = new Callback(); p.begin_ice_id().whenCompleted(cb.ice_id, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_opVoid(); p.end_opVoid(r); } { Callback cb = new Callback(); p.begin_opVoid().whenCompleted(cb.opVoid, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_opByte(0xff, 0x0f); byte p3; byte ret = p.end_opByte(out p3, r); test(p3 == 0xf0); test(ret == 0xff); } { Callback cb = new Callback(); p.begin_opByte(0xff, 0x0f).whenCompleted(cb.opByte, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opBool(true, false).whenCompleted(cb.opBool, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opShortIntLong(10, 11, 12).whenCompleted(cb.opShortIntLong, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opFloatDouble(3.14f, 1.1E10).whenCompleted(cb.opFloatDouble, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opString("hello", "world").whenCompleted(cb.opString, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opMyEnum(Test.MyEnum.enum2).whenCompleted(cb.opMyEnum, cb.exCB); cb.check(); } { Callback cb = new Callback(communicator); p.begin_opMyClass(p).whenCompleted(cb.opMyClass, cb.exCB); cb.check(); } { Test.Structure si1 = new Test.Structure(); si1.p = p; si1.e = Test.MyEnum.enum3; si1.s = new Test.AnotherStruct(); si1.s.s = "abc"; Test.Structure si2 = new Test.Structure(); si2.p = null; si2.e = Test.MyEnum.enum2; si2.s = new Test.AnotherStruct(); si2.s.s = "def"; Callback cb = new Callback(communicator); p.begin_opStruct(si1, si2).whenCompleted(cb.opStruct, cb.exCB); cb.check(); } { byte[] tbsi1 = new byte[] { 0x01, 0x11, 0x12, 0x22 }; Test.ByteS bsi1 = new Test.ByteS(tbsi1); byte[] tbsi2 = new byte[] { 0xf1, 0xf2, 0xf3, 0xf4 }; Test.ByteS bsi2 = new Test.ByteS(tbsi2); Callback cb = new Callback(); p.begin_opByteS(bsi1, bsi2).whenCompleted(cb.opByteS, cb.exCB); cb.check(); } { bool[] tbsi1 = new bool[] { true, true, false }; Test.BoolS bsi1 = new Test.BoolS(tbsi1); bool[] tbsi2 = new bool[] { false }; Test.BoolS bsi2 = new Test.BoolS(tbsi2); Callback cb = new Callback(); p.begin_opBoolS(bsi1, bsi2).whenCompleted(cb.opBoolS, cb.exCB); cb.check(); } { short[] tssi = new short[] { 1, 2, 3 }; Test.ShortS ssi = new Test.ShortS(tssi); int[] tisi = new int[] { 5, 6, 7, 8 }; Test.IntS isi = new Test.IntS(tisi); long[] tlsi = new long[] { 10, 30, 20 }; Test.LongS lsi = new Test.LongS(tlsi); Callback cb = new Callback(); p.begin_opShortIntLongS(ssi, isi, lsi).whenCompleted(cb.opShortIntLongS, cb.exCB); cb.check(); } { float[] tfsi = new float[] { 3.14f, 1.11f }; Test.FloatS fsi = new Test.FloatS(tfsi); double[] tdsi = new double[] { 1.1e10, 1.2e10, 1.3e10 }; Test.DoubleS dsi = new Test.DoubleS(tdsi); Callback cb = new Callback(); p.begin_opFloatDoubleS(fsi, dsi).whenCompleted(cb.opFloatDoubleS, cb.exCB); cb.check(); } { string[] tssi1 = new string[] { "abc", "de", "fghi" }; Test.StringS ssi1 = new Test.StringS(tssi1); string[] tssi2 = new string[] { "xyz" }; Test.StringS ssi2 = new Test.StringS(tssi2); Callback cb = new Callback(); p.begin_opStringS(ssi1, ssi2).whenCompleted(cb.opStringS, cb.exCB); cb.check(); } { Test.ByteS s11 = new Test.ByteS(new byte[] { 0x01, 0x11, 0x12 }); Test.ByteS s12 = new Test.ByteS(new byte[] { 0xff }); Test.ByteSS bsi1 = new Test.ByteSS(new Test.ByteS[] { s11, s12 }); Test.ByteS s21 = new Test.ByteS(new byte[] { 0x0e }); Test.ByteS s22 = new Test.ByteS(new byte[] { 0xf2, 0xf1 }); Test.ByteSS bsi2 = new Test.ByteSS(new Test.ByteS[] { s21, s22 }); Callback cb = new Callback(); p.begin_opByteSS(bsi1, bsi2).whenCompleted(cb.opByteSS, cb.exCB); cb.check(); } { Test.FloatS f11 = new Test.FloatS(new float[] { 3.14f }); Test.FloatS f12 = new Test.FloatS(new float[] { 1.11f }); Test.FloatS f13 = new Test.FloatS(new float[] { }); Test.FloatSS fsi = new Test.FloatSS(new Test.FloatS[] { f11, f12, f13 }); Test.DoubleS d11 = new Test.DoubleS(new double[] { 1.1e10, 1.2e10, 1.3e10 }); Test.DoubleSS dsi = new Test.DoubleSS(new Test.DoubleS[] { d11 }); Callback cb = new Callback(); p.begin_opFloatDoubleSS(fsi, dsi).whenCompleted(cb.opFloatDoubleSS, cb.exCB); cb.check(); } { Test.StringS s11 = new Test.StringS(); s11.Add("abc"); Test.StringS s12 = new Test.StringS(); s12.Add("de"); s12.Add("fghi"); Test.StringSS ssi1 = new Test.StringSS(); ssi1.Add(s11); ssi1.Add(s12); Test.StringS s21 = new Test.StringS(); Test.StringS s22 = new Test.StringS(); Test.StringS s23 = new Test.StringS(); s23.Add("xyz"); Test.StringSS ssi2 = new Test.StringSS(); ssi2.Add(s21); ssi2.Add(s22); ssi2.Add(s23); Callback cb = new Callback(); p.begin_opStringSS(ssi1, ssi2).whenCompleted(cb.opStringSS, cb.exCB); cb.check(); } { Test.StringSS[] sssi1 = { new Test.StringSS(), new Test.StringSS() }; sssi1[0].Add(new Test.StringS()); sssi1[0].Add(new Test.StringS()); sssi1[0][0].Add("abc"); sssi1[0][0].Add("de"); sssi1[0][1].Add("xyz"); sssi1[1].Add(new Test.StringS()); sssi1[1][0].Add("hello"); Test.StringSS[] sssi2 = { new Test.StringSS(), new Test.StringSS(), new Test.StringSS() }; sssi2[0].Add(new Test.StringS()); sssi2[0].Add(new Test.StringS()); sssi2[0][0].Add(""); sssi2[0][0].Add(""); sssi2[0][1].Add("abcd"); sssi2[1].Add(new Test.StringS()); sssi2[1][0].Add(""); Callback cb = new Callback(); p.begin_opStringSSS(sssi1, sssi2).whenCompleted(cb.opStringSSS, cb.exCB); cb.check(); } { Dictionary <byte, bool> di1 = new Dictionary <byte, bool>(); di1[10] = true; di1[100] = false; Dictionary <byte, bool> di2 = new Dictionary <byte, bool>(); di2[10] = true; di2[11] = false; di2[101] = true; Callback cb = new Callback(); p.begin_opByteBoolD(di1, di2).whenCompleted(cb.opByteBoolD, cb.exCB); cb.check(); } { Dictionary <short, int> di1 = new Dictionary <short, int>(); di1[110] = -1; di1[1100] = 123123; Dictionary <short, int> di2 = new Dictionary <short, int>(); di2[110] = -1; di2[111] = -100; di2[1101] = 0; Callback cb = new Callback(); p.begin_opShortIntD(di1, di2).whenCompleted(cb.opShortIntD, cb.exCB); cb.check(); } { Dictionary <long, float> di1 = new Dictionary <long, float>(); di1[999999110L] = -1.1f; di1[999999111L] = 123123.2f; Dictionary <long, float> di2 = new Dictionary <long, float>(); di2[999999110L] = -1.1f; di2[999999120L] = -100.4f; di2[999999130L] = 0.5f; Callback cb = new Callback(); p.begin_opLongFloatD(di1, di2).whenCompleted(cb.opLongFloatD, cb.exCB); cb.check(); } { Dictionary <string, string> di1 = new Dictionary <string, string>(); di1["foo"] = "abc -1.1"; di1["bar"] = "abc 123123.2"; Dictionary <string, string> di2 = new Dictionary <string, string>(); di2["foo"] = "abc -1.1"; di2["FOO"] = "abc -100.4"; di2["BAR"] = "abc 0.5"; Callback cb = new Callback(); p.begin_opStringStringD(di1, di2).whenCompleted(cb.opStringStringD, cb.exCB); cb.check(); } { Dictionary <string, Test.MyEnum> di1 = new Dictionary <string, Test.MyEnum>(); di1["abc"] = Test.MyEnum.enum1; di1[""] = Test.MyEnum.enum2; Dictionary <string, Test.MyEnum> di2 = new Dictionary <string, Test.MyEnum>(); di2["abc"] = Test.MyEnum.enum1; di2["qwerty"] = Test.MyEnum.enum3; di2["Hello!!"] = Test.MyEnum.enum2; Callback cb = new Callback(); p.begin_opStringMyEnumD(di1, di2).whenCompleted(cb.opStringMyEnumD, cb.exCB); cb.check(); } { Dictionary <Test.MyEnum, string> di1 = new Dictionary <Test.MyEnum, string>(); di1[Test.MyEnum.enum1] = "abc"; Dictionary <Test.MyEnum, string> di2 = new Dictionary <Test.MyEnum, string>(); di2[Test.MyEnum.enum2] = "Hello!!"; di2[Test.MyEnum.enum3] = "qwerty"; Callback cb = new Callback(); p.begin_opMyEnumStringD(di1, di2).whenCompleted(cb.opMyEnumStringD, cb.exCB); cb.check(); } { Test.MyStruct s11 = new Test.MyStruct(1, 1); Test.MyStruct s12 = new Test.MyStruct(1, 2); Dictionary <Test.MyStruct, Test.MyEnum> di1 = new Dictionary <Test.MyStruct, Test.MyEnum>(); di1[s11] = Test.MyEnum.enum1; di1[s12] = Test.MyEnum.enum2; Test.MyStruct s22 = new Test.MyStruct(2, 2); Test.MyStruct s23 = new Test.MyStruct(2, 3); Dictionary <Test.MyStruct, Test.MyEnum> di2 = new Dictionary <Test.MyStruct, Test.MyEnum>(); di2[s11] = Test.MyEnum.enum1; di2[s22] = Test.MyEnum.enum3; di2[s23] = Test.MyEnum.enum2; Callback cb = new Callback(); p.begin_opMyStructMyEnumD(di1, di2).whenCompleted(cb.opMyStructMyEnumD, cb.exCB); cb.check(); } { int[] lengths = new int[] { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; for (int l = 0; l < lengths.Length; ++l) { Test.IntS s = new Test.IntS(); for (int i = 0; i < lengths[l]; ++i) { s.Add(i); } Callback cb = new Callback(lengths[l]); p.begin_opIntS(s).whenCompleted(cb.opIntS, cb.exCB); cb.check(); } } { Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; { test(p.ice_getContext().Count == 0); Callback cb = new Callback(ctx); p.begin_opContext().whenCompleted(cb.opContextNotEqual, cb.exCB); cb.check(); } { test(p.ice_getContext().Count == 0); Callback cb = new Callback(ctx); p.begin_opContext(ctx).whenCompleted(cb.opContextEqual, cb.exCB); cb.check(); } { Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); test(Ice.CollectionComparer.Equals(p2.ice_getContext(), ctx)); Callback cb = new Callback(ctx); p2.begin_opContext().whenCompleted(cb.opContextEqual, cb.exCB); cb.check(); } { Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); Callback cb = new Callback(ctx); p2.begin_opContext(ctx).whenCompleted(cb.opContextEqual, cb.exCB); cb.check(); } } { // // Test implicit context propagation // string[] impls = { "Shared", "PerThread" }; for (int i = 0; i < 2; i++) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.ImplicitContext", impls[i]); Ice.Communicator ic = Ice.Util.initialize(initData); Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; Test.MyClassPrx p3 = Test.MyClassPrxHelper.uncheckedCast( ic.stringToProxy("test:default -p 12010")); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(ic.getImplicitContext().getContext(), ctx)); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary <string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, ctx)); } ic.getImplicitContext().put("zero", "ZERO"); ctx = ic.getImplicitContext().getContext(); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary <string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, ctx)); } Dictionary <string, string> prxContext = new Dictionary <string, string>(); prxContext["one"] = "UN"; prxContext["four"] = "QUATRE"; Dictionary <string, string> combined = prxContext; foreach (KeyValuePair <string, string> e in ctx) { try { combined.Add(e.Key, e.Value); } catch (System.ArgumentException) { // Ignore. } } test(combined["one"].Equals("UN")); p3 = Test.MyClassPrxHelper.uncheckedCast(p.ice_context(prxContext)); ic.getImplicitContext().setContext(null); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary <string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, prxContext)); } ic.getImplicitContext().setContext(ctx); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary <string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, combined)); } //ic.getImplicitContext().setContext(null); ic.destroy(); } } { Ice.AsyncResult r = p.begin_opIdempotent(); p.end_opIdempotent(r); } { Callback cb = new Callback(); p.begin_opIdempotent().whenCompleted(cb.opIdempotent, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_opNonmutating(); p.end_opNonmutating(r); } { Callback cb = new Callback(); p.begin_opNonmutating().whenCompleted(cb.opNonmutating, cb.exCB); cb.check(); } { Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(p); test(derived != null); Callback cb = new Callback(); derived.begin_opDerived().whenCompleted(cb.opDerived, cb.exCB); cb.check(); } }
internal static void twowaysAMI(Ice.Communicator communicator, Test.MyClassPrx p) { { // Check that a call to a void operation raises NoEndpointException // in the ice_exception() callback instead of at the point of call. Test.MyClassPrx indirect = Test.MyClassPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); AMI_MyClass_opVoidExI cb = new AMI_MyClass_opVoidExI(); try { test(!indirect.opVoid_async(cb)); } catch (Ice.Exception) { test(false); } cb.check(); } { // Check that a call to a twoway operation raises NoEndpointException // in the ice_exception() callback instead of at the point of call. Test.MyClassPrx indirect = Test.MyClassPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); AMI_MyClass_opByteExI cb = new AMI_MyClass_opByteExI(); try { test(!indirect.opByte_async(cb, (byte)0, (byte)0)); } catch (Ice.Exception) { test(false); } cb.check(); } { AMI_MyClass_opVoidI cb = new AMI_MyClass_opVoidI(); p.opVoid_async(cb); cb.check(); // Let's check if we can reuse the callback object for another call. p.opVoid_async(cb); cb.check(); } { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); Ice.Communicator ic = Ice.Util.initialize(initData); Ice.ObjectPrx obj = ic.stringToProxy(p.ToString()); Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(obj); ic.destroy(); AMI_MyClass_opVoidI cb = new AMI_MyClass_opVoidI(); try { test(!p2.opVoid_async(cb)); test(false); } catch (Ice.CommunicatorDestroyedException) { // Expected. } } { AMI_MyClass_opByteI cb = new AMI_MyClass_opByteI(); p.opByte_async(cb, 0xff, 0x0f); cb.check(); } { AMI_MyClass_opBoolI cb = new AMI_MyClass_opBoolI(); p.opBool_async(cb, true, false); cb.check(); } { AMI_MyClass_opShortIntLongI cb = new AMI_MyClass_opShortIntLongI(); p.opShortIntLong_async(cb, (short)10, 11, 12L); cb.check(); } { AMI_MyClass_opFloatDoubleI cb = new AMI_MyClass_opFloatDoubleI(); p.opFloatDouble_async(cb, 3.14f, 1.1e10); cb.check(); } { AMI_MyClass_opStringI cb = new AMI_MyClass_opStringI(); p.opString_async(cb, "hello", "world"); cb.check(); } { AMI_MyClass_opMyEnumI cb = new AMI_MyClass_opMyEnumI(); p.opMyEnum_async(cb, Test.MyEnum.enum2); cb.check(); } { AMI_MyClass_opMyClassI cb = new AMI_MyClass_opMyClassI(communicator); p.opMyClass_async(cb, p); cb.check(); } { Test.Structure si1 = new Test.Structure(); si1.p = p; si1.e = Test.MyEnum.enum3; si1.s = new Test.AnotherStruct(); si1.s.s = "abc"; Test.Structure si2 = new Test.Structure(); si2.p = null; si2.e = Test.MyEnum.enum2; si2.s = new Test.AnotherStruct(); si2.s.s = "def"; AMI_MyClass_opStructI cb = new AMI_MyClass_opStructI(communicator); p.opStruct_async(cb, si1, si2); cb.check(); } { Test.ByteS bsi1 = new Test.ByteS(new byte[] { 0x01, 0x11, 0x12, 0x22 }); Test.ByteS bsi2 = new Test.ByteS(new byte[] { 0xf1, 0xf2, 0xf3, 0xf4 }); AMI_MyClass_opByteSI cb = new AMI_MyClass_opByteSI(); p.opByteS_async(cb, bsi1, bsi2); cb.check(); } { Test.BoolS bsi1 = new Test.BoolS(new bool[] { true, true, false }); Test.BoolS bsi2 = new Test.BoolS(new bool[] { false }); AMI_MyClass_opBoolSI cb = new AMI_MyClass_opBoolSI(); p.opBoolS_async(cb, bsi1, bsi2); cb.check(); } { Test.ShortS ssi = new Test.ShortS(new short[] { 1, 2, 3 }); Test.IntS isi = new Test.IntS(new int[] { 5, 6, 7, 8 }); Test.LongS lsi = new Test.LongS(new long[] { 10, 30, 20 }); AMI_MyClass_opShortIntLongSI cb = new AMI_MyClass_opShortIntLongSI(); p.opShortIntLongS_async(cb, ssi, isi, lsi); cb.check(); } { Test.FloatS fsi = new Test.FloatS(new float[] { 3.14f, 1.11f }); Test.DoubleS dsi = new Test.DoubleS(new double[] { 1.1e10, 1.2e10, 1.3e10 }); AMI_MyClass_opFloatDoubleSI cb = new AMI_MyClass_opFloatDoubleSI(); p.opFloatDoubleS_async(cb, fsi, dsi); cb.check(); } { Test.StringS ssi1 = new Test.StringS(new string[] { "abc", "de", "fghi" }); Test.StringS ssi2 = new Test.StringS(new string[] { "xyz" }); AMI_MyClass_opStringSI cb = new AMI_MyClass_opStringSI(); p.opStringS_async(cb, ssi1, ssi2); cb.check(); } { Test.ByteSS bsi1 = new Test.ByteSS(); bsi1.Add(new Test.ByteS()); bsi1.Add(new Test.ByteS()); bsi1[0].Add(0x01); bsi1[0].Add(0x11); bsi1[0].Add(0x12); bsi1[1].Add(0xff); Test.ByteSS bsi2 = new Test.ByteSS(); bsi2.Add(new Test.ByteS()); bsi2.Add(new Test.ByteS()); bsi2[0].Add(0x0e); bsi2[1].Add(0xf2); bsi2[1].Add(0xf1); AMI_MyClass_opByteSSI cb = new AMI_MyClass_opByteSSI(); p.opByteSS_async(cb, bsi1, bsi2); cb.check(); } { Test.FloatSS fsi = new Test.FloatSS(); fsi.Add(new Test.FloatS(new float[] { 3.14f })); fsi.Add(new Test.FloatS(new float[] { 1.11f })); fsi.Add(new Test.FloatS(new float[] { })); Test.DoubleSS dsi = new Test.DoubleSS(); dsi.Add(new Test.DoubleS(new double[] { 1.1E10, 1.2E10, 1.3E10 })); AMI_MyClass_opFloatDoubleSSI cb = new AMI_MyClass_opFloatDoubleSSI(); p.opFloatDoubleSS_async(cb, fsi, dsi); cb.check(); } { Test.StringSS ssi1 = new Test.StringSS(); ssi1.Add(new Test.StringS()); ssi1.Add(new Test.StringS()); ssi1[0].Add("abc"); ssi1[1].Add("de"); ssi1[1].Add("fghi"); Test.StringSS ssi2 = new Test.StringSS(); ssi2.Add(new Test.StringS()); ssi2.Add(new Test.StringS()); ssi2.Add(new Test.StringS()); ssi2[2].Add("xyz"); AMI_MyClass_opStringSSI cb = new AMI_MyClass_opStringSSI(); p.opStringSS_async(cb, ssi1, ssi2); cb.check(); } { Test.StringSS[] sssi1 = { new Test.StringSS(), new Test.StringSS() }; sssi1[0].Add(new Test.StringS()); sssi1[0].Add(new Test.StringS()); sssi1[0][0].Add("abc"); sssi1[0][0].Add("de"); sssi1[0][1].Add("xyz"); sssi1[1].Add(new Test.StringS()); sssi1[1][0].Add("hello"); Test.StringSS[] sssi2 = { new Test.StringSS(), new Test.StringSS(), new Test.StringSS() }; sssi2[0].Add(new Test.StringS()); sssi2[0].Add(new Test.StringS()); sssi2[0][0].Add(""); sssi2[0][0].Add(""); sssi2[0][1].Add("abcd"); sssi2[1].Add(new Test.StringS()); sssi2[1][0].Add(""); AMI_MyClass_opStringSSSI cb = new AMI_MyClass_opStringSSSI(); p.opStringSSS_async(cb, sssi1, sssi2); cb.check(); } { Dictionary <byte, bool> di1 = new Dictionary <byte, bool>(); di1[10] = true; di1[100] = false; Dictionary <byte, bool> di2 = new Dictionary <byte, bool>(); // di2[10] = true; // Disabled since new dictionary mapping. di2[11] = false; di2[101] = true; AMI_MyClass_opByteBoolDI cb = new AMI_MyClass_opByteBoolDI(); p.opByteBoolD_async(cb, di1, di2); cb.check(); } { Dictionary <short, int> di1 = new Dictionary <short, int>(); di1[110] = -1; di1[1100] = 123123; Dictionary <short, int> di2 = new Dictionary <short, int>(); // di2[110] = -1; // Disabled since new dictionary mapping. di2[111] = -100; di2[1101] = 0; AMI_MyClass_opShortIntDI cb = new AMI_MyClass_opShortIntDI(); p.opShortIntD_async(cb, di1, di2); cb.check(); } { Dictionary <long, float> di1 = new Dictionary <long, float>(); di1[999999110L] = -1.1f; di1[999999111L] = 123123.2f; Dictionary <long, float> di2 = new Dictionary <long, float>(); // di2[999999110L] = -1.1f; // Disabled since new dictionary mapping. di2[999999120L] = -100.4f; di2[999999130L] = 0.5f; AMI_MyClass_opLongFloatDI cb = new AMI_MyClass_opLongFloatDI(); p.opLongFloatD_async(cb, di1, di2); cb.check(); } { Dictionary <string, string> di1 = new Dictionary <string, string>(); di1["foo"] = "abc -1.1"; di1["bar"] = "abc 123123.2"; Dictionary <string, string> di2 = new Dictionary <string, string>(); // di2["foo"] = "abc -1.1"; // Disabled since new dictionary mapping di2["FOO"] = "abc -100.4"; di2["BAR"] = "abc 0.5"; AMI_MyClass_opStringStringDI cb = new AMI_MyClass_opStringStringDI(); p.opStringStringD_async(cb, di1, di2); cb.check(); } { Dictionary <string, Test.MyEnum> di1 = new Dictionary <string, Test.MyEnum>(); di1["abc"] = Test.MyEnum.enum1; di1[""] = Test.MyEnum.enum2; Dictionary <string, Test.MyEnum> di2 = new Dictionary <string, Test.MyEnum>(); // di2["abc"] = Test.MyEnum.enum1; // Disabled since new dictionary mapping di2["qwerty"] = Test.MyEnum.enum3; di2["Hello!!"] = Test.MyEnum.enum2; AMI_MyClass_opStringMyEnumDI cb = new AMI_MyClass_opStringMyEnumDI(); p.opStringMyEnumD_async(cb, di1, di2); cb.check(); } { Dictionary <Test.MyEnum, string> di1 = new Dictionary <Test.MyEnum, string>(); di1[Test.MyEnum.enum1] = "abc"; Dictionary <Test.MyEnum, string> di2 = new Dictionary <Test.MyEnum, string>(); di2[Test.MyEnum.enum2] = "Hello!!"; di2[Test.MyEnum.enum3] = "qwerty"; AMI_MyClass_opMyEnumStringDI cb = new AMI_MyClass_opMyEnumStringDI(); p.opMyEnumStringD_async(cb, di1, di2); cb.check(); } { Test.MyStruct s11 = new Test.MyStruct(1, 1); Test.MyStruct s12 = new Test.MyStruct(1, 2); Dictionary <Test.MyStruct, Test.MyEnum> di1 = new Dictionary <Test.MyStruct, Test.MyEnum>(); di1[s11] = Test.MyEnum.enum1; di1[s12] = Test.MyEnum.enum2; Test.MyStruct s22 = new Test.MyStruct(2, 2); Test.MyStruct s23 = new Test.MyStruct(2, 3); Dictionary <Test.MyStruct, Test.MyEnum> di2 = new Dictionary <Test.MyStruct, Test.MyEnum>(); di2[s22] = Test.MyEnum.enum3; di2[s23] = Test.MyEnum.enum2; AMI_MyClass_opMyStructMyEnumDI cb = new AMI_MyClass_opMyStructMyEnumDI(); p.opMyStructMyEnumD_async(cb, di1, di2); cb.check(); } { int[] lengths = new int[] { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; for (int l = 0; l < lengths.Length; ++l) { Test.IntS s = new Test.IntS(); for (int i = 0; i < lengths[l]; ++i) { s.Add(i); } AMI_MyClass_opIntSI cb = new AMI_MyClass_opIntSI(lengths[l]); p.opIntS_async(cb, s); cb.check(); } } { Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; { test(p.ice_getContext().Count == 0); AMI_MyClass_opContextNotEqualI cb = new AMI_MyClass_opContextNotEqualI(ctx); p.opContext_async(cb); cb.check(); } { test(p.ice_getContext().Count == 0); AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p.opContext_async(cb, ctx); cb.check(); } Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); test(Ice.CollectionComparer.Equals(p2.ice_getContext(), ctx)); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p2.opContext_async(cb); cb.check(); } { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p2.opContext_async(cb, ctx); cb.check(); } } { // // Test implicit context propagation // string[] impls = { "Shared", "PerThread" }; for (int i = 0; i < 2; i++) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.ImplicitContext", impls[i]); Ice.Communicator ic = Ice.Util.initialize(initData); Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; Test.MyClassPrx p3 = Test.MyClassPrxHelper.uncheckedCast( ic.stringToProxy("test:default -p 12010")); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(ic.getImplicitContext().getContext(), ctx)); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p3.opContext_async(cb); cb.check(); } ic.getImplicitContext().put("zero", "ZERO"); ctx = ic.getImplicitContext().getContext(); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p3.opContext_async(cb); cb.check(); } Dictionary <string, string> prxContext = new Dictionary <string, string>(); prxContext["one"] = "UN"; prxContext["four"] = "QUATRE"; Dictionary <string, string> combined = new Dictionary <string, string>(prxContext); foreach (KeyValuePair <string, string> e in ctx) { try { combined.Add(e.Key, e.Value); } catch (System.ArgumentException) { // Ignore. } } test(combined["one"].Equals("UN")); p3 = Test.MyClassPrxHelper.uncheckedCast(p3.ice_context(prxContext)); ic.getImplicitContext().setContext(null); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(prxContext); p3.opContext_async(cb); cb.check(); } ic.getImplicitContext().setContext(ctx); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(combined); p3.opContext_async(cb); cb.check(); } ic.getImplicitContext().setContext(null); ic.destroy(); } } { AMI_MyClass_opIdempotentI cb = new AMI_MyClass_opIdempotentI(); p.opIdempotent_async(cb); cb.check(); } { AMI_MyClass_opNonmutatingI cb = new AMI_MyClass_opNonmutatingI(); p.opNonmutating_async(cb); cb.check(); } { Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(p); test(derived != null); AMI_MyDerivedClass_opDerivedI cb = new AMI_MyDerivedClass_opDerivedI(); derived.opDerived_async(cb); cb.check(); } }
public override Test.StringSS[] opStringSSS(Test.StringSS[] p1, Test.StringSS[] p2, out Test.StringSS[] p3, Ice.Current current) { p3 = new Test.StringSS[p1.Length + p2.Length]; p1.CopyTo(p3, 0); p2.CopyTo(p3, p1.Length); Test.StringSS[] r = new Test.StringSS[p2.Length]; for(int i = 0; i < p2.Length; i++) { r[i] = p2[p2.Length - (i + 1)]; } return r; }
internal static void twoways(Ice.Communicator communicator, Test.MyClassPrx p) { p.ice_ping(); test(p.ice_isA(Test.MyClass.ice_staticId())); test(p.ice_id().Equals(Test.MyDerivedClass.ice_staticId())); { string[] ids = p.ice_ids(); test(ids.Length == 3); test(ids[0].Equals("::Ice::Object")); test(ids[1].Equals("::Test::MyClass")); test(ids[2].Equals("::Test::MyDerivedClass")); } { p.opVoid(); } { byte b; byte r; r = p.opByte(0xff, 0x0f, out b); test(b == 0xf0); test(r == 0xff); } { bool b; bool r; r = p.opBool(true, false, out b); test(b); test(!r); } { short s; int i; long l; long r; r = p.opShortIntLong(10, 11, 12L, out s, out i, out l); test(s == 10); test(i == 11); test(l == 12); test(r == 12L); r = p.opShortIntLong(Int16.MinValue, Int32.MinValue, Int64.MinValue, out s, out i, out l); test(s == Int16.MinValue); test(i == Int32.MinValue); test(l == Int64.MinValue); test(r == Int64.MinValue); r = p.opShortIntLong(Int16.MaxValue, Int32.MaxValue, Int64.MaxValue, out s, out i, out l); test(s == Int16.MaxValue); test(i == Int32.MaxValue); test(l == Int64.MaxValue); test(r == Int64.MaxValue); } { float f; double d; double r; r = p.opFloatDouble(3.14f, 1.1e10, out f, out d); test(f == 3.14f); test(d == 1.1e10); test(r == 1.1e10); r = p.opFloatDouble(Single.Epsilon, Double.MinValue, out f, out d); test(f == Single.Epsilon); test(d == Double.MinValue); test(r == Double.MinValue); r = p.opFloatDouble(Single.MaxValue, Double.MaxValue, out f, out d); test(f == Single.MaxValue); test(d == Double.MaxValue); test(r == Double.MaxValue); } { string s; string r; r = p.opString("hello", "world", out s); test(s.Equals("world hello")); test(r.Equals("hello world")); } { Test.MyEnum e; Test.MyEnum r; r = p.opMyEnum(Test.MyEnum.enum2, out e); test(e == Test.MyEnum.enum2); test(r == Test.MyEnum.enum3); } { Test.MyClassPrx c1; Test.MyClassPrx c2; Test.MyClassPrx r; r = p.opMyClass(p, out c1, out c2); test(Ice.Util.proxyIdentityAndFacetCompare(c1, p) == 0); test(Ice.Util.proxyIdentityAndFacetCompare(c2, p) != 0); test(Ice.Util.proxyIdentityAndFacetCompare(r, p) == 0); test(c1.ice_getIdentity().Equals(communicator.stringToIdentity("test"))); test(c2.ice_getIdentity().Equals(communicator.stringToIdentity("noSuchIdentity"))); test(r.ice_getIdentity().Equals(communicator.stringToIdentity("test"))); r.opVoid(); c1.opVoid(); try { c2.opVoid(); test(false); } catch (Ice.ObjectNotExistException) { } r = p.opMyClass(null, out c1, out c2); test(c1 == null); test(c2 != null); test(Ice.Util.proxyIdentityAndFacetCompare(r, p) == 0); r.opVoid(); } { Test.Structure si1 = new Test.Structure(); si1.p = p; si1.e = Test.MyEnum.enum3; si1.s = new Test.AnotherStruct(); si1.s.s = "abc"; Test.Structure si2 = new Test.Structure(); si2.p = null; si2.e = Test.MyEnum.enum2; si2.s = new Test.AnotherStruct(); si2.s.s = "def"; Test.Structure so; Test.Structure rso = p.opStruct(si1, si2, out so); test(rso.p == null); test(rso.e == Test.MyEnum.enum2); test(rso.s.s.Equals("def")); test(so.p.Equals(p)); test(so.e == Test.MyEnum.enum3); test(so.s.s.Equals("a new string")); so.p.opVoid(); } { byte[] tbsi1 = new byte[] { 0x01, 0x11, 0x12, 0x22 }; Test.ByteS bsi1 = new Test.ByteS(tbsi1); byte[] tbsi2 = new byte[] { 0xf1, 0xf2, 0xf3, 0xf4 }; Test.ByteS bsi2 = new Test.ByteS(tbsi2); Test.ByteS bso; Test.ByteS rso; rso = p.opByteS(bsi1, bsi2, out bso); test(bso.Count == 4); test(bso[0] == 0x22); test(bso[1] == 0x12); test(bso[2] == 0x11); test(bso[3] == 0x01); test(rso.Count == 8); test(rso[0] == 0x01); test(rso[1] == 0x11); test(rso[2] == 0x12); test(rso[3] == 0x22); test(rso[4] == 0xf1); test(rso[5] == 0xf2); test(rso[6] == 0xf3); test(rso[7] == 0xf4); } { bool[] tbsi1 = new bool[] { true, true, false }; Test.BoolS bsi1 = new Test.BoolS(tbsi1); bool[] tbsi2 = new bool[] { false }; Test.BoolS bsi2 = new Test.BoolS(tbsi2); Test.BoolS bso; Test.BoolS rso; rso = p.opBoolS(bsi1, bsi2, out bso); test(bso.Count == 4); test(bso[0]); test(bso[1]); test(!bso[2]); test(!bso[3]); test(rso.Count == 3); test(!rso[0]); test(rso[1]); test(rso[2]); } { short[] tssi = new short[] { 1, 2, 3 }; Test.ShortS ssi = new Test.ShortS(tssi); int[] tisi = new int[] { 5, 6, 7, 8 }; Test.IntS isi = new Test.IntS(tisi); long[] tlsi = new long[] { 10, 30, 20 }; Test.LongS lsi = new Test.LongS(tlsi); Test.ShortS sso; Test.IntS iso; Test.LongS lso; Test.LongS rso; rso = p.opShortIntLongS(ssi, isi, lsi, out sso, out iso, out lso); test(sso.Count == 3); test(sso[0] == 1); test(sso[1] == 2); test(sso[2] == 3); test(iso.Count == 4); test(iso[0] == 8); test(iso[1] == 7); test(iso[2] == 6); test(iso[3] == 5); test(lso.Count == 6); test(lso[0] == 10); test(lso[1] == 30); test(lso[2] == 20); test(lso[3] == 10); test(lso[4] == 30); test(lso[5] == 20); test(rso.Count == 3); test(rso[0] == 10); test(rso[1] == 30); test(rso[2] == 20); } { float[] tfsi = new float[] { 3.14f, 1.11f }; Test.FloatS fsi = new Test.FloatS(tfsi); double[] tdsi = new double[] { 1.1e10, 1.2e10, 1.3e10 }; Test.DoubleS dsi = new Test.DoubleS(tdsi); Test.FloatS fso; Test.DoubleS dso; Test.DoubleS rso; rso = p.opFloatDoubleS(fsi, dsi, out fso, out dso); test(fso.Count == 2); test(fso[0] == 3.14f); test(fso[1] == 1.11f); test(dso.Count == 3); test(dso[0] == 1.3e10); test(dso[1] == 1.2e10); test(dso[2] == 1.1e10); test(rso.Count == 5); test(rso[0] == 1.1e10); test(rso[1] == 1.2e10); test(rso[2] == 1.3e10); test((float)rso[3] == 3.14f); test((float)rso[4] == 1.11f); } { string[] tssi1 = new string[] { "abc", "de", "fghi" }; Test.StringS ssi1 = new Test.StringS(tssi1); string[] tssi2 = new string[] { "xyz" }; Test.StringS ssi2 = new Test.StringS(tssi2); Test.StringS sso; Test.StringS rso; rso = p.opStringS(ssi1, ssi2, out sso); test(sso.Count == 4); test(sso[0].Equals("abc")); test(sso[1].Equals("de")); test(sso[2].Equals("fghi")); test(sso[3].Equals("xyz")); test(rso.Count == 3); test(rso[0].Equals("fghi")); test(rso[1].Equals("de")); test(rso[2].Equals("abc")); } { Test.ByteS s11 = new Test.ByteS(new byte[] { 0x01, 0x11, 0x12 }); Test.ByteS s12 = new Test.ByteS(new byte[] { 0xff }); Test.ByteSS bsi1 = new Test.ByteSS(new Test.ByteS[] { s11, s12 }); Test.ByteS s21 = new Test.ByteS(new byte[] { 0x0e }); Test.ByteS s22 = new Test.ByteS(new byte[] { 0xf2, 0xf1 }); Test.ByteSS bsi2 = new Test.ByteSS(new Test.ByteS[] { s21, s22 }); Test.ByteSS bso; Test.ByteSS rso; rso = p.opByteSS(bsi1, bsi2, out bso); test(bso.Count == 2); test(bso[0].Count == 1); test(bso[0][0] == 0xff); test(bso[1].Count == 3); test(bso[1][0] == 0x01); test(bso[1][1] == 0x11); test(bso[1][2] == 0x12); test(rso.Count == 4); test(rso[0].Count == 3); test(rso[0][0] == 0x01); test(rso[0][1] == 0x11); test(rso[0][2] == 0x12); test(rso[1].Count == 1); test(rso[1][0] == 0xff); test(rso[2].Count == 1); test(rso[2][0] == 0x0e); test(rso[3].Count == 2); test(rso[3][0] == 0xf2); test(rso[3][1] == 0xf1); } { Test.FloatS f11 = new Test.FloatS(new float[] { 3.14f }); Test.FloatS f12 = new Test.FloatS(new float[] { 1.11f }); Test.FloatS f13 = new Test.FloatS(new float[] { }); Test.FloatSS fsi = new Test.FloatSS(new Test.FloatS[] { f11, f12, f13 }); Test.DoubleS d11 = new Test.DoubleS(new double[] { 1.1e10, 1.2e10, 1.3e10 }); Test.DoubleSS dsi = new Test.DoubleSS(new Test.DoubleS[] { d11 }); Test.FloatSS fso; Test.DoubleSS dso; Test.DoubleSS rso; rso = p.opFloatDoubleSS(fsi, dsi, out fso, out dso); test(fso.Count == 3); test(fso[0].Count == 1); test(fso[0][0] == 3.14f); test(fso[1].Count == 1); test(fso[1][0] == 1.11f); test(fso[2].Count == 0); test(dso.Count == 1); test(dso[0].Count == 3); test(dso[0][0] == 1.1e10); test(dso[0][1] == 1.2e10); test(dso[0][2] == 1.3e10); test(rso.Count == 2); test(rso[0].Count == 3); test(rso[0][0] == 1.1e10); test(rso[0][1] == 1.2e10); test(rso[0][2] == 1.3e10); test(rso[1].Count == 3); test(rso[1][0] == 1.1e10); test(rso[1][1] == 1.2e10); test(rso[1][2] == 1.3e10); } { Test.StringS s11 = new Test.StringS(); s11.Add("abc"); Test.StringS s12 = new Test.StringS(); s12.Add("de"); s12.Add("fghi"); Test.StringSS ssi1 = new Test.StringSS(); ssi1.Add(s11); ssi1.Add(s12); Test.StringS s21 = new Test.StringS(); Test.StringS s22 = new Test.StringS(); Test.StringS s23 = new Test.StringS(); s23.Add("xyz"); Test.StringSS ssi2 = new Test.StringSS(); ssi2.Add(s21); ssi2.Add(s22); ssi2.Add(s23); Test.StringSS sso; Test.StringSS rso; rso = p.opStringSS(ssi1, ssi2, out sso); test(sso.Count == 5); test(sso[0].Count == 1); test(sso[0][0].Equals("abc")); test(sso[1].Count == 2); test(sso[1][0].Equals("de")); test(sso[1][1].Equals("fghi")); test(sso[2].Count == 0); test(sso[3].Count == 0); test(sso[4].Count == 1); test(sso[4][0].Equals("xyz")); test(rso.Count == 3); test(rso[0].Count == 1); test(rso[0][0].Equals("xyz")); test(rso[1].Count == 0); test(rso[2].Count == 0); } { Test.StringSS[] sssi1 = { new Test.StringSS(), new Test.StringSS() }; sssi1[0].Add(new Test.StringS()); sssi1[0].Add(new Test.StringS()); sssi1[0][0].Add("abc"); sssi1[0][0].Add("de"); sssi1[0][1].Add("xyz"); sssi1[1].Add(new Test.StringS()); sssi1[1][0].Add("hello"); Test.StringSS[] sssi2 = { new Test.StringSS(), new Test.StringSS(), new Test.StringSS() }; sssi2[0].Add(new Test.StringS()); sssi2[0].Add(new Test.StringS()); sssi2[0][0].Add(""); sssi2[0][0].Add(""); sssi2[0][1].Add("abcd"); sssi2[1].Add(new Test.StringS()); sssi2[1][0].Add(""); Test.StringSS[] ssso; Test.StringSS[] rsso = p.opStringSSS(sssi1, sssi2, out ssso); test(ssso.Length == 5); test(ssso[0].Count == 2); test(ssso[0][0].Count == 2); test(ssso[0][1].Count == 1); test(ssso[1].Count == 1); test(ssso[1][0].Count == 1); test(ssso[2].Count == 2); test(ssso[2][0].Count == 2); test(ssso[2][1].Count == 1); test(ssso[3].Count == 1); test(ssso[3][0].Count == 1); test(ssso[4].Count == 0); test(ssso[0][0][0].Equals("abc")); test(ssso[0][0][1].Equals("de")); test(ssso[0][1][0].Equals("xyz")); test(ssso[1][0][0].Equals("hello")); test(ssso[2][0][0].Equals("")); test(ssso[2][0][1].Equals("")); test(ssso[2][1][0].Equals("abcd")); test(ssso[3][0][0].Equals("")); test(rsso.Length == 3); test(rsso[0].Count == 0); test(rsso[1].Count == 1); test(rsso[1][0].Count == 1); test(rsso[2].Count == 2); test(rsso[2][0].Count == 2); test(rsso[2][1].Count == 1); test(rsso[1][0][0].Equals("")); test(rsso[2][0][0].Equals("")); test(rsso[2][0][1].Equals("")); test(rsso[2][1][0].Equals("abcd")); } { Dictionary <byte, bool> di1 = new Dictionary <byte, bool>(); di1[10] = true; di1[100] = false; Dictionary <byte, bool> di2 = new Dictionary <byte, bool>(); di2[10] = true; di2[11] = false; di2[101] = true; Dictionary <byte, bool> _do; Dictionary <byte, bool> ro = p.opByteBoolD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[10] == true); test(ro[11] == false); test(ro[100] == false); test(ro[101] == true); } { Dictionary <short, int> di1 = new Dictionary <short, int>(); di1[110] = -1; di1[1100] = 123123; Dictionary <short, int> di2 = new Dictionary <short, int>(); di2[110] = -1; di2[111] = -100; di2[1101] = 0; Dictionary <short, int> _do; Dictionary <short, int> ro = p.opShortIntD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[110] == -1); test(ro[111] == -100); test(ro[1100] == 123123); test(ro[1101] == 0); } { Dictionary <long, float> di1 = new Dictionary <long, float>(); di1[999999110L] = -1.1f; di1[999999111L] = 123123.2f; Dictionary <long, float> di2 = new Dictionary <long, float>(); di2[999999110L] = -1.1f; di2[999999120L] = -100.4f; di2[999999130L] = 0.5f; Dictionary <long, float> _do; Dictionary <long, float> ro = p.opLongFloatD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[999999110L] == -1.1f); test(ro[999999120L] == -100.4f); test(ro[999999111L] == 123123.2f); test(ro[999999130L] == 0.5f); } { Dictionary <string, string> di1 = new Dictionary <string, string>(); di1["foo"] = "abc -1.1"; di1["bar"] = "abc 123123.2"; Dictionary <string, string> di2 = new Dictionary <string, string>(); di2["foo"] = "abc -1.1"; di2["FOO"] = "abc -100.4"; di2["BAR"] = "abc 0.5"; Dictionary <string, string> _do; Dictionary <string, string> ro = p.opStringStringD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro["foo"].Equals("abc -1.1")); test(ro["FOO"].Equals("abc -100.4")); test(ro["bar"].Equals("abc 123123.2")); test(ro["BAR"].Equals("abc 0.5")); } { Dictionary <string, Test.MyEnum> di1 = new Dictionary <string, Test.MyEnum>(); di1["abc"] = Test.MyEnum.enum1; di1[""] = Test.MyEnum.enum2; Dictionary <string, Test.MyEnum> di2 = new Dictionary <string, Test.MyEnum>(); di2["abc"] = Test.MyEnum.enum1; di2["qwerty"] = Test.MyEnum.enum3; di2["Hello!!"] = Test.MyEnum.enum2; Dictionary <string, Test.MyEnum> _do; Dictionary <string, Test.MyEnum> ro = p.opStringMyEnumD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro["abc"] == Test.MyEnum.enum1); test(ro["qwerty"] == Test.MyEnum.enum3); test(ro[""] == Test.MyEnum.enum2); test(ro["Hello!!"] == Test.MyEnum.enum2); } { Dictionary <Test.MyEnum, string> di1 = new Dictionary <Test.MyEnum, string>(); di1[Test.MyEnum.enum1] = "abc"; Dictionary <Test.MyEnum, string> di2 = new Dictionary <Test.MyEnum, string>(); di2[Test.MyEnum.enum2] = "Hello!!"; di2[Test.MyEnum.enum3] = "qwerty"; Dictionary <Test.MyEnum, string> _do; Dictionary <Test.MyEnum, string> ro = p.opMyEnumStringD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 3); test(ro[Test.MyEnum.enum1].Equals("abc")); test(ro[Test.MyEnum.enum2].Equals("Hello!!")); test(ro[Test.MyEnum.enum3].Equals("qwerty")); } { Test.MyStruct s11 = new Test.MyStruct(1, 1); Test.MyStruct s12 = new Test.MyStruct(1, 2); Dictionary <Test.MyStruct, Test.MyEnum> di1 = new Dictionary <Test.MyStruct, Test.MyEnum>(); di1[s11] = Test.MyEnum.enum1; di1[s12] = Test.MyEnum.enum2; Test.MyStruct s22 = new Test.MyStruct(2, 2); Test.MyStruct s23 = new Test.MyStruct(2, 3); Dictionary <Test.MyStruct, Test.MyEnum> di2 = new Dictionary <Test.MyStruct, Test.MyEnum>(); di2[s11] = Test.MyEnum.enum1; di2[s22] = Test.MyEnum.enum3; di2[s23] = Test.MyEnum.enum2; Dictionary <Test.MyStruct, Test.MyEnum> _do; Dictionary <Test.MyStruct, Test.MyEnum> ro = p.opMyStructMyEnumD(di1, di2, out _do); test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); test(ro[s11] == Test.MyEnum.enum1); test(ro[s12] == Test.MyEnum.enum2); test(ro[s22] == Test.MyEnum.enum3); test(ro[s23] == Test.MyEnum.enum2); } { int[] lengths = new int[] { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; for (int l = 0; l < lengths.Length; ++l) { Test.IntS s = new Test.IntS(); for (int i = 0; i < lengths[l]; ++i) { s.Add(i); } Test.IntS r = p.opIntS(s); test(r.Count == lengths[l]); for (int j = 0; j < r.Count; ++j) { test(r[j] == -j); } } } { Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; { test(p.ice_getContext().Count == 0); Dictionary <string, string> r = p.opContext(); test(!r.Equals(ctx)); } { Dictionary <string, string> r = p.opContext(ctx); test(p.ice_getContext().Count == 0); test(Ice.CollectionComparer.Equals(r, ctx)); } { Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); test(Ice.CollectionComparer.Equals(p2.ice_getContext(), ctx)); Dictionary <string, string> r = p2.opContext(); test(Ice.CollectionComparer.Equals(r, ctx)); r = p2.opContext(ctx); test(Ice.CollectionComparer.Equals(r, ctx)); } } { // // Test implicit context propagation // String[] impls = { "Shared", "PerThread" }; for (int i = 0; i < 2; i++) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.ImplicitContext", impls[i]); Ice.Communicator ic = Ice.Util.initialize(initData); Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; Test.MyClassPrx p3 = Test.MyClassPrxHelper.uncheckedCast( ic.stringToProxy("test:default -p 12010")); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(ic.getImplicitContext().getContext(), ctx)); test(Ice.CollectionComparer.Equals(p3.opContext(), ctx)); test(ic.getImplicitContext().containsKey("zero") == false); String r = ic.getImplicitContext().put("zero", "ZERO"); test(r.Equals("")); test(ic.getImplicitContext().get("zero").Equals("ZERO")); ctx = ic.getImplicitContext().getContext(); test(Ice.CollectionComparer.Equals(p3.opContext(), ctx)); Dictionary <string, string> prxContext = new Dictionary <string, string>(); prxContext["one"] = "UN"; prxContext["four"] = "QUATRE"; Dictionary <string, string> combined = new Dictionary <string, string>(prxContext); foreach (KeyValuePair <string, string> e in ctx) { try { combined.Add(e.Key, e.Value); } catch (System.ArgumentException) { // Ignore. } } test(combined["one"].Equals("UN")); p3 = Test.MyClassPrxHelper.uncheckedCast(p3.ice_context(prxContext)); ic.getImplicitContext().setContext(null); test(Ice.CollectionComparer.Equals(p3.opContext(), prxContext)); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(p3.opContext(), combined)); test(ic.getImplicitContext().remove("one").Equals("ONE")); if (impls[i].Equals("PerThread")) { PerThreadContextInvokeThread thread = new PerThreadContextInvokeThread( Test.MyClassPrxHelper.uncheckedCast(p3.ice_context(null))); thread.Start(); thread.Join(); } ic.destroy(); } } { p.opIdempotent(); } { p.opNonmutating(); } }
public override Test.StringSS opStringSS(Test.StringSS p1, Test.StringSS p2, out Test.StringSS p3, Ice.Current current) { p3 = new Test.StringSS(); p3.AddRange(p1); p3.AddRange(p2); Test.StringSS r = new Test.StringSS(); for(int i = 0; i < p2.Count; i++) { r.Add(p2[p2.Count - (i + 1)]); } return r; }
public void opStringSS_async(Test.AMD_MyClass_opStringSS cb, Test.StringSS p1, Test.StringSS p2, Ice.Current current) { Test.StringSS p3 = new Test.StringSS(); p3.AddRange(p1); p3.AddRange(p2); Test.StringSS r = new Test.StringSS(); for(int i = 0; i < p2.Count; i++) { r.Add(p2[p2.Count - (i + 1)]); } cb.ice_response(r, p3); }
public void opStringSSS_async(Test.AMD_MyClass_opStringSSS cb, Test.StringSS[] p1, Test.StringSS[] p2, Ice.Current current) { Test.StringSS[] p3 = new Test.StringSS[p1.Length + p2.Length]; Array.Copy(p1, 0, p3, 0, p1.Length); Array.Copy(p2, 0, p3, p1.Length, p2.Length); Test.StringSS[] r = new Test.StringSS[p2.Length]; for(int i = 0; i < p2.Length; i++) { r[i] = p2[p2.Length - (i + 1)]; } cb.ice_response(r, p3); }
internal static void twowaysNewAMI(Ice.Communicator communicator, Test.MyClassPrx p) { { Ice.AsyncResult r = p.begin_ice_ping(); p.end_ice_ping(r); } { Callback cb = new Callback(); p.begin_ice_ping().whenCompleted(cb.ice_ping, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_ice_isA(Test.MyClass.ice_staticId()); test(p.end_ice_isA(r)); } { Callback cb = new Callback(); p.begin_ice_isA(Test.MyClass.ice_staticId()).whenCompleted(cb.ice_isA, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_ice_ids(); test(p.end_ice_ids(r).Length == 3); } { Callback cb = new Callback(); p.begin_ice_ids().whenCompleted(cb.ice_ids, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_ice_id(); test(p.end_ice_id(r).Equals(Test.MyDerivedClass.ice_staticId())); } { Callback cb = new Callback(); p.begin_ice_id().whenCompleted(cb.ice_id, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_opVoid(); p.end_opVoid(r); } { Callback cb = new Callback(); p.begin_opVoid().whenCompleted(cb.opVoid, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_opByte(0xff, 0x0f); byte p3; byte ret = p.end_opByte(out p3, r); test(p3 == 0xf0); test(ret == 0xff); } { Callback cb = new Callback(); p.begin_opByte(0xff, 0x0f).whenCompleted(cb.opByte, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opBool(true, false).whenCompleted(cb.opBool, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opShortIntLong(10, 11, 12).whenCompleted(cb.opShortIntLong, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opFloatDouble(3.14f, 1.1E10).whenCompleted(cb.opFloatDouble, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opString("hello", "world").whenCompleted(cb.opString, cb.exCB); cb.check(); } { Callback cb = new Callback(); p.begin_opMyEnum(Test.MyEnum.enum2).whenCompleted(cb.opMyEnum, cb.exCB); cb.check(); } { Callback cb = new Callback(communicator); p.begin_opMyClass(p).whenCompleted(cb.opMyClass, cb.exCB); cb.check(); } { Test.Structure si1 = new Test.Structure(); si1.p = p; si1.e = Test.MyEnum.enum3; si1.s = new Test.AnotherStruct(); si1.s.s = "abc"; Test.Structure si2 = new Test.Structure(); si2.p = null; si2.e = Test.MyEnum.enum2; si2.s = new Test.AnotherStruct(); si2.s.s = "def"; Callback cb = new Callback(communicator); p.begin_opStruct(si1, si2).whenCompleted(cb.opStruct, cb.exCB); cb.check(); } { byte[] tbsi1 = new byte[] { 0x01, 0x11, 0x12, 0x22 }; Test.ByteS bsi1 = new Test.ByteS(tbsi1); byte[] tbsi2 = new byte[] { 0xf1, 0xf2, 0xf3, 0xf4 }; Test.ByteS bsi2 = new Test.ByteS(tbsi2); Callback cb = new Callback(); p.begin_opByteS(bsi1, bsi2).whenCompleted(cb.opByteS, cb.exCB); cb.check(); } { bool[] tbsi1 = new bool[] { true, true, false }; Test.BoolS bsi1 = new Test.BoolS(tbsi1); bool[] tbsi2 = new bool[] { false }; Test.BoolS bsi2 = new Test.BoolS(tbsi2); Callback cb = new Callback(); p.begin_opBoolS(bsi1, bsi2).whenCompleted(cb.opBoolS, cb.exCB); cb.check(); } { short[] tssi = new short[] { 1, 2, 3 }; Test.ShortS ssi = new Test.ShortS(tssi); int[] tisi = new int[] { 5, 6, 7, 8 }; Test.IntS isi = new Test.IntS(tisi); long[] tlsi = new long[] { 10, 30, 20 }; Test.LongS lsi = new Test.LongS(tlsi); Callback cb = new Callback(); p.begin_opShortIntLongS(ssi, isi, lsi).whenCompleted(cb.opShortIntLongS, cb.exCB); cb.check(); } { float[] tfsi = new float[] { 3.14f, 1.11f }; Test.FloatS fsi = new Test.FloatS(tfsi); double[] tdsi = new double[] { 1.1e10, 1.2e10, 1.3e10 }; Test.DoubleS dsi = new Test.DoubleS(tdsi); Callback cb = new Callback(); p.begin_opFloatDoubleS(fsi, dsi).whenCompleted(cb.opFloatDoubleS, cb.exCB); cb.check(); } { string[] tssi1 = new string[] { "abc", "de", "fghi" }; Test.StringS ssi1 = new Test.StringS(tssi1); string[] tssi2 = new string[] { "xyz" }; Test.StringS ssi2 = new Test.StringS(tssi2); Callback cb = new Callback(); p.begin_opStringS(ssi1, ssi2).whenCompleted(cb.opStringS, cb.exCB); cb.check(); } { Test.ByteS s11 = new Test.ByteS(new byte[] { 0x01, 0x11, 0x12 }); Test.ByteS s12 = new Test.ByteS(new byte[] { 0xff }); Test.ByteSS bsi1 = new Test.ByteSS(new Test.ByteS[] { s11, s12 }); Test.ByteS s21 = new Test.ByteS(new byte[] { 0x0e }); Test.ByteS s22 = new Test.ByteS(new byte[] { 0xf2, 0xf1 }); Test.ByteSS bsi2 = new Test.ByteSS(new Test.ByteS[] { s21, s22 }); Callback cb = new Callback(); p.begin_opByteSS(bsi1, bsi2).whenCompleted(cb.opByteSS, cb.exCB); cb.check(); } { Test.FloatS f11 = new Test.FloatS(new float[] { 3.14f }); Test.FloatS f12 = new Test.FloatS(new float[] { 1.11f }); Test.FloatS f13 = new Test.FloatS(new float[] { }); Test.FloatSS fsi = new Test.FloatSS(new Test.FloatS[] { f11, f12, f13 }); Test.DoubleS d11 = new Test.DoubleS(new double[] { 1.1e10, 1.2e10, 1.3e10 }); Test.DoubleSS dsi = new Test.DoubleSS(new Test.DoubleS[] { d11 }); Callback cb = new Callback(); p.begin_opFloatDoubleSS(fsi, dsi).whenCompleted(cb.opFloatDoubleSS, cb.exCB); cb.check(); } { Test.StringS s11 = new Test.StringS(); s11.Add("abc"); Test.StringS s12 = new Test.StringS(); s12.Add("de"); s12.Add("fghi"); Test.StringSS ssi1 = new Test.StringSS(); ssi1.Add(s11); ssi1.Add(s12); Test.StringS s21 = new Test.StringS(); Test.StringS s22 = new Test.StringS(); Test.StringS s23 = new Test.StringS(); s23.Add("xyz"); Test.StringSS ssi2 = new Test.StringSS(); ssi2.Add(s21); ssi2.Add(s22); ssi2.Add(s23); Callback cb = new Callback(); p.begin_opStringSS(ssi1, ssi2).whenCompleted(cb.opStringSS, cb.exCB); cb.check(); } { Test.StringSS[] sssi1 = { new Test.StringSS(), new Test.StringSS() }; sssi1[0].Add(new Test.StringS()); sssi1[0].Add(new Test.StringS()); sssi1[0][0].Add("abc"); sssi1[0][0].Add("de"); sssi1[0][1].Add("xyz"); sssi1[1].Add(new Test.StringS()); sssi1[1][0].Add("hello"); Test.StringSS[] sssi2 = { new Test.StringSS(), new Test.StringSS(), new Test.StringSS() }; sssi2[0].Add(new Test.StringS()); sssi2[0].Add(new Test.StringS()); sssi2[0][0].Add(""); sssi2[0][0].Add(""); sssi2[0][1].Add("abcd"); sssi2[1].Add(new Test.StringS()); sssi2[1][0].Add(""); Callback cb = new Callback(); p.begin_opStringSSS(sssi1, sssi2).whenCompleted(cb.opStringSSS, cb.exCB); cb.check(); } { Dictionary<byte, bool> di1 = new Dictionary<byte, bool>(); di1[10] = true; di1[100] = false; Dictionary<byte, bool> di2 = new Dictionary<byte, bool>(); di2[10] = true; di2[11] = false; di2[101] = true; Callback cb = new Callback(); p.begin_opByteBoolD(di1, di2).whenCompleted(cb.opByteBoolD, cb.exCB); cb.check(); } { Dictionary<short, int> di1 = new Dictionary<short, int>(); di1[110] = -1; di1[1100] = 123123; Dictionary<short, int> di2 = new Dictionary<short, int>(); di2[110] = -1; di2[111] = -100; di2[1101] = 0; Callback cb = new Callback(); p.begin_opShortIntD(di1, di2).whenCompleted(cb.opShortIntD, cb.exCB); cb.check(); } { Dictionary<long, float> di1 = new Dictionary<long, float>(); di1[999999110L] = -1.1f; di1[999999111L] = 123123.2f; Dictionary<long, float> di2 = new Dictionary<long, float>(); di2[999999110L] = -1.1f; di2[999999120L] = -100.4f; di2[999999130L] = 0.5f; Callback cb = new Callback(); p.begin_opLongFloatD(di1, di2).whenCompleted(cb.opLongFloatD, cb.exCB); cb.check(); } { Dictionary<string, string> di1 = new Dictionary<string, string>(); di1["foo"] = "abc -1.1"; di1["bar"] = "abc 123123.2"; Dictionary<string, string> di2 = new Dictionary<string, string>(); di2["foo"] = "abc -1.1"; di2["FOO"] = "abc -100.4"; di2["BAR"] = "abc 0.5"; Callback cb = new Callback(); p.begin_opStringStringD(di1, di2).whenCompleted(cb.opStringStringD, cb.exCB); cb.check(); } { Dictionary<string, Test.MyEnum> di1 = new Dictionary<string, Test.MyEnum>(); di1["abc"] = Test.MyEnum.enum1; di1[""] = Test.MyEnum.enum2; Dictionary<string, Test.MyEnum> di2 = new Dictionary<string, Test.MyEnum>(); di2["abc"] = Test.MyEnum.enum1; di2["qwerty"] = Test.MyEnum.enum3; di2["Hello!!"] = Test.MyEnum.enum2; Callback cb = new Callback(); p.begin_opStringMyEnumD(di1, di2).whenCompleted(cb.opStringMyEnumD, cb.exCB); cb.check(); } { Dictionary<Test.MyEnum, string> di1 = new Dictionary<Test.MyEnum, string>(); di1[Test.MyEnum.enum1] = "abc"; Dictionary<Test.MyEnum, string> di2 = new Dictionary<Test.MyEnum, string>(); di2[Test.MyEnum.enum2] = "Hello!!"; di2[Test.MyEnum.enum3] = "qwerty"; Callback cb = new Callback(); p.begin_opMyEnumStringD(di1, di2).whenCompleted(cb.opMyEnumStringD, cb.exCB); cb.check(); } { Test.MyStruct s11 = new Test.MyStruct(1, 1); Test.MyStruct s12 = new Test.MyStruct(1, 2); Dictionary<Test.MyStruct, Test.MyEnum> di1 = new Dictionary<Test.MyStruct, Test.MyEnum>(); di1[s11] = Test.MyEnum.enum1; di1[s12] = Test.MyEnum.enum2; Test.MyStruct s22 = new Test.MyStruct(2, 2); Test.MyStruct s23 = new Test.MyStruct(2, 3); Dictionary<Test.MyStruct, Test.MyEnum> di2 = new Dictionary<Test.MyStruct, Test.MyEnum>(); di2[s11] = Test.MyEnum.enum1; di2[s22] = Test.MyEnum.enum3; di2[s23] = Test.MyEnum.enum2; Callback cb = new Callback(); p.begin_opMyStructMyEnumD(di1, di2).whenCompleted(cb.opMyStructMyEnumD, cb.exCB); cb.check(); } { int[] lengths = new int[] { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; for(int l = 0; l < lengths.Length; ++l) { Test.IntS s = new Test.IntS(); for(int i = 0; i < lengths[l]; ++i) { s.Add(i); } Callback cb = new Callback(lengths[l]); p.begin_opIntS(s).whenCompleted(cb.opIntS, cb.exCB); cb.check(); } } { Dictionary<string, string> ctx = new Dictionary<string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; { test(p.ice_getContext().Count == 0); Callback cb = new Callback(ctx); p.begin_opContext().whenCompleted(cb.opContextNotEqual, cb.exCB); cb.check(); } { test(p.ice_getContext().Count == 0); Callback cb = new Callback(ctx); p.begin_opContext(ctx).whenCompleted(cb.opContextEqual, cb.exCB); cb.check(); } { Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); test(Ice.CollectionComparer.Equals(p2.ice_getContext(), ctx)); Callback cb = new Callback(ctx); p2.begin_opContext().whenCompleted(cb.opContextEqual, cb.exCB); cb.check(); } { Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); Callback cb = new Callback(ctx); p2.begin_opContext(ctx).whenCompleted(cb.opContextEqual, cb.exCB); cb.check(); } } { // // Test implicit context propagation // string[] impls = {"Shared", "PerThread"}; for(int i = 0; i < 2; i++) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.ImplicitContext", impls[i]); Ice.Communicator ic = Ice.Util.initialize(initData); Dictionary<string, string> ctx = new Dictionary<string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; Test.MyClassPrx p3 = Test.MyClassPrxHelper.uncheckedCast( ic.stringToProxy("test:default -p 12010")); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(ic.getImplicitContext().getContext(), ctx)); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary<string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, ctx)); } ic.getImplicitContext().put("zero", "ZERO"); ctx = ic.getImplicitContext().getContext(); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary<string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, ctx)); } Dictionary<string, string> prxContext = new Dictionary<string, string>(); prxContext["one"] = "UN"; prxContext["four"] = "QUATRE"; Dictionary<string, string> combined = prxContext; foreach(KeyValuePair<string, string> e in ctx) { try { combined.Add(e.Key, e.Value); } catch(System.ArgumentException) { // Ignore. } } test(combined["one"].Equals("UN")); p3 = Test.MyClassPrxHelper.uncheckedCast(p.ice_context(prxContext)); ic.getImplicitContext().setContext(null); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary<string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, prxContext)); } ic.getImplicitContext().setContext(ctx); { Ice.AsyncResult r = p3.begin_opContext(); Dictionary<string, string> c = p3.end_opContext(r); test(Ice.CollectionComparer.Equals(c, combined)); } //ic.getImplicitContext().setContext(null); ic.destroy(); } } { Ice.AsyncResult r = p.begin_opIdempotent(); p.end_opIdempotent(r); } { Callback cb = new Callback(); p.begin_opIdempotent().whenCompleted(cb.opIdempotent, cb.exCB); cb.check(); } { Ice.AsyncResult r = p.begin_opNonmutating(); p.end_opNonmutating(r); } { Callback cb = new Callback(); p.begin_opNonmutating().whenCompleted(cb.opNonmutating, cb.exCB); cb.check(); } { Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(p); test(derived != null); Callback cb = new Callback(); derived.begin_opDerived().whenCompleted(cb.opDerived, cb.exCB); cb.check(); } }
internal static void twowaysAMI(Ice.Communicator communicator, Test.MyClassPrx p) { { // Check that a call to a void operation raises NoEndpointException // in the ice_exception() callback instead of at the point of call. Test.MyClassPrx indirect = Test.MyClassPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); AMI_MyClass_opVoidExI cb = new AMI_MyClass_opVoidExI(); try { test(!indirect.opVoid_async(cb)); } catch(Ice.Exception) { test(false); } cb.check(); } { // Check that a call to a twoway operation raises NoEndpointException // in the ice_exception() callback instead of at the point of call. Test.MyClassPrx indirect = Test.MyClassPrxHelper.uncheckedCast(p.ice_adapterId("dummy")); AMI_MyClass_opByteExI cb = new AMI_MyClass_opByteExI(); try { test(!indirect.opByte_async(cb, (byte)0, (byte)0)); } catch(Ice.Exception) { test(false); } cb.check(); } { AMI_MyClass_opVoidI cb = new AMI_MyClass_opVoidI(); p.opVoid_async(cb); cb.check(); // Let's check if we can reuse the callback object for another call. p.opVoid_async(cb); cb.check(); } { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); Ice.Communicator ic = Ice.Util.initialize(initData); Ice.ObjectPrx obj = ic.stringToProxy(p.ToString()); Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(obj); ic.destroy(); AMI_MyClass_opVoidI cb = new AMI_MyClass_opVoidI(); try { test(!p2.opVoid_async(cb)); test(false); } catch(Ice.CommunicatorDestroyedException) { // Expected. } } { AMI_MyClass_opByteI cb = new AMI_MyClass_opByteI(); p.opByte_async(cb, 0xff, 0x0f); cb.check(); } { AMI_MyClass_opBoolI cb = new AMI_MyClass_opBoolI(); p.opBool_async(cb, true, false); cb.check(); } { AMI_MyClass_opShortIntLongI cb = new AMI_MyClass_opShortIntLongI(); p.opShortIntLong_async(cb, (short) 10, 11, 12L); cb.check(); } { AMI_MyClass_opFloatDoubleI cb = new AMI_MyClass_opFloatDoubleI(); p.opFloatDouble_async(cb, 3.14f, 1.1e10); cb.check(); } { AMI_MyClass_opStringI cb = new AMI_MyClass_opStringI(); p.opString_async(cb, "hello", "world"); cb.check(); } { AMI_MyClass_opMyEnumI cb = new AMI_MyClass_opMyEnumI(); p.opMyEnum_async(cb, Test.MyEnum.enum2); cb.check(); } { AMI_MyClass_opMyClassI cb = new AMI_MyClass_opMyClassI(communicator); p.opMyClass_async(cb, p); cb.check(); } { Test.Structure si1 = new Test.Structure(); si1.p = p; si1.e = Test.MyEnum.enum3; si1.s = new Test.AnotherStruct(); si1.s.s = "abc"; Test.Structure si2 = new Test.Structure(); si2.p = null; si2.e = Test.MyEnum.enum2; si2.s = new Test.AnotherStruct(); si2.s.s = "def"; AMI_MyClass_opStructI cb = new AMI_MyClass_opStructI(communicator); p.opStruct_async(cb, si1, si2); cb.check(); } { Test.ByteS bsi1 = new Test.ByteS(new byte[] { 0x01, 0x11, 0x12, 0x22 }); Test.ByteS bsi2 = new Test.ByteS(new byte[] { 0xf1, 0xf2, 0xf3, 0xf4 }); AMI_MyClass_opByteSI cb = new AMI_MyClass_opByteSI(); p.opByteS_async(cb, bsi1, bsi2); cb.check(); } { Test.BoolS bsi1 = new Test.BoolS(new bool[] { true, true, false }); Test.BoolS bsi2 = new Test.BoolS(new bool[] { false }); AMI_MyClass_opBoolSI cb = new AMI_MyClass_opBoolSI(); p.opBoolS_async(cb, bsi1, bsi2); cb.check(); } { Test.ShortS ssi = new Test.ShortS(new short[] { 1, 2, 3 }); Test.IntS isi = new Test.IntS(new int[] { 5, 6, 7, 8 }); Test.LongS lsi = new Test.LongS(new long[] { 10, 30, 20 }); AMI_MyClass_opShortIntLongSI cb = new AMI_MyClass_opShortIntLongSI(); p.opShortIntLongS_async(cb, ssi, isi, lsi); cb.check(); } { Test.FloatS fsi = new Test.FloatS(new float[] { 3.14f, 1.11f }); Test.DoubleS dsi = new Test.DoubleS(new double[] { 1.1e10, 1.2e10, 1.3e10 }); AMI_MyClass_opFloatDoubleSI cb = new AMI_MyClass_opFloatDoubleSI(); p.opFloatDoubleS_async(cb, fsi, dsi); cb.check(); } { Test.StringS ssi1 = new Test.StringS(new string[] { "abc", "de", "fghi" }); Test.StringS ssi2 = new Test.StringS(new string[] { "xyz" }); AMI_MyClass_opStringSI cb = new AMI_MyClass_opStringSI(); p.opStringS_async(cb, ssi1, ssi2); cb.check(); } { Test.ByteSS bsi1 = new Test.ByteSS(); bsi1.Add(new Test.ByteS()); bsi1.Add(new Test.ByteS()); bsi1[0].Add(0x01); bsi1[0].Add(0x11); bsi1[0].Add(0x12); bsi1[1].Add(0xff); Test.ByteSS bsi2 = new Test.ByteSS(); bsi2.Add(new Test.ByteS()); bsi2.Add(new Test.ByteS()); bsi2[0].Add(0x0e); bsi2[1].Add(0xf2); bsi2[1].Add(0xf1); AMI_MyClass_opByteSSI cb = new AMI_MyClass_opByteSSI(); p.opByteSS_async(cb, bsi1, bsi2); cb.check(); } { Test.FloatSS fsi = new Test.FloatSS(); fsi.Add(new Test.FloatS(new float[] { 3.14f })); fsi.Add(new Test.FloatS(new float[] { 1.11f })); fsi.Add(new Test.FloatS(new float[] { })); Test.DoubleSS dsi = new Test.DoubleSS(); dsi.Add(new Test.DoubleS(new double[] { 1.1E10, 1.2E10, 1.3E10 })); AMI_MyClass_opFloatDoubleSSI cb = new AMI_MyClass_opFloatDoubleSSI(); p.opFloatDoubleSS_async(cb, fsi, dsi); cb.check(); } { Test.StringSS ssi1 = new Test.StringSS(); ssi1.Add(new Test.StringS()); ssi1.Add(new Test.StringS()); ssi1[0].Add("abc"); ssi1[1].Add("de"); ssi1[1].Add("fghi"); Test.StringSS ssi2 = new Test.StringSS(); ssi2.Add(new Test.StringS()); ssi2.Add(new Test.StringS()); ssi2.Add(new Test.StringS()); ssi2[2].Add("xyz"); AMI_MyClass_opStringSSI cb = new AMI_MyClass_opStringSSI(); p.opStringSS_async(cb, ssi1, ssi2); cb.check(); } { Test.StringSS[] sssi1 = { new Test.StringSS(), new Test.StringSS() }; sssi1[0].Add(new Test.StringS()); sssi1[0].Add(new Test.StringS()); sssi1[0][0].Add("abc"); sssi1[0][0].Add("de"); sssi1[0][1].Add("xyz"); sssi1[1].Add(new Test.StringS()); sssi1[1][0].Add("hello"); Test.StringSS[] sssi2 = { new Test.StringSS(), new Test.StringSS(), new Test.StringSS() }; sssi2[0].Add(new Test.StringS()); sssi2[0].Add(new Test.StringS()); sssi2[0][0].Add(""); sssi2[0][0].Add(""); sssi2[0][1].Add("abcd"); sssi2[1].Add(new Test.StringS()); sssi2[1][0].Add(""); AMI_MyClass_opStringSSSI cb = new AMI_MyClass_opStringSSSI(); p.opStringSSS_async(cb, sssi1, sssi2); cb.check(); } { Dictionary<byte, bool> di1 = new Dictionary<byte, bool>(); di1[10] = true; di1[100] = false; Dictionary<byte, bool> di2 = new Dictionary<byte, bool>(); // di2[10] = true; // Disabled since new dictionary mapping. di2[11] = false; di2[101] = true; AMI_MyClass_opByteBoolDI cb = new AMI_MyClass_opByteBoolDI(); p.opByteBoolD_async(cb, di1, di2); cb.check(); } { Dictionary<short, int> di1 = new Dictionary<short, int>(); di1[110] = -1; di1[1100] = 123123; Dictionary<short, int> di2 = new Dictionary<short, int>(); // di2[110] = -1; // Disabled since new dictionary mapping. di2[111] = -100; di2[1101] = 0; AMI_MyClass_opShortIntDI cb = new AMI_MyClass_opShortIntDI(); p.opShortIntD_async(cb, di1, di2); cb.check(); } { Dictionary<long, float> di1 = new Dictionary<long, float>(); di1[999999110L] = -1.1f; di1[999999111L] = 123123.2f; Dictionary<long, float> di2 = new Dictionary<long, float>(); // di2[999999110L] = -1.1f; // Disabled since new dictionary mapping. di2[999999120L] = -100.4f; di2[999999130L] = 0.5f; AMI_MyClass_opLongFloatDI cb = new AMI_MyClass_opLongFloatDI(); p.opLongFloatD_async(cb, di1, di2); cb.check(); } { Dictionary<string, string> di1 = new Dictionary<string, string>(); di1["foo"] = "abc -1.1"; di1["bar"] = "abc 123123.2"; Dictionary<string, string> di2 = new Dictionary<string, string>(); // di2["foo"] = "abc -1.1"; // Disabled since new dictionary mapping di2["FOO"] = "abc -100.4"; di2["BAR"] = "abc 0.5"; AMI_MyClass_opStringStringDI cb = new AMI_MyClass_opStringStringDI(); p.opStringStringD_async(cb, di1, di2); cb.check(); } { Dictionary<string, Test.MyEnum> di1 = new Dictionary<string, Test.MyEnum>(); di1["abc"] = Test.MyEnum.enum1; di1[""] = Test.MyEnum.enum2; Dictionary<string, Test.MyEnum> di2 = new Dictionary<string, Test.MyEnum>(); // di2["abc"] = Test.MyEnum.enum1; // Disabled since new dictionary mapping di2["qwerty"] = Test.MyEnum.enum3; di2["Hello!!"] = Test.MyEnum.enum2; AMI_MyClass_opStringMyEnumDI cb = new AMI_MyClass_opStringMyEnumDI(); p.opStringMyEnumD_async(cb, di1, di2); cb.check(); } { Dictionary<Test.MyEnum, string> di1 = new Dictionary<Test.MyEnum, string>(); di1[Test.MyEnum.enum1] = "abc"; Dictionary<Test.MyEnum, string> di2 = new Dictionary<Test.MyEnum, string>(); di2[Test.MyEnum.enum2] = "Hello!!"; di2[Test.MyEnum.enum3] = "qwerty"; AMI_MyClass_opMyEnumStringDI cb = new AMI_MyClass_opMyEnumStringDI(); p.opMyEnumStringD_async(cb, di1, di2); cb.check(); } { Test.MyStruct s11 = new Test.MyStruct(1, 1); Test.MyStruct s12 = new Test.MyStruct(1, 2); Dictionary<Test.MyStruct, Test.MyEnum> di1 = new Dictionary<Test.MyStruct, Test.MyEnum>(); di1[s11] = Test.MyEnum.enum1; di1[s12] = Test.MyEnum.enum2; Test.MyStruct s22 = new Test.MyStruct(2, 2); Test.MyStruct s23 = new Test.MyStruct(2, 3); Dictionary<Test.MyStruct, Test.MyEnum> di2 = new Dictionary<Test.MyStruct, Test.MyEnum>(); di2[s22] = Test.MyEnum.enum3; di2[s23] = Test.MyEnum.enum2; AMI_MyClass_opMyStructMyEnumDI cb = new AMI_MyClass_opMyStructMyEnumDI(); p.opMyStructMyEnumD_async(cb, di1, di2); cb.check(); } { int[] lengths = new int[] {0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000}; for(int l = 0; l < lengths.Length; ++l) { Test.IntS s = new Test.IntS(); for(int i = 0; i < lengths[l]; ++i) { s.Add(i); } AMI_MyClass_opIntSI cb = new AMI_MyClass_opIntSI(lengths[l]); p.opIntS_async(cb, s); cb.check(); } } { Dictionary<string, string> ctx = new Dictionary<string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; { test(p.ice_getContext().Count == 0); AMI_MyClass_opContextNotEqualI cb = new AMI_MyClass_opContextNotEqualI(ctx); p.opContext_async(cb); cb.check(); } { test(p.ice_getContext().Count == 0); AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p.opContext_async(cb, ctx); cb.check(); } Test.MyClassPrx p2 = Test.MyClassPrxHelper.checkedCast(p.ice_context(ctx)); test(Ice.CollectionComparer.Equals(p2.ice_getContext(), ctx)); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p2.opContext_async(cb); cb.check(); } { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p2.opContext_async(cb, ctx); cb.check(); } } { // // Test implicit context propagation // string[] impls = {"Shared", "PerThread"}; for(int i = 0; i < 2; i++) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.ImplicitContext", impls[i]); Ice.Communicator ic = Ice.Util.initialize(initData); Dictionary<string, string> ctx = new Dictionary<string, string>(); ctx["one"] = "ONE"; ctx["two"] = "TWO"; ctx["three"] = "THREE"; Test.MyClassPrx p3 = Test.MyClassPrxHelper.uncheckedCast( ic.stringToProxy("test:default -p 12010")); ic.getImplicitContext().setContext(ctx); test(Ice.CollectionComparer.Equals(ic.getImplicitContext().getContext(), ctx)); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p3.opContext_async(cb); cb.check(); } ic.getImplicitContext().put("zero", "ZERO"); ctx = ic.getImplicitContext().getContext(); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(ctx); p3.opContext_async(cb); cb.check(); } Dictionary<string, string> prxContext = new Dictionary<string, string>(); prxContext["one"] = "UN"; prxContext["four"] = "QUATRE"; Dictionary<string, string> combined = new Dictionary<string, string>(prxContext); foreach(KeyValuePair<string, string> e in ctx) { try { combined.Add(e.Key, e.Value); } catch(System.ArgumentException) { // Ignore. } } test(combined["one"].Equals("UN")); p3 = Test.MyClassPrxHelper.uncheckedCast(p3.ice_context(prxContext)); ic.getImplicitContext().setContext(null); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(prxContext); p3.opContext_async(cb); cb.check(); } ic.getImplicitContext().setContext(ctx); { AMI_MyClass_opContextEqualI cb = new AMI_MyClass_opContextEqualI(combined); p3.opContext_async(cb); cb.check(); } ic.getImplicitContext().setContext(null); ic.destroy(); } } { AMI_MyClass_opIdempotentI cb = new AMI_MyClass_opIdempotentI(); p.opIdempotent_async(cb); cb.check(); } { AMI_MyClass_opNonmutatingI cb = new AMI_MyClass_opNonmutatingI(); p.opNonmutating_async(cb); cb.check(); } { Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(p); test(derived != null); AMI_MyDerivedClass_opDerivedI cb = new AMI_MyDerivedClass_opDerivedI(); derived.opDerived_async(cb); cb.check(); } }