THRIFT-3130 - C++ Lib: removed no longer needed macro THRIFT_OVERLOAD_IF

Client: C++
Patch: Jim King <jim.king@simplivity.com>

This closes #483
diff --git a/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp
index 73bcdba..fec1b9c 100644
--- a/lib/cpp/test/TServerIntegrationTest.cpp
+++ b/lib/cpp/test/TServerIntegrationTest.cpp
@@ -22,6 +22,7 @@
 #include <boost/bind.hpp>
 #include <boost/foreach.hpp>
 #include <boost/format.hpp>
+#include <boost/make_shared.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
 #include <thrift/server/TSimpleServer.h>
@@ -56,7 +57,12 @@
 using apache::thrift::server::TThreadedServer;
 using apache::thrift::test::ParentServiceClient;
 using apache::thrift::test::ParentServiceIf;
+using apache::thrift::test::ParentServiceIfFactory;
+using apache::thrift::test::ParentServiceIfSingletonFactory;
 using apache::thrift::test::ParentServiceProcessor;
+using apache::thrift::test::ParentServiceProcessorFactory;
+using apache::thrift::TProcessor;
+using apache::thrift::TProcessorFactory;
 using boost::posix_time::milliseconds;
 
 /**
@@ -117,15 +123,19 @@
   }
 
   void getDataWait(std::string& _return, int32_t length) {
+    THRIFT_UNUSED_VARIABLE(_return);
+    THRIFT_UNUSED_VARIABLE(length);
   }
 
   void onewayWait() {
   }
 
   void exceptionWait(const std::string& message) {
+    THRIFT_UNUSED_VARIABLE(message);
   }
 
   void unexpectedExceptionWait(const std::string& message) {
+    THRIFT_UNUSED_VARIABLE(message);
   }
 
 protected:
@@ -143,10 +153,9 @@
 class TServerIntegrationTestFixture : public TestPortFixture
 {
 public:
-  TServerIntegrationTestFixture() :
+  TServerIntegrationTestFixture(const boost::shared_ptr<TProcessorFactory>& _processorFactory) :
       pServer(new TServerType(
-                    boost::shared_ptr<ParentServiceProcessor>(new ParentServiceProcessor(
-                            boost::shared_ptr<ParentServiceIf>(new ParentHandler))),
+                    _processorFactory,
                     boost::shared_ptr<TServerTransport>(new TServerSocket("localhost", m_serverPort)),
                     boost::shared_ptr<TTransportFactory>(new TTransportFactory),
                     boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))),
@@ -155,6 +164,17 @@
     pServer->setServerEventHandler(pEventHandler);
   }
 
+  TServerIntegrationTestFixture(const boost::shared_ptr<TProcessor>& _processor) :
+      pServer(new TServerType(
+                    _processor,
+                    boost::shared_ptr<TServerTransport>(new TServerSocket("localhost", 0)),
+                    boost::shared_ptr<TTransportFactory>(new TTransportFactory),
+                    boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory))),
+      pEventHandler(boost::shared_ptr<TServerReadyEventHandler>(new TServerReadyEventHandler))
+  {
+    pServer->setServerEventHandler(pEventHandler);
+  }
+
   void startServer() {
     pServerThread.reset(new boost::thread(boost::bind(&TServerType::serve, pServer.get())));
 
@@ -191,6 +211,11 @@
     stopServer();
   }
 
+  int getServerPort() {
+    TServerSocket *pSock = dynamic_cast<TServerSocket *>(pServer->getServerTransport().get());
+    return pSock->getPort();
+  }
+
   void delayClose(boost::shared_ptr<TTransport> toClose, boost::posix_time::time_duration after) {
     boost::this_thread::sleep(after);
     toClose->close();
@@ -202,7 +227,7 @@
     std::vector<boost::shared_ptr<boost::thread> > holdThreads;
 
     for (int64_t i = 0; i < numToMake; ++i) {
-        boost::shared_ptr<TSocket> pClientSock(new TSocket("localhost", m_serverPort), autoSocketCloser);
+        boost::shared_ptr<TSocket> pClientSock(new TSocket("localhost", getServerPort()), autoSocketCloser);
         holdSockets.push_back(pClientSock);
         boost::shared_ptr<TProtocol> pClientProtocol(new TBinaryProtocol(pClientSock));
         ParentServiceClient client(pClientProtocol);
@@ -229,25 +254,56 @@
   boost::shared_ptr<boost::thread> pServerThread;
 };
 
-BOOST_FIXTURE_TEST_SUITE( Baseline, TestPortFixture )
+template<class TServerType>
+class TServerIntegrationProcessorFactoryTestFixture : public TServerIntegrationTestFixture<TServerType>
+{
+public:
+    TServerIntegrationProcessorFactoryTestFixture() :
+        TServerIntegrationTestFixture<TServerType>(
+                boost::make_shared<ParentServiceProcessorFactory>(
+                    boost::make_shared<ParentServiceIfSingletonFactory>(
+                            boost::make_shared<ParentHandler>()))) { }
+};
 
-BOOST_FIXTURE_TEST_CASE(test_simple, TServerIntegrationTestFixture<TSimpleServer>)
+template<class TServerType>
+class TServerIntegrationProcessorTestFixture : public TServerIntegrationTestFixture<TServerType>
+{
+public:
+    TServerIntegrationProcessorTestFixture() :
+        TServerIntegrationTestFixture<TServerType>(
+                boost::make_shared<ParentServiceProcessor>(
+                        boost::make_shared<ParentHandler>())) { }
+};
+
+BOOST_AUTO_TEST_SUITE(constructors)
+
+BOOST_FIXTURE_TEST_CASE(test_simple_factory, TServerIntegrationProcessorFactoryTestFixture<TSimpleServer>)
 {
     baseline(3, 1);
 }
 
-BOOST_FIXTURE_TEST_CASE(test_threaded, TServerIntegrationTestFixture<TThreadedServer>)
+BOOST_FIXTURE_TEST_CASE(test_simple, TServerIntegrationProcessorTestFixture<TSimpleServer>)
+{
+    baseline(3, 1);
+}
+
+BOOST_FIXTURE_TEST_CASE(test_threaded_factory, TServerIntegrationProcessorFactoryTestFixture<TThreadedServer>)
 {
     baseline(10, 10);
 }
 
-BOOST_FIXTURE_TEST_CASE(test_threaded_bound, TServerIntegrationTestFixture<TThreadedServer>)
+BOOST_FIXTURE_TEST_CASE(test_threaded, TServerIntegrationProcessorTestFixture<TThreadedServer>)
+{
+    baseline(10, 10);
+}
+
+BOOST_FIXTURE_TEST_CASE(test_threaded_bound, TServerIntegrationProcessorTestFixture<TThreadedServer>)
 {
     pServer->setConcurrentClientLimit(4);
     baseline(10, 4);
 }
 
-BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationTestFixture<TThreadPoolServer>)
+BOOST_FIXTURE_TEST_CASE(test_threadpool_factory, TServerIntegrationProcessorFactoryTestFixture<TThreadPoolServer>)
 {
     pServer->getThreadManager()->threadFactory(
             boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
@@ -262,7 +318,22 @@
     baseline(10, 5);
 }
 
-BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationTestFixture<TThreadPoolServer>)
+BOOST_FIXTURE_TEST_CASE(test_threadpool, TServerIntegrationProcessorTestFixture<TThreadPoolServer>)
+{
+    pServer->getThreadManager()->threadFactory(
+            boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
+                    new apache::thrift::concurrency::PlatformThreadFactory));
+    pServer->getThreadManager()->start();
+
+    // thread factory has 4 threads as a default
+    // thread factory however is a bad way to limit concurrent clients
+    // as accept() will be called to grab a 5th client socket, in this case
+    // and then the thread factory will block adding the thread to manage
+    // that client.
+    baseline(10, 5);
+}
+
+BOOST_FIXTURE_TEST_CASE(test_threadpool_bound, TServerIntegrationProcessorTestFixture<TThreadPoolServer>)
 {
     pServer->getThreadManager()->threadFactory(
             boost::shared_ptr<apache::thrift::concurrency::ThreadFactory>(
@@ -276,7 +347,7 @@
 BOOST_AUTO_TEST_SUITE_END()
 
 
-BOOST_FIXTURE_TEST_SUITE ( TServerIntegrationTest, TServerIntegrationTestFixture<TThreadedServer> )
+BOOST_FIXTURE_TEST_SUITE ( TServerIntegrationTest, TServerIntegrationProcessorTestFixture<TThreadedServer> )
 
 BOOST_AUTO_TEST_CASE(test_stop_with_interruptable_clients_connected)
 {
@@ -284,10 +355,10 @@
 
     startServer();
 
-    boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock1->open();
 
-    boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock2->open();
 
     // Ensure they have been accepted
@@ -313,10 +384,10 @@
 
     startServer();
 
-    boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock1->open();
 
-    boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock2->open();
 
     // Ensure they have been accepted
@@ -340,19 +411,19 @@
     BOOST_CHECK_EQUAL(0, pServer->getConcurrentClientCount());
     BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientLimit());
 
-    boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock1(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock1->open();
     blockUntilAccepted(1);
     BOOST_CHECK_EQUAL(1, pServer->getConcurrentClientCount());
 
-    boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock2(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock2->open();
     blockUntilAccepted(2);
     BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());
 
     // a third client cannot connect until one of the other two closes
     boost::thread t2(boost::bind(&TServerIntegrationTestFixture::delayClose, this, pClientSock2, milliseconds(250)));
-    boost::shared_ptr<TSocket> pClientSock3(new TSocket("localhost", m_serverPort), autoSocketCloser);
+    boost::shared_ptr<TSocket> pClientSock3(new TSocket("localhost", getServerPort()), autoSocketCloser);
     pClientSock2->open();
     blockUntilAccepted(2);
     BOOST_CHECK_EQUAL(2, pServer->getConcurrentClientCount());