1
// **********************************************************************
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
5
// This copy of Ice is licensed to you under the terms described in the
6
// ICE_LICENSE file included in this distribution.
8
// **********************************************************************
11
#include <TestCommon.h>
19
class CallbackBase : public Ice::LocalObject
28
virtual ~CallbackBase()
34
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_m);
46
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_m);
54
IceUtil::Monitor<IceUtil::Mutex> _m;
58
typedef IceUtil::Handle<CallbackBase> CallbackBasePtr;
60
class Callback : public CallbackBase
68
Callback(const Ice::CommunicatorPtr& communicator)
69
: _communicator(communicator)
84
void id(const string& id)
86
test(id == Test::MyDerivedClass::ice_staticId());
90
void ids(const Ice::StringSeq& ids)
92
test(ids.size() == 3);
93
test(ids[0] == "::Ice::Object");
94
test(ids[1] == "::Test::MyClass");
95
test(ids[2] == "::Test::MyDerivedClass");
104
void opContext(const Ice::Context&)
109
void opByte(Ice::Byte r, Ice::Byte b)
111
test(b == Ice::Byte(0xf0));
112
test(r == Ice::Byte(0xff));
116
void opBool(bool r, bool b)
123
void opShortIntLong(Ice::Long r, Ice::Short s, Ice::Int i, Ice::Long l)
132
void opFloatDouble(Ice::Double r, Ice::Float f, Ice::Double d)
134
test(f == Ice::Float(3.14));
135
test(d == Ice::Double(1.1E10));
136
test(r == Ice::Double(1.1E10));
140
void opString(const ::std::string& r, const ::std::string& s)
142
test(s == "world hello");
143
test(r == "hello world");
147
void opMyEnum(Test::MyEnum r, Test::MyEnum e)
149
test(e == Test::enum2);
150
test(r == Test::enum3);
154
void opMyClass(const Test::MyClassPrx& r, const Test::MyClassPrx& c1, const Test::MyClassPrx& c2)
156
test(c1->ice_getIdentity() == _communicator->stringToIdentity("test"));
157
test(c2->ice_getIdentity() == _communicator->stringToIdentity("noSuchIdentity"));
158
test(r->ice_getIdentity() == _communicator->stringToIdentity("test"));
161
// We can't do the callbacks below in connection serialization mode.
163
if(_communicator->getProperties()->getPropertyAsInt("Ice.ThreadPool.Client.Serialize"))
172
catch(const Ice::ObjectNotExistException&)
179
void opStruct(const Test::Structure& rso, const Test::Structure& so)
182
test(rso.e == Test::enum2);
183
test(rso.s.s == "def");
184
test(so.e == Test::enum3);
185
test(so.s.s == "a new string");
188
// We can't do the callbacks below in connection serialization mode.
190
if(_communicator->getProperties()->getPropertyAsInt("Ice.ThreadPool.Client.Serialize"))
197
void opByteS(const Test::ByteS& rso, const Test::ByteS& bso)
199
test(bso.size() == 4);
200
test(bso[0] == Ice::Byte(0x22));
201
test(bso[1] == Ice::Byte(0x12));
202
test(bso[2] == Ice::Byte(0x11));
203
test(bso[3] == Ice::Byte(0x01));
204
test(rso.size() == 8);
205
test(rso[0] == Ice::Byte(0x01));
206
test(rso[1] == Ice::Byte(0x11));
207
test(rso[2] == Ice::Byte(0x12));
208
test(rso[3] == Ice::Byte(0x22));
209
test(rso[4] == Ice::Byte(0xf1));
210
test(rso[5] == Ice::Byte(0xf2));
211
test(rso[6] == Ice::Byte(0xf3));
212
test(rso[7] == Ice::Byte(0xf4));
216
void opBoolS(const Test::BoolS& rso, const Test::BoolS& bso)
218
test(bso.size() == 4);
223
test(rso.size() == 3);
230
void opShortIntLongS(const Test::LongS& rso, const Test::ShortS& sso, const Test::IntS& iso, const Test::LongS& lso)
232
test(sso.size() == 3);
236
test(iso.size() == 4);
241
test(lso.size() == 6);
248
test(rso.size() == 3);
255
void opFloatDoubleS(const Test::DoubleS& rso, const Test::FloatS& fso, const Test::DoubleS& dso)
257
test(fso.size() == 2);
258
test(fso[0] == ::Ice::Float(3.14));
259
test(fso[1] == ::Ice::Float(1.11));
260
test(dso.size() == 3);
261
test(dso[0] == ::Ice::Double(1.3E10));
262
test(dso[1] == ::Ice::Double(1.2E10));
263
test(dso[2] == ::Ice::Double(1.1E10));
264
test(rso.size() == 5);
265
test(rso[0] == ::Ice::Double(1.1E10));
266
test(rso[1] == ::Ice::Double(1.2E10));
267
test(rso[2] == ::Ice::Double(1.3E10));
268
test(::Ice::Float(rso[3]) == ::Ice::Float(3.14));
269
test(::Ice::Float(rso[4]) == ::Ice::Float(1.11));
273
void opStringS(const Test::StringS& rso, const Test::StringS& sso)
275
test(sso.size() == 4);
276
test(sso[0] == "abc");
277
test(sso[1] == "de");
278
test(sso[2] == "fghi");
279
test(sso[3] == "xyz");
280
test(rso.size() == 3);
281
test(rso[0] == "fghi");
282
test(rso[1] == "de");
283
test(rso[2] == "abc");
287
void opByteSS(const Test::ByteSS& rso, const Test::ByteSS& bso)
289
test(bso.size() == 2);
290
test(bso[0].size() == 1);
291
test(bso[0][0] == Ice::Byte(0xff));
292
test(bso[1].size() == 3);
293
test(bso[1][0] == Ice::Byte(0x01));
294
test(bso[1][1] == Ice::Byte(0x11));
295
test(bso[1][2] == Ice::Byte(0x12));
296
test(rso.size() == 4);
297
test(rso[0].size() == 3);
298
test(rso[0][0] == Ice::Byte(0x01));
299
test(rso[0][1] == Ice::Byte(0x11));
300
test(rso[0][2] == Ice::Byte(0x12));
301
test(rso[1].size() == 1);
302
test(rso[1][0] == Ice::Byte(0xff));
303
test(rso[2].size() == 1);
304
test(rso[2][0] == Ice::Byte(0x0e));
305
test(rso[3].size() == 2);
306
test(rso[3][0] == Ice::Byte(0xf2));
307
test(rso[3][1] == Ice::Byte(0xf1));
311
void opFloatDoubleSS(const Test::DoubleSS& rso, const Test::FloatSS& fso, const Test::DoubleSS& dso)
313
test(fso.size() == 3);
314
test(fso[0].size() == 1);
315
test(fso[0][0] == ::Ice::Float(3.14));
316
test(fso[1].size() == 1);
317
test(fso[1][0] == ::Ice::Float(1.11));
318
test(fso[2].size() == 0);
319
test(dso.size() == 1);
320
test(dso[0].size() == 3);
321
test(dso[0][0] == ::Ice::Double(1.1E10));
322
test(dso[0][1] == ::Ice::Double(1.2E10));
323
test(dso[0][2] == ::Ice::Double(1.3E10));
324
test(rso.size() == 2);
325
test(rso[0].size() == 3);
326
test(rso[0][0] == ::Ice::Double(1.1E10));
327
test(rso[0][1] == ::Ice::Double(1.2E10));
328
test(rso[0][2] == ::Ice::Double(1.3E10));
329
test(rso[1].size() == 3);
330
test(rso[1][0] == ::Ice::Double(1.1E10));
331
test(rso[1][1] == ::Ice::Double(1.2E10));
332
test(rso[1][2] == ::Ice::Double(1.3E10));
336
void opStringSS(const Test::StringSS& rso, const Test::StringSS& sso)
338
test(sso.size() == 5);
339
test(sso[0].size() == 1);
340
test(sso[0][0] == "abc");
341
test(sso[1].size() == 2);
342
test(sso[1][0] == "de");
343
test(sso[1][1] == "fghi");
344
test(sso[2].size() == 0);
345
test(sso[3].size() == 0);
346
test(sso[4].size() == 1);
347
test(sso[4][0] == "xyz");
348
test(rso.size() == 3);
349
test(rso[0].size() == 1);
350
test(rso[0][0] == "xyz");
351
test(rso[1].size() == 0);
352
test(rso[2].size() == 0);
356
void opByteBoolD(const Test::ByteBoolD& ro, const Test::ByteBoolD& _do)
362
test(ro.size() == 4);
363
test(ro.find(10) != ro.end());
364
test(ro.find(10)->second == true);
365
test(ro.find(11) != ro.end());
366
test(ro.find(11)->second == false);
367
test(ro.find(100) != ro.end());
368
test(ro.find(100)->second == false);
369
test(ro.find(101) != ro.end());
370
test(ro.find(101)->second == true);
374
void opShortIntD(const Test::ShortIntD& ro, const Test::ShortIntD& _do)
380
test(ro.size() == 4);
381
test(ro.find(110) != ro.end());
382
test(ro.find(110)->second == -1);
383
test(ro.find(111) != ro.end());
384
test(ro.find(111)->second == -100);
385
test(ro.find(1100) != ro.end());
386
test(ro.find(1100)->second == 123123);
387
test(ro.find(1101) != ro.end());
388
test(ro.find(1101)->second == 0);
392
void opLongFloatD(const Test::LongFloatD& ro, const Test::LongFloatD& _do)
394
Test::LongFloatD di1;
395
di1[999999110] = Ice::Float(-1.1);
396
di1[999999111] = Ice::Float(123123.2);
398
test(ro.size() == 4);
399
test(ro.find(999999110) != ro.end());
400
test(ro.find(999999110)->second == Ice::Float(-1.1));
401
test(ro.find(999999120) != ro.end());
402
test(ro.find(999999120)->second == Ice::Float(-100.4));
403
test(ro.find(999999111) != ro.end());
404
test(ro.find(999999111)->second == Ice::Float(123123.2));
405
test(ro.find(999999130) != ro.end());
406
test(ro.find(999999130)->second == Ice::Float(0.5));
410
void opStringStringD(const Test::StringStringD& ro, const Test::StringStringD& _do)
412
Test::StringStringD di1;
413
di1["foo"] = "abc -1.1";
414
di1["bar"] = "abc 123123.2";
416
test(ro.size() == 4);
417
test(ro.find("foo") != ro.end());
418
test(ro.find("foo")->second == "abc -1.1");
419
test(ro.find("FOO") != ro.end());
420
test(ro.find("FOO")->second == "abc -100.4");
421
test(ro.find("bar") != ro.end());
422
test(ro.find("bar")->second == "abc 123123.2");
423
test(ro.find("BAR") != ro.end());
424
test(ro.find("BAR")->second == "abc 0.5");
428
void opStringMyEnumD(const Test::StringMyEnumD& ro, const Test::StringMyEnumD& _do)
430
Test::StringMyEnumD di1;
431
di1["abc"] = Test::enum1;
432
di1[""] = Test::enum2;
434
test(ro.size() == 4);
435
test(ro.find("abc") != ro.end());
436
test(ro.find("abc")->second == Test::enum1);
437
test(ro.find("qwerty") != ro.end());
438
test(ro.find("qwerty")->second == Test::enum3);
439
test(ro.find("") != ro.end());
440
test(ro.find("")->second == Test::enum2);
441
test(ro.find("Hello!!") != ro.end());
442
test(ro.find("Hello!!")->second == Test::enum2);
446
void opMyStructMyEnumD(const Test::MyStructMyEnumD& ro, const Test::MyStructMyEnumD& _do)
448
Test::MyStruct s11 = { 1, 1 };
449
Test::MyStruct s12 = { 1, 2 };
450
Test::MyStructMyEnumD di1;
451
di1[s11] = Test::enum1;
452
di1[s12] = Test::enum2;
454
Test::MyStruct s22 = { 2, 2 };
455
Test::MyStruct s23 = { 2, 3 };
456
test(ro.size() == 4);
457
test(ro.find(s11) != ro.end());
458
test(ro.find(s11)->second == Test::enum1);
459
test(ro.find(s12) != ro.end());
460
test(ro.find(s12)->second == Test::enum2);
461
test(ro.find(s22) != ro.end());
462
test(ro.find(s22)->second == Test::enum3);
463
test(ro.find(s23) != ro.end());
464
test(ro.find(s23)->second == Test::enum2);
468
void opIntS(const Test::IntS& r)
470
for(int j = 0; j < static_cast<int>(r.size()); ++j)
477
void opDoubleMarshaling()
487
void exCB(const Ice::Exception& ex)
494
Ice::CommunicatorPtr _communicator;
496
typedef IceUtil::Handle<Callback> CallbackPtr;
501
twowaysNewAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p)
504
CallbackPtr cb = new Callback;
505
Ice::Callback_Object_ice_pingPtr callback = Ice::newCallback_Object_ice_ping(cb,
508
p->begin_ice_ping(callback);
513
CallbackPtr cb = new Callback;
514
Ice::Callback_Object_ice_isAPtr callback = Ice::newCallback_Object_ice_isA(cb,
517
p->begin_ice_isA(Test::MyClass::ice_staticId(), callback);
522
CallbackPtr cb = new Callback;
523
Ice::Callback_Object_ice_idPtr callback = Ice::newCallback_Object_ice_id(cb,
526
p->begin_ice_id(callback);
531
CallbackPtr cb = new Callback;
532
Ice::Callback_Object_ice_idsPtr callback = Ice::newCallback_Object_ice_ids(cb,
535
p->begin_ice_ids(callback);
540
CallbackPtr cb = new Callback;
541
Test::Callback_MyClass_opVoidPtr callback = Test::newCallback_MyClass_opVoid(cb,
544
p->begin_opVoid(callback);
549
Ice::Double d = 1278312346.0 / 13.0;
550
Test::DoubleS ds(5, d);
551
CallbackPtr cb = new Callback;
552
Test::Callback_MyClass_opBytePtr callback = Test::newCallback_MyClass_opByte(cb,
555
p->begin_opByte(Ice::Byte(0xff), Ice::Byte(0x0f), callback);
561
CallbackPtr cb = new Callback;
562
Test::Callback_MyClass_opVoidPtr callback = Test::newCallback_MyClass_opVoid(cb,
565
p->begin_opVoid(callback);
570
CallbackPtr cb = new Callback;
571
Test::Callback_MyClass_opBoolPtr callback = Test::newCallback_MyClass_opBool(cb,
574
p->begin_opBool(true, false, callback);
579
CallbackPtr cb = new Callback;
580
Test::Callback_MyClass_opShortIntLongPtr callback =
581
Test::newCallback_MyClass_opShortIntLong(cb, &Callback::opShortIntLong, &Callback::exCB);
582
p->begin_opShortIntLong(10, 11, 12, callback);
587
CallbackPtr cb = new Callback;
588
Test::Callback_MyClass_opFloatDoublePtr callback =
589
Test::newCallback_MyClass_opFloatDouble(cb, &Callback::opFloatDouble, &Callback::exCB);
590
p->begin_opFloatDouble(Ice::Float(3.14), Ice::Double(1.1E10), callback);
595
CallbackPtr cb = new Callback;
596
Test::Callback_MyClass_opStringPtr callback = Test::newCallback_MyClass_opString(cb,
599
p->begin_opString("hello", "world", callback);
604
CallbackPtr cb = new Callback;
605
Test::Callback_MyClass_opMyEnumPtr callback = Test::newCallback_MyClass_opMyEnum(cb,
608
p->begin_opMyEnum(Test::enum2, callback);
613
CallbackPtr cb = new Callback(communicator);
614
Test::Callback_MyClass_opMyClassPtr callback = Test::newCallback_MyClass_opMyClass(cb,
615
&Callback::opMyClass,
617
p->begin_opMyClass(p, callback);
631
CallbackPtr cb = new Callback(communicator);
632
Test::Callback_MyClass_opStructPtr callback = Test::newCallback_MyClass_opStruct(cb,
635
p->begin_opStruct(si1, si2, callback);
643
bsi1.push_back(Ice::Byte(0x01));
644
bsi1.push_back(Ice::Byte(0x11));
645
bsi1.push_back(Ice::Byte(0x12));
646
bsi1.push_back(Ice::Byte(0x22));
648
bsi2.push_back(Ice::Byte(0xf1));
649
bsi2.push_back(Ice::Byte(0xf2));
650
bsi2.push_back(Ice::Byte(0xf3));
651
bsi2.push_back(Ice::Byte(0xf4));
653
CallbackPtr cb = new Callback;
654
Test::Callback_MyClass_opByteSPtr callback = Test::newCallback_MyClass_opByteS(cb,
657
p->begin_opByteS(bsi1, bsi2, callback);
665
bsi1.push_back(true);
666
bsi1.push_back(true);
667
bsi1.push_back(false);
669
bsi2.push_back(false);
671
CallbackPtr cb = new Callback;
672
Test::Callback_MyClass_opBoolSPtr callback = Test::newCallback_MyClass_opBoolS(cb,
675
p->begin_opBoolS(bsi1, bsi2, callback);
697
CallbackPtr cb = new Callback;
698
Test::Callback_MyClass_opShortIntLongSPtr callback =
699
Test::newCallback_MyClass_opShortIntLongS(cb, &Callback::opShortIntLongS, &Callback::exCB);
700
p->begin_opShortIntLongS(ssi, isi, lsi, callback);
708
fsi.push_back(Ice::Float(3.14));
709
fsi.push_back(Ice::Float(1.11));
711
dsi.push_back(Ice::Double(1.1E10));
712
dsi.push_back(Ice::Double(1.2E10));
713
dsi.push_back(Ice::Double(1.3E10));
715
CallbackPtr cb = new Callback;
716
Test::Callback_MyClass_opFloatDoubleSPtr callback =
717
Test::newCallback_MyClass_opFloatDoubleS(cb, &Callback::opFloatDoubleS, &Callback::exCB);
718
p->begin_opFloatDoubleS(fsi, dsi, callback);
726
ssi1.push_back("abc");
727
ssi1.push_back("de");
728
ssi1.push_back("fghi");
730
ssi2.push_back("xyz");
732
CallbackPtr cb = new Callback;
733
Test::Callback_MyClass_opStringSPtr callback = Test::newCallback_MyClass_opStringS(cb,
734
&Callback::opStringS,
736
p->begin_opStringS(ssi1, ssi2, callback);
746
bsi1[0].push_back(Ice::Byte(0x01));
747
bsi1[0].push_back(Ice::Byte(0x11));
748
bsi1[0].push_back(Ice::Byte(0x12));
749
bsi1[1].push_back(Ice::Byte(0xff));
751
bsi2[0].push_back(Ice::Byte(0x0e));
752
bsi2[1].push_back(Ice::Byte(0xf2));
753
bsi2[1].push_back(Ice::Byte(0xf1));
755
CallbackPtr cb = new Callback;
756
Test::Callback_MyClass_opByteSSPtr callback = Test::newCallback_MyClass_opByteSS(cb,
759
p->begin_opByteSS(bsi1, bsi2, callback);
769
fsi[0].push_back(Ice::Float(3.14));
770
fsi[1].push_back(Ice::Float(1.11));
772
dsi[0].push_back(Ice::Double(1.1E10));
773
dsi[0].push_back(Ice::Double(1.2E10));
774
dsi[0].push_back(Ice::Double(1.3E10));
776
CallbackPtr cb = new Callback;
777
Test::Callback_MyClass_opFloatDoubleSSPtr callback =
778
Test::newCallback_MyClass_opFloatDoubleSS(cb, &Callback::opFloatDoubleSS, &Callback::exCB);
779
p->begin_opFloatDoubleSS(fsi, dsi, callback);
789
ssi1[0].push_back("abc");
790
ssi1[1].push_back("de");
791
ssi1[1].push_back("fghi");
793
ssi2[2].push_back("xyz");
795
CallbackPtr cb = new Callback;
796
Test::Callback_MyClass_opStringSSPtr callback =
797
Test::newCallback_MyClass_opStringSS(cb, &Callback::opStringSS, &Callback::exCB);
798
p->begin_opStringSS(ssi1, ssi2, callback);
811
CallbackPtr cb = new Callback;
812
Test::Callback_MyClass_opByteBoolDPtr callback =
813
Test::newCallback_MyClass_opByteBoolD(cb, &Callback::opByteBoolD, &Callback::exCB);
814
p->begin_opByteBoolD(di1, di2, callback);
827
CallbackPtr cb = new Callback;
828
Test::Callback_MyClass_opShortIntDPtr callback =
829
Test::newCallback_MyClass_opShortIntD(cb, &Callback::opShortIntD, &Callback::exCB);
830
p->begin_opShortIntD(di1, di2, callback);
835
Test::LongFloatD di1;
836
di1[999999110] = Ice::Float(-1.1);
837
di1[999999111] = Ice::Float(123123.2);
838
Test::LongFloatD di2;
839
di2[999999110] = Ice::Float(-1.1);
840
di2[999999120] = Ice::Float(-100.4);
841
di2[999999130] = Ice::Float(0.5);
843
CallbackPtr cb = new Callback;
844
Test::Callback_MyClass_opLongFloatDPtr callback =
845
Test::newCallback_MyClass_opLongFloatD(cb, &Callback::opLongFloatD, &Callback::exCB);
846
p->begin_opLongFloatD(di1, di2, callback);
851
Test::StringStringD di1;
852
di1["foo"] = "abc -1.1";
853
di1["bar"] = "abc 123123.2";
854
Test::StringStringD di2;
855
di2["foo"] = "abc -1.1";
856
di2["FOO"] = "abc -100.4";
857
di2["BAR"] = "abc 0.5";
859
CallbackPtr cb = new Callback;
860
Test::Callback_MyClass_opStringStringDPtr callback =
861
Test::newCallback_MyClass_opStringStringD(cb, &Callback::opStringStringD, &Callback::exCB);
862
p->begin_opStringStringD(di1, di2, callback);
867
Test::StringMyEnumD di1;
868
di1["abc"] = Test::enum1;
869
di1[""] = Test::enum2;
870
Test::StringMyEnumD di2;
871
di2["abc"] = Test::enum1;
872
di2["qwerty"] = Test::enum3;
873
di2["Hello!!"] = Test::enum2;
875
CallbackPtr cb = new Callback;
876
Test::Callback_MyClass_opStringMyEnumDPtr callback =
877
Test::newCallback_MyClass_opStringMyEnumD(cb, &Callback::opStringMyEnumD, &Callback::exCB);
878
p->begin_opStringMyEnumD(di1, di2, callback);
883
Test::MyStruct s11 = { 1, 1 };
884
Test::MyStruct s12 = { 1, 2 };
885
Test::MyStructMyEnumD di1;
886
di1[s11] = Test::enum1;
887
di1[s12] = Test::enum2;
889
Test::MyStruct s22 = { 2, 2 };
890
Test::MyStruct s23 = { 2, 3 };
891
Test::MyStructMyEnumD di2;
892
di2[s11] = Test::enum1;
893
di2[s22] = Test::enum3;
894
di2[s23] = Test::enum2;
896
CallbackPtr cb = new Callback;
897
Test::Callback_MyClass_opMyStructMyEnumDPtr callback =
898
Test::newCallback_MyClass_opMyStructMyEnumD(cb, &Callback::opMyStructMyEnumD, &Callback::exCB);
899
p->begin_opMyStructMyEnumD(di1, di2, callback);
904
const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 };
906
for(unsigned int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l)
909
for(int i = 0; i < lengths[l]; ++i)
913
CallbackPtr cb = new Callback;
914
Test::Callback_MyClass_opIntSPtr callback =
915
Test::newCallback_MyClass_opIntS(cb, &Callback::opIntS, &Callback::exCB);
916
p->begin_opIntS(s, callback);
922
Test::StringStringD ctx;
925
ctx["three"] = "THREE";
927
test(p->ice_getContext().empty());
928
Ice::AsyncResultPtr r = p->begin_opContext();
929
Ice::Context c = p->end_opContext(r);
933
test(p->ice_getContext().empty());
934
Ice::AsyncResultPtr r = p->begin_opContext(ctx);
935
Ice::Context c = p->end_opContext(r);
938
Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx));
939
test(p2->ice_getContext() == ctx);
941
Ice::AsyncResultPtr r = p2->begin_opContext();
942
Ice::Context c = p2->end_opContext(r);
946
Test::MyClassPrx p2 = Test::MyClassPrx::checkedCast(p->ice_context(ctx));
947
Ice::AsyncResultPtr r = p2->begin_opContext(ctx);
948
Ice::Context c = p2->end_opContext(r);
954
// Test implicit context propagation
957
string impls[] = {"Shared", "PerThread"};
958
for(int i = 0; i < 2; i++)
960
Ice::InitializationData initData;
961
initData.properties = communicator->getProperties()->clone();
962
initData.properties->setProperty("Ice.ImplicitContext", impls[i]);
964
Ice::CommunicatorPtr ic = Ice::initialize(initData);
969
ctx["three"] = "THREE";
972
Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast(
973
ic->stringToProxy("test:default -p 12010"));
976
ic->getImplicitContext()->setContext(ctx);
977
test(ic->getImplicitContext()->getContext() == ctx);
979
Ice::AsyncResultPtr r = p->begin_opContext();
980
Ice::Context c = p->end_opContext(r);
984
ic->getImplicitContext()->put("zero", "ZERO");
986
ctx = ic->getImplicitContext()->getContext();
988
Ice::AsyncResultPtr r = p->begin_opContext();
989
Ice::Context c = p->end_opContext(r);
993
Ice::Context prxContext;
994
prxContext["one"] = "UN";
995
prxContext["four"] = "QUATRE";
997
Ice::Context combined = prxContext;
998
combined.insert(ctx.begin(), ctx.end());
999
test(combined["one"] == "UN");
1001
p = Test::MyClassPrx::uncheckedCast(p->ice_context(prxContext));
1003
ic->getImplicitContext()->setContext(Ice::Context());
1005
Ice::AsyncResultPtr r = p->begin_opContext();
1006
Ice::Context c = p->end_opContext(r);
1007
test(c == prxContext);
1010
ic->getImplicitContext()->setContext(ctx);
1012
Ice::AsyncResultPtr r = p->begin_opContext();
1013
Ice::Context c = p->end_opContext(r);
1014
test(c == combined);
1017
ic->getImplicitContext()->setContext(Ice::Context());
1024
Ice::Double d = 1278312346.0 / 13.0;
1025
Test::DoubleS ds(5, d);
1026
CallbackPtr cb = new Callback;
1027
Test::Callback_MyClass_opDoubleMarshalingPtr callback =
1028
Test::newCallback_MyClass_opDoubleMarshaling(cb, &Callback::opDoubleMarshaling, &Callback::exCB);
1029
p->begin_opDoubleMarshaling(d, ds, callback);
1034
Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(p);
1036
CallbackPtr cb = new Callback;
1037
Test::Callback_MyDerivedClass_opDerivedPtr callback =
1038
Test::newCallback_MyDerivedClass_opDerived(cb, &Callback::opDerived, &Callback::exCB);
1039
derived->begin_opDerived(callback);