summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/info/AllTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/info/AllTests.cpp')
-rw-r--r--cpp/test/Ice/info/AllTests.cpp98
1 files changed, 65 insertions, 33 deletions
diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp
index 81da1e2aafa..e9edf0327ee 100644
--- a/cpp/test/Ice/info/AllTests.cpp
+++ b/cpp/test/Ice/info/AllTests.cpp
@@ -15,6 +15,39 @@
using namespace std;
using namespace Test;
+namespace
+{
+
+Ice::TCPEndpointInfoPtr
+getTCPEndpointInfo(const Ice::EndpointInfoPtr& info)
+{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::TCPEndpointInfoPtr tcpInfo = ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, p);
+ if(tcpInfo)
+ {
+ return tcpInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+Ice::TCPConnectionInfoPtr
+getTCPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::TCPConnectionInfoPtr tcpInfo = ICE_DYNAMIC_CAST(Ice::TCPConnectionInfo, p);
+ if(tcpInfo)
+ {
+ return tcpInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -27,7 +60,8 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq endps = p1->ice_getEndpoints();
- Ice::IPEndpointInfoPtr ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, endps[0]->getInfo());
+ Ice::EndpointInfoPtr info = endps[0]->getInfo();
+ Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(info);
test(ipEndpoint);
test(ipEndpoint->host == "tcphost");
test(ipEndpoint->port == 10000);
@@ -38,13 +72,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(ipEndpoint->compress);
test(!ipEndpoint->datagram());
test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
- (ipEndpoint->type() == IceSSL::EndpointType && ipEndpoint->secure()) ||
+ (ipEndpoint->type() == Ice::SSLEndpointType && ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
- test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == IceSSL::EndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(IceSSL::WSSEndpointInfo, ipEndpoint)));
+
+ test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::SSLEndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)));
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endps[1]->getInfo());
test(udpEndpoint);
@@ -81,9 +116,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
- Ice::IPEndpointInfoPtr ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, endpoints[0]->getInfo());
+ Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo());
test(ipEndpoint);
- test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == IceSSL::EndpointType ||
+ test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType ||
ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port > 0);
@@ -108,11 +143,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, (*p)->getInfo());
+ ipEndpoint = getTCPEndpointInfo((*p)->getInfo());
test(ipEndpoint->port == 12020);
}
- ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, publishedEndpoints[0]->getInfo());
+ ipEndpoint = getTCPEndpointInfo(publishedEndpoints[0]->getInfo());
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port == 12020);
@@ -126,15 +161,15 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "test connection endpoint information... " << flush;
{
Ice::EndpointInfoPtr info = base->ice_getConnection()->getEndpoint()->getInfo();
- Ice::IPEndpointInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, info);
- test(ipinfo->port == 12010);
- test(!ipinfo->compress);
- test(ipinfo->host == defaultHost);
+ Ice::TCPEndpointInfoPtr tcpinfo = getTCPEndpointInfo(info);
+ test(tcpinfo->port == 12010);
+ test(!tcpinfo->compress);
+ test(tcpinfo->host == defaultHost);
ostringstream os;
Ice::Context ctx = testIntf->getEndpointInfoAsContext();
- test(ctx["host"] == ipinfo->host);
+ test(ctx["host"] == tcpinfo->host);
test(ctx["compress"] == "false");
istringstream is(ctx["port"]);
int port;
@@ -154,7 +189,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::ConnectionPtr connection = base->ice_getConnection();
connection->setBufferSize(1024, 2048);
- Ice::IPConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connection->getInfo());
+ Ice::TCPConnectionInfoPtr info = getTCPConnectionInfo(connection->getInfo());
test(info);
test(!info->incoming);
test(info->adapterName.empty());
@@ -188,16 +223,13 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
Ice::HeaderDict headers;
- Ice::WSConnectionInfoPtr wsinfo = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, info);
- if(wsinfo)
- {
- headers = wsinfo->headers;
- }
+ Ice::WSConnectionInfoPtr wsinfo = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, connection->getInfo());
+ test(wsinfo);
+ headers = wsinfo->headers;
- IceSSL::WSSConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, info);
- if(wssinfo)
+ if(base->ice_getConnection()->type() == "wss")
{
- headers = wssinfo->headers;
+ IceSSL::ConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, wsinfo->underlying);
test(wssinfo->verified);
#if !defined(ICE_OS_WINRT) && TARGET_OS_IPHONE==0
test(!wssinfo->certs.empty());
@@ -219,20 +251,20 @@ allTests(const Ice::CommunicatorPtr& communicator)
connection = base->ice_datagram()->ice_getConnection();
connection->setBufferSize(2048, 1024);
- info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connection->getInfo());
- test(!info->incoming);
- test(info->adapterName.empty());
- test(info->localPort > 0);
- test(info->remotePort == 12010);
+ Ice::UDPConnectionInfoPtr udpinfo = ICE_DYNAMIC_CAST(Ice::UDPConnectionInfo, connection->getInfo());
+ test(!udpinfo->incoming);
+ test(udpinfo->adapterName.empty());
+ test(udpinfo->localPort > 0);
+ test(udpinfo->remotePort == 12010);
if(defaultHost == "127.0.0.1")
{
- test(info->remoteAddress == defaultHost);
- test(info->localAddress == defaultHost);
+ test(udpinfo->remoteAddress == defaultHost);
+ test(udpinfo->localAddress == defaultHost);
}
#if !defined(ICE_OS_WINRT)
- test(info->rcvSize >= 2048);
- test(info->sndSize >= 1024);
+ test(udpinfo->rcvSize >= 2048);
+ test(udpinfo->sndSize >= 1024);
#endif
}
cout << "ok" << endl;