1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
|
// **********************************************************************
//
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <IceUtil/Random.h>
#include <Ice/Ice.h>
#include <TestCommon.h>
#include <Test.h>
#include <set>
#include <functional>
using namespace std;
using namespace Test;
struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
{
ptrdiff_t operator()(ptrdiff_t d)
{
return IceUtilInternal::random(static_cast<int>(d));
}
};
class GetAdapterNameCB : public AMI_TestIntf_getAdapterName, public IceUtil::Monitor<IceUtil::Mutex>
{
public:
virtual void
ice_response(const string& name)
{
Lock sync(*this);
assert(!name.empty());
_name = name;
notify();
}
virtual void
ice_exception(const Ice::Exception&)
{
test(false);
}
virtual string
getResult()
{
Lock sync(*this);
while(_name.empty())
{
wait();
}
return _name;
}
private:
string _name;
};
typedef IceUtil::Handle<GetAdapterNameCB> GetAdapterNameCBPtr;
string
getAdapterNameWithAMI(const TestIntfPrx& test)
{
GetAdapterNameCBPtr cb = new GetAdapterNameCB();
test->getAdapterName_async(cb);
return cb->getResult();
}
TestIntfPrx
createTestIntfPrx(vector<RemoteObjectAdapterPrx>& adapters)
{
Ice::EndpointSeq endpoints;
TestIntfPrx test;
for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
test = (*p)->getTestIntf();
Ice::EndpointSeq edpts = test->ice_getEndpoints();
endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
}
return TestIntfPrx::uncheckedCast(test->ice_endpoints(endpoints));
}
void
deactivate(const RemoteCommunicatorPrx& com, vector<RemoteObjectAdapterPrx>& adapters)
{
for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
com->deactivateObjectAdapter(*p);
}
}
void
allTests(const Ice::CommunicatorPtr& communicator)
{
string ref = "communicator:default -p 12010 -t 10000";
RemoteCommunicatorPrx com = RemoteCommunicatorPrx::uncheckedCast(communicator->stringToProxy(ref));
RandomNumberGenerator rng;
cout << "testing binding with single endpoint... " << flush;
{
RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter", "default");
TestIntfPrx test1 = adapter->getTestIntf();
TestIntfPrx test2 = adapter->getTestIntf();
test(test1->ice_getConnection() == test2->ice_getConnection());
test1->ice_ping();
test2->ice_ping();
com->deactivateObjectAdapter(adapter);
TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1);
test(test3->ice_getConnection() == test1->ice_getConnection());
test(test3->ice_getConnection() == test2->ice_getConnection());
try
{
test3->ice_ping();
test(false);
}
catch(const Ice::ConnectionRefusedException&)
{
}
}
cout << "ok" << endl;
cout << "testing binding with multiple endpoints... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter11", "default"));
adapters.push_back(com->createObjectAdapter("Adapter12", "default"));
adapters.push_back(com->createObjectAdapter("Adapter13", "default"));
//
// Ensure that when a connection is opened it's reused for new
// proxies and that all endpoints are eventually tried.
//
set<string> names;
names.insert("Adapter11");
names.insert("Adapter12");
names.insert("Adapter13");
while(!names.empty())
{
vector<RemoteObjectAdapterPrx> adpts = adapters;
TestIntfPrx test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
test(test2->ice_getConnection() == test3->ice_getConnection());
names.erase(test1->getAdapterName());
test1->ice_getConnection()->close(false);
}
//
// Ensure that the proxy correctly caches the connection (we
// always send the request over the same connection.)
//
{
for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
(*p)->getTestIntf()->ice_ping();
}
TestIntfPrx test = createTestIntfPrx(adapters);
string name = test->getAdapterName();
const int nRetry = 10;
int i;
for(i = 0; i < nRetry && test->getAdapterName() == name; i++);
test(i == nRetry);
for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
{
(*q)->getTestIntf()->ice_getConnection()->close(false);
}
}
//
// Deactivate an adapter and ensure that we can still
// establish the connection to the remaining adapters.
//
com->deactivateObjectAdapter(adapters[0]);
names.insert("Adapter12");
names.insert("Adapter13");
while(!names.empty())
{
vector<RemoteObjectAdapterPrx> adpts = adapters;
TestIntfPrx test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
test(test2->ice_getConnection() == test3->ice_getConnection());
names.erase(test1->getAdapterName());
test1->ice_getConnection()->close(false);
}
//
// Deactivate an adapter and ensure that we can still
// establish the connection to the remaining adapter.
//
com->deactivateObjectAdapter(adapters[2]);
TestIntfPrx test = createTestIntfPrx(adapters);
test(test->getAdapterName() == "Adapter12");
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing binding with multiple endpoints and AMI... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("AdapterAMI11", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI12", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI13", "default"));
//
// Ensure that when a connection is opened it's reused for new
// proxies and that all endpoints are eventually tried.
//
set<string> names;
names.insert("AdapterAMI11");
names.insert("AdapterAMI12");
names.insert("AdapterAMI13");
while(!names.empty())
{
vector<RemoteObjectAdapterPrx> adpts = adapters;
TestIntfPrx test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
test(test2->ice_getConnection() == test3->ice_getConnection());
names.erase(getAdapterNameWithAMI(test1));
test1->ice_getConnection()->close(false);
}
//
// Ensure that the proxy correctly caches the connection (we
// always send the request over the same connection.)
//
{
for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
(*p)->getTestIntf()->ice_ping();
}
TestIntfPrx test = createTestIntfPrx(adapters);
string name = getAdapterNameWithAMI(test);
const int nRetry = 10;
int i;
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == name; i++);
test(i == nRetry);
for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
{
(*q)->getTestIntf()->ice_getConnection()->close(false);
}
}
//
// Deactivate an adapter and ensure that we can still
// establish the connection to the remaining adapters.
//
com->deactivateObjectAdapter(adapters[0]);
names.insert("AdapterAMI12");
names.insert("AdapterAMI13");
while(!names.empty())
{
vector<RemoteObjectAdapterPrx> adpts = adapters;
TestIntfPrx test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
TestIntfPrx test3 = createTestIntfPrx(adpts);
test(test1->ice_getConnection() == test2->ice_getConnection());
test(test2->ice_getConnection() == test3->ice_getConnection());
names.erase(test1->getAdapterName());
test1->ice_getConnection()->close(false);
}
//
// Deactivate an adapter and ensure that we can still
// establish the connection to the remaining adapter.
//
com->deactivateObjectAdapter(adapters[2]);
TestIntfPrx test = createTestIntfPrx(adapters);
test(test->getAdapterName() == "AdapterAMI12");
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing random endpoint selection... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter21", "default"));
adapters.push_back(com->createObjectAdapter("Adapter22", "default"));
adapters.push_back(com->createObjectAdapter("Adapter23", "default"));
TestIntfPrx test = createTestIntfPrx(adapters);
test(test->ice_getEndpointSelection() == Ice::Random);
set<string> names;
names.insert("Adapter21");
names.insert("Adapter22");
names.insert("Adapter23");
while(!names.empty())
{
names.erase(test->getAdapterName());
test->ice_getConnection()->close(false);
}
test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Random));
test(test->ice_getEndpointSelection() == Ice::Random);
names.insert("Adapter21");
names.insert("Adapter22");
names.insert("Adapter23");
while(!names.empty())
{
names.erase(test->getAdapterName());
test->ice_getConnection()->close(false);
}
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing ordered endpoint selection... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter31", "default"));
adapters.push_back(com->createObjectAdapter("Adapter32", "default"));
adapters.push_back(com->createObjectAdapter("Adapter33", "default"));
TestIntfPrx test = createTestIntfPrx(adapters);
test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered));
test(test->ice_getEndpointSelection() == Ice::Ordered);
const int nRetry = 5;
int i;
//
// Ensure that endpoints are tried in order by deactiving the adapters
// one after the other.
//
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter31"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[0]);
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter32"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[1]);
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter33"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[2]);
try
{
#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
IceUtil::DummyBCC dummy;
#endif
test->getAdapterName();
}
catch(const Ice::ConnectionRefusedException&)
{
}
Ice::EndpointSeq endpoints = test->ice_getEndpoints();
adapters.clear();
//
// Now, re-activate the adapters with the same endpoints in the opposite
// order.
//
adapters.push_back(com->createObjectAdapter("Adapter36", endpoints[2]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter36"; i++);
test(i == nRetry);
test->ice_getConnection()->close(false);
adapters.push_back(com->createObjectAdapter("Adapter35", endpoints[1]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++);
test(i == nRetry);
test->ice_getConnection()->close(false);
adapters.push_back(com->createObjectAdapter("Adapter34", endpoints[0]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++);
test(i == nRetry);
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing per request binding with single endpoint... " << flush;
{
RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter41", "default");
TestIntfPrx test1 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false));
TestIntfPrx test2 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false));
test(!test1->ice_isConnectionCached());
test(!test2->ice_isConnectionCached());
test(test1->ice_getConnection() == test2->ice_getConnection());
test1->ice_ping();
com->deactivateObjectAdapter(adapter);
TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1);
try
{
#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
IceUtil::DummyBCC dummy;
#endif
test(test3->ice_getConnection() == test1->ice_getConnection());
test(false);
}
catch(const Ice::ConnectionRefusedException&)
{
}
}
cout << "ok" << endl;
cout << "testing per request binding with multiple endpoints... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter51", "default"));
adapters.push_back(com->createObjectAdapter("Adapter52", "default"));
adapters.push_back(com->createObjectAdapter("Adapter53", "default"));
TestIntfPrx test = TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters)->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
set<string> names;
names.insert("Adapter51");
names.insert("Adapter52");
names.insert("Adapter53");
while(!names.empty())
{
names.erase(test->getAdapterName());
}
com->deactivateObjectAdapter(adapters[0]);
names.insert("Adapter52");
names.insert("Adapter53");
while(!names.empty())
{
names.erase(test->getAdapterName());
}
com->deactivateObjectAdapter(adapters[2]);
test(test->getAdapterName() == "Adapter52");
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing per request binding with multiple endpoints and AMI... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("AdapterAMI51", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI52", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI53", "default"));
TestIntfPrx test = TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters)->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
set<string> names;
names.insert("AdapterAMI51");
names.insert("AdapterAMI52");
names.insert("AdapterAMI53");
while(!names.empty())
{
names.erase(getAdapterNameWithAMI(test));
}
com->deactivateObjectAdapter(adapters[0]);
names.insert("AdapterAMI52");
names.insert("AdapterAMI53");
while(!names.empty())
{
names.erase(getAdapterNameWithAMI(test));
}
com->deactivateObjectAdapter(adapters[2]);
test(test->getAdapterName() == "AdapterAMI52");
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing per request binding and ordered endpoint selection... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter61", "default"));
adapters.push_back(com->createObjectAdapter("Adapter62", "default"));
adapters.push_back(com->createObjectAdapter("Adapter63", "default"));
TestIntfPrx test = createTestIntfPrx(adapters);
test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered));
test(test->ice_getEndpointSelection() == Ice::Ordered);
test = TestIntfPrx::uncheckedCast(test->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
const int nRetry = 5;
int i;
//
// Ensure that endpoints are tried in order by deactiving the adapters
// one after the other.
//
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter61"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[0]);
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter62"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[1]);
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter63"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[2]);
try
{
#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
IceUtil::DummyBCC dummy;
#endif
test->getAdapterName();
}
catch(const Ice::ConnectionRefusedException&)
{
}
Ice::EndpointSeq endpoints = test->ice_getEndpoints();
adapters.clear();
//
// Now, re-activate the adapters with the same endpoints in the opposite
// order.
//
adapters.push_back(com->createObjectAdapter("Adapter66", endpoints[2]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter66"; i++);
test(i == nRetry);
adapters.push_back(com->createObjectAdapter("Adapter65", endpoints[1]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter65"; i++);
test(i == nRetry);
adapters.push_back(com->createObjectAdapter("Adapter64", endpoints[0]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter64"; i++);
test(i == nRetry);
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing per request binding and ordered endpoint selection and AMI... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("AdapterAMI61", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI62", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI63", "default"));
TestIntfPrx test = createTestIntfPrx(adapters);
test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Ordered));
test(test->ice_getEndpointSelection() == Ice::Ordered);
test = TestIntfPrx::uncheckedCast(test->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
const int nRetry = 5;
int i;
//
// Ensure that endpoints are tried in order by deactiving the adapters
// one after the other.
//
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI61"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[0]);
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI62"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[1]);
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI63"; i++);
test(i == nRetry);
com->deactivateObjectAdapter(adapters[2]);
try
{
test->getAdapterName();
}
catch(const Ice::ConnectionRefusedException&)
{
}
Ice::EndpointSeq endpoints = test->ice_getEndpoints();
adapters.clear();
//
// Now, re-activate the adapters with the same endpoints in the opposite
// order.
//
adapters.push_back(com->createObjectAdapter("AdapterAMI66", endpoints[2]->toString()));
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI66"; i++);
test(i == nRetry);
adapters.push_back(com->createObjectAdapter("AdapterAMI65", endpoints[1]->toString()));
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI65"; i++);
test(i == nRetry);
adapters.push_back(com->createObjectAdapter("AdapterAMI64", endpoints[0]->toString()));
for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI64"; i++);
test(i == nRetry);
deactivate(com, adapters);
}
cout << "ok" << endl;
cout << "testing endpoint mode filtering... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter71", "default"));
adapters.push_back(com->createObjectAdapter("Adapter72", "udp"));
TestIntfPrx test = createTestIntfPrx(adapters);
test(test->getAdapterName() == "Adapter71");
TestIntfPrx testUDP = TestIntfPrx::uncheckedCast(test->ice_datagram());
test(test->ice_getConnection() != testUDP->ice_getConnection());
try
{
testUDP->getAdapterName();
}
catch(const Ice::TwowayOnlyException&)
{
}
}
cout << "ok" << endl;
if(!communicator->getProperties()->getProperty("Ice.Plugin.IceSSL").empty())
{
cout << "testing unsecure vs. secure endpoints... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
adapters.push_back(com->createObjectAdapter("Adapter81", "ssl"));
adapters.push_back(com->createObjectAdapter("Adapter82", "tcp"));
TestIntfPrx test = createTestIntfPrx(adapters);
int i;
for(i = 0; i < 5; i++)
{
test(test->getAdapterName() == "Adapter82");
test->ice_getConnection()->close(false);
}
TestIntfPrx testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true));
test(testSecure->ice_isSecure());
testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(false));
test(!testSecure->ice_isSecure());
testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true));
test(testSecure->ice_isSecure());
test(test->ice_getConnection() != testSecure->ice_getConnection());
com->deactivateObjectAdapter(adapters[1]);
for(i = 0; i < 5; i++)
{
test(test->getAdapterName() == "Adapter81");
test->ice_getConnection()->close(false);
}
com->createObjectAdapter("Adapter83", (test->ice_getEndpoints()[1])->toString()); // Reactive tcp OA.
for(i = 0; i < 5; i++)
{
test(test->getAdapterName() == "Adapter83");
test->ice_getConnection()->close(false);
}
com->deactivateObjectAdapter(adapters[0]);
try
{
testSecure->ice_ping();
test(false);
}
catch(const Ice::ConnectionRefusedException&)
{
}
deactivate(com, adapters);
}
cout << "ok" << endl;
}
com->shutdown();
}
|