THRIFT-2358 C++: add compact protocol to cross language test suite
Patch: Roger Meier
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index a0ada14..acb0518 100755
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -22,6 +22,7 @@
 
 #include <iostream>
 #include <thrift/protocol/TBinaryProtocol.h>
+#include <thrift/protocol/TCompactProtocol.h>
 #include <thrift/protocol/TJSONProtocol.h>
 #include <thrift/transport/THttpClient.h>
 #include <thrift/transport/TTransportUtils.h>
@@ -109,7 +110,7 @@
       ("port", boost::program_options::value<int>(&port)->default_value(port), "Port number to connect")
 	  ("domain-socket", boost::program_options::value<string>(&domain_socket)->default_value(domain_socket), "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port")
       ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type), "Transport: buffered, framed, http, evhttp")
-      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type), "Protocol: binary, json")
+      ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type), "Protocol: binary, compact, json")
 	  ("ssl", "Encrypted Transport using SSL")
       ("testloops,n", boost::program_options::value<int>(&numTests)->default_value(numTests), "Number of Tests")
   ;
@@ -188,6 +189,9 @@
   if (protocol_type.compare("json") == 0) {
     boost::shared_ptr<TProtocol> jsonProtocol(new TJSONProtocol(transport));
     protocol = jsonProtocol;
+  } else if (protocol_type.compare("compact") == 0) {
+    boost::shared_ptr<TProtocol> compactProtocol(new TCompactProtocol(transport));
+    protocol = compactProtocol;
   } else{
     boost::shared_ptr<TBinaryProtocol> binaryProtocol(new TBinaryProtocol(transport));
     protocol = binaryProtocol;
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index af43d72..8cf8db1 100755
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -23,6 +23,7 @@
 #include <thrift/concurrency/ThreadManager.h>
 #include <thrift/concurrency/PlatformThreadFactory.h>
 #include <thrift/protocol/TBinaryProtocol.h>
+#include <thrift/protocol/TCompactProtocol.h>
 #include <thrift/protocol/TJSONProtocol.h>
 #include <thrift/server/TSimpleServer.h>
 #include <thrift/server/TThreadedServer.h>
@@ -515,7 +516,7 @@
       ("transport", boost::program_options::value<string>(&transport_type)->default_value(transport_type),
         "transport: buffered, framed, http")
       ("protocol", boost::program_options::value<string>(&protocol_type)->default_value(protocol_type),
-        "protocol: binary, json")
+        "protocol: binary, compact, json")
 	  ("ssl", "Encrypted Transport using SSL")
 	  ("processor-events", "processor-events")
       ("workers,n", boost::program_options::value<size_t>(&workers)->default_value(workers),
@@ -574,6 +575,9 @@
   if (protocol_type == "json") {
     boost::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory());
     protocolFactory = jsonProtocolFactory;
+  } else if (protocol_type == "compact") {
+    boost::shared_ptr<TProtocolFactory> compactProtocolFactory(new TCompactProtocolFactory());
+    protocolFactory = compactProtocolFactory;
   } else {
     boost::shared_ptr<TProtocolFactory> binaryProtocolFactory(new TBinaryProtocolFactoryT<TBufferBase>());
     protocolFactory = binaryProtocolFactory;