THRIFT-2501: C# The test parameters from the TestServer and TestClient are different...
authorJens Geyer <jensg@apache.org>
Fri, 2 May 2014 20:23:15 +0000 (22:23 +0200)
committerJens Geyer <jensg@apache.org>
Fri, 2 May 2014 20:23:15 +0000 (22:23 +0200)
Client: C#
Patch: Beat Kaeslin

This closes #108

commit 0fb9ff4ae19702ffe6d098a6515f6a23d60e88d5
 Author: Beat Kaeslin <beat.kaeslin@siemens.com>
 Date: 2014-04-23T06:33:59Z

Parameter aligned with thrift.apache.org/test/

lib/csharp/test/ThriftTest/TestClient.cs
lib/csharp/test/ThriftTest/TestServer.cs

index 593169f..db0fe63 100644 (file)
@@ -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 <name>
+                                               {
+                                                       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 <name>
-                                               {
-                                                       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)
index f0e9abb..f0f539f 100644 (file)
@@ -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();