You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2018/01/14 13:42:48 UTC
[2/9] thrift git commit: THRIFT-4434: .NET Core cleanup and the
beginnings of compiler unit tests Client: netcore
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/Server/TestServer.cs
----------------------------------------------------------------------
diff --git a/test/netcore/Server/TestServer.cs b/test/netcore/Server/TestServer.cs
new file mode 100644
index 0000000..bfd3335
--- /dev/null
+++ b/test/netcore/Server/TestServer.cs
@@ -0,0 +1,594 @@
+// Licensed to the Apache Software Foundation(ASF) under one
+// or more contributor license agreements.See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Authentication;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using Thrift;
+using Thrift.Collections;
+using Thrift.Protocols;
+using Thrift.Server;
+using Thrift.Transports;
+using Thrift.Transports.Server;
+
+namespace ThriftTest
+{
+ internal class ServerParam
+ {
+ internal bool useBufferedSockets = false;
+ internal bool useFramed = false;
+ internal bool useEncryption = false;
+ internal bool compact = false;
+ internal bool json = false;
+ internal int port = 9090;
+ internal string pipe = null;
+
+ internal void Parse(List<string> args)
+ {
+ for (var i = 0; i < args.Count; i++)
+ {
+ if (args[i].StartsWith("--pipe="))
+ {
+ pipe = args[i].Substring(args[i].IndexOf("=") + 1);
+ }
+ else if (args[i].StartsWith("--port="))
+ {
+ port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1));
+ }
+ 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] == "--binary" || args[i] == "--protocol=binary")
+ {
+ // nothing needed
+ }
+ 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] == "--threaded" || args[i] == "--server-type=threaded")
+ {
+ throw new NotImplementedException(args[i]);
+ }
+ else if (args[i] == "--threadpool" || args[i] == "--server-type=threadpool")
+ {
+ throw new NotImplementedException(args[i]);
+ }
+ else if (args[i] == "--prototype" || args[i] == "--processor=prototype")
+ {
+ throw new NotImplementedException(args[i]);
+ }
+ else if (args[i] == "--ssl")
+ {
+ useEncryption = true;
+ }
+ else
+ {
+ //throw new ArgumentException(args[i]);
+ }
+ }
+
+ }
+ }
+
+ public class TestServer
+ {
+ public static int _clientID = -1;
+ public delegate void TestLogDelegate(string msg, params object[] values);
+
+ public class MyServerEventHandler : TServerEventHandler
+ {
+ public int callCount = 0;
+
+ public Task PreServeAsync(CancellationToken cancellationToken)
+ {
+ callCount++;
+ return Task.CompletedTask;
+ }
+
+ public Task<object> CreateContextAsync(TProtocol input, TProtocol output, CancellationToken cancellationToken)
+ {
+ callCount++;
+ return Task.FromResult<object>(null);
+ }
+
+ public Task DeleteContextAsync(object serverContext, TProtocol input, TProtocol output, CancellationToken cancellationToken)
+ {
+ callCount++;
+ return Task.CompletedTask;
+ }
+
+ public Task ProcessContextAsync(object serverContext, TClientTransport transport, CancellationToken cancellationToken)
+ {
+ callCount++;
+ return Task.CompletedTask;
+ }
+ }
+
+ public class TestHandlerAsync : ThriftTest.IAsync
+ {
+ public TBaseServer server { get; set; }
+ private int handlerID;
+ private StringBuilder sb = new StringBuilder();
+ private TestLogDelegate logger;
+
+ public TestHandlerAsync()
+ {
+ handlerID = Interlocked.Increment(ref _clientID);
+ logger += testConsoleLogger;
+ logger.Invoke("New TestHandler instance created");
+ }
+
+ public void testConsoleLogger(string msg, params object[] values)
+ {
+ sb.Clear();
+ sb.AppendFormat("handler{0:D3}:", handlerID);
+ sb.AppendFormat(msg, values);
+ sb.AppendLine();
+ Console.Write(sb.ToString());
+ }
+
+ public Task testVoidAsync(CancellationToken cancellationToken)
+ {
+ logger.Invoke("testVoid()");
+ return Task.CompletedTask;
+ }
+
+ public Task<string> testStringAsync(string thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testString({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<bool> testBoolAsync(bool thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testBool({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<sbyte> testByteAsync(sbyte thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testByte({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<int> testI32Async(int thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testI32({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<long> testI64Async(long thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testI64({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<double> testDoubleAsync(double thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testDouble({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<byte[]> testBinaryAsync(byte[] thing, CancellationToken cancellationToken)
+ {
+ var hex = BitConverter.ToString(thing).Replace("-", string.Empty);
+ logger.Invoke("testBinary({0:X})", hex);
+ return Task.FromResult(thing);
+ }
+
+ public Task<Xtruct> testStructAsync(Xtruct thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testStruct({{\"{0}\", {1}, {2}, {3}}})", thing.String_thing, thing.Byte_thing, thing.I32_thing, thing.I64_thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<Xtruct2> testNestAsync(Xtruct2 nest, CancellationToken cancellationToken)
+ {
+ var thing = nest.Struct_thing;
+ logger.Invoke("testNest({{{0}, {{\"{1}\", {2}, {3}, {4}, {5}}}}})",
+ nest.Byte_thing,
+ thing.String_thing,
+ thing.Byte_thing,
+ thing.I32_thing,
+ thing.I64_thing,
+ nest.I32_thing);
+ return Task.FromResult(nest);
+ }
+
+ public Task<Dictionary<int, int>> testMapAsync(Dictionary<int, int> thing, CancellationToken cancellationToken)
+ {
+ sb.Clear();
+ sb.Append("testMap({{");
+ var first = true;
+ foreach (var key in thing.Keys)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ sb.Append(", ");
+ }
+ sb.AppendFormat("{0} => {1}", key, thing[key]);
+ }
+ sb.Append("}})");
+ logger.Invoke(sb.ToString());
+ return Task.FromResult(thing);
+ }
+
+ public Task<Dictionary<string, string>> testStringMapAsync(Dictionary<string, string> thing, CancellationToken cancellationToken)
+ {
+ sb.Clear();
+ sb.Append("testStringMap({{");
+ var first = true;
+ foreach (var key in thing.Keys)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ sb.Append(", ");
+ }
+ sb.AppendFormat("{0} => {1}", key, thing[key]);
+ }
+ sb.Append("}})");
+ logger.Invoke(sb.ToString());
+ return Task.FromResult(thing);
+ }
+
+ public Task<THashSet<int>> testSetAsync(THashSet<int> thing, CancellationToken cancellationToken)
+ {
+ sb.Clear();
+ sb.Append("testSet({{");
+ var first = true;
+ foreach (int elem in thing)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ sb.Append(", ");
+ }
+ sb.AppendFormat("{0}", elem);
+ }
+ sb.Append("}})");
+ logger.Invoke(sb.ToString());
+ return Task.FromResult(thing);
+ }
+
+ public Task<List<int>> testListAsync(List<int> thing, CancellationToken cancellationToken)
+ {
+ sb.Clear();
+ sb.Append("testList({{");
+ var first = true;
+ foreach (var elem in thing)
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ sb.Append(", ");
+ }
+ sb.AppendFormat("{0}", elem);
+ }
+ sb.Append("}})");
+ logger.Invoke(sb.ToString());
+ return Task.FromResult(thing);
+ }
+
+ public Task<Numberz> testEnumAsync(Numberz thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testEnum({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<long> testTypedefAsync(long thing, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testTypedef({0})", thing);
+ return Task.FromResult(thing);
+ }
+
+ public Task<Dictionary<int, Dictionary<int, int>>> testMapMapAsync(int hello, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testMapMap({0})", hello);
+ var mapmap = new Dictionary<int, Dictionary<int, int>>();
+
+ var pos = new Dictionary<int, int>();
+ var neg = new Dictionary<int, int>();
+ for (var i = 1; i < 5; i++)
+ {
+ pos[i] = i;
+ neg[-i] = -i;
+ }
+
+ mapmap[4] = pos;
+ mapmap[-4] = neg;
+
+ return Task.FromResult(mapmap);
+ }
+
+ public Task<Dictionary<long, Dictionary<Numberz, Insanity>>> testInsanityAsync(Insanity argument, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testInsanity()");
+
+ /** from ThriftTest.thrift:
+ * So you think you've got this all worked, out eh?
+ *
+ * Creates a the returned map with these values and prints it out:
+ * { 1 => { 2 => argument,
+ * 3 => argument,
+ * },
+ * 2 => { 6 => <empty Insanity struct>, },
+ * }
+ * @return map<UserId, map<Numberz,Insanity>> - a map with the above values
+ */
+
+ var first_map = new Dictionary<Numberz, Insanity>();
+ var second_map = new Dictionary<Numberz, Insanity>(); ;
+
+ first_map[Numberz.TWO] = argument;
+ first_map[Numberz.THREE] = argument;
+
+ second_map[Numberz.SIX] = new Insanity();
+
+ var insane = new Dictionary<long, Dictionary<Numberz, Insanity>>
+ {
+ [1] = first_map,
+ [2] = second_map
+ };
+
+ return Task.FromResult(insane);
+ }
+
+ public Task<Xtruct> testMultiAsync(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5,
+ CancellationToken cancellationToken)
+ {
+ logger.Invoke("testMulti()");
+
+ var hello = new Xtruct(); ;
+ hello.String_thing = "Hello2";
+ hello.Byte_thing = arg0;
+ hello.I32_thing = arg1;
+ hello.I64_thing = arg2;
+ return Task.FromResult(hello);
+ }
+
+ public Task testExceptionAsync(string arg, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testException({0})", arg);
+ if (arg == "Xception")
+ {
+ var x = new Xception
+ {
+ ErrorCode = 1001,
+ Message = arg
+ };
+ throw x;
+ }
+ if (arg == "TException")
+ {
+ throw new TException();
+ }
+ return Task.CompletedTask;
+ }
+
+ public Task<Xtruct> testMultiExceptionAsync(string arg0, string arg1, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testMultiException({0}, {1})", arg0, arg1);
+ if (arg0 == "Xception")
+ {
+ var x = new Xception
+ {
+ ErrorCode = 1001,
+ Message = "This is an Xception"
+ };
+ throw x;
+ }
+
+ if (arg0 == "Xception2")
+ {
+ var x = new Xception2
+ {
+ ErrorCode = 2002,
+ Struct_thing = new Xtruct { String_thing = "This is an Xception2" }
+ };
+ throw x;
+ }
+
+ var result = new Xtruct { String_thing = arg1 };
+ return Task.FromResult(result);
+ }
+
+ public Task testOnewayAsync(int secondsToSleep, CancellationToken cancellationToken)
+ {
+ logger.Invoke("testOneway({0}), sleeping...", secondsToSleep);
+ Task.Delay(secondsToSleep * 1000, cancellationToken).GetAwaiter().GetResult();
+ logger.Invoke("testOneway finished");
+
+ return Task.CompletedTask;
+ }
+ }
+
+ internal static void PrintOptionsHelp()
+ {
+ Console.WriteLine("Server options:");
+ Console.WriteLine(" --pipe=<pipe name>");
+ Console.WriteLine(" --port=<port number>");
+ Console.WriteLine(" --transport=<transport name> one of buffered,framed (defaults to none)");
+ Console.WriteLine(" --protocol=<protocol name> one of compact,json (defaults to binary)");
+ Console.WriteLine(" --server-type=<type> one of threaded,threadpool (defaults to simple)");
+ Console.WriteLine(" --processor=<prototype>");
+ Console.WriteLine(" --ssl");
+ Console.WriteLine();
+ }
+
+ private static X509Certificate2 GetServerCert()
+ {
+ var serverCertName = "server.p12";
+ var possiblePaths = new List<string>
+ {
+ "../../../keys/",
+ "../../keys/",
+ "../keys/",
+ "keys/",
+ };
+
+ string existingPath = null;
+ foreach (var possiblePath in possiblePaths)
+ {
+ var path = Path.GetFullPath(possiblePath + serverCertName);
+ if (File.Exists(path))
+ {
+ existingPath = path;
+ break;
+ }
+ }
+
+ if (string.IsNullOrEmpty(existingPath))
+ {
+ throw new FileNotFoundException($"Cannot find file: {serverCertName}");
+ }
+
+ var cert = new X509Certificate2(existingPath, "thrift");
+
+ return cert;
+ }
+
+ public static int Execute(List<string> args)
+ {
+ var loggerFactory = new LoggerFactory();//.AddConsole().AddDebug();
+ var logger = new LoggerFactory().CreateLogger("Test");
+
+ try
+ {
+ var param = new ServerParam();
+
+ try
+ {
+ param.Parse(args);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("*** FAILED ***");
+ Console.WriteLine("Error while parsing arguments");
+ Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
+ return 1;
+ }
+
+
+ // Transport
+ TServerTransport trans;
+ if (param.pipe != null)
+ {
+ trans = new TNamedPipeServerTransport(param.pipe);
+ }
+// else if (param.useFramed)
+// {
+// trans = new TServerFramedTransport(param.port);
+// }
+ else
+ {
+ if (param.useEncryption)
+ {
+ var cert = GetServerCert();
+
+ if (cert == null || !cert.HasPrivateKey)
+ {
+ throw new InvalidOperationException("Certificate doesn't contain private key");
+ }
+
+ trans = new TTlsServerSocketTransport(param.port, param.useBufferedSockets, param.useFramed, cert,
+ (sender, certificate, chain, errors) => true,
+ null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12);
+ }
+ else
+ {
+ trans = new TServerSocketTransport(param.port, 0, param.useBufferedSockets, param.useFramed);
+ }
+ }
+
+ ITProtocolFactory proto;
+ if (param.compact)
+ proto = new TCompactProtocol.Factory();
+ else if (param.json)
+ proto = new TJsonProtocol.Factory();
+ else
+ proto = new TBinaryProtocol.Factory();
+
+ ITProcessorFactory processorFactory;
+
+ // Processor
+ var testHandler = new TestHandlerAsync();
+ var testProcessor = new ThriftTest.AsyncProcessor(testHandler);
+ processorFactory = new SingletonTProcessorFactory(testProcessor);
+
+ TTransportFactory transFactory = new TTransportFactory();
+
+ TBaseServer serverEngine = new AsyncBaseServer(processorFactory, trans, transFactory, transFactory, proto, proto, logger);
+
+ //Server event handler
+ var serverEvents = new MyServerEventHandler();
+ serverEngine.SetEventHandler(serverEvents);
+
+ // Run it
+ var where = (! string.IsNullOrEmpty(param.pipe)) ? "on pipe " + param.pipe : "on port " + param.port;
+ Console.WriteLine("Starting the AsyncBaseServer " + where +
+ " with processor TPrototypeProcessorFactory prototype factory " +
+ (param.useBufferedSockets ? " with buffered socket" : "") +
+ (param.useFramed ? " with framed transport" : "") +
+ (param.useEncryption ? " with encryption" : "") +
+ (param.compact ? " with compact protocol" : "") +
+ (param.json ? " with json protocol" : "") +
+ "...");
+ serverEngine.ServeAsync(CancellationToken.None).GetAwaiter().GetResult();
+ Console.ReadLine();
+ }
+ catch (Exception x)
+ {
+ Console.Error.Write(x);
+ return 1;
+ }
+ Console.WriteLine("done.");
+ return 0;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/ThriftTest.sln
----------------------------------------------------------------------
diff --git a/test/netcore/ThriftTest.sln b/test/netcore/ThriftTest.sln
index c3f194b..2ab241a 100644
--- a/test/netcore/ThriftTest.sln
+++ b/test/netcore/ThriftTest.sln
@@ -1,11 +1,13 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
+Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThriftTest", "ThriftTest\ThriftTest.csproj", "{DDED46FF-F359-47B4-BA7E-9B70F216BD44}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thrift", "..\..\lib\netcore\Thrift\Thrift.csproj", "{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{21039F25-6ED7-4E80-A545-EBC93472EBD1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{0C6E8685-F191-4479-9842-882A38961127}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -16,18 +18,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x64.ActiveCfg = Debug|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x64.Build.0 = Debug|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x86.ActiveCfg = Debug|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x86.Build.0 = Debug|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|Any CPU.Build.0 = Release|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x64.ActiveCfg = Release|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x64.Build.0 = Release|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x86.ActiveCfg = Release|Any CPU
- {DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x86.Build.0 = Release|Any CPU
{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -40,6 +30,30 @@ Global
{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x64.Build.0 = Release|Any CPU
{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x86.ActiveCfg = Release|Any CPU
{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x86.Build.0 = Release|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Debug|x64.Build.0 = Debug|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Debug|x86.Build.0 = Debug|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Release|x64.ActiveCfg = Release|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Release|x64.Build.0 = Release|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Release|x86.ActiveCfg = Release|Any CPU
+ {21039F25-6ED7-4E80-A545-EBC93472EBD1}.Release|x86.Build.0 = Release|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Debug|x64.Build.0 = Debug|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Debug|x86.Build.0 = Debug|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Release|x64.ActiveCfg = Release|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Release|x64.Build.0 = Release|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Release|x86.ActiveCfg = Release|Any CPU
+ {0C6E8685-F191-4479-9842-882A38961127}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/ThriftTest/Program.cs
----------------------------------------------------------------------
diff --git a/test/netcore/ThriftTest/Program.cs b/test/netcore/ThriftTest/Program.cs
deleted file mode 100644
index 94ed9d9..0000000
--- a/test/netcore/ThriftTest/Program.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-// Licensed to the Apache Software Foundation(ASF) under one
-// or more contributor license agreements.See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-using System;
-using System.Collections.Generic;
-using Test;
-
-namespace ThriftTest
-{
- public class Program
- {
- public static int Main(string[] args)
- {
- try
- {
- Console.SetBufferSize(Console.BufferWidth, 4096);
- }
- catch (Exception)
- {
- Console.WriteLine("Failed to grow scroll-back buffer");
- }
-
- // split mode and options
- var subArgs = new List<string>(args);
- var firstArg = string.Empty;
- if (subArgs.Count > 0)
- {
- firstArg = subArgs[0];
- subArgs.RemoveAt(0);
- }
-
- // run whatever mode is choosen
- switch(firstArg)
- {
- case "client":
- return TestClient.Execute(subArgs);
- case "server":
- return TestServer.Execute(subArgs);
- case "--help":
- PrintHelp();
- return 0;
- default:
- PrintHelp();
- return -1;
- }
- }
-
- private static void PrintHelp()
- {
- Console.WriteLine("Usage:");
- Console.WriteLine(" ThriftTest server [options]'");
- Console.WriteLine(" ThriftTest client [options]'");
- Console.WriteLine(" ThriftTest --help");
- Console.WriteLine("");
-
- TestServer.PrintOptionsHelp();
- TestClient.PrintOptionsHelp();
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/ThriftTest/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/test/netcore/ThriftTest/Properties/AssemblyInfo.cs b/test/netcore/ThriftTest/Properties/AssemblyInfo.cs
deleted file mode 100644
index efc9e33..0000000
--- a/test/netcore/ThriftTest/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the Apache Software Foundation(ASF) under one
-// or more contributor license agreements.See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-
-[assembly: AssemblyTitle("ThriftTest")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("The Apache Software Foundation")]
-[assembly: AssemblyProduct("Thrift")]
-[assembly: AssemblyCopyright("The Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-
-[assembly: Guid("B0C13DA0-3117-4844-8AE8-B1775E46223D")]
-
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/ThriftTest/Properties/launchSettings.json
----------------------------------------------------------------------
diff --git a/test/netcore/ThriftTest/Properties/launchSettings.json b/test/netcore/ThriftTest/Properties/launchSettings.json
deleted file mode 100644
index ddafa79..0000000
--- a/test/netcore/ThriftTest/Properties/launchSettings.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "profiles": {
- "ThriftTest": {
- "commandName": "Project"
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/ThriftTest/TestClient.cs
----------------------------------------------------------------------
diff --git a/test/netcore/ThriftTest/TestClient.cs b/test/netcore/ThriftTest/TestClient.cs
deleted file mode 100644
index f6cc900..0000000
--- a/test/netcore/ThriftTest/TestClient.cs
+++ /dev/null
@@ -1,898 +0,0 @@
-// Licensed to the Apache Software Foundation(ASF) under one
-// or more contributor license agreements.See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using ThriftAsync.Test;
-using Thrift.Collections;
-using Thrift.Protocols;
-using Thrift.Transports;
-using Thrift.Transports.Client;
-
-namespace Test
-{
- public class TestClient
- {
- private class TestParams
- {
- public int numIterations = 1;
- public IPAddress host = IPAddress.Loopback;
- public int port = 9090;
- public int numThreads = 1;
- public string url;
- public string pipe;
- public bool buffered;
- public bool framed;
- public string protocol;
- public bool encrypted = false;
-
- internal void Parse( List<string> args)
- {
- for (var i = 0; i < args.Count; ++i)
- {
- if (args[i] == "-u")
- {
- url = args[++i];
- }
- else if (args[i] == "-n")
- {
- numIterations = Convert.ToInt32(args[++i]);
- }
- else if (args[i].StartsWith("--pipe="))
- {
- pipe = args[i].Substring(args[i].IndexOf("=") + 1);
- Console.WriteLine("Using named pipes transport");
- }
- else if (args[i].StartsWith("--host="))
- {
- // check there for ipaddress
- host = new IPAddress(Encoding.Unicode.GetBytes(args[i].Substring(args[i].IndexOf("=") + 1)));
- }
- else if (args[i].StartsWith("--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" || args[i] == "--transport=framed")
- {
- framed = true;
- Console.WriteLine("Using framed transport");
- }
- else if (args[i] == "-t")
- {
- numThreads = Convert.ToInt32(args[++i]);
- }
- else if (args[i] == "--binary" || args[i] == "--protocol=binary")
- {
- protocol = "binary";
- Console.WriteLine("Using binary protocol");
- }
- else if (args[i] == "--compact" || args[i] == "--protocol=compact")
- {
- protocol = "compact";
- Console.WriteLine("Using compact protocol");
- }
- 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");
- }
- else
- {
- throw new ArgumentException(args[i]);
- }
- }
- }
-
- public TClientTransport CreateTransport()
- {
- if (url == null)
- {
- // endpoint transport
- TClientTransport trans = null;
-
- if (pipe != null)
- {
- trans = new TNamedPipeClientTransport(pipe);
- }
- else
- {
- if (encrypted)
- {
- var certPath = "../../keys/client.p12";
- var cert = new X509Certificate2(certPath, "thrift");
- trans = new TTlsSocketClientTransport(host, port, 0, cert, (o, c, chain, errors) => true, null, SslProtocols.Tls);
- }
- else
- {
- trans = new TSocketClientTransport(host, port);
- }
- }
-
- // layered transport
- if (buffered)
- {
- trans = new TBufferedClientTransport(trans);
- }
-
- if (framed)
- {
- trans = new TFramedClientTransport(trans);
- }
-
- return trans;
- }
-
- return new THttpClientTransport(new Uri(url), null);
- }
-
- public TProtocol CreateProtocol(TClientTransport transport)
- {
- if (protocol == "compact")
- {
- return new TCompactProtocol(transport);
- }
-
- if (protocol == "json")
- {
- return new TJsonProtocol(transport);
- }
-
- return new TBinaryProtocol(transport);
- }
- }
-
-
- private const int ErrorBaseTypes = 1;
- private const int ErrorStructs = 2;
- private const int ErrorContainers = 4;
- private const int ErrorExceptions = 8;
- private const int ErrorUnknown = 64;
-
- private class ClientTest
- {
- private readonly TClientTransport transport;
- private readonly ThriftAsync.Test.ThriftTest.Client client;
- private readonly int numIterations;
- private bool done;
-
- public int ReturnCode { get; set; }
-
- public ClientTest(TestParams param)
- {
- transport = param.CreateTransport();
- client = new ThriftAsync.Test.ThriftTest.Client(param.CreateProtocol(transport));
- numIterations = param.numIterations;
- }
-
- public void Execute()
- {
- var token = CancellationToken.None;
-
- if (done)
- {
- Console.WriteLine("Execute called more than once");
- throw new InvalidOperationException();
- }
-
- for (var i = 0; i < numIterations; i++)
- {
- try
- {
- if (!transport.IsOpen)
- {
- transport.OpenAsync(token).GetAwaiter().GetResult();
- }
- }
- catch (TTransportException ex)
- {
- Console.WriteLine("*** FAILED ***");
- Console.WriteLine("Connect failed: " + ex.Message);
- ReturnCode |= ErrorUnknown;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- continue;
- }
-
- try
- {
- ReturnCode |= ExecuteClientTestAsync(client).GetAwaiter().GetResult(); ;
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- ReturnCode |= ErrorUnknown;
- }
- }
- try
- {
- transport.Close();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error while closing transport");
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
- done = true;
- }
- }
-
- internal static void PrintOptionsHelp()
- {
- Console.WriteLine("Client options:");
- Console.WriteLine(" -u <URL>");
- Console.WriteLine(" -t <# of threads to run> default = 1");
- Console.WriteLine(" -n <# of iterations> per thread");
- Console.WriteLine(" --pipe=<pipe name>");
- Console.WriteLine(" --host=<IP address>");
- Console.WriteLine(" --port=<port number>");
- Console.WriteLine(" --transport=<transport name> one of buffered,framed (defaults to none)");
- Console.WriteLine(" --protocol=<protocol name> one of compact,json (defaults to binary)");
- Console.WriteLine(" --ssl");
- Console.WriteLine();
- }
-
- public static int Execute(List<string> args)
- {
- try
- {
- var param = new TestParams();
-
- try
- {
- param.Parse(args);
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- Console.WriteLine("Error while parsing arguments");
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- return ErrorUnknown;
- }
-
- var tests = Enumerable.Range(0, param.numThreads).Select(_ => new ClientTest(param)).ToArray();
-
- //issue tests on separate threads simultaneously
- var threads = tests.Select(test => new Thread(test.Execute)).ToArray();
- var start = DateTime.Now;
- foreach (var t in threads)
- {
- t.Start();
- }
-
- foreach (var t in threads)
- {
- t.Join();
- }
-
- Console.WriteLine("Total time: " + (DateTime.Now - start));
- Console.WriteLine();
- return tests.Select(t => t.ReturnCode).Aggregate((r1, r2) => r1 | r2);
- }
- catch (Exception outerEx)
- {
- Console.WriteLine("*** FAILED ***");
- Console.WriteLine("Unexpected error");
- Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace);
- return ErrorUnknown;
- }
- }
-
- public static string BytesToHex(byte[] data)
- {
- return BitConverter.ToString(data).Replace("-", string.Empty);
- }
-
- public static byte[] PrepareTestData(bool randomDist)
- {
- var retval = new byte[0x100];
- var initLen = Math.Min(0x100, retval.Length);
-
- // linear distribution, unless random is requested
- if (!randomDist)
- {
- for (var i = 0; i < initLen; ++i)
- {
- retval[i] = (byte)i;
- }
- return retval;
- }
-
- // random distribution
- for (var i = 0; i < initLen; ++i)
- {
- retval[i] = (byte)0;
- }
- var rnd = new Random();
- for (var i = 1; i < initLen; ++i)
- {
- while (true)
- {
- var nextPos = rnd.Next() % initLen;
- if (retval[nextPos] == 0)
- {
- retval[nextPos] = (byte)i;
- break;
- }
- }
- }
- return retval;
- }
-
- public static async Task<int> ExecuteClientTestAsync(ThriftAsync.Test.ThriftTest.Client client)
- {
- var token = CancellationToken.None;
- var returnCode = 0;
-
- Console.Write("testVoid()");
- await client.testVoidAsync(token);
- Console.WriteLine(" = void");
-
- Console.Write("testString(\"Test\")");
- var s = await client.testStringAsync("Test", token);
- Console.WriteLine(" = \"" + s + "\"");
- if ("Test" != s)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- Console.Write("testBool(true)");
- var t = await client.testBoolAsync((bool)true, token);
- Console.WriteLine(" = " + t);
- if (!t)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
- Console.Write("testBool(false)");
- var f = await client.testBoolAsync((bool)false, token);
- Console.WriteLine(" = " + f);
- if (f)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- Console.Write("testByte(1)");
- var i8 = await client.testByteAsync((sbyte)1, token);
- Console.WriteLine(" = " + i8);
- if (1 != i8)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- Console.Write("testI32(-1)");
- var i32 = await client.testI32Async(-1, token);
- Console.WriteLine(" = " + i32);
- if (-1 != i32)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- Console.Write("testI64(-34359738368)");
- var i64 = await client.testI64Async(-34359738368, token);
- Console.WriteLine(" = " + i64);
- if (-34359738368 != i64)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- // TODO: Validate received message
- Console.Write("testDouble(5.325098235)");
- var dub = await client.testDoubleAsync(5.325098235, token);
- Console.WriteLine(" = " + dub);
- if (5.325098235 != dub)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
- Console.Write("testDouble(-0.000341012439638598279)");
- dub = await client.testDoubleAsync(-0.000341012439638598279, token);
- Console.WriteLine(" = " + dub);
- if (-0.000341012439638598279 != dub)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- var binOut = PrepareTestData(true);
- Console.Write("testBinary(" + BytesToHex(binOut) + ")");
- try
- {
- var binIn = await client.testBinaryAsync(binOut, token);
- Console.WriteLine(" = " + BytesToHex(binIn));
- if (binIn.Length != binOut.Length)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
- for (var ofs = 0; ofs < Math.Min(binIn.Length, binOut.Length); ++ofs)
- if (binIn[ofs] != binOut[ofs])
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
- }
- catch (Thrift.TApplicationException ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
-
- // binary equals? only with hashcode option enabled ...
- Console.WriteLine("Test CrazyNesting");
- var one = new CrazyNesting();
- var two = new CrazyNesting();
- one.String_field = "crazy";
- two.String_field = "crazy";
- one.Binary_field = new byte[] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
- two.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
- if (typeof(CrazyNesting).GetMethod("Equals")?.DeclaringType == typeof(CrazyNesting))
- {
- if (!one.Equals(two))
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorContainers;
- throw new Exception("CrazyNesting.Equals failed");
- }
- }
-
- // TODO: Validate received message
- Console.Write("testStruct({\"Zero\", 1, -3, -5})");
- var o = new Xtruct();
- o.String_thing = "Zero";
- o.Byte_thing = (sbyte)1;
- o.I32_thing = -3;
- o.I64_thing = -5;
- var i = await client.testStructAsync(o, token);
- Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");
-
- // TODO: Validate received message
- Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
- var o2 = new Xtruct2();
- o2.Byte_thing = (sbyte)1;
- o2.Struct_thing = o;
- o2.I32_thing = 5;
- var i2 = await client.testNestAsync(o2, token);
- i = i2.Struct_thing;
- Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}");
-
- var mapout = new Dictionary<int, int>();
- for (var j = 0; j < 5; j++)
- {
- mapout[j] = j - 10;
- }
- Console.Write("testMap({");
- var first = true;
- foreach (var key in mapout.Keys)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(key + " => " + mapout[key]);
- }
- Console.Write("})");
-
- var mapin = await client.testMapAsync(mapout, token);
-
- Console.Write(" = {");
- first = true;
- foreach (var key in mapin.Keys)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(key + " => " + mapin[key]);
- }
- Console.WriteLine("}");
-
- // TODO: Validate received message
- var listout = new List<int>();
- for (var j = -2; j < 3; j++)
- {
- listout.Add(j);
- }
- Console.Write("testList({");
- first = true;
- foreach (var j in listout)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
- Console.Write("})");
-
- var listin = await client.testListAsync(listout, token);
-
- Console.Write(" = {");
- first = true;
- foreach (var j in listin)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
- Console.WriteLine("}");
-
- //set
- // TODO: Validate received message
- var setout = new THashSet<int>();
- for (var j = -2; j < 3; j++)
- {
- setout.Add(j);
- }
- Console.Write("testSet({");
- first = true;
- foreach (int j in setout)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
- Console.Write("})");
-
- var setin = await client.testSetAsync(setout, token);
-
- Console.Write(" = {");
- first = true;
- foreach (int j in setin)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
- Console.WriteLine("}");
-
-
- Console.Write("testEnum(ONE)");
- var ret = await client.testEnumAsync(Numberz.ONE, token);
- Console.WriteLine(" = " + ret);
- if (Numberz.ONE != ret)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorStructs;
- }
-
- Console.Write("testEnum(TWO)");
- ret = await client.testEnumAsync(Numberz.TWO, token);
- Console.WriteLine(" = " + ret);
- if (Numberz.TWO != ret)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorStructs;
- }
-
- Console.Write("testEnum(THREE)");
- ret = await client.testEnumAsync(Numberz.THREE, token);
- Console.WriteLine(" = " + ret);
- if (Numberz.THREE != ret)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorStructs;
- }
-
- Console.Write("testEnum(FIVE)");
- ret = await client.testEnumAsync(Numberz.FIVE, token);
- Console.WriteLine(" = " + ret);
- if (Numberz.FIVE != ret)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorStructs;
- }
-
- Console.Write("testEnum(EIGHT)");
- ret = await client.testEnumAsync(Numberz.EIGHT, token);
- Console.WriteLine(" = " + ret);
- if (Numberz.EIGHT != ret)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorStructs;
- }
-
- Console.Write("testTypedef(309858235082523)");
- var uid = await client.testTypedefAsync(309858235082523L, token);
- Console.WriteLine(" = " + uid);
- if (309858235082523L != uid)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorStructs;
- }
-
- // TODO: Validate received message
- Console.Write("testMapMap(1)");
- var mm = await client.testMapMapAsync(1, token);
- Console.Write(" = {");
- foreach (var key in mm.Keys)
- {
- Console.Write(key + " => {");
- var m2 = mm[key];
- foreach (var k2 in m2.Keys)
- {
- Console.Write(k2 + " => " + m2[k2] + ", ");
- }
- Console.Write("}, ");
- }
- Console.WriteLine("}");
-
- // TODO: Validate received message
- var insane = new Insanity();
- insane.UserMap = new Dictionary<Numberz, long>();
- insane.UserMap[Numberz.FIVE] = 5000L;
- var truck = new Xtruct();
- truck.String_thing = "Truck";
- truck.Byte_thing = (sbyte)8;
- truck.I32_thing = 8;
- truck.I64_thing = 8;
- insane.Xtructs = new List<Xtruct>();
- insane.Xtructs.Add(truck);
- Console.Write("testInsanity()");
- var whoa = await client.testInsanityAsync(insane, token);
- Console.Write(" = {");
- foreach (var key in whoa.Keys)
- {
- var val = whoa[key];
- Console.Write(key + " => {");
-
- foreach (var k2 in val.Keys)
- {
- var v2 = val[k2];
-
- Console.Write(k2 + " => {");
- var userMap = v2.UserMap;
-
- Console.Write("{");
- if (userMap != null)
- {
- foreach (var k3 in userMap.Keys)
- {
- Console.Write(k3 + " => " + userMap[k3] + ", ");
- }
- }
- else
- {
- Console.Write("null");
- }
- Console.Write("}, ");
-
- var xtructs = v2.Xtructs;
-
- Console.Write("{");
- if (xtructs != null)
- {
- foreach (var x in xtructs)
- {
- Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
- }
- }
- else
- {
- Console.Write("null");
- }
- Console.Write("}");
-
- Console.Write("}, ");
- }
- Console.Write("}, ");
- }
- Console.WriteLine("}");
-
- sbyte arg0 = 1;
- var arg1 = 2;
- var arg2 = long.MaxValue;
- var multiDict = new Dictionary<short, string>();
- multiDict[1] = "one";
-
- var tmpMultiDict = new List<string>();
- foreach (var pair in multiDict)
- tmpMultiDict.Add(pair.Key +" => "+ pair.Value);
-
- var arg4 = Numberz.FIVE;
- long arg5 = 5000000;
- Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + ",{" + string.Join(",", tmpMultiDict) + "}," + arg4 + "," + arg5 + ")");
- var multiResponse = await client.testMultiAsync(arg0, arg1, arg2, multiDict, arg4, arg5, token);
- Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
- + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
-
- try
- {
- Console.WriteLine("testException(\"Xception\")");
- await client.testExceptionAsync("Xception", token);
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- catch (Xception ex)
- {
- if (ex.ErrorCode != 1001 || ex.Message != "Xception")
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
- try
- {
- Console.WriteLine("testException(\"TException\")");
- await client.testExceptionAsync("TException", token);
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- catch (Thrift.TException)
- {
- // OK
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
- try
- {
- Console.WriteLine("testException(\"ok\")");
- await client.testExceptionAsync("ok", token);
- // OK
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
-
- try
- {
- Console.WriteLine("testMultiException(\"Xception\", ...)");
- await client.testMultiExceptionAsync("Xception", "ignore", token);
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- catch (Xception ex)
- {
- if (ex.ErrorCode != 1001 || ex.Message != "This is an Xception")
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
- try
- {
- Console.WriteLine("testMultiException(\"Xception2\", ...)");
- await client.testMultiExceptionAsync("Xception2", "ignore", token);
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- catch (Xception2 ex)
- {
- if (ex.ErrorCode != 2002 || ex.Struct_thing.String_thing != "This is an Xception2")
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
- try
- {
- Console.WriteLine("testMultiException(\"success\", \"OK\")");
- if ("OK" != (await client.testMultiExceptionAsync("success", "OK", token)).String_thing)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorExceptions;
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- }
-
- var sw = new Stopwatch();
- sw.Start();
- Console.WriteLine("Test Oneway(1)");
- await client.testOnewayAsync(1, token);
- sw.Stop();
- if (sw.ElapsedMilliseconds > 1000)
- {
- Console.WriteLine("*** FAILED ***");
- returnCode |= ErrorBaseTypes;
- }
-
- Console.Write("Test Calltime()");
- var times = 50;
- sw.Reset();
- sw.Start();
- for (var k = 0; k < times; ++k)
- await client.testVoidAsync(token);
- sw.Stop();
- Console.WriteLine(" = {0} ms a testVoid() call", sw.ElapsedMilliseconds / times);
- return returnCode;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/54993296/test/netcore/ThriftTest/TestServer.cs
----------------------------------------------------------------------
diff --git a/test/netcore/ThriftTest/TestServer.cs b/test/netcore/ThriftTest/TestServer.cs
deleted file mode 100644
index aa25c91..0000000
--- a/test/netcore/ThriftTest/TestServer.cs
+++ /dev/null
@@ -1,560 +0,0 @@
-// Licensed to the Apache Software Foundation(ASF) under one
-// or more contributor license agreements.See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-using System;
-using System.Collections.Generic;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Logging;
-using ThriftAsync.Test;
-using Thrift;
-using Thrift.Collections;
-using Thrift.Protocols;
-using Thrift.Server;
-using Thrift.Transports;
-using Thrift.Transports.Server;
-
-namespace Test
-{
- internal class ServerParam
- {
- internal bool useBufferedSockets = false;
- internal bool useFramed = false;
- internal bool useEncryption = false;
- internal bool compact = false;
- internal bool json = false;
- internal int port = 9090;
- internal string pipe = null;
-
- internal void Parse(List<string> args)
- {
- for (var i = 0; i < args.Count; i++)
- {
- if (args[i].StartsWith("--pipe="))
- {
- pipe = args[i].Substring(args[i].IndexOf("=") + 1);
- }
- else if (args[i].StartsWith("--port="))
- {
- port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1));
- }
- 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] == "--binary" || args[i] == "--protocol=binary")
- {
- // nothing needed
- }
- 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] == "--threaded" || args[i] == "--server-type=threaded")
- {
- throw new NotImplementedException(args[i]);
- }
- else if (args[i] == "--threadpool" || args[i] == "--server-type=threadpool")
- {
- throw new NotImplementedException(args[i]);
- }
- else if (args[i] == "--prototype" || args[i] == "--processor=prototype")
- {
- throw new NotImplementedException(args[i]);
- }
- else if (args[i] == "--ssl")
- {
- useEncryption = true;
- }
- else
- {
- throw new ArgumentException(args[i]);
- }
- }
-
- }
- }
-
- public class TestServer
- {
- public static int _clientID = -1;
- public delegate void TestLogDelegate(string msg, params object[] values);
-
- public class MyServerEventHandler : TServerEventHandler
- {
- public int callCount = 0;
-
- public Task PreServeAsync(CancellationToken cancellationToken)
- {
- callCount++;
- return Task.CompletedTask;
- }
-
- public Task<object> CreateContextAsync(TProtocol input, TProtocol output, CancellationToken cancellationToken)
- {
- callCount++;
- return Task.FromResult<object>(null);
- }
-
- public Task DeleteContextAsync(object serverContext, TProtocol input, TProtocol output, CancellationToken cancellationToken)
- {
- callCount++;
- return Task.CompletedTask;
- }
-
- public Task ProcessContextAsync(object serverContext, TClientTransport transport, CancellationToken cancellationToken)
- {
- callCount++;
- return Task.CompletedTask;
- }
- };
-
- public class TestHandlerAsync : ThriftAsync.Test.ThriftTest.IAsync
- {
- public TBaseServer server { get; set; }
- private int handlerID;
- private StringBuilder sb = new StringBuilder();
- private TestLogDelegate logger;
-
- public TestHandlerAsync()
- {
- handlerID = Interlocked.Increment(ref _clientID);
- logger += testConsoleLogger;
- logger.Invoke("New TestHandler instance created");
- }
-
- public void testConsoleLogger(string msg, params object[] values)
- {
- sb.Clear();
- sb.AppendFormat("handler{0:D3}:", handlerID);
- sb.AppendFormat(msg, values);
- sb.AppendLine();
- Console.Write(sb.ToString());
- }
-
- public Task testVoidAsync(CancellationToken cancellationToken)
- {
- logger.Invoke("testVoid()");
- return Task.CompletedTask;
- }
-
- public Task<string> testStringAsync(string thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testString({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<bool> testBoolAsync(bool thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testBool({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<sbyte> testByteAsync(sbyte thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testByte({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<int> testI32Async(int thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testI32({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<long> testI64Async(long thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testI64({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<double> testDoubleAsync(double thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testDouble({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<byte[]> testBinaryAsync(byte[] thing, CancellationToken cancellationToken)
- {
- var hex = BitConverter.ToString(thing).Replace("-", string.Empty);
- logger.Invoke("testBinary({0:X})", hex);
- return Task.FromResult(thing);
- }
-
- public Task<Xtruct> testStructAsync(Xtruct thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testStruct({{\"{0}\", {1}, {2}, {3}}})", thing.String_thing, thing.Byte_thing, thing.I32_thing, thing.I64_thing);
- return Task.FromResult(thing);
- }
-
- public Task<Xtruct2> testNestAsync(Xtruct2 nest, CancellationToken cancellationToken)
- {
- var thing = nest.Struct_thing;
- logger.Invoke("testNest({{{0}, {{\"{1}\", {2}, {3}, {4}, {5}}}}})",
- nest.Byte_thing,
- thing.String_thing,
- thing.Byte_thing,
- thing.I32_thing,
- thing.I64_thing,
- nest.I32_thing);
- return Task.FromResult(nest);
- }
-
- public Task<Dictionary<int, int>> testMapAsync(Dictionary<int, int> thing, CancellationToken cancellationToken)
- {
- sb.Clear();
- sb.Append("testMap({{");
- var first = true;
- foreach (var key in thing.Keys)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- sb.Append(", ");
- }
- sb.AppendFormat("{0} => {1}", key, thing[key]);
- }
- sb.Append("}})");
- logger.Invoke(sb.ToString());
- return Task.FromResult(thing);
- }
-
- public Task<Dictionary<string, string>> testStringMapAsync(Dictionary<string, string> thing, CancellationToken cancellationToken)
- {
- sb.Clear();
- sb.Append("testStringMap({{");
- var first = true;
- foreach (var key in thing.Keys)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- sb.Append(", ");
- }
- sb.AppendFormat("{0} => {1}", key, thing[key]);
- }
- sb.Append("}})");
- logger.Invoke(sb.ToString());
- return Task.FromResult(thing);
- }
-
- public Task<THashSet<int>> testSetAsync(THashSet<int> thing, CancellationToken cancellationToken)
- {
- sb.Clear();
- sb.Append("testSet({{");
- var first = true;
- foreach (int elem in thing)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- sb.Append(", ");
- }
- sb.AppendFormat("{0}", elem);
- }
- sb.Append("}})");
- logger.Invoke(sb.ToString());
- return Task.FromResult(thing);
- }
-
- public Task<List<int>> testListAsync(List<int> thing, CancellationToken cancellationToken)
- {
- sb.Clear();
- sb.Append("testList({{");
- var first = true;
- foreach (var elem in thing)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- sb.Append(", ");
- }
- sb.AppendFormat("{0}", elem);
- }
- sb.Append("}})");
- logger.Invoke(sb.ToString());
- return Task.FromResult(thing);
- }
-
- public Task<Numberz> testEnumAsync(Numberz thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testEnum({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<long> testTypedefAsync(long thing, CancellationToken cancellationToken)
- {
- logger.Invoke("testTypedef({0})", thing);
- return Task.FromResult(thing);
- }
-
- public Task<Dictionary<int, Dictionary<int, int>>> testMapMapAsync(int hello, CancellationToken cancellationToken)
- {
- logger.Invoke("testMapMap({0})", hello);
- var mapmap = new Dictionary<int, Dictionary<int, int>>();
-
- var pos = new Dictionary<int, int>();
- var neg = new Dictionary<int, int>();
- for (var i = 1; i < 5; i++)
- {
- pos[i] = i;
- neg[-i] = -i;
- }
-
- mapmap[4] = pos;
- mapmap[-4] = neg;
-
- return Task.FromResult(mapmap);
- }
-
- public Task<Dictionary<long, Dictionary<Numberz, Insanity>>> testInsanityAsync(Insanity argument, CancellationToken cancellationToken)
- {
- logger.Invoke("testInsanity()");
-
- /** from ThriftTest.thrift:
- * So you think you've got this all worked, out eh?
- *
- * Creates a the returned map with these values and prints it out:
- * { 1 => { 2 => argument,
- * 3 => argument,
- * },
- * 2 => { 6 => <empty Insanity struct>, },
- * }
- * @return map<UserId, map<Numberz,Insanity>> - a map with the above values
- */
-
- var first_map = new Dictionary<Numberz, Insanity>();
- var second_map = new Dictionary<Numberz, Insanity>(); ;
-
- first_map[Numberz.TWO] = argument;
- first_map[Numberz.THREE] = argument;
-
- second_map[Numberz.SIX] = new Insanity();
-
- var insane = new Dictionary<long, Dictionary<Numberz, Insanity>>
- {
- [1] = first_map,
- [2] = second_map
- };
-
- return Task.FromResult(insane);
- }
-
- public Task<Xtruct> testMultiAsync(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5,
- CancellationToken cancellationToken)
- {
- logger.Invoke("testMulti()");
-
- var hello = new Xtruct(); ;
- hello.String_thing = "Hello2";
- hello.Byte_thing = arg0;
- hello.I32_thing = arg1;
- hello.I64_thing = arg2;
- return Task.FromResult(hello);
- }
-
- public Task testExceptionAsync(string arg, CancellationToken cancellationToken)
- {
- logger.Invoke("testException({0})", arg);
- if (arg == "Xception")
- {
- var x = new Xception
- {
- ErrorCode = 1001,
- Message = arg
- };
- throw x;
- }
- if (arg == "TException")
- {
- throw new TException();
- }
- return Task.CompletedTask;
- }
-
- public Task<Xtruct> testMultiExceptionAsync(string arg0, string arg1, CancellationToken cancellationToken)
- {
- logger.Invoke("testMultiException({0}, {1})", arg0, arg1);
- if (arg0 == "Xception")
- {
- var x = new Xception
- {
- ErrorCode = 1001,
- Message = "This is an Xception"
- };
- throw x;
- }
-
- if (arg0 == "Xception2")
- {
- var x = new Xception2
- {
- ErrorCode = 2002,
- Struct_thing = new Xtruct { String_thing = "This is an Xception2" }
- };
- throw x;
- }
-
- var result = new Xtruct { String_thing = arg1 };
- return Task.FromResult(result);
- }
-
- public Task testOnewayAsync(int secondsToSleep, CancellationToken cancellationToken)
- {
- logger.Invoke("testOneway({0}), sleeping...", secondsToSleep);
- Thread.Sleep(secondsToSleep * 1000);
- logger.Invoke("testOneway finished");
-
- return Task.CompletedTask;
- }
- }
-
-
- private enum ProcessorFactoryType
- {
- TSingletonProcessorFactory,
- TPrototypeProcessorFactory,
- }
-
- internal static void PrintOptionsHelp()
- {
- Console.WriteLine("Server options:");
- Console.WriteLine(" --pipe=<pipe name>");
- Console.WriteLine(" --port=<port number>");
- Console.WriteLine(" --transport=<transport name> one of buffered,framed (defaults to none)");
- Console.WriteLine(" --protocol=<protocol name> one of compact,json (defaults to binary)");
- Console.WriteLine(" --server-type=<type> one of threaded,threadpool (defaults to simple)");
- Console.WriteLine(" --processor=<prototype>");
- Console.WriteLine(" --ssl");
- Console.WriteLine();
- }
-
- public static int Execute(List<string> args)
- {
- var logger = new LoggerFactory().CreateLogger("Test");
-
- try
- {
- var param = new ServerParam();
-
- try
- {
- param.Parse(args);
- }
- catch (Exception ex)
- {
- Console.WriteLine("*** FAILED ***");
- Console.WriteLine("Error while parsing arguments");
- Console.WriteLine(ex.Message + " ST: " + ex.StackTrace);
- return 1;
- }
-
-
- // Transport
- TServerTransport trans;
- if (param.pipe != null)
- {
- trans = new TNamedPipeServerTransport(param.pipe);
- }
- else
- {
- if (param.useEncryption)
- {
- var certPath = "../../keys/server.p12";
- trans = new TTlsServerSocketTransport(param.port, param.useBufferedSockets, new X509Certificate2(certPath, "thrift"), null, null, SslProtocols.Tls);
- }
- else
- {
- trans = new TServerSocketTransport(param.port, 0, param.useBufferedSockets);
- }
- }
-
- ITProtocolFactory proto;
- if (param.compact)
- proto = new TCompactProtocol.Factory();
- else if (param.json)
- proto = new TJsonProtocol.Factory();
- else
- proto = new TBinaryProtocol.Factory();
-
- ITProcessorFactory processorFactory;
-
- // Processor
- var testHandler = new TestHandlerAsync();
- var testProcessor = new ThriftAsync.Test.ThriftTest.AsyncProcessor(testHandler);
- processorFactory = new SingletonTProcessorFactory(testProcessor);
-
-
- TTransportFactory transFactory;
- if (param.useFramed)
- throw new NotImplementedException("framed"); // transFactory = new TFramedTransport.Factory();
- else
- transFactory = new TTransportFactory();
-
- TBaseServer serverEngine = new AsyncBaseServer(processorFactory, trans, transFactory, transFactory, proto, proto, logger);
-
- //Server event handler
- var serverEvents = new MyServerEventHandler();
- serverEngine.SetEventHandler(serverEvents);
-
- // Run it
- var where = (! string.IsNullOrEmpty(param.pipe)) ? "on pipe " + param.pipe : "on port " + param.port;
- Console.WriteLine("Starting the AsyncBaseServer " + where +
- " with processor TPrototypeProcessorFactory prototype factory " +
- (param.useBufferedSockets ? " with buffered socket" : "") +
- (param.useFramed ? " with framed transport" : "") +
- (param.useEncryption ? " with encryption" : "") +
- (param.compact ? " with compact protocol" : "") +
- (param.json ? " with json protocol" : "") +
- "...");
- serverEngine.ServeAsync(CancellationToken.None).GetAwaiter().GetResult();
- Console.ReadLine();
- }
- catch (Exception x)
- {
- Console.Error.Write(x);
- return 1;
- }
- Console.WriteLine("done.");
- return 0;
- }
- }
-
-}