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.TTransport;
|
||||
import org.apache.thrift.transport.TTransportException;
|
||||
import org.apache.thrift.transport.TZlibTransport;
|
||||
|
||||
// Generated code
|
||||
import thrift.test.Insanity;
|
||||
@ -77,6 +78,7 @@ public class TestClient {
|
||||
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 @@ public class TestClient {
|
||||
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 @@ public class TestClient {
|
||||
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 @@ public class TestClient {
|
||||
} 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 @@ public class TestClient {
|
||||
}
|
||||
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) {
|
||||
|
@ -42,6 +42,7 @@ import org.apache.thrift.server.TThreadedSelectorServer;
|
||||
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 @@ public class TestServer {
|
||||
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 @@ public class TestServer {
|
||||
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 @@ public class TestServer {
|
||||
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 @@ public class TestServer {
|
||||
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 @@ public class TestServer {
|
||||
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();
|
||||
}
|
||||
|
@ -152,7 +152,8 @@
|
||||
"transports": [
|
||||
"buffered",
|
||||
"framed",
|
||||
"framed:fastframed"
|
||||
"framed:fastframed",
|
||||
"zlib"
|
||||
],
|
||||
"sockets": [
|
||||
"ip",
|
||||
|
Loading…
Reference in New Issue
Block a user