THRIFT-5060: Add cross tests for TZlibTransport in Java
Client: Java
Patch: Kengo Seki

This closes #1978
diff --git a/lib/java/test/org/apache/thrift/test/TestClient.java b/lib/java/test/org/apache/thrift/test/TestClient.java
index dbada08..b402854 100644
--- a/lib/java/test/org/apache/thrift/test/TestClient.java
+++ b/lib/java/test/org/apache/thrift/test/TestClient.java
@@ -44,6 +44,7 @@
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
+import org.apache.thrift.transport.TZlibTransport;
 
 // Generated code
 import thrift.test.Insanity;
@@ -77,6 +78,7 @@
     String protocol_type = "binary";
     String transport_type = "buffered";
     boolean ssl = false;
+    boolean zlib = false;
     boolean http_client = false;
 
     int socketTimeout = 1000;
@@ -101,6 +103,8 @@
           transport_type.trim();
         } else if (args[i].equals("--ssl")) {
           ssl = true;
+        } else if (args[i].equals("--zlib")) {
+          zlib = true;
         } else if (args[i].equals("--client")) {
           http_client = true;  
         } else if (args[i].equals("--help")) {
@@ -108,9 +112,10 @@
           System.out.println("  --help\t\t\tProduce help message");
           System.out.println("  --host=arg (=" + host + ")\tHost to connect");
           System.out.println("  --port=arg (=" + port + ")\tPort number to connect");
-          System.out.println("  --transport=arg (=" + transport_type + ")\n\t\t\t\tTransport: buffered, framed, fastframed, http");
+          System.out.println("  --transport=arg (=" + transport_type + ")\n\t\t\t\tTransport: buffered, framed, fastframed, http, zlib");
           System.out.println("  --protocol=arg (=" + protocol_type + ")\tProtocol: binary, compact, json, multi, multic, multij");
           System.out.println("  --ssl\t\t\tEncrypted Transport using SSL");
+          System.out.println("  --zlib\t\t\tCompressed Transport using Zlib");
           System.out.println("  --testloops[--n]=arg (=" + numTests + ")\tNumber of Tests");
           System.exit(0);
         }
@@ -134,6 +139,7 @@
       } else if (transport_type.equals("framed")) {
       } else if (transport_type.equals("fastframed")) {
       } else if (transport_type.equals("http")) {
+      } else if (transport_type.equals("zlib")) {
       } else {
         throw new Exception("Unknown transport type! " + transport_type);
       }
@@ -165,11 +171,18 @@
         }
         socket.setTimeout(socketTimeout);
         transport = socket;
-        if (transport_type.equals("buffered")) {
-        } else if (transport_type.equals("framed")) {
-          transport = new TFramedTransport(transport);
-        } else if (transport_type.equals("fastframed")) {
-          transport = new TFastFramedTransport(transport);
+        if (transport_type.equals("zlib")) {
+          transport = new TZlibTransport(transport);
+        } else {
+          if (transport_type.equals("buffered")) {
+          } else if (transport_type.equals("framed")) {
+            transport = new TFramedTransport(transport);
+          } else if (transport_type.equals("fastframed")) {
+            transport = new TFastFramedTransport(transport);
+          }
+          if (zlib) {
+            transport = new TZlibTransport(transport);
+          }
         }
       }
     } catch (Exception x) {
diff --git a/lib/java/test/org/apache/thrift/test/TestServer.java b/lib/java/test/org/apache/thrift/test/TestServer.java
index 1f3e555..25a329c 100644
--- a/lib/java/test/org/apache/thrift/test/TestServer.java
+++ b/lib/java/test/org/apache/thrift/test/TestServer.java
@@ -42,6 +42,7 @@
 import org.apache.thrift.server.TNonblockingServer;
 import org.apache.thrift.transport.TFramedTransport;
 import org.apache.thrift.transport.TFastFramedTransport;
+import org.apache.thrift.transport.TZlibTransport;
 import org.apache.thrift.transport.TServerSocket;
 import org.apache.thrift.transport.TSSLTransportFactory;
 import org.apache.thrift.transport.TTransport;
@@ -127,6 +128,7 @@
     try {
       int port = 9090;
       boolean ssl = false;
+      boolean zlib = false;
       String transport_type = "buffered";
       String protocol_type = "binary";
       String server_type = "thread-pool";
@@ -150,6 +152,8 @@
             transport_type.trim();
           } else if (args[i].equals("--ssl")) {
             ssl = true;
+          } else if (args[i].equals("--zlib")) {
+            zlib = true;
           } else if (args[i].startsWith("--string-limit")) {
             string_limit = Integer.valueOf(args[i].split("=")[1]);
           } else if (args[i].startsWith("--container-limit")) {
@@ -158,9 +162,10 @@
             System.out.println("Allowed options:");
             System.out.println("  --help\t\t\tProduce help message");
             System.out.println("  --port=arg (=" + port + ")\tPort number to connect");
-            System.out.println("  --transport=arg (=" + transport_type + ")\n\t\t\t\tTransport: buffered, framed, fastframed");
+            System.out.println("  --transport=arg (=" + transport_type + ")\n\t\t\t\tTransport: buffered, framed, fastframed, zlib");
             System.out.println("  --protocol=arg (=" + protocol_type + ")\tProtocol: binary, compact, json, multi, multic, multij");
             System.out.println("  --ssl\t\t\tEncrypted Transport using SSL");
+            System.out.println("  --zlib\t\t\tCompressed Transport using Zlib");
             System.out.println("  --server-type=arg (=" + server_type +")\n\t\t\t\tType of server: simple, thread-pool, nonblocking, threaded-selector");
             System.out.println("  --string-limit=arg (=" + string_limit + ")\tString read length limit");
             System.out.println("  --container-limit=arg (=" + container_limit + ")\tContainer read length limit");
@@ -198,6 +203,7 @@
         if (transport_type.equals("buffered")) {
         } else if (transport_type.equals("framed")) {
         } else if (transport_type.equals("fastframed")) {
+        } else if (transport_type.equals("zlib")) {
         } else {
           throw new Exception("Unknown transport type! " + transport_type);
         }
@@ -229,6 +235,8 @@
         tTransportFactory = new TFramedTransport.Factory();
       } else if (transport_type.equals("fastframed")) {
         tTransportFactory = new TFastFramedTransport.Factory();
+      } else if (transport_type.equals("zlib")) {
+        tTransportFactory = new TZlibTransport.Factory();
       } else { // .equals("buffered") => default value
         tTransportFactory = new TTransportFactory();
       }
diff --git a/test/tests.json b/test/tests.json
index b8b85be..fc9046b 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -152,7 +152,8 @@
     "transports": [
       "buffered",
       "framed",
-      "framed:fastframed"
+      "framed:fastframed",
+      "zlib"
     ],
     "sockets": [
       "ip",