Repository: thrift
Updated Branches:
  refs/heads/master 885c67912 -> 2a9e6a491


THRIFT-2501: C# The test parameters from the TestServer and TestClient are 
different from the http://thrift.apache.org/test/
Client: C#
Patch: Beat Kaeslin

This closes #108

commit 0fb9ff4ae19702ffe6d098a6515f6a23d60e88d5
 Author: Beat Kaeslin <[email protected]>
 Date: 2014-04-23T06:33:59Z

Parameter aligned with thrift.apache.org/test/


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2a9e6a49
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2a9e6a49
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2a9e6a49

Branch: refs/heads/master
Commit: 2a9e6a491e2c6e97bd35f715f39788582eb8b027
Parents: 885c679
Author: Jens Geyer <[email protected]>
Authored: Fri May 2 22:23:15 2014 +0200
Committer: Jens Geyer <[email protected]>
Committed: Fri May 2 22:23:15 2014 +0200

----------------------------------------------------------------------
 lib/csharp/test/ThriftTest/TestClient.cs | 47 +++++++++---------
 lib/csharp/test/ThriftTest/TestServer.cs | 68 +++++++++++----------------
 2 files changed, 50 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/2a9e6a49/lib/csharp/test/ThriftTest/TestClient.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/test/ThriftTest/TestClient.cs 
b/lib/csharp/test/ThriftTest/TestClient.cs
index 593169f..db0fe63 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 <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)

http://git-wip-us.apache.org/repos/asf/thrift/blob/2a9e6a49/lib/csharp/test/ThriftTest/TestServer.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/test/ThriftTest/TestServer.cs 
b/lib/csharp/test/ThriftTest/TestServer.cs
index f0e9abb..f0f539f 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();
 

Reply via email to