1 // **********************************************************************
3 // Copyright (c) 2003-2011 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 // **********************************************************************
10 #include <IceUtil/Random.h>
12 #include <TestCommon.h>
21 struct RandomNumberGenerator
: public std::unary_function
<ptrdiff_t, ptrdiff_t>
23 ptrdiff_t operator()(ptrdiff_t d
)
25 return IceUtilInternal::random(static_cast<int>(d
));
29 class GetAdapterNameCB
: public IceUtil::Shared
, public IceUtil::Monitor
<IceUtil::Mutex
>
34 response(const string
& name
)
37 assert(!name
.empty());
43 exception(const Ice::Exception
&)
63 typedef IceUtil::Handle
<GetAdapterNameCB
> GetAdapterNameCBPtr
;
66 getAdapterNameWithAMI(const TestIntfPrx
& test
)
68 GetAdapterNameCBPtr cb
= new GetAdapterNameCB();
69 test
->begin_getAdapterName(
70 newCallback_TestIntf_getAdapterName(cb
, &GetAdapterNameCB::response
, &GetAdapterNameCB::exception
));
71 return cb
->getResult();
75 createTestIntfPrx(vector
<RemoteObjectAdapterPrx
>& adapters
)
77 Ice::EndpointSeq endpoints
;
79 for(vector
<RemoteObjectAdapterPrx
>::const_iterator p
= adapters
.begin(); p
!= adapters
.end(); ++p
)
81 test
= (*p
)->getTestIntf();
82 Ice::EndpointSeq edpts
= test
->ice_getEndpoints();
83 endpoints
.insert(endpoints
.end(), edpts
.begin(), edpts
.end());
85 return TestIntfPrx::uncheckedCast(test
->ice_endpoints(endpoints
));
89 deactivate(const RemoteCommunicatorPrx
& com
, vector
<RemoteObjectAdapterPrx
>& adapters
)
91 for(vector
<RemoteObjectAdapterPrx
>::const_iterator p
= adapters
.begin(); p
!= adapters
.end(); ++p
)
93 com
->deactivateObjectAdapter(*p
);
98 allTests(const Ice::CommunicatorPtr
& communicator
)
100 string ref
= "communicator:default -p 12010";
101 RemoteCommunicatorPrx com
= RemoteCommunicatorPrx::uncheckedCast(communicator
->stringToProxy(ref
));
103 RandomNumberGenerator rng
;
105 cout
<< "testing binding with single endpoint... " << flush
;
107 RemoteObjectAdapterPrx adapter
= com
->createObjectAdapter("Adapter", "default");
109 TestIntfPrx test1
= adapter
->getTestIntf();
110 TestIntfPrx test2
= adapter
->getTestIntf();
111 test(test1
->ice_getConnection() == test2
->ice_getConnection());
116 com
->deactivateObjectAdapter(adapter
);
118 TestIntfPrx test3
= TestIntfPrx::uncheckedCast(test1
);
119 test(test3
->ice_getConnection() == test1
->ice_getConnection());
120 test(test3
->ice_getConnection() == test2
->ice_getConnection());
127 catch(const Ice::ConnectionRefusedException
&)
131 cout
<< "ok" << endl
;
133 cout
<< "testing binding with multiple endpoints... " << flush
;
135 vector
<RemoteObjectAdapterPrx
> adapters
;
136 adapters
.push_back(com
->createObjectAdapter("Adapter11", "default"));
137 adapters
.push_back(com
->createObjectAdapter("Adapter12", "default"));
138 adapters
.push_back(com
->createObjectAdapter("Adapter13", "default"));
141 // Ensure that when a connection is opened it's reused for new
142 // proxies and that all endpoints are eventually tried.
145 names
.insert("Adapter11");
146 names
.insert("Adapter12");
147 names
.insert("Adapter13");
148 while(!names
.empty())
150 vector
<RemoteObjectAdapterPrx
> adpts
= adapters
;
152 TestIntfPrx test1
= createTestIntfPrx(adpts
);
153 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
154 TestIntfPrx test2
= createTestIntfPrx(adpts
);
155 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
156 TestIntfPrx test3
= createTestIntfPrx(adpts
);
158 test(test1
->ice_getConnection() == test2
->ice_getConnection());
159 test(test2
->ice_getConnection() == test3
->ice_getConnection());
161 names
.erase(test1
->getAdapterName());
162 test1
->ice_getConnection()->close(false);
166 // Ensure that the proxy correctly caches the connection (we
167 // always send the request over the same connection.)
170 for(vector
<RemoteObjectAdapterPrx
>::const_iterator p
= adapters
.begin(); p
!= adapters
.end(); ++p
)
172 (*p
)->getTestIntf()->ice_ping();
175 TestIntfPrx test
= createTestIntfPrx(adapters
);
176 string name
= test
->getAdapterName();
177 const int nRetry
= 10;
179 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == name
; i
++);
182 for(vector
<RemoteObjectAdapterPrx
>::const_iterator q
= adapters
.begin(); q
!= adapters
.end(); ++q
)
184 (*q
)->getTestIntf()->ice_getConnection()->close(false);
189 // Deactivate an adapter and ensure that we can still
190 // establish the connection to the remaining adapters.
192 com
->deactivateObjectAdapter(adapters
[0]);
193 names
.insert("Adapter12");
194 names
.insert("Adapter13");
195 while(!names
.empty())
197 vector
<RemoteObjectAdapterPrx
> adpts
= adapters
;
199 TestIntfPrx test1
= createTestIntfPrx(adpts
);
200 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
201 TestIntfPrx test2
= createTestIntfPrx(adpts
);
202 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
203 TestIntfPrx test3
= createTestIntfPrx(adpts
);
205 test(test1
->ice_getConnection() == test2
->ice_getConnection());
206 test(test2
->ice_getConnection() == test3
->ice_getConnection());
208 names
.erase(test1
->getAdapterName());
209 test1
->ice_getConnection()->close(false);
213 // Deactivate an adapter and ensure that we can still
214 // establish the connection to the remaining adapter.
216 com
->deactivateObjectAdapter(adapters
[2]);
217 TestIntfPrx test
= createTestIntfPrx(adapters
);
218 test(test
->getAdapterName() == "Adapter12");
220 deactivate(com
, adapters
);
222 cout
<< "ok" << endl
;
224 cout
<< "testing binding with multiple random endpoints... " << flush
;
226 vector
<RemoteObjectAdapterPrx
> adapters
;
227 adapters
.push_back(com
->createObjectAdapter("AdapterRandom11", "default"));
228 adapters
.push_back(com
->createObjectAdapter("AdapterRandom12", "default"));
229 adapters
.push_back(com
->createObjectAdapter("AdapterRandom13", "default"));
230 adapters
.push_back(com
->createObjectAdapter("AdapterRandom14", "default"));
231 adapters
.push_back(com
->createObjectAdapter("AdapterRandom15", "default"));
238 int adapterCount
= static_cast<int>(adapters
.size());
244 com
->deactivateObjectAdapter(adapters
[4]);
247 vector
<TestIntfPrx
> proxies
;
250 if(count
< 60 && count
% 10 == 0)
252 com
->deactivateObjectAdapter(adapters
[count
/ 10 - 1]);
255 vector
<TestIntfPrx
> proxies
;
259 for(i
= 0; i
< proxies
.size(); ++i
)
261 vector
<RemoteObjectAdapterPrx
> adpts
;
262 adpts
.resize(IceUtilInternal::random(static_cast<int>(adapters
.size())));
267 for(vector
<RemoteObjectAdapterPrx
>::iterator p
= adpts
.begin(); p
!= adpts
.end(); ++p
)
269 *p
= adapters
[IceUtilInternal::random(static_cast<int>(adapters
.size()))];
271 proxies
[i
] = createTestIntfPrx(adpts
);
274 for(i
= 0; i
< proxies
.size(); i
++)
276 proxies
[i
]->begin_getAdapterName();
278 for(i
= 0; i
< proxies
.size(); i
++)
282 proxies
[i
]->ice_ping();
284 catch(const Ice::LocalException
&)
288 set
<Ice::ConnectionPtr
> connections
;
289 for(i
= 0; i
< proxies
.size(); i
++)
291 if(proxies
[i
]->ice_getCachedConnection())
293 connections
.insert(proxies
[i
]->ice_getCachedConnection());
296 test(static_cast<int>(connections
.size()) <= adapterCount
);
298 for(vector
<RemoteObjectAdapterPrx
>::const_iterator q
= adapters
.begin(); q
!= adapters
.end(); ++q
)
302 (*q
)->getTestIntf()->ice_getConnection()->close(false);
304 catch(const Ice::LocalException
&)
306 // Expected if adapter is down.
311 cout
<< "ok" << endl
;
313 cout
<< "testing binding with multiple endpoints and AMI... " << flush
;
315 vector
<RemoteObjectAdapterPrx
> adapters
;
316 adapters
.push_back(com
->createObjectAdapter("AdapterAMI11", "default"));
317 adapters
.push_back(com
->createObjectAdapter("AdapterAMI12", "default"));
318 adapters
.push_back(com
->createObjectAdapter("AdapterAMI13", "default"));
321 // Ensure that when a connection is opened it's reused for new
322 // proxies and that all endpoints are eventually tried.
325 names
.insert("AdapterAMI11");
326 names
.insert("AdapterAMI12");
327 names
.insert("AdapterAMI13");
328 while(!names
.empty())
330 vector
<RemoteObjectAdapterPrx
> adpts
= adapters
;
332 TestIntfPrx test1
= createTestIntfPrx(adpts
);
333 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
334 TestIntfPrx test2
= createTestIntfPrx(adpts
);
335 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
336 TestIntfPrx test3
= createTestIntfPrx(adpts
);
338 test(test1
->ice_getConnection() == test2
->ice_getConnection());
339 test(test2
->ice_getConnection() == test3
->ice_getConnection());
341 names
.erase(getAdapterNameWithAMI(test1
));
342 test1
->ice_getConnection()->close(false);
346 // Ensure that the proxy correctly caches the connection (we
347 // always send the request over the same connection.)
350 for(vector
<RemoteObjectAdapterPrx
>::const_iterator p
= adapters
.begin(); p
!= adapters
.end(); ++p
)
352 (*p
)->getTestIntf()->ice_ping();
355 TestIntfPrx test
= createTestIntfPrx(adapters
);
356 string name
= getAdapterNameWithAMI(test
);
357 const int nRetry
= 10;
359 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == name
; i
++);
362 for(vector
<RemoteObjectAdapterPrx
>::const_iterator q
= adapters
.begin(); q
!= adapters
.end(); ++q
)
364 (*q
)->getTestIntf()->ice_getConnection()->close(false);
369 // Deactivate an adapter and ensure that we can still
370 // establish the connection to the remaining adapters.
372 com
->deactivateObjectAdapter(adapters
[0]);
373 names
.insert("AdapterAMI12");
374 names
.insert("AdapterAMI13");
375 while(!names
.empty())
377 vector
<RemoteObjectAdapterPrx
> adpts
= adapters
;
379 TestIntfPrx test1
= createTestIntfPrx(adpts
);
380 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
381 TestIntfPrx test2
= createTestIntfPrx(adpts
);
382 random_shuffle(adpts
.begin(), adpts
.end(), rng
);
383 TestIntfPrx test3
= createTestIntfPrx(adpts
);
385 test(test1
->ice_getConnection() == test2
->ice_getConnection());
386 test(test2
->ice_getConnection() == test3
->ice_getConnection());
388 names
.erase(test1
->getAdapterName());
389 test1
->ice_getConnection()->close(false);
393 // Deactivate an adapter and ensure that we can still
394 // establish the connection to the remaining adapter.
396 com
->deactivateObjectAdapter(adapters
[2]);
397 TestIntfPrx test
= createTestIntfPrx(adapters
);
398 test(test
->getAdapterName() == "AdapterAMI12");
400 deactivate(com
, adapters
);
402 cout
<< "ok" << endl
;
404 cout
<< "testing random endpoint selection... " << flush
;
406 vector
<RemoteObjectAdapterPrx
> adapters
;
407 adapters
.push_back(com
->createObjectAdapter("Adapter21", "default"));
408 adapters
.push_back(com
->createObjectAdapter("Adapter22", "default"));
409 adapters
.push_back(com
->createObjectAdapter("Adapter23", "default"));
411 TestIntfPrx test
= createTestIntfPrx(adapters
);
412 test(test
->ice_getEndpointSelection() == Ice::Random
);
415 names
.insert("Adapter21");
416 names
.insert("Adapter22");
417 names
.insert("Adapter23");
418 while(!names
.empty())
420 names
.erase(test
->getAdapterName());
421 test
->ice_getConnection()->close(false);
424 test
= TestIntfPrx::uncheckedCast(test
->ice_endpointSelection(Ice::Random
));
425 test(test
->ice_getEndpointSelection() == Ice::Random
);
427 names
.insert("Adapter21");
428 names
.insert("Adapter22");
429 names
.insert("Adapter23");
430 while(!names
.empty())
432 names
.erase(test
->getAdapterName());
433 test
->ice_getConnection()->close(false);
436 deactivate(com
, adapters
);
438 cout
<< "ok" << endl
;
440 cout
<< "testing ordered endpoint selection... " << flush
;
442 vector
<RemoteObjectAdapterPrx
> adapters
;
443 adapters
.push_back(com
->createObjectAdapter("Adapter31", "default"));
444 adapters
.push_back(com
->createObjectAdapter("Adapter32", "default"));
445 adapters
.push_back(com
->createObjectAdapter("Adapter33", "default"));
447 TestIntfPrx test
= createTestIntfPrx(adapters
);
448 test
= TestIntfPrx::uncheckedCast(test
->ice_endpointSelection(Ice::Ordered
));
449 test(test
->ice_getEndpointSelection() == Ice::Ordered
);
450 const int nRetry
= 5;
454 // Ensure that endpoints are tried in order by deactiving the adapters
455 // one after the other.
457 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter31"; i
++);
459 com
->deactivateObjectAdapter(adapters
[0]);
460 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter32"; i
++);
462 com
->deactivateObjectAdapter(adapters
[1]);
463 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter33"; i
++);
465 com
->deactivateObjectAdapter(adapters
[2]);
469 test
->getAdapterName();
471 catch(const Ice::ConnectionRefusedException
&)
475 Ice::EndpointSeq endpoints
= test
->ice_getEndpoints();
480 // Now, re-activate the adapters with the same endpoints in the opposite
483 adapters
.push_back(com
->createObjectAdapter("Adapter36", endpoints
[2]->toString()));
484 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter36"; i
++);
486 test
->ice_getConnection()->close(false);
487 adapters
.push_back(com
->createObjectAdapter("Adapter35", endpoints
[1]->toString()));
488 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter35"; i
++);
490 test
->ice_getConnection()->close(false);
491 adapters
.push_back(com
->createObjectAdapter("Adapter34", endpoints
[0]->toString()));
492 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter34"; i
++);
495 deactivate(com
, adapters
);
497 cout
<< "ok" << endl
;
499 cout
<< "testing per request binding with single endpoint... " << flush
;
501 RemoteObjectAdapterPrx adapter
= com
->createObjectAdapter("Adapter41", "default");
503 TestIntfPrx test1
= TestIntfPrx::uncheckedCast(adapter
->getTestIntf()->ice_connectionCached(false));
504 TestIntfPrx test2
= TestIntfPrx::uncheckedCast(adapter
->getTestIntf()->ice_connectionCached(false));
505 test(!test1
->ice_isConnectionCached());
506 test(!test2
->ice_isConnectionCached());
507 test(test1
->ice_getConnection() == test2
->ice_getConnection());
511 com
->deactivateObjectAdapter(adapter
);
513 TestIntfPrx test3
= TestIntfPrx::uncheckedCast(test1
);
516 test(test3
->ice_getConnection() == test1
->ice_getConnection());
519 catch(const Ice::ConnectionRefusedException
&)
523 cout
<< "ok" << endl
;
525 cout
<< "testing per request binding with multiple endpoints... " << flush
;
527 vector
<RemoteObjectAdapterPrx
> adapters
;
528 adapters
.push_back(com
->createObjectAdapter("Adapter51", "default"));
529 adapters
.push_back(com
->createObjectAdapter("Adapter52", "default"));
530 adapters
.push_back(com
->createObjectAdapter("Adapter53", "default"));
532 TestIntfPrx test
= TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters
)->ice_connectionCached(false));
533 test(!test
->ice_isConnectionCached());
536 names
.insert("Adapter51");
537 names
.insert("Adapter52");
538 names
.insert("Adapter53");
539 while(!names
.empty())
541 names
.erase(test
->getAdapterName());
544 com
->deactivateObjectAdapter(adapters
[0]);
546 names
.insert("Adapter52");
547 names
.insert("Adapter53");
548 while(!names
.empty())
550 names
.erase(test
->getAdapterName());
553 com
->deactivateObjectAdapter(adapters
[2]);
555 test(test
->getAdapterName() == "Adapter52");
557 deactivate(com
, adapters
);
559 cout
<< "ok" << endl
;
561 cout
<< "testing per request binding with multiple endpoints and AMI... " << flush
;
563 vector
<RemoteObjectAdapterPrx
> adapters
;
564 adapters
.push_back(com
->createObjectAdapter("AdapterAMI51", "default"));
565 adapters
.push_back(com
->createObjectAdapter("AdapterAMI52", "default"));
566 adapters
.push_back(com
->createObjectAdapter("AdapterAMI53", "default"));
568 TestIntfPrx test
= TestIntfPrx::uncheckedCast(createTestIntfPrx(adapters
)->ice_connectionCached(false));
569 test(!test
->ice_isConnectionCached());
572 names
.insert("AdapterAMI51");
573 names
.insert("AdapterAMI52");
574 names
.insert("AdapterAMI53");
575 while(!names
.empty())
577 names
.erase(getAdapterNameWithAMI(test
));
580 com
->deactivateObjectAdapter(adapters
[0]);
582 names
.insert("AdapterAMI52");
583 names
.insert("AdapterAMI53");
584 while(!names
.empty())
586 names
.erase(getAdapterNameWithAMI(test
));
589 com
->deactivateObjectAdapter(adapters
[2]);
591 test(test
->getAdapterName() == "AdapterAMI52");
593 deactivate(com
, adapters
);
595 cout
<< "ok" << endl
;
597 cout
<< "testing per request binding and ordered endpoint selection... " << flush
;
599 vector
<RemoteObjectAdapterPrx
> adapters
;
600 adapters
.push_back(com
->createObjectAdapter("Adapter61", "default"));
601 adapters
.push_back(com
->createObjectAdapter("Adapter62", "default"));
602 adapters
.push_back(com
->createObjectAdapter("Adapter63", "default"));
604 TestIntfPrx test
= createTestIntfPrx(adapters
);
605 test
= TestIntfPrx::uncheckedCast(test
->ice_endpointSelection(Ice::Ordered
));
606 test(test
->ice_getEndpointSelection() == Ice::Ordered
);
607 test
= TestIntfPrx::uncheckedCast(test
->ice_connectionCached(false));
608 test(!test
->ice_isConnectionCached());
609 const int nRetry
= 5;
613 // Ensure that endpoints are tried in order by deactiving the adapters
614 // one after the other.
616 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter61"; i
++);
618 com
->deactivateObjectAdapter(adapters
[0]);
619 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter62"; i
++);
621 com
->deactivateObjectAdapter(adapters
[1]);
622 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter63"; i
++);
624 com
->deactivateObjectAdapter(adapters
[2]);
628 test
->getAdapterName();
630 catch(const Ice::ConnectionRefusedException
&)
634 Ice::EndpointSeq endpoints
= test
->ice_getEndpoints();
639 // Now, re-activate the adapters with the same endpoints in the opposite
642 adapters
.push_back(com
->createObjectAdapter("Adapter66", endpoints
[2]->toString()));
643 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter66"; i
++);
645 adapters
.push_back(com
->createObjectAdapter("Adapter65", endpoints
[1]->toString()));
646 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter65"; i
++);
648 adapters
.push_back(com
->createObjectAdapter("Adapter64", endpoints
[0]->toString()));
649 for(i
= 0; i
< nRetry
&& test
->getAdapterName() == "Adapter64"; i
++);
652 deactivate(com
, adapters
);
654 cout
<< "ok" << endl
;
656 cout
<< "testing per request binding and ordered endpoint selection and AMI... " << flush
;
658 vector
<RemoteObjectAdapterPrx
> adapters
;
659 adapters
.push_back(com
->createObjectAdapter("AdapterAMI61", "default"));
660 adapters
.push_back(com
->createObjectAdapter("AdapterAMI62", "default"));
661 adapters
.push_back(com
->createObjectAdapter("AdapterAMI63", "default"));
663 TestIntfPrx test
= createTestIntfPrx(adapters
);
664 test
= TestIntfPrx::uncheckedCast(test
->ice_endpointSelection(Ice::Ordered
));
665 test(test
->ice_getEndpointSelection() == Ice::Ordered
);
666 test
= TestIntfPrx::uncheckedCast(test
->ice_connectionCached(false));
667 test(!test
->ice_isConnectionCached());
668 const int nRetry
= 5;
672 // Ensure that endpoints are tried in order by deactiving the adapters
673 // one after the other.
675 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == "AdapterAMI61"; i
++);
677 com
->deactivateObjectAdapter(adapters
[0]);
678 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == "AdapterAMI62"; i
++);
680 com
->deactivateObjectAdapter(adapters
[1]);
681 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == "AdapterAMI63"; i
++);
683 com
->deactivateObjectAdapter(adapters
[2]);
687 test
->getAdapterName();
689 catch(const Ice::ConnectionRefusedException
&)
693 Ice::EndpointSeq endpoints
= test
->ice_getEndpoints();
698 // Now, re-activate the adapters with the same endpoints in the opposite
701 adapters
.push_back(com
->createObjectAdapter("AdapterAMI66", endpoints
[2]->toString()));
702 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == "AdapterAMI66"; i
++);
704 adapters
.push_back(com
->createObjectAdapter("AdapterAMI65", endpoints
[1]->toString()));
705 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == "AdapterAMI65"; i
++);
707 adapters
.push_back(com
->createObjectAdapter("AdapterAMI64", endpoints
[0]->toString()));
708 for(i
= 0; i
< nRetry
&& getAdapterNameWithAMI(test
) == "AdapterAMI64"; i
++);
711 deactivate(com
, adapters
);
713 cout
<< "ok" << endl
;
715 cout
<< "testing endpoint mode filtering... " << flush
;
717 vector
<RemoteObjectAdapterPrx
> adapters
;
718 adapters
.push_back(com
->createObjectAdapter("Adapter71", "default"));
719 adapters
.push_back(com
->createObjectAdapter("Adapter72", "udp"));
721 TestIntfPrx test
= createTestIntfPrx(adapters
);
722 test(test
->getAdapterName() == "Adapter71");
724 TestIntfPrx testUDP
= TestIntfPrx::uncheckedCast(test
->ice_datagram());
725 test(test
->ice_getConnection() != testUDP
->ice_getConnection());
728 testUDP
->getAdapterName();
730 catch(const Ice::TwowayOnlyException
&)
734 cout
<< "ok" << endl
;
736 if(!communicator
->getProperties()->getProperty("Ice.Plugin.IceSSL").empty())
738 cout
<< "testing unsecure vs. secure endpoints... " << flush
;
740 vector
<RemoteObjectAdapterPrx
> adapters
;
741 adapters
.push_back(com
->createObjectAdapter("Adapter81", "ssl"));
742 adapters
.push_back(com
->createObjectAdapter("Adapter82", "tcp"));
744 TestIntfPrx test
= createTestIntfPrx(adapters
);
746 for(i
= 0; i
< 5; i
++)
748 test(test
->getAdapterName() == "Adapter82");
749 test
->ice_getConnection()->close(false);
752 TestIntfPrx testSecure
= TestIntfPrx::uncheckedCast(test
->ice_secure(true));
753 test(testSecure
->ice_isSecure());
754 testSecure
= TestIntfPrx::uncheckedCast(test
->ice_secure(false));
755 test(!testSecure
->ice_isSecure());
756 testSecure
= TestIntfPrx::uncheckedCast(test
->ice_secure(true));
757 test(testSecure
->ice_isSecure());
758 test(test
->ice_getConnection() != testSecure
->ice_getConnection());
760 com
->deactivateObjectAdapter(adapters
[1]);
762 for(i
= 0; i
< 5; i
++)
764 test(test
->getAdapterName() == "Adapter81");
765 test
->ice_getConnection()->close(false);
768 com
->createObjectAdapter("Adapter83", (test
->ice_getEndpoints()[1])->toString()); // Reactive tcp OA.
770 for(i
= 0; i
< 5; i
++)
772 test(test
->getAdapterName() == "Adapter83");
773 test
->ice_getConnection()->close(false);
776 com
->deactivateObjectAdapter(adapters
[0]);
779 testSecure
->ice_ping();
782 catch(const Ice::ConnectionRefusedException
&)
786 deactivate(com
, adapters
);
788 cout
<< "ok" << endl
;