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.cpp436
1 files changed, 269 insertions, 167 deletions
diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp
index cb5b8c80140..332ff919d3c 100644
--- a/cpp/test/Ice/binding/AllTests.cpp
+++ b/cpp/test/Ice/binding/AllTests.cpp
@@ -26,6 +26,7 @@ struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
}
};
+#ifndef ICE_CPP11_MAPPING
class GetAdapterNameCB : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex>
{
public:
@@ -61,34 +62,39 @@ private:
string _name;
};
typedef IceUtil::Handle<GetAdapterNameCB> GetAdapterNameCBPtr;
+#endif
string
-getAdapterNameWithAMI(const TestIntfPrx& test)
+getAdapterNameWithAMI(const TestIntfPrxPtr& test)
{
+#ifdef ICE_CPP11_MAPPING
+ return test->getAdapterNameAsync().get();
+#else
GetAdapterNameCBPtr cb = new GetAdapterNameCB();
test->begin_getAdapterName(
newCallback_TestIntf_getAdapterName(cb, &GetAdapterNameCB::response, &GetAdapterNameCB::exception));
return cb->getResult();
+#endif
}
-TestIntfPrx
-createTestIntfPrx(vector<RemoteObjectAdapterPrx>& adapters)
+TestIntfPrxPtr
+createTestIntfPrx(vector<RemoteObjectAdapterPrxPtr>& adapters)
{
Ice::EndpointSeq endpoints;
- TestIntfPrx test;
- for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
+ TestIntfPrxPtr test;
+ for(vector<RemoteObjectAdapterPrxPtr>::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));
+ return ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_endpoints(endpoints));
}
void
-deactivate(const RemoteCommunicatorPrx& com, vector<RemoteObjectAdapterPrx>& adapters)
+deactivate(const RemoteCommunicatorPrxPtr& com, vector<RemoteObjectAdapterPrxPtr>& adapters)
{
- for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
+ for(vector<RemoteObjectAdapterPrxPtr>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
com->deactivateObjectAdapter(*p);
}
@@ -97,28 +103,28 @@ deactivate(const RemoteCommunicatorPrx& com, vector<RemoteObjectAdapterPrx>& ada
void
allTests(const Ice::CommunicatorPtr& communicator)
{
- string ref = "communicator:default -p 12010";
- RemoteCommunicatorPrx com = RemoteCommunicatorPrx::uncheckedCast(communicator->stringToProxy(ref));
+ string ref = "communicator:" + getTestEndpoint(communicator, 0);
+ RemoteCommunicatorPrxPtr com = ICE_UNCHECKED_CAST(RemoteCommunicatorPrx, communicator->stringToProxy(ref));
RandomNumberGenerator rng;
- cout << "testing binding with single endpoint... " << flush;
+ cout << "testing binding with single endpoint... " << flush;
{
- RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter", "default");
+ RemoteObjectAdapterPrxPtr adapter = com->createObjectAdapter("Adapter", "default");
- TestIntfPrx test1 = adapter->getTestIntf();
- TestIntfPrx test2 = adapter->getTestIntf();
+ TestIntfPrxPtr test1 = adapter->getTestIntf();
+ TestIntfPrxPtr test2 = adapter->getTestIntf();
test(test1->ice_getConnection() == test2->ice_getConnection());
test1->ice_ping();
test2->ice_ping();
-
+
com->deactivateObjectAdapter(adapter);
-
- TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1);
+
+ TestIntfPrxPtr test3 = ICE_UNCHECKED_CAST(TestIntfPrx, test1);
test(test3->ice_getConnection() == test1->ice_getConnection());
test(test3->ice_getConnection() == test2->ice_getConnection());
-
+
try
{
test3->ice_ping();
@@ -127,12 +133,17 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectFailedException&)
{
}
+#ifdef _WIN32
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ }
+#endif
}
cout << "ok" << endl;
cout << "testing binding with multiple endpoints... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> adapters;
adapters.push_back(com->createObjectAdapter("Adapter11", "default"));
adapters.push_back(com->createObjectAdapter("Adapter12", "default"));
adapters.push_back(com->createObjectAdapter("Adapter13", "default"));
@@ -147,19 +158,19 @@ allTests(const Ice::CommunicatorPtr& communicator)
names.insert("Adapter13");
while(!names.empty())
{
- vector<RemoteObjectAdapterPrx> adpts = adapters;
+ vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
- TestIntfPrx test1 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test2 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test3 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr 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);
+ test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
//
@@ -167,23 +178,24 @@ allTests(const Ice::CommunicatorPtr& communicator)
// always send the request over the same connection.)
//
{
- for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
+ for(vector<RemoteObjectAdapterPrxPtr>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
(*p)->getTestIntf()->ice_ping();
}
-
- TestIntfPrx test = createTestIntfPrx(adapters);
+
+ TestIntfPrxPtr 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)
+ for(vector<RemoteObjectAdapterPrxPtr>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
{
- (*q)->getTestIntf()->ice_getConnection()->close(false);
+ (*q)->getTestIntf()->ice_getConnection()->close(
+ Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
- }
+ }
//
// Deactivate an adapter and ensure that we can still
@@ -194,28 +206,28 @@ allTests(const Ice::CommunicatorPtr& communicator)
names.insert("Adapter13");
while(!names.empty())
{
- vector<RemoteObjectAdapterPrx> adpts = adapters;
+ vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
- TestIntfPrx test1 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test2 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test3 = createTestIntfPrx(adpts);
-
+ TestIntfPrxPtr 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);
+ test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
-
+
//
// 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");
+ com->deactivateObjectAdapter(adapters[2]);
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
+ test(test->getAdapterName() == "Adapter12");
deactivate(com, adapters);
}
@@ -223,7 +235,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing binding with multiple random endpoints... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> adapters;
adapters.push_back(com->createObjectAdapter("AdapterRandom11", "default"));
adapters.push_back(com->createObjectAdapter("AdapterRandom12", "default"));
adapters.push_back(com->createObjectAdapter("AdapterRandom13", "default"));
@@ -231,20 +243,20 @@ allTests(const Ice::CommunicatorPtr& communicator)
adapters.push_back(com->createObjectAdapter("AdapterRandom15", "default"));
#ifdef _WIN32
- int count = 60;
-#else
int count = 20;
+#else
+ int count = 60;
#endif
int adapterCount = static_cast<int>(adapters.size());
while(--count > 0)
{
#ifdef _WIN32
- if(count == 10)
+ if(count == 1)
{
com->deactivateObjectAdapter(adapters[4]);
--adapterCount;
}
- vector<TestIntfPrx> proxies;
+ vector<TestIntfPrxPtr> proxies;
proxies.resize(10);
#else
if(count < 60 && count % 10 == 0)
@@ -252,28 +264,32 @@ allTests(const Ice::CommunicatorPtr& communicator)
com->deactivateObjectAdapter(adapters[count / 10 - 1]);
--adapterCount;
}
- vector<TestIntfPrx> proxies;
+ vector<TestIntfPrxPtr> proxies;
proxies.resize(40);
#endif
unsigned int i;
for(i = 0; i < proxies.size(); ++i)
{
- vector<RemoteObjectAdapterPrx> adpts;
+ vector<RemoteObjectAdapterPrxPtr> 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)
+ for(vector<RemoteObjectAdapterPrxPtr>::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++)
{
+#ifdef ICE_CPP11_MAPPING
+ proxies[i]->getAdapterNameAsync();
+#else
proxies[i]->begin_getAdapterName();
+#endif
}
for(i = 0; i < proxies.size(); i++)
{
@@ -295,11 +311,12 @@ allTests(const Ice::CommunicatorPtr& communicator)
}
test(static_cast<int>(connections.size()) <= adapterCount);
- for(vector<RemoteObjectAdapterPrx>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
+ for(vector<RemoteObjectAdapterPrxPtr>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
{
try
{
- (*q)->getTestIntf()->ice_getConnection()->close(false);
+ (*q)->getTestIntf()->ice_getConnection()->close(
+ Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
catch(const Ice::LocalException&)
{
@@ -312,7 +329,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing binding with multiple endpoints and AMI... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> adapters;
adapters.push_back(com->createObjectAdapter("AdapterAMI11", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI12", "default"));
adapters.push_back(com->createObjectAdapter("AdapterAMI13", "default"));
@@ -327,19 +344,19 @@ allTests(const Ice::CommunicatorPtr& communicator)
names.insert("AdapterAMI13");
while(!names.empty())
{
- vector<RemoteObjectAdapterPrx> adpts = adapters;
+ vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
- TestIntfPrx test1 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test2 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test3 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr 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);
+ test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
//
@@ -347,23 +364,24 @@ allTests(const Ice::CommunicatorPtr& communicator)
// always send the request over the same connection.)
//
{
- for(vector<RemoteObjectAdapterPrx>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
+ for(vector<RemoteObjectAdapterPrxPtr>::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
(*p)->getTestIntf()->ice_ping();
}
-
- TestIntfPrx test = createTestIntfPrx(adapters);
+
+ TestIntfPrxPtr 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)
+ for(vector<RemoteObjectAdapterPrxPtr>::const_iterator q = adapters.begin(); q != adapters.end(); ++q)
{
- (*q)->getTestIntf()->ice_getConnection()->close(false);
+ (*q)->getTestIntf()->ice_getConnection()->close(
+ Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
- }
+ }
//
// Deactivate an adapter and ensure that we can still
@@ -374,28 +392,28 @@ allTests(const Ice::CommunicatorPtr& communicator)
names.insert("AdapterAMI13");
while(!names.empty())
{
- vector<RemoteObjectAdapterPrx> adpts = adapters;
+ vector<RemoteObjectAdapterPrxPtr> adpts = adapters;
- TestIntfPrx test1 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test1 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test2 = createTestIntfPrx(adpts);
+ TestIntfPrxPtr test2 = createTestIntfPrx(adpts);
random_shuffle(adpts.begin(), adpts.end(), rng);
- TestIntfPrx test3 = createTestIntfPrx(adpts);
-
+ TestIntfPrxPtr 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);
+ test1->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
-
+
//
// 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");
+ com->deactivateObjectAdapter(adapters[2]);
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
+ test(test->getAdapterName() == "AdapterAMI12");
deactivate(com, adapters);
}
@@ -403,13 +421,13 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing random endpoint selection... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> 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);
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
+ test(test->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Random));
set<string> names;
names.insert("Adapter21");
@@ -418,11 +436,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
while(!names.empty())
{
names.erase(test->getAdapterName());
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
- test = TestIntfPrx::uncheckedCast(test->ice_endpointSelection(Ice::Random));
- test(test->ice_getEndpointSelection() == Ice::Random);
+ test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Random)));
+ test(test->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Random));
names.insert("Adapter21");
names.insert("Adapter22");
@@ -430,7 +448,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
while(!names.empty())
{
names.erase(test->getAdapterName());
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
deactivate(com, adapters);
@@ -439,14 +457,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing ordered endpoint selection... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> 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);
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
+ test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)));
+ test(test->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Ordered));
const int nRetry = 5;
int i;
@@ -458,7 +476,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#if TARGET_OS_IPHONE > 0
if(i != nRetry)
{
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter31"; i++);
}
#endif
@@ -468,7 +486,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#if TARGET_OS_IPHONE > 0
if(i != nRetry)
{
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter32"; i++);
}
#endif
@@ -478,13 +496,13 @@ allTests(const Ice::CommunicatorPtr& communicator)
#if TARGET_OS_IPHONE > 0
if(i != nRetry)
{
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter33"; i++);
}
#endif
test(i == nRetry);
com->deactivateObjectAdapter(adapters[2]);
-
+
try
{
test->getAdapterName();
@@ -492,7 +510,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectFailedException&)
{
}
-
+#ifdef _WIN32
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ }
+#endif
Ice::EndpointSeq endpoints = test->ice_getEndpoints();
adapters.clear();
@@ -500,35 +522,35 @@ allTests(const Ice::CommunicatorPtr& communicator)
//
// 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++);
#if TARGET_OS_IPHONE > 0
if(i != nRetry)
{
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter36"; i++);
}
#endif
test(i == nRetry);
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
adapters.push_back(com->createObjectAdapter("Adapter35", endpoints[1]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++);
#if TARGET_OS_IPHONE > 0
if(i != nRetry)
{
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter35"; i++);
}
#endif
test(i == nRetry);
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
adapters.push_back(com->createObjectAdapter("Adapter34", endpoints[0]->toString()));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++);
#if TARGET_OS_IPHONE > 0
if(i != nRetry)
{
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
for(i = 0; i < nRetry && test->getAdapterName() == "Adapter34"; i++);
}
#endif
@@ -540,19 +562,20 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing per request binding with single endpoint... " << flush;
{
- RemoteObjectAdapterPrx adapter = com->createObjectAdapter("Adapter41", "default");
+ RemoteObjectAdapterPrxPtr adapter = com->createObjectAdapter("Adapter41", "default");
- TestIntfPrx test1 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false));
- TestIntfPrx test2 = TestIntfPrx::uncheckedCast(adapter->getTestIntf()->ice_connectionCached(false));
+ TestIntfPrxPtr test1 = ICE_UNCHECKED_CAST(TestIntfPrx, adapter->getTestIntf()->ice_connectionCached(false));
+ TestIntfPrxPtr test2 = ICE_UNCHECKED_CAST(TestIntfPrx, adapter->getTestIntf()->ice_connectionCached(false));
test(!test1->ice_isConnectionCached());
test(!test2->ice_isConnectionCached());
+ test(test1->ice_getConnection() && test2->ice_getConnection());
test(test1->ice_getConnection() == test2->ice_getConnection());
test1->ice_ping();
-
+
com->deactivateObjectAdapter(adapter);
-
- TestIntfPrx test3 = TestIntfPrx::uncheckedCast(test1);
+
+ TestIntfPrxPtr test3 = ICE_UNCHECKED_CAST(TestIntfPrx, test1);
try
{
test(test3->ice_getConnection() == test1->ice_getConnection());
@@ -561,17 +584,22 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectFailedException&)
{
}
+#ifdef _WIN32
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ }
+#endif
}
cout << "ok" << endl;
cout << "testing per request binding with multiple endpoints... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> 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));
+ TestIntfPrxPtr test = ICE_UNCHECKED_CAST(TestIntfPrx, createTestIntfPrx(adapters)->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
set<string> names;
@@ -595,19 +623,19 @@ allTests(const Ice::CommunicatorPtr& communicator)
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;
+ vector<RemoteObjectAdapterPrxPtr> 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));
+ TestIntfPrxPtr test = ICE_UNCHECKED_CAST(TestIntfPrx, createTestIntfPrx(adapters)->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
set<string> names;
@@ -631,22 +659,22 @@ allTests(const Ice::CommunicatorPtr& communicator)
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;
+ vector<RemoteObjectAdapterPrxPtr> 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));
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
+ test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)));
+ test(test->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Ordered));
+ test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
const int nRetry = 5;
int i;
@@ -676,7 +704,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(i == nRetry);
#endif
com->deactivateObjectAdapter(adapters[2]);
-
+
try
{
test->getAdapterName();
@@ -684,7 +712,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectFailedException&)
{
}
-
+#ifdef _WIN32
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ }
+#endif
Ice::EndpointSeq endpoints = test->ice_getEndpoints();
adapters.clear();
@@ -692,7 +724,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
//
// 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++);
#if TARGET_OS_IPHONE > 0
@@ -721,15 +753,15 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing per request binding and ordered endpoint selection and AMI... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> 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));
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
+ test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_endpointSelection(Ice::ICE_ENUM(EndpointSelectionType, Ordered)));
+ test(test->ice_getEndpointSelection() == Ice::ICE_ENUM(EndpointSelectionType, Ordered));
+ test = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_connectionCached(false));
test(!test->ice_isConnectionCached());
const int nRetry = 5;
int i;
@@ -759,7 +791,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(i == nRetry);
#endif
com->deactivateObjectAdapter(adapters[2]);
-
+
try
{
test->getAdapterName();
@@ -767,7 +799,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectFailedException&)
{
}
-
+#ifdef _WIN32
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ }
+#endif
Ice::EndpointSeq endpoints = test->ice_getEndpoints();
adapters.clear();
@@ -775,7 +811,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
//
// 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++);
#if TARGET_OS_IPHONE > 0
@@ -796,14 +832,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing endpoint mode filtering... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> adapters;
adapters.push_back(com->createObjectAdapter("Adapter71", "default"));
adapters.push_back(com->createObjectAdapter("Adapter72", "udp"));
- TestIntfPrx test = createTestIntfPrx(adapters);
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
test(test->getAdapterName() == "Adapter71");
-
- TestIntfPrx testUDP = TestIntfPrx::uncheckedCast(test->ice_datagram());
+
+ TestIntfPrxPtr testUDP = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_datagram());
test(test->ice_getConnection() != testUDP->ice_getConnection());
try
{
@@ -812,6 +848,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::TwowayOnlyException&)
{
}
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
}
cout << "ok" << endl;
@@ -820,32 +859,32 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
cout << "testing unsecure vs. secure endpoints... " << flush;
{
- vector<RemoteObjectAdapterPrx> adapters;
+ vector<RemoteObjectAdapterPrxPtr> adapters;
adapters.push_back(com->createObjectAdapter("Adapter81", "ssl"));
adapters.push_back(com->createObjectAdapter("Adapter82", "tcp"));
-
- TestIntfPrx test = createTestIntfPrx(adapters);
+
+ TestIntfPrxPtr test = createTestIntfPrx(adapters);
int i;
for(i = 0; i < 5; i++)
{
test(test->getAdapterName() == "Adapter82");
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
-
- TestIntfPrx testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true));
+
+ TestIntfPrxPtr testSecure = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_secure(true));
test(testSecure->ice_isSecure());
- testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(false));
+ testSecure = ICE_UNCHECKED_CAST(TestIntfPrx, test->ice_secure(false));
test(!testSecure->ice_isSecure());
- testSecure = TestIntfPrx::uncheckedCast(test->ice_secure(true));
+ testSecure = ICE_UNCHECKED_CAST(TestIntfPrx, 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);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
com->createObjectAdapter("Adapter83", (test->ice_getEndpoints()[1])->toString()); // Reactive tcp OA.
@@ -853,7 +892,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
for(i = 0; i < 5; i++)
{
test(test->getAdapterName() == "Adapter83");
- test->ice_getConnection()->close(false);
+ test->ice_getConnection()->close(Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
}
com->deactivateObjectAdapter(adapters[0]);
@@ -865,6 +904,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectFailedException&)
{
}
+#ifdef _WIN32
+ catch(const Ice::ConnectTimeoutException&)
+ {
+ }
+#endif
deactivate(com, adapters);
}
@@ -902,19 +946,26 @@ allTests(const Ice::CommunicatorPtr& communicator)
clientProps.push_back(bothPreferIPv4);
clientProps.push_back(bothPreferIPv6);
+ string endpoint;
+ {
+ ostringstream str;
+ str << "tcp -p " << getTestPort(communicator->getProperties(), 2);
+ endpoint = str.str();
+ }
+
Ice::PropertiesPtr anyipv4 = ipv4->clone();
- anyipv4->setProperty("Adapter.Endpoints", "tcp -p 12012");
- anyipv4->setProperty("Adapter.PublishedEndpoints", "tcp -h 127.0.0.1 -p 12012");
+ anyipv4->setProperty("Adapter.Endpoints", endpoint);
+ anyipv4->setProperty("Adapter.PublishedEndpoints", endpoint + " -h 127.0.0.1");
Ice::PropertiesPtr anyipv6 = ipv6->clone();
- anyipv6->setProperty("Adapter.Endpoints", "tcp -p 12012");
- anyipv6->setProperty("Adapter.PublishedEndpoints", "tcp -h \"::1\" -p 12012");
+ anyipv6->setProperty("Adapter.Endpoints", endpoint);
+ anyipv6->setProperty("Adapter.PublishedEndpoints", endpoint + " -h \"::1\"");
Ice::PropertiesPtr anyboth = Ice::createProperties();
anyboth->setProperty("Ice.IPv4", "1");
anyboth->setProperty("Ice.IPv6", "1");
- anyboth->setProperty("Adapter.Endpoints", "tcp -p 12012");
- anyboth->setProperty("Adapter.PublishedEndpoints", "tcp -h \"::1\" -p 12012:tcp -h 127.0.0.1 -p 12012");
+ anyboth->setProperty("Adapter.Endpoints", endpoint);
+ anyboth->setProperty("Adapter.PublishedEndpoints", endpoint + " -p 12012:" + endpoint + " -p 12012");
Ice::PropertiesPtr localipv4 = ipv4->clone();
localipv4->setProperty("Adapter.Endpoints", "tcp -h 127.0.0.1");
@@ -929,21 +980,6 @@ allTests(const Ice::CommunicatorPtr& communicator)
serverProps.push_back(localipv4);
serverProps.push_back(localipv6);
-#if defined(_WIN32) && !defined(ICE_OS_WINRT)
- OSVERSIONINFO ver;
- ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-# if defined(_MSC_VER) && _MSC_VER >= 1800
-# pragma warning (disable : 4996)
-# endif
- GetVersionEx(&ver);
-# if defined(_MSC_VER) && _MSC_VER >= 1800
-# pragma warning (default : 4996)
-# endif
- const bool dualStack = ver.dwMajorVersion >= 6; // Windows XP IPv6 doesn't support dual-stack
-#else
- const bool dualStack = true;
-#endif
-
bool ipv6NotSupported = false;
for(vector<Ice::PropertiesPtr>::const_iterator p = serverProps.begin(); p != serverProps.end(); ++p)
{
@@ -974,7 +1010,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
// Ensure the published endpoints are actually valid. On
// Fedora, binding to "localhost" with IPv6 only works but
// resolving localhost don't return the IPv6 adress.
- Ice::ObjectPrx prx = oa->createProxy(serverCommunicator->stringToIdentity("dummy"));
+ Ice::ObjectPrxPtr prx = oa->createProxy(Ice::stringToIdentity("dummy"));
try
{
prx->ice_collocationOptimized(false)->ice_ping();
@@ -990,8 +1026,8 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
Ice::InitializationData clientInitData;
clientInitData.properties = *q;
- Ice::CommunicatorPtr clientCommunicator = Ice::initialize(clientInitData);
- Ice::ObjectPrx prx = clientCommunicator->stringToProxy(strPrx);
+ Ice::CommunicatorHolder clientCommunicator = Ice::initialize(clientInitData);
+ Ice::ObjectPrxPtr prx = clientCommunicator->stringToProxy(strPrx);
try
{
prx->ice_ping();
@@ -1015,12 +1051,10 @@ allTests(const Ice::CommunicatorPtr& communicator)
(*p == bothPreferIPv4 && *q == ipv6) || (*p == bothPreferIPv6 && *q == ipv4) ||
(*p == bothPreferIPv6 && *q == ipv6 && ipv6NotSupported) ||
(*p == anyipv4 && *q == ipv6) || (*p == anyipv6 && *q == ipv4) ||
- (*p == anyboth && *q == ipv4 && !dualStack) ||
(*p == localipv4 && *q == ipv6) || (*p == localipv6 && *q == ipv4) ||
- (*p == ipv6 && *q == bothPreferIPv4) || (*p == ipv6 && *q == bothPreferIPv6) ||
+ (*p == ipv6 && *q == bothPreferIPv4) || (*p == ipv6 && *q == bothPreferIPv6) ||
(*p == bothPreferIPv6 && *q == ipv6));
}
- clientCommunicator->destroy();
}
serverCommunicator->destroy();
}
@@ -1028,5 +1062,73 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
}
+ //
+ // On Windows, the FD limit is very high and there's no way to limit the number of FDs
+ // for the server so we don't run this test.
+ //
+#if !defined(_WIN32) && (!defined(__APPLE__) || TARGET_OS_IPHONE == 0)
+ {
+ cout << "testing FD limit... " << flush;
+
+ RemoteObjectAdapterPrxPtr adapter = com->createObjectAdapter("Adapter", "default");
+
+ TestIntfPrxPtr test = adapter->getTestIntf();
+ int i = 0;
+ while(true)
+ {
+ try
+ {
+ ostringstream os;
+ os << i;
+ test->ice_connectionId(os.str())->ice_ping();
+ ++i;
+ }
+ catch(const Ice::LocalException&)
+ {
+ break;
+ }
+ }
+
+ try
+ {
+ ostringstream os;
+ os << i;
+ test->ice_connectionId(os.str())->ice_ping();
+ test(false);
+ }
+ catch(const Ice::ConnectionRefusedException&)
+ {
+ // Close the connection now to free a FD (it could be done after the sleep but
+ // there could be race condiutation since the connection might not be closed
+ // immediately due to threading).
+ test->ice_connectionId("0")->ice_getConnection()->close(
+ Ice::ICE_SCOPED_ENUM(ConnectionClose, GracefullyWithWait));
+
+ //
+ // The server closed the acceptor, wait one second and retry after freeing a FD.
+ //
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1100));
+ try
+ {
+ ostringstream os;
+ os << i;
+ test->ice_connectionId(os.str())->ice_ping();
+ }
+ catch(const Ice::LocalException&)
+ {
+ test(false);
+ }
+ }
+ catch(const Ice::LocalException&)
+ {
+ // The server didn't close the acceptor but we still get a failure (it's possible
+ // that the client reached the FD limit depending on the server we are running
+ // against...).
+ }
+
+ cout << "ok" << endl;
+ }
+#endif
+
com->shutdown();
}