mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-06 18:35:19 +00:00
THRIFT-5060: Add cross tests for TZlibTransport in Java
Client: Java Patch: Kengo Seki This closes #1978
This commit is contained in:
parent
46554d0a4c
commit
c97e6aa860
@ -44,6 +44,7 @@ import org.apache.thrift.transport.TSSLTransportFactory;
|
|||||||
import org.apache.thrift.transport.TSocket;
|
import org.apache.thrift.transport.TSocket;
|
||||||
import org.apache.thrift.transport.TTransport;
|
import org.apache.thrift.transport.TTransport;
|
||||||
import org.apache.thrift.transport.TTransportException;
|
import org.apache.thrift.transport.TTransportException;
|
||||||
|
import org.apache.thrift.transport.TZlibTransport;
|
||||||
|
|
||||||
// Generated code
|
// Generated code
|
||||||
import thrift.test.Insanity;
|
import thrift.test.Insanity;
|
||||||
@ -77,6 +78,7 @@ public class TestClient {
|
|||||||
String protocol_type = "binary";
|
String protocol_type = "binary";
|
||||||
String transport_type = "buffered";
|
String transport_type = "buffered";
|
||||||
boolean ssl = false;
|
boolean ssl = false;
|
||||||
|
boolean zlib = false;
|
||||||
boolean http_client = false;
|
boolean http_client = false;
|
||||||
|
|
||||||
int socketTimeout = 1000;
|
int socketTimeout = 1000;
|
||||||
@ -101,6 +103,8 @@ public class TestClient {
|
|||||||
transport_type.trim();
|
transport_type.trim();
|
||||||
} else if (args[i].equals("--ssl")) {
|
} else if (args[i].equals("--ssl")) {
|
||||||
ssl = true;
|
ssl = true;
|
||||||
|
} else if (args[i].equals("--zlib")) {
|
||||||
|
zlib = true;
|
||||||
} else if (args[i].equals("--client")) {
|
} else if (args[i].equals("--client")) {
|
||||||
http_client = true;
|
http_client = true;
|
||||||
} else if (args[i].equals("--help")) {
|
} else if (args[i].equals("--help")) {
|
||||||
@ -108,9 +112,10 @@ public class TestClient {
|
|||||||
System.out.println(" --help\t\t\tProduce help message");
|
System.out.println(" --help\t\t\tProduce help message");
|
||||||
System.out.println(" --host=arg (=" + host + ")\tHost to connect");
|
System.out.println(" --host=arg (=" + host + ")\tHost to connect");
|
||||||
System.out.println(" --port=arg (=" + port + ")\tPort number 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(" --protocol=arg (=" + protocol_type + ")\tProtocol: binary, compact, json, multi, multic, multij");
|
||||||
System.out.println(" --ssl\t\t\tEncrypted Transport using SSL");
|
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.out.println(" --testloops[--n]=arg (=" + numTests + ")\tNumber of Tests");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
@ -134,6 +139,7 @@ public class TestClient {
|
|||||||
} else if (transport_type.equals("framed")) {
|
} else if (transport_type.equals("framed")) {
|
||||||
} else if (transport_type.equals("fastframed")) {
|
} else if (transport_type.equals("fastframed")) {
|
||||||
} else if (transport_type.equals("http")) {
|
} else if (transport_type.equals("http")) {
|
||||||
|
} else if (transport_type.equals("zlib")) {
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown transport type! " + transport_type);
|
throw new Exception("Unknown transport type! " + transport_type);
|
||||||
}
|
}
|
||||||
@ -165,11 +171,18 @@ public class TestClient {
|
|||||||
}
|
}
|
||||||
socket.setTimeout(socketTimeout);
|
socket.setTimeout(socketTimeout);
|
||||||
transport = socket;
|
transport = socket;
|
||||||
if (transport_type.equals("buffered")) {
|
if (transport_type.equals("zlib")) {
|
||||||
} else if (transport_type.equals("framed")) {
|
transport = new TZlibTransport(transport);
|
||||||
transport = new TFramedTransport(transport);
|
} else {
|
||||||
} else if (transport_type.equals("fastframed")) {
|
if (transport_type.equals("buffered")) {
|
||||||
transport = new TFastFramedTransport(transport);
|
} 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) {
|
} catch (Exception x) {
|
||||||
|
@ -42,6 +42,7 @@ import org.apache.thrift.server.TThreadedSelectorServer;
|
|||||||
import org.apache.thrift.server.TNonblockingServer;
|
import org.apache.thrift.server.TNonblockingServer;
|
||||||
import org.apache.thrift.transport.TFramedTransport;
|
import org.apache.thrift.transport.TFramedTransport;
|
||||||
import org.apache.thrift.transport.TFastFramedTransport;
|
import org.apache.thrift.transport.TFastFramedTransport;
|
||||||
|
import org.apache.thrift.transport.TZlibTransport;
|
||||||
import org.apache.thrift.transport.TServerSocket;
|
import org.apache.thrift.transport.TServerSocket;
|
||||||
import org.apache.thrift.transport.TSSLTransportFactory;
|
import org.apache.thrift.transport.TSSLTransportFactory;
|
||||||
import org.apache.thrift.transport.TTransport;
|
import org.apache.thrift.transport.TTransport;
|
||||||
@ -127,6 +128,7 @@ public class TestServer {
|
|||||||
try {
|
try {
|
||||||
int port = 9090;
|
int port = 9090;
|
||||||
boolean ssl = false;
|
boolean ssl = false;
|
||||||
|
boolean zlib = false;
|
||||||
String transport_type = "buffered";
|
String transport_type = "buffered";
|
||||||
String protocol_type = "binary";
|
String protocol_type = "binary";
|
||||||
String server_type = "thread-pool";
|
String server_type = "thread-pool";
|
||||||
@ -150,6 +152,8 @@ public class TestServer {
|
|||||||
transport_type.trim();
|
transport_type.trim();
|
||||||
} else if (args[i].equals("--ssl")) {
|
} else if (args[i].equals("--ssl")) {
|
||||||
ssl = true;
|
ssl = true;
|
||||||
|
} else if (args[i].equals("--zlib")) {
|
||||||
|
zlib = true;
|
||||||
} else if (args[i].startsWith("--string-limit")) {
|
} else if (args[i].startsWith("--string-limit")) {
|
||||||
string_limit = Integer.valueOf(args[i].split("=")[1]);
|
string_limit = Integer.valueOf(args[i].split("=")[1]);
|
||||||
} else if (args[i].startsWith("--container-limit")) {
|
} else if (args[i].startsWith("--container-limit")) {
|
||||||
@ -158,9 +162,10 @@ public class TestServer {
|
|||||||
System.out.println("Allowed options:");
|
System.out.println("Allowed options:");
|
||||||
System.out.println(" --help\t\t\tProduce help message");
|
System.out.println(" --help\t\t\tProduce help message");
|
||||||
System.out.println(" --port=arg (=" + port + ")\tPort number 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");
|
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(" --protocol=arg (=" + protocol_type + ")\tProtocol: binary, compact, json, multi, multic, multij");
|
||||||
System.out.println(" --ssl\t\t\tEncrypted Transport using SSL");
|
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(" --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(" --string-limit=arg (=" + string_limit + ")\tString read length limit");
|
||||||
System.out.println(" --container-limit=arg (=" + container_limit + ")\tContainer read length limit");
|
System.out.println(" --container-limit=arg (=" + container_limit + ")\tContainer read length limit");
|
||||||
@ -198,6 +203,7 @@ public class TestServer {
|
|||||||
if (transport_type.equals("buffered")) {
|
if (transport_type.equals("buffered")) {
|
||||||
} else if (transport_type.equals("framed")) {
|
} else if (transport_type.equals("framed")) {
|
||||||
} else if (transport_type.equals("fastframed")) {
|
} else if (transport_type.equals("fastframed")) {
|
||||||
|
} else if (transport_type.equals("zlib")) {
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown transport type! " + transport_type);
|
throw new Exception("Unknown transport type! " + transport_type);
|
||||||
}
|
}
|
||||||
@ -229,6 +235,8 @@ public class TestServer {
|
|||||||
tTransportFactory = new TFramedTransport.Factory();
|
tTransportFactory = new TFramedTransport.Factory();
|
||||||
} else if (transport_type.equals("fastframed")) {
|
} else if (transport_type.equals("fastframed")) {
|
||||||
tTransportFactory = new TFastFramedTransport.Factory();
|
tTransportFactory = new TFastFramedTransport.Factory();
|
||||||
|
} else if (transport_type.equals("zlib")) {
|
||||||
|
tTransportFactory = new TZlibTransport.Factory();
|
||||||
} else { // .equals("buffered") => default value
|
} else { // .equals("buffered") => default value
|
||||||
tTransportFactory = new TTransportFactory();
|
tTransportFactory = new TTransportFactory();
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,8 @@
|
|||||||
"transports": [
|
"transports": [
|
||||||
"buffered",
|
"buffered",
|
||||||
"framed",
|
"framed",
|
||||||
"framed:fastframed"
|
"framed:fastframed",
|
||||||
|
"zlib"
|
||||||
],
|
],
|
||||||
"sockets": [
|
"sockets": [
|
||||||
"ip",
|
"ip",
|
||||||
|
Loading…
Reference in New Issue
Block a user