summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/binding/AllTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/binding/AllTests.cpp')
-rw-r--r--cpp/test/Ice/binding/AllTests.cpp105
1 files changed, 104 insertions, 1 deletions
diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp
index eec35751912..1f9b133d7c9 100644
--- a/cpp/test/Ice/binding/AllTests.cpp
+++ b/cpp/test/Ice/binding/AllTests.cpp
@@ -62,6 +62,21 @@ private:
};
typedef IceUtil::Handle<GetAdapterNameCB> GetAdapterNameCBPtr;
+class NoOpGetAdapterNameCB : public AMI_TestIntf_getAdapterName
+{
+public:
+
+ virtual void
+ ice_response(const string&)
+ {
+ }
+
+ virtual void
+ ice_exception(const Ice::Exception&)
+ {
+ }
+};
+
string
getAdapterNameWithAMI(const TestIntfPrx& test)
{
@@ -220,6 +235,95 @@ allTests(const Ice::CommunicatorPtr& communicator)
}
cout << "ok" << endl;
+ cout << "testing binding with multiple random endpoints... " << flush;
+ {
+ vector<RemoteObjectAdapterPrx> adapters;
+ adapters.push_back(com->createObjectAdapter("AdapterRandom11", "default"));
+ adapters.push_back(com->createObjectAdapter("AdapterRandom12", "default"));
+ adapters.push_back(com->createObjectAdapter("AdapterRandom13", "default"));
+ adapters.push_back(com->createObjectAdapter("AdapterRandom14", "default"));
+ adapters.push_back(com->createObjectAdapter("AdapterRandom15", "default"));
+
+#ifdef _WIN32
+ int count = 60;
+#else
+ int count = 20;
+#endif
+ int adapterCount = adapters.size();
+ while(--count > 0)
+ {
+#ifdef _WIN32
+ if(count == 10)
+ {
+ com->deactivateObjectAdapter(adapters[4]);
+ --adapterCount;
+ }
+ vector<TestIntfPrx> proxies;
+ proxies.resize(10);
+#else
+ if(count < 60 && count % 10 == 0)
+ {
+ com->deactivateObjectAdapter(adapters[count / 10 - 1]);
+ --adapterCount;
+ }
+ vector<TestIntfPrx> proxies;
+ proxies.resize(40);
+#endif
+ unsigned int i;
+ for(i = 0; i < proxies.size(); ++i)
+ {
+ vector<RemoteObjectAdapterPrx> adpts;
+ adpts.resize(IceUtilInternal::random(static_cast<int>(adapters.size())));
+ if(adpts.empty())
+ {
+ adpts.resize(1);
+ }
+ for(vector<RemoteObjectAdapterPrx>::iterator p = adpts.begin(); p != adpts.end(); ++p)
+ {
+ *p = adapters[IceUtilInternal::random(static_cast<int>(adapters.size()))];
+ }
+ proxies[i] = createTestIntfPrx(adpts);
+ }
+
+ for(i = 0; i < proxies.size(); i++)
+ {
+ proxies[i]->getAdapterName_async(new NoOpGetAdapterNameCB());
+ }
+ for(i = 0; i < proxies.size(); i++)
+ {
+ try
+ {
+ proxies[i]->ice_ping();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ }
+ set<Ice::ConnectionPtr> connections;
+ for(i = 0; i < proxies.size(); i++)
+ {
+ if(proxies[i]->ice_getCachedConnection())
+ {
+ connections.insert(proxies[i]->ice_getCachedConnection());
+ }
+ }
+ test(static_cast<int>(connections.size()) <= adapterCount);
+
+ for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
+ {
+ try
+ {
+ (*q)->getTestIntf()->ice_getConnection()->close(false);
+ }
+ catch(const Ice::LocalException&)
+ {
+ // Expected if adapter is down.
+ }
+ }
+ }
+ }
+ cout << "ok" << endl;
+
cout << "testing binding with multiple endpoints and AMI... " << flush;
{
vector<RemoteObjectAdapterPrx> adapters;
@@ -468,7 +572,6 @@ allTests(const Ice::CommunicatorPtr& communicator)
com->deactivateObjectAdapter(adapters[2]);
-
test(test->getAdapterName() == "Adapter52");
deactivate(com, adapters);