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