THRIFT-1103. py: TZlibTransport for python, a zlib compressed transport

This patch adds a new TZlibTransport to the Python library and extends the test suite to exercise it.

Patch: Will Pierce

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1084276 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index eecb850..6429ec3 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -28,6 +28,7 @@
 from thrift.transport import TTransport
 from thrift.transport import TSocket
 from thrift.transport import THttpClient
+from thrift.transport import TZlibTransport
 from thrift.protocol import TBinaryProtocol
 from thrift.protocol import TCompactProtocol
 import unittest
@@ -40,6 +41,10 @@
     help="connect to server at port")
 parser.add_option("--host", type="string", dest="host",
     help="connect to server")
+parser.add_option("--zlib", action="store_true", dest="zlib",
+    help="use zlib wrapper for compressed transport")
+parser.add_option("--ssl", action="store_true", dest="ssl",
+    help="use SSL for encrypted transport")
 parser.add_option("--framed", action="store_true", dest="framed",
     help="use framed transport")
 parser.add_option("--http", dest="http_path",
@@ -58,19 +63,21 @@
 class AbstractTest(unittest.TestCase):
   def setUp(self):
     if options.http_path:
-      self.transport = THttpClient.THttpClient(
-          options.host, options.port, options.http_path)
+      self.transport = THttpClient.THttpClient(options.host, port=options.port, path=options.http_path)
     else:
-      socket = TSocket.TSocket(options.host, options.port)
-
+      if options.ssl:
+        from thrift.transport import TSSLSocket
+        socket = TSSLSocket.TSSLSocket(options.host, options.port, validate=False)
+      else:
+        socket = TSocket.TSocket(options.host, options.port)
       # frame or buffer depending upon args
       if options.framed:
         self.transport = TTransport.TFramedTransport(socket)
       else:
         self.transport = TTransport.TBufferedTransport(socket)
-
+      if options.zlib:
+        self.transport = TZlibTransport.TZlibTransport(self.transport, 9)
     self.transport.open()
-
     protocol = self.protocol_factory.getProtocol(self.transport)
     self.client = ThriftTest.Client(protocol)
 
@@ -82,7 +89,7 @@
     self.client.testVoid()
 
   def testString(self):
-    self.assertEqual(self.client.testString('Python'), 'Python')
+    self.assertEqual(self.client.testString('Python' * 20), 'Python' * 20)
     self.assertEqual(self.client.testString(''), '')
 
   def testByte(self):