ICE 3.4.2
[php5-ice-freebsdport.git] / cpp / test / Ice / binding / AllTests.cpp
blobf4da896a920c136234a99047404ae01be14c19e5
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 #include <IceUtil/Random.h>
11 #include <Ice/Ice.h>
12 #include <TestCommon.h>
13 #include <Test.h>
14 #include <set>
16 #include <functional>
18 using namespace std;
19 using namespace Test;
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>
31 public:
33 void
34 response(const string& name)
36 Lock sync(*this);
37 assert(!name.empty());
38 _name = name;
39 notify();
42 void
43 exception(const Ice::Exception&)
45 test(false);
48 virtual string
49 getResult()
51 Lock sync(*this);
52 while(_name.empty())
54 wait();
56 return _name;
59 private:
61 string _name;
63 typedef IceUtil::Handle<GetAdapterNameCB> GetAdapterNameCBPtr;
65 string
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();
74 TestIntfPrx
75 createTestIntfPrx(vector<RemoteObjectAdapterPrx>& adapters)
77 Ice::EndpointSeq endpoints;
78 TestIntfPrx test;
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));
88 void
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);
97 void
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());
113 test1->ice_ping();
114 test2->ice_ping();
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());
124 test3->ice_ping();
125 test(false);
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.
144 set<string> names;
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;
178 int i;
179 for(i = 0; i < nRetry && test->getAdapterName() == name; i++);
180 test(i == nRetry);
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"));
233 #ifdef _WIN32
234 int count = 60;
235 #else
236 int count = 20;
237 #endif
238 int adapterCount = static_cast<int>(adapters.size());
239 while(--count > 0)
241 #ifdef _WIN32
242 if(count == 10)
244 com->deactivateObjectAdapter(adapters[4]);
245 --adapterCount;
247 vector<TestIntfPrx> proxies;
248 proxies.resize(10);
249 #else
250 if(count < 60 && count % 10 == 0)
252 com->deactivateObjectAdapter(adapters[count / 10 - 1]);
253 --adapterCount;
255 vector<TestIntfPrx> proxies;
256 proxies.resize(40);
257 #endif
258 unsigned int i;
259 for(i = 0; i < proxies.size(); ++i)
261 vector<RemoteObjectAdapterPrx> adpts;
262 adpts.resize(IceUtilInternal::random(static_cast<int>(adapters.size())));
263 if(adpts.empty())
265 adpts.resize(1);
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.
324 set<string> names;
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;
358 int i;
359 for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == name; i++);
360 test(i == nRetry);
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);
414 set<string> names;
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;
451 int i;
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++);
458 test(i == nRetry);
459 com->deactivateObjectAdapter(adapters[0]);
460 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter32"; i++);
461 test(i == nRetry);
462 com->deactivateObjectAdapter(adapters[1]);
463 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter33"; i++);
464 test(i == nRetry);
465 com->deactivateObjectAdapter(adapters[2]);
469 test->getAdapterName();
471 catch(const Ice::ConnectionRefusedException&)
475 Ice::EndpointSeq endpoints = test->ice_getEndpoints();
477 adapters.clear();
480 // Now, re-activate the adapters with the same endpoints in the opposite
481 // order.
483 adapters.push_back(com->createObjectAdapter("Adapter36", endpoints[2]->toString()));
484 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter36"; i++);
485 test(i == nRetry);
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++);
489 test(i == nRetry);
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++);
493 test(i == nRetry);
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());
509 test1->ice_ping();
511 com->deactivateObjectAdapter(adapter);
513 TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1);
516 test(test3->ice_getConnection() == test1->ice_getConnection());
517 test(false);
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());
535 set<string> names;
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());
571 set<string> names;
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;
610 int i;
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++);
617 test(i == nRetry);
618 com->deactivateObjectAdapter(adapters[0]);
619 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter62"; i++);
620 test(i == nRetry);
621 com->deactivateObjectAdapter(adapters[1]);
622 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter63"; i++);
623 test(i == nRetry);
624 com->deactivateObjectAdapter(adapters[2]);
628 test->getAdapterName();
630 catch(const Ice::ConnectionRefusedException&)
634 Ice::EndpointSeq endpoints = test->ice_getEndpoints();
636 adapters.clear();
639 // Now, re-activate the adapters with the same endpoints in the opposite
640 // order.
642 adapters.push_back(com->createObjectAdapter("Adapter66", endpoints[2]->toString()));
643 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter66"; i++);
644 test(i == nRetry);
645 adapters.push_back(com->createObjectAdapter("Adapter65", endpoints[1]->toString()));
646 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter65"; i++);
647 test(i == nRetry);
648 adapters.push_back(com->createObjectAdapter("Adapter64", endpoints[0]->toString()));
649 for(i = 0; i < nRetry && test->getAdapterName() == "Adapter64"; i++);
650 test(i == nRetry);
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;
669 int i;
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++);
676 test(i == nRetry);
677 com->deactivateObjectAdapter(adapters[0]);
678 for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI62"; i++);
679 test(i == nRetry);
680 com->deactivateObjectAdapter(adapters[1]);
681 for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI63"; i++);
682 test(i == nRetry);
683 com->deactivateObjectAdapter(adapters[2]);
687 test->getAdapterName();
689 catch(const Ice::ConnectionRefusedException&)
693 Ice::EndpointSeq endpoints = test->ice_getEndpoints();
695 adapters.clear();
698 // Now, re-activate the adapters with the same endpoints in the opposite
699 // order.
701 adapters.push_back(com->createObjectAdapter("AdapterAMI66", endpoints[2]->toString()));
702 for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI66"; i++);
703 test(i == nRetry);
704 adapters.push_back(com->createObjectAdapter("AdapterAMI65", endpoints[1]->toString()));
705 for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI65"; i++);
706 test(i == nRetry);
707 adapters.push_back(com->createObjectAdapter("AdapterAMI64", endpoints[0]->toString()));
708 for(i = 0; i < nRetry && getAdapterNameWithAMI(test) == "AdapterAMI64"; i++);
709 test(i == nRetry);
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);
745 int i;
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();
780 test(false);
782 catch(const Ice::ConnectionRefusedException&)
786 deactivate(com, adapters);
788 cout << "ok" << endl;
791 com->shutdown();