From: Jens Geyer Date: Fri, 2 May 2014 20:23:15 +0000 (+0200) Subject: THRIFT-2501: C# The test parameters from the TestServer and TestClient are different... X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=2a9e6a491e2c6e97bd35f715f39788582eb8b027;p=common%2Fthrift.git THRIFT-2501: C# The test parameters from the TestServer and TestClient are different from the thrift.apache.org/test/ Client: C# Patch: Beat Kaeslin This closes #108 commit 0fb9ff4ae19702ffe6d098a6515f6a23d60e88d5 Author: Beat Kaeslin Date: 2014-04-23T06:33:59Z Parameter aligned with thrift.apache.org/test/ --- diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs index 593169f0..db0fe63e 100644 --- a/lib/csharp/test/ThriftTest/TestClient.cs +++ b/lib/csharp/test/ThriftTest/TestClient.cs @@ -46,16 +46,7 @@ namespace Test { for (int i = 0; i < args.Length; i++) { - if (args[i] == "-h") - { - string[] hostport = args[++i].Split(':'); - host = hostport[0]; - if (hostport.Length > 1) - { - port = Convert.ToInt32(hostport[1]); - } - } - else if (args[i] == "-u") + if (args[i] == "-u") { url = args[++i]; } @@ -63,40 +54,48 @@ namespace Test { numIterations = Convert.ToInt32(args[++i]); } - else if (args[i] == "-b" || args[i] == "-buffered") + else if (args[i] == "-pipe") // -pipe + { + pipe = args[++i]; + Console.WriteLine("Using named pipes transport"); + } + else if (args[i].Contains("--host=")) + { + host = args[i].Substring(args[i].IndexOf("=") + 1); + } + else if (args[i].Contains("--port=")) + { + port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1)); + } + else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered") { buffered = true; Console.WriteLine("Using buffered sockets"); } - else if (args[i] == "-f" || args[i] == "-framed") + else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed") { framed = true; Console.WriteLine("Using framed transport"); } - else if (args[i] == "-pipe") // -pipe - { - pipe = args[++i]; - Console.WriteLine("Using named pipes transport"); - } else if (args[i] == "-t") { numThreads = Convert.ToInt32(args[++i]); } - else if (args[i] == "-ssl") - { - encrypted = true; - Console.WriteLine("Using encrypted transport"); - } - else if (args[i] == "-compact") + else if (args[i] == "--compact" || args[i] == "--protocol=compact") { protocol = "compact"; Console.WriteLine("Using compact protocol"); } - else if (args[i] == "-json") + else if (args[i] == "--json" || args[i] == "--protocol=json") { protocol = "json"; Console.WriteLine("Using JSON protocol"); } + else if (args[i] == "--ssl") + { + encrypted = true; + Console.WriteLine("Using encrypted transport"); + } } } catch (Exception e) diff --git a/lib/csharp/test/ThriftTest/TestServer.cs b/lib/csharp/test/ThriftTest/TestServer.cs index f0e9abbf..f0f539fa 100644 --- a/lib/csharp/test/ThriftTest/TestServer.cs +++ b/lib/csharp/test/ThriftTest/TestServer.cs @@ -323,52 +323,37 @@ namespace Test try { bool useBufferedSockets = false, useFramed = false, useEncryption = false, compact = false, json = false; - int port = 9090, i = 0; + int port = 9090; string pipe = null; - if (args.Length > 0) + for (int i = 0; i < args.Length; i++) { - i = 0; if (args[i] == "-pipe") // -pipe name { pipe = args[++i]; } - else // default to port number (compatibility) + else if (args[i].Contains("--port=")) { - port = int.Parse(args[i]); + port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1)); } - - ++i; - if (args.Length > i) + else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered") + { + useBufferedSockets = true; + } + else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed") + { + useFramed = true; + } + else if (args[i] == "--compact" || args[i] == "--protocol=compact") + { + compact = true; + } + else if (args[i] == "--json" || args[i] == "--protocol=json") + { + json = true; + } + else if (args[i] == "--ssl") { - if ( args[i] == "raw" ) - { - // as default - } - else if (args[i] == "buffered") - { - useBufferedSockets = true; - } - else if (args[i] == "framed") - { - useFramed = true; - } - else if (args[i] == "ssl") - { - useEncryption = true; - } - else if (args[i] == "compact" ) - { - compact = true; - } - else if (args[i] == "json" ) - { - json = true; - } - else - { - // Fall back to the older boolean syntax - bool.TryParse(args[i], out useBufferedSockets); - } + useEncryption = true; } } @@ -420,10 +405,11 @@ namespace Test // Run it string where = ( pipe != null ? "on pipe "+pipe : "on port " + port); Console.WriteLine("Starting the server " + where + - (useBufferedSockets ? " with buffered socket" : "") + - (useFramed ? " with framed transport" : "") + - (useEncryption ? " with encryption" : "") + - (compact ? " with compact protocol" : "") + + (useBufferedSockets ? " with buffered socket" : "") + + (useFramed ? " with framed transport" : "") + + (useEncryption ? " with encryption" : "") + + (compact ? " with compact protocol" : "") + + (json ? " with json protocol" : "") + "..."); serverEngine.Serve();