David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 20 | using System; |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 21 | using System.Linq; |
| 22 | using System.Diagnostics; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 23 | using System.Collections.Generic; |
David Reiss | d831a21 | 2009-02-13 03:09:52 +0000 | [diff] [blame] | 24 | using System.Threading; |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 25 | using System.Security.Cryptography.X509Certificates; |
David Reiss | d831a21 | 2009-02-13 03:09:52 +0000 | [diff] [blame] | 26 | using Thrift.Collections; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 27 | using Thrift.Protocol; |
| 28 | using Thrift.Transport; |
| 29 | using Thrift.Test; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 30 | |
| 31 | namespace Test |
| 32 | { |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 33 | public class TestClient |
| 34 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 35 | private class TestParams |
| 36 | { |
| 37 | public int numIterations = 1; |
| 38 | public string host = "localhost"; |
| 39 | public int port = 9090; |
| 40 | public string url; |
| 41 | public string pipe; |
| 42 | public bool buffered; |
| 43 | public bool framed; |
| 44 | public string protocol; |
| 45 | public bool encrypted = false; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 46 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 47 | public TTransport CreateTransport() |
| 48 | { |
| 49 | if (url == null) |
| 50 | { |
| 51 | // endpoint transport |
| 52 | TTransport trans = null; |
| 53 | if (pipe != null) |
| 54 | trans = new TNamedPipeClientTransport(pipe); |
| 55 | else |
| 56 | { |
| 57 | if (encrypted) |
| 58 | { |
| 59 | string certPath = "../../../../test/keys/client.p12"; |
| 60 | X509Certificate cert = new X509Certificate2(certPath, "thrift"); |
| 61 | trans = new TTLSSocket(host, port, cert, (o, c, chain, errors) => true); |
| 62 | } |
| 63 | else |
| 64 | { |
| 65 | trans = new TSocket(host, port); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // layered transport |
| 70 | if (buffered) |
| 71 | trans = new TBufferedTransport(trans); |
| 72 | if (framed) |
| 73 | trans = new TFramedTransport(trans); |
| 74 | |
| 75 | //ensure proper open/close of transport |
| 76 | trans.Open(); |
| 77 | trans.Close(); |
| 78 | return trans; |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | return new THttpClient(new Uri(url)); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | public TProtocol CreateProtocol(TTransport transport) |
| 87 | { |
| 88 | if (protocol == "compact") |
| 89 | return new TCompactProtocol(transport); |
| 90 | else if (protocol == "json") |
| 91 | return new TJSONProtocol(transport); |
| 92 | else |
| 93 | return new TBinaryProtocol(transport); |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | private const int ErrorBaseTypes = 1; |
| 98 | private const int ErrorStructs = 2; |
| 99 | private const int ErrorContainers = 4; |
| 100 | private const int ErrorExceptions = 8; |
| 101 | private const int ErrorUnknown = 64; |
| 102 | |
| 103 | private class ClientTest |
| 104 | { |
| 105 | private readonly TTransport transport; |
| 106 | private readonly ThriftTest.Client client; |
| 107 | private readonly int numIterations; |
| 108 | private bool done; |
| 109 | |
| 110 | public int ReturnCode { get; set; } |
| 111 | |
| 112 | public ClientTest(TestParams param) |
| 113 | { |
| 114 | transport = param.CreateTransport(); |
| 115 | client = new ThriftTest.Client(param.CreateProtocol(transport)); |
| 116 | numIterations = param.numIterations; |
| 117 | } |
| 118 | public void Execute() |
| 119 | { |
| 120 | if (done) |
| 121 | { |
| 122 | Console.WriteLine("Execute called more than once"); |
| 123 | throw new InvalidOperationException(); |
| 124 | } |
| 125 | |
| 126 | for (int i = 0; i < numIterations; i++) |
| 127 | { |
| 128 | try |
| 129 | { |
| 130 | if (!transport.IsOpen) |
| 131 | transport.Open(); |
| 132 | } |
| 133 | catch (TTransportException ex) |
| 134 | { |
| 135 | Console.WriteLine("*** FAILED ***"); |
| 136 | Console.WriteLine("Connect failed: " + ex.Message); |
| 137 | ReturnCode |= ErrorUnknown; |
| 138 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 139 | continue; |
| 140 | } |
| 141 | |
| 142 | try |
| 143 | { |
| 144 | ReturnCode |= ExecuteClientTest(client); |
| 145 | } |
| 146 | catch (Exception ex) |
| 147 | { |
| 148 | Console.WriteLine("*** FAILED ***"); |
| 149 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 150 | ReturnCode |= ErrorUnknown; |
| 151 | } |
| 152 | } |
| 153 | try |
| 154 | { |
| 155 | transport.Close(); |
| 156 | } |
| 157 | catch(Exception ex) |
| 158 | { |
| 159 | Console.WriteLine("Error while closing transport"); |
| 160 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 161 | } |
| 162 | done = true; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | public static int Execute(string[] args) |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 167 | { |
| 168 | try |
| 169 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 170 | TestParams param = new TestParams(); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 171 | int numThreads = 1; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 172 | try |
| 173 | { |
| 174 | for (int i = 0; i < args.Length; i++) |
| 175 | { |
| 176 | if (args[i] == "-u") |
| 177 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 178 | param.url = args[++i]; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 179 | } |
| 180 | else if (args[i] == "-n") |
| 181 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 182 | param.numIterations = Convert.ToInt32(args[++i]); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 183 | } |
| 184 | else if (args[i] == "-pipe") // -pipe <name> |
| 185 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 186 | param.pipe = args[++i]; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 187 | Console.WriteLine("Using named pipes transport"); |
| 188 | } |
| 189 | else if (args[i].Contains("--host=")) |
| 190 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 191 | param.host = args[i].Substring(args[i].IndexOf("=") + 1); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 192 | } |
| 193 | else if (args[i].Contains("--port=")) |
| 194 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 195 | param.port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1)); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 196 | } |
| 197 | else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered") |
| 198 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 199 | param.buffered = true; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 200 | Console.WriteLine("Using buffered sockets"); |
| 201 | } |
| 202 | else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed") |
| 203 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 204 | param.framed = true; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 205 | Console.WriteLine("Using framed transport"); |
| 206 | } |
| 207 | else if (args[i] == "-t") |
| 208 | { |
| 209 | numThreads = Convert.ToInt32(args[++i]); |
| 210 | } |
| 211 | else if (args[i] == "--compact" || args[i] == "--protocol=compact") |
| 212 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 213 | param.protocol = "compact"; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 214 | Console.WriteLine("Using compact protocol"); |
| 215 | } |
| 216 | else if (args[i] == "--json" || args[i] == "--protocol=json") |
| 217 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 218 | param.protocol = "json"; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 219 | Console.WriteLine("Using JSON protocol"); |
| 220 | } |
| 221 | else if (args[i] == "--ssl") |
| 222 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 223 | param.encrypted = true; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 224 | Console.WriteLine("Using encrypted transport"); |
| 225 | } |
| 226 | } |
| 227 | } |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 228 | catch (Exception ex) |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 229 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 230 | Console.WriteLine("*** FAILED ***"); |
| 231 | Console.WriteLine("Error while parsing arguments"); |
| 232 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 233 | return ErrorUnknown; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 234 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 235 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 236 | var tests = Enumerable.Range(0, numThreads).Select(_ => new ClientTest(param)).ToArray(); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 237 | //issue tests on separate threads simultaneously |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 238 | var threads = tests.Select(test => new Thread(test.Execute)).ToArray(); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 239 | DateTime start = DateTime.Now; |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 240 | foreach (var t in threads) |
| 241 | t.Start(); |
| 242 | foreach (var t in threads) |
| 243 | t.Join(); |
| 244 | Console.WriteLine("Total time: " + (DateTime.Now - start)); |
| 245 | Console.WriteLine(); |
| 246 | return tests.Select(t => t.ReturnCode).Aggregate((r1, r2) => r1 | r2); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 247 | } |
| 248 | catch (Exception outerEx) |
| 249 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 250 | Console.WriteLine("*** FAILED ***"); |
| 251 | Console.WriteLine("Unexpected error"); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 252 | Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 253 | return ErrorUnknown; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 254 | } |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 255 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 256 | |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 257 | public static string BytesToHex(byte[] data) { |
| 258 | return BitConverter.ToString(data).Replace("-", string.Empty); |
| 259 | } |
| 260 | |
| 261 | public static byte[] PrepareTestData(bool randomDist) |
| 262 | { |
| 263 | byte[] retval = new byte[0x100]; |
| 264 | int initLen = Math.Min(0x100,retval.Length); |
| 265 | |
| 266 | // linear distribution, unless random is requested |
| 267 | if (!randomDist) { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 268 | for (var i = 0; i < initLen; ++i) { |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 269 | retval[i] = (byte)i; |
| 270 | } |
| 271 | return retval; |
| 272 | } |
| 273 | |
| 274 | // random distribution |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 275 | for (var i = 0; i < initLen; ++i) { |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 276 | retval[i] = (byte)0; |
| 277 | } |
| 278 | var rnd = new Random(); |
| 279 | for (var i = 1; i < initLen; ++i) { |
| 280 | while( true) { |
| 281 | int nextPos = rnd.Next() % initLen; |
| 282 | if (retval[nextPos] == 0) { |
| 283 | retval[nextPos] = (byte)i; |
| 284 | break; |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | return retval; |
| 289 | } |
| 290 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 291 | public static int ExecuteClientTest(ThriftTest.Client client) |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 292 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 293 | int returnCode = 0; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 294 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 295 | Console.Write("testVoid()"); |
| 296 | client.testVoid(); |
| 297 | Console.WriteLine(" = void"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 298 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 299 | Console.Write("testString(\"Test\")"); |
| 300 | string s = client.testString("Test"); |
| 301 | Console.WriteLine(" = \"" + s + "\""); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 302 | if ("Test" != s) |
| 303 | { |
| 304 | Console.WriteLine("*** FAILED ***"); |
| 305 | returnCode |= ErrorBaseTypes; |
| 306 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 307 | |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 308 | Console.Write("testBool(true)"); |
| 309 | bool t = client.testBool((bool)true); |
| 310 | Console.WriteLine(" = " + t); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 311 | if (!t) |
| 312 | { |
| 313 | Console.WriteLine("*** FAILED ***"); |
| 314 | returnCode |= ErrorBaseTypes; |
| 315 | } |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 316 | Console.Write("testBool(false)"); |
| 317 | bool f = client.testBool((bool)false); |
| 318 | Console.WriteLine(" = " + f); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 319 | if (f) |
| 320 | { |
| 321 | Console.WriteLine("*** FAILED ***"); |
| 322 | returnCode |= ErrorBaseTypes; |
| 323 | } |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 324 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 325 | Console.Write("testByte(1)"); |
| 326 | sbyte i8 = client.testByte((sbyte)1); |
| 327 | Console.WriteLine(" = " + i8); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 328 | if (1 != i8) |
| 329 | { |
| 330 | Console.WriteLine("*** FAILED ***"); |
| 331 | returnCode |= ErrorBaseTypes; |
| 332 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 333 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 334 | Console.Write("testI32(-1)"); |
| 335 | int i32 = client.testI32(-1); |
| 336 | Console.WriteLine(" = " + i32); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 337 | if (-1 != i32) |
| 338 | { |
| 339 | Console.WriteLine("*** FAILED ***"); |
| 340 | returnCode |= ErrorBaseTypes; |
| 341 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 342 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 343 | Console.Write("testI64(-34359738368)"); |
| 344 | long i64 = client.testI64(-34359738368); |
| 345 | Console.WriteLine(" = " + i64); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 346 | if (-34359738368 != i64) |
| 347 | { |
| 348 | Console.WriteLine("*** FAILED ***"); |
| 349 | returnCode |= ErrorBaseTypes; |
| 350 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 351 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 352 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 353 | Console.Write("testDouble(5.325098235)"); |
| 354 | double dub = client.testDouble(5.325098235); |
| 355 | Console.WriteLine(" = " + dub); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 356 | if (5.325098235 != dub) |
| 357 | { |
| 358 | Console.WriteLine("*** FAILED ***"); |
| 359 | returnCode |= ErrorBaseTypes; |
| 360 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 361 | |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 362 | byte[] binOut = PrepareTestData(true); |
| 363 | Console.Write("testBinary(" + BytesToHex(binOut) + ")"); |
| 364 | try |
| 365 | { |
| 366 | byte[] binIn = client.testBinary(binOut); |
| 367 | Console.WriteLine(" = " + BytesToHex(binIn)); |
| 368 | if (binIn.Length != binOut.Length) |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 369 | { |
| 370 | Console.WriteLine("*** FAILED ***"); |
| 371 | returnCode |= ErrorBaseTypes; |
| 372 | } |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 373 | for (int ofs = 0; ofs < Math.Min(binIn.Length, binOut.Length); ++ofs) |
| 374 | if (binIn[ofs] != binOut[ofs]) |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 375 | { |
| 376 | Console.WriteLine("*** FAILED ***"); |
| 377 | returnCode |= ErrorBaseTypes; |
| 378 | } |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 379 | } |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 380 | catch (Thrift.TApplicationException ex) |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 381 | { |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 382 | Console.WriteLine("*** FAILED ***"); |
| 383 | returnCode |= ErrorBaseTypes; |
| 384 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
Jens Geyer | 71e814a | 2014-12-13 23:40:35 +0100 | [diff] [blame] | 385 | } |
| 386 | |
Jens Geyer | 80aa53e | 2015-02-18 22:04:09 +0100 | [diff] [blame] | 387 | // binary equals? only with hashcode option enabled ... |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 388 | Console.WriteLine("Test CrazyNesting"); |
| 389 | if( typeof(CrazyNesting).GetMethod("Equals").DeclaringType == typeof(CrazyNesting)) |
Jens Geyer | 80aa53e | 2015-02-18 22:04:09 +0100 | [diff] [blame] | 390 | { |
| 391 | CrazyNesting one = new CrazyNesting(); |
| 392 | CrazyNesting two = new CrazyNesting(); |
| 393 | one.String_field = "crazy"; |
| 394 | two.String_field = "crazy"; |
| 395 | one.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF }; |
| 396 | two.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF }; |
| 397 | if (!one.Equals(two)) |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 398 | { |
| 399 | Console.WriteLine("*** FAILED ***"); |
| 400 | returnCode |= ErrorContainers; |
Jens Geyer | 80aa53e | 2015-02-18 22:04:09 +0100 | [diff] [blame] | 401 | throw new Exception("CrazyNesting.Equals failed"); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 402 | } |
Jens Geyer | 80aa53e | 2015-02-18 22:04:09 +0100 | [diff] [blame] | 403 | } |
| 404 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 405 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 406 | Console.Write("testStruct({\"Zero\", 1, -3, -5})"); |
| 407 | Xtruct o = new Xtruct(); |
| 408 | o.String_thing = "Zero"; |
| 409 | o.Byte_thing = (sbyte)1; |
| 410 | o.I32_thing = -3; |
| 411 | o.I64_thing = -5; |
| 412 | Xtruct i = client.testStruct(o); |
| 413 | Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 414 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 415 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 416 | Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})"); |
| 417 | Xtruct2 o2 = new Xtruct2(); |
| 418 | o2.Byte_thing = (sbyte)1; |
| 419 | o2.Struct_thing = o; |
| 420 | o2.I32_thing = 5; |
| 421 | Xtruct2 i2 = client.testNest(o2); |
| 422 | i = i2.Struct_thing; |
| 423 | Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 424 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 425 | Dictionary<int, int> mapout = new Dictionary<int, int>(); |
| 426 | for (int j = 0; j < 5; j++) |
| 427 | { |
| 428 | mapout[j] = j - 10; |
| 429 | } |
| 430 | Console.Write("testMap({"); |
| 431 | bool first = true; |
| 432 | foreach (int key in mapout.Keys) |
| 433 | { |
| 434 | if (first) |
| 435 | { |
| 436 | first = false; |
| 437 | } |
| 438 | else |
| 439 | { |
| 440 | Console.Write(", "); |
| 441 | } |
| 442 | Console.Write(key + " => " + mapout[key]); |
| 443 | } |
| 444 | Console.Write("})"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 445 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 446 | Dictionary<int, int> mapin = client.testMap(mapout); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 447 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 448 | Console.Write(" = {"); |
| 449 | first = true; |
| 450 | foreach (int key in mapin.Keys) |
| 451 | { |
| 452 | if (first) |
| 453 | { |
| 454 | first = false; |
| 455 | } |
| 456 | else |
| 457 | { |
| 458 | Console.Write(", "); |
| 459 | } |
| 460 | Console.Write(key + " => " + mapin[key]); |
| 461 | } |
| 462 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 463 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 464 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 465 | List<int> listout = new List<int>(); |
| 466 | for (int j = -2; j < 3; j++) |
| 467 | { |
| 468 | listout.Add(j); |
| 469 | } |
| 470 | Console.Write("testList({"); |
| 471 | first = true; |
| 472 | foreach (int j in listout) |
| 473 | { |
| 474 | if (first) |
| 475 | { |
| 476 | first = false; |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | Console.Write(", "); |
| 481 | } |
| 482 | Console.Write(j); |
| 483 | } |
| 484 | Console.Write("})"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 485 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 486 | List<int> listin = client.testList(listout); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 487 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 488 | Console.Write(" = {"); |
| 489 | first = true; |
| 490 | foreach (int j in listin) |
| 491 | { |
| 492 | if (first) |
| 493 | { |
| 494 | first = false; |
| 495 | } |
| 496 | else |
| 497 | { |
| 498 | Console.Write(", "); |
| 499 | } |
| 500 | Console.Write(j); |
| 501 | } |
| 502 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 503 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 504 | //set |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 505 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 506 | THashSet<int> setout = new THashSet<int>(); |
| 507 | for (int j = -2; j < 3; j++) |
| 508 | { |
| 509 | setout.Add(j); |
| 510 | } |
| 511 | Console.Write("testSet({"); |
| 512 | first = true; |
| 513 | foreach (int j in setout) |
| 514 | { |
| 515 | if (first) |
| 516 | { |
| 517 | first = false; |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | Console.Write(", "); |
| 522 | } |
| 523 | Console.Write(j); |
| 524 | } |
| 525 | Console.Write("})"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 526 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 527 | THashSet<int> setin = client.testSet(setout); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 528 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 529 | Console.Write(" = {"); |
| 530 | first = true; |
| 531 | foreach (int j in setin) |
| 532 | { |
| 533 | if (first) |
| 534 | { |
| 535 | first = false; |
| 536 | } |
| 537 | else |
| 538 | { |
| 539 | Console.Write(", "); |
| 540 | } |
| 541 | Console.Write(j); |
| 542 | } |
| 543 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 544 | |
| 545 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 546 | Console.Write("testEnum(ONE)"); |
| 547 | Numberz ret = client.testEnum(Numberz.ONE); |
| 548 | Console.WriteLine(" = " + ret); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 549 | if (Numberz.ONE != ret) |
| 550 | { |
| 551 | Console.WriteLine("*** FAILED ***"); |
| 552 | returnCode |= ErrorStructs; |
| 553 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 554 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 555 | Console.Write("testEnum(TWO)"); |
| 556 | ret = client.testEnum(Numberz.TWO); |
| 557 | Console.WriteLine(" = " + ret); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 558 | if (Numberz.TWO != ret) |
| 559 | { |
| 560 | Console.WriteLine("*** FAILED ***"); |
| 561 | returnCode |= ErrorStructs; |
| 562 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 563 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 564 | Console.Write("testEnum(THREE)"); |
| 565 | ret = client.testEnum(Numberz.THREE); |
| 566 | Console.WriteLine(" = " + ret); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 567 | if (Numberz.THREE != ret) |
| 568 | { |
| 569 | Console.WriteLine("*** FAILED ***"); |
| 570 | returnCode |= ErrorStructs; |
| 571 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 572 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 573 | Console.Write("testEnum(FIVE)"); |
| 574 | ret = client.testEnum(Numberz.FIVE); |
| 575 | Console.WriteLine(" = " + ret); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 576 | if (Numberz.FIVE != ret) |
| 577 | { |
| 578 | Console.WriteLine("*** FAILED ***"); |
| 579 | returnCode |= ErrorStructs; |
| 580 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 581 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 582 | Console.Write("testEnum(EIGHT)"); |
| 583 | ret = client.testEnum(Numberz.EIGHT); |
| 584 | Console.WriteLine(" = " + ret); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 585 | if (Numberz.EIGHT != ret) |
| 586 | { |
| 587 | Console.WriteLine("*** FAILED ***"); |
| 588 | returnCode |= ErrorStructs; |
| 589 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 590 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 591 | Console.Write("testTypedef(309858235082523)"); |
| 592 | long uid = client.testTypedef(309858235082523L); |
| 593 | Console.WriteLine(" = " + uid); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 594 | if (309858235082523L != uid) |
| 595 | { |
| 596 | Console.WriteLine("*** FAILED ***"); |
| 597 | returnCode |= ErrorStructs; |
| 598 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 599 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 600 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 601 | Console.Write("testMapMap(1)"); |
| 602 | Dictionary<int, Dictionary<int, int>> mm = client.testMapMap(1); |
| 603 | Console.Write(" = {"); |
| 604 | foreach (int key in mm.Keys) |
| 605 | { |
| 606 | Console.Write(key + " => {"); |
| 607 | Dictionary<int, int> m2 = mm[key]; |
| 608 | foreach (int k2 in m2.Keys) |
| 609 | { |
| 610 | Console.Write(k2 + " => " + m2[k2] + ", "); |
| 611 | } |
| 612 | Console.Write("}, "); |
| 613 | } |
| 614 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 615 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 616 | // TODO: Validate received message |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 617 | Insanity insane = new Insanity(); |
| 618 | insane.UserMap = new Dictionary<Numberz, long>(); |
| 619 | insane.UserMap[Numberz.FIVE] = 5000L; |
| 620 | Xtruct truck = new Xtruct(); |
| 621 | truck.String_thing = "Truck"; |
| 622 | truck.Byte_thing = (sbyte)8; |
| 623 | truck.I32_thing = 8; |
| 624 | truck.I64_thing = 8; |
| 625 | insane.Xtructs = new List<Xtruct>(); |
| 626 | insane.Xtructs.Add(truck); |
| 627 | Console.Write("testInsanity()"); |
| 628 | Dictionary<long, Dictionary<Numberz, Insanity>> whoa = client.testInsanity(insane); |
| 629 | Console.Write(" = {"); |
| 630 | foreach (long key in whoa.Keys) |
| 631 | { |
| 632 | Dictionary<Numberz, Insanity> val = whoa[key]; |
| 633 | Console.Write(key + " => {"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 634 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 635 | foreach (Numberz k2 in val.Keys) |
| 636 | { |
| 637 | Insanity v2 = val[k2]; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 638 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 639 | Console.Write(k2 + " => {"); |
| 640 | Dictionary<Numberz, long> userMap = v2.UserMap; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 641 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 642 | Console.Write("{"); |
| 643 | if (userMap != null) |
| 644 | { |
| 645 | foreach (Numberz k3 in userMap.Keys) |
| 646 | { |
| 647 | Console.Write(k3 + " => " + userMap[k3] + ", "); |
| 648 | } |
| 649 | } |
| 650 | else |
| 651 | { |
| 652 | Console.Write("null"); |
| 653 | } |
| 654 | Console.Write("}, "); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 655 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 656 | List<Xtruct> xtructs = v2.Xtructs; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 657 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 658 | Console.Write("{"); |
| 659 | if (xtructs != null) |
| 660 | { |
| 661 | foreach (Xtruct x in xtructs) |
| 662 | { |
| 663 | Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, "); |
| 664 | } |
| 665 | } |
| 666 | else |
| 667 | { |
| 668 | Console.Write("null"); |
| 669 | } |
| 670 | Console.Write("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 671 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 672 | Console.Write("}, "); |
| 673 | } |
| 674 | Console.Write("}, "); |
| 675 | } |
| 676 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 677 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 678 | sbyte arg0 = 1; |
| 679 | int arg1 = 2; |
| 680 | long arg2 = long.MaxValue; |
| 681 | Dictionary<short, string> multiDict = new Dictionary<short, string>(); |
| 682 | multiDict[1] = "one"; |
| 683 | Numberz arg4 = Numberz.FIVE; |
| 684 | long arg5 = 5000000; |
| 685 | Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")"); |
| 686 | Xtruct multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5); |
| 687 | Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing |
| 688 | + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 689 | |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 690 | try |
| 691 | { |
| 692 | Console.WriteLine("testException(\"Xception\")"); |
| 693 | client.testException("Xception"); |
| 694 | Console.WriteLine("*** FAILED ***"); |
| 695 | returnCode |= ErrorExceptions; |
| 696 | } |
| 697 | catch (Xception ex) |
| 698 | { |
| 699 | if (ex.ErrorCode != 1001 || ex.Message != "Xception") |
| 700 | { |
| 701 | Console.WriteLine("*** FAILED ***"); |
| 702 | returnCode |= ErrorExceptions; |
| 703 | } |
| 704 | } |
| 705 | catch (Exception ex) |
| 706 | { |
| 707 | Console.WriteLine("*** FAILED ***"); |
| 708 | returnCode |= ErrorExceptions; |
| 709 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 710 | } |
| 711 | try |
| 712 | { |
| 713 | Console.WriteLine("testException(\"TException\")"); |
| 714 | client.testException("TException"); |
| 715 | Console.WriteLine("*** FAILED ***"); |
| 716 | returnCode |= ErrorExceptions; |
| 717 | } |
| 718 | catch (Thrift.TException) |
| 719 | { |
| 720 | // OK |
| 721 | } |
| 722 | catch (Exception ex) |
| 723 | { |
| 724 | Console.WriteLine("*** FAILED ***"); |
| 725 | returnCode |= ErrorExceptions; |
| 726 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 727 | } |
| 728 | try |
| 729 | { |
| 730 | Console.WriteLine("testException(\"ok\")"); |
| 731 | client.testException("ok"); |
| 732 | // OK |
| 733 | } |
| 734 | catch (Exception ex) |
| 735 | { |
| 736 | Console.WriteLine("*** FAILED ***"); |
| 737 | returnCode |= ErrorExceptions; |
| 738 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 739 | } |
| 740 | |
| 741 | try |
| 742 | { |
| 743 | Console.WriteLine("testMultiException(\"Xception\", ...)"); |
| 744 | client.testMultiException("Xception", "ignore"); |
| 745 | Console.WriteLine("*** FAILED ***"); |
| 746 | returnCode |= ErrorExceptions; |
| 747 | } |
| 748 | catch (Xception ex) |
| 749 | { |
| 750 | if (ex.ErrorCode != 1001 || ex.Message != "This is an Xception") |
| 751 | { |
| 752 | Console.WriteLine("*** FAILED ***"); |
| 753 | returnCode |= ErrorExceptions; |
| 754 | } |
| 755 | } |
| 756 | catch (Exception ex) |
| 757 | { |
| 758 | Console.WriteLine("*** FAILED ***"); |
| 759 | returnCode |= ErrorExceptions; |
| 760 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 761 | } |
| 762 | try |
| 763 | { |
| 764 | Console.WriteLine("testMultiException(\"Xception2\", ...)"); |
| 765 | client.testMultiException("Xception2", "ignore"); |
| 766 | Console.WriteLine("*** FAILED ***"); |
| 767 | returnCode |= ErrorExceptions; |
| 768 | } |
| 769 | catch (Xception2 ex) |
| 770 | { |
| 771 | if (ex.ErrorCode != 2002 || ex.Struct_thing.String_thing != "This is an Xception2") |
| 772 | { |
| 773 | Console.WriteLine("*** FAILED ***"); |
| 774 | returnCode |= ErrorExceptions; |
| 775 | } |
| 776 | } |
| 777 | catch (Exception ex) |
| 778 | { |
| 779 | Console.WriteLine("*** FAILED ***"); |
| 780 | returnCode |= ErrorExceptions; |
| 781 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 782 | } |
| 783 | try |
| 784 | { |
| 785 | Console.WriteLine("testMultiException(\"success\", \"OK\")"); |
| 786 | if ("OK" != client.testMultiException("success", "OK").String_thing) |
| 787 | { |
| 788 | Console.WriteLine("*** FAILED ***"); |
| 789 | returnCode |= ErrorExceptions; |
| 790 | } |
| 791 | } |
| 792 | catch (Exception ex) |
| 793 | { |
| 794 | Console.WriteLine("*** FAILED ***"); |
| 795 | returnCode |= ErrorExceptions; |
| 796 | Console.WriteLine(ex.Message + " ST: " + ex.StackTrace); |
| 797 | } |
| 798 | |
| 799 | Stopwatch sw = new Stopwatch(); |
| 800 | sw.Start(); |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 801 | Console.WriteLine("Test Oneway(1)"); |
| 802 | client.testOneway(1); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 803 | sw.Stop(); |
| 804 | if (sw.ElapsedMilliseconds > 1000) |
| 805 | { |
| 806 | Console.WriteLine("*** FAILED ***"); |
| 807 | returnCode |= ErrorBaseTypes; |
| 808 | } |
T Jake Luciani | 7070aaa | 2011-01-27 02:51:51 +0000 | [diff] [blame] | 809 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 810 | Console.Write("Test Calltime()"); |
| 811 | var startt = DateTime.UtcNow; |
| 812 | for ( int k=0; k<1000; ++k ) |
| 813 | client.testVoid(); |
| 814 | Console.WriteLine(" = " + (DateTime.UtcNow - startt).TotalSeconds.ToString() + " ms a testVoid() call" ); |
Jens Geyer | 178b813 | 2015-09-30 23:16:45 +0200 | [diff] [blame^] | 815 | return returnCode; |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 816 | } |
| 817 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 818 | } |