THRIFT-2013: add multiplex server and client test support to cpp language
add multiplex client test support to csharp and java languages
fix a bug in the server-side header protocol factory
fix a bug in the cpp SSL server socket implementation
remove unnecessary sleep in cpp server testOneway
This closes #1414
diff --git a/test/csharp/TestClient.cs b/test/csharp/TestClient.cs
index fad1057..17e5978 100644
--- a/test/csharp/TestClient.cs
+++ b/test/csharp/TestClient.cs
@@ -33,7 +33,7 @@
{
public class TestClient
{
- private class TestParams
+ public class TestParams
{
public int numIterations = 1;
public string host = "localhost";
@@ -44,6 +44,7 @@
public bool framed;
public string protocol;
public bool encrypted = false;
+ public bool multiplexed = false;
protected bool _isFirstTransport = true;
@@ -105,21 +106,30 @@
private const int ErrorStructs = 2;
private const int ErrorContainers = 4;
private const int ErrorExceptions = 8;
+ private const int ErrorProtocol = 16;
private const int ErrorUnknown = 64;
private class ClientTest
{
+ private readonly TestParams param;
private readonly TTransport transport;
+ private readonly SecondService.Client second;
private readonly ThriftTest.Client client;
private readonly int numIterations;
private bool done;
public int ReturnCode { get; set; }
- public ClientTest(TestParams param)
+ public ClientTest(TestParams paramin)
{
+ param = paramin;
transport = param.CreateTransport();
- client = new ThriftTest.Client(param.CreateProtocol(transport));
+ TProtocol protocol = param.CreateProtocol(transport);
+ if (param.multiplexed)
+ {
+ second = new SecondService.Client(new TMultiplexedProtocol(protocol, "SecondService"));
+ }
+ client = new ThriftTest.Client(protocol);
numIterations = param.numIterations;
}
public void Execute()
@@ -148,7 +158,7 @@
try
{
- ReturnCode |= ExecuteClientTest(client);
+ ReturnCode |= ExecuteClientTest(client, second, param);
}
catch (Exception ex)
{
@@ -215,12 +225,12 @@
{
numThreads = Convert.ToInt32(args[++i]);
}
- else if (args[i] == "--compact" || args[i] == "--protocol=compact")
+ else if (args[i] == "--compact" || args[i] == "--protocol=compact" || args[i] == "--protocol=multic")
{
param.protocol = "compact";
Console.WriteLine("Using compact protocol");
}
- else if (args[i] == "--json" || args[i] == "--protocol=json")
+ else if (args[i] == "--json" || args[i] == "--protocol=json" || args[i] == "--protocol=multij")
{
param.protocol = "json";
Console.WriteLine("Using JSON protocol");
@@ -230,6 +240,11 @@
param.encrypted = true;
Console.WriteLine("Using encrypted transport");
}
+
+ if (args[i].StartsWith("--protocol=multi"))
+ {
+ param.multiplexed = true;
+ }
}
}
catch (Exception ex)
@@ -296,7 +311,7 @@
return retval;
}
- public static int ExecuteClientTest(ThriftTest.Client client)
+ public static int ExecuteClientTest(ThriftTest.Client client, SecondService.Client second, TestParams param)
{
int returnCode = 0;
@@ -313,6 +328,18 @@
returnCode |= ErrorBaseTypes;
}
+ if (param.multiplexed)
+ {
+ Console.WriteLine("secondTestString(\"Test2\")");
+ s = second.secondtestString("Test2");
+ Console.WriteLine(" = \"" + s + "\"");
+ if ("testString(\"Test2\")" != s)
+ {
+ Console.WriteLine("*** FAILED ***");
+ returnCode |= ErrorProtocol;
+ }
+ }
+
Console.Write("testBool(true)");
bool t = client.testBool((bool)true);
Console.WriteLine(" = " + t);