Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 1 | /// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | /// or more contributor license agreements. See the NOTICE file |
| 3 | /// distributed with this work for additional information |
| 4 | /// regarding copyright ownership. The ASF licenses this file |
| 5 | /// to you under the Apache License, Version 2.0 (the |
| 6 | /// 'License'); you may not use this file except in compliance |
| 7 | /// with the License. You may obtain a copy of the License at |
| 8 | /// |
| 9 | /// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | /// |
| 11 | /// Unless required by applicable law or agreed to in writing, |
| 12 | /// software distributed under the License is distributed on an |
| 13 | /// 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | /// KIND, either express or implied. See the License for the |
| 15 | /// specific language governing permissions and limitations |
| 16 | /// under the License. |
| 17 | |
| 18 | import 'dart:async'; |
| 19 | import 'dart:convert'; |
| 20 | import 'dart:io'; |
| 21 | |
| 22 | import 'package:args/args.dart'; |
Mark Erickson | 56c1c64 | 2016-03-01 16:53:35 -0600 | [diff] [blame] | 23 | import 'package:collection/collection.dart'; |
| 24 | import 'package:http/http.dart' as http; |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 25 | import 'package:thrift/thrift.dart'; |
| 26 | import 'package:thrift/thrift_console.dart'; |
| 27 | import 'package:thrift_test/thrift_test.dart'; |
| 28 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 29 | const TEST_BASETYPES = 1; // 0000 0001 |
| 30 | const TEST_STRUCTS = 2; // 0000 0010 |
| 31 | const TEST_CONTAINERS = 4; // 0000 0100 |
| 32 | const TEST_EXCEPTIONS = 8; // 0000 1000 |
| 33 | const TEST_UNKNOWN = 64; // 0100 0000 (Failed to prepare environemt etc.) |
| 34 | const TEST_TIMEOUT = 128; // 1000 0000 |
| 35 | const TEST_NOTUSED = 48; // 0011 0000 (reserved bits) |
| 36 | |
| 37 | typedef Future FutureFunction(); |
| 38 | |
| 39 | class TTest { |
| 40 | final int errorCode; |
| 41 | final String name; |
| 42 | final FutureFunction func; |
| 43 | |
| 44 | TTest(this.errorCode, this.name, this.func); |
| 45 | } |
| 46 | |
| 47 | class TTestError extends Error { |
| 48 | final actual; |
| 49 | final expected; |
| 50 | |
| 51 | TTestError(this.actual, this.expected); |
| 52 | |
| 53 | String toString() => '$actual != $expected'; |
| 54 | } |
| 55 | |
| 56 | List<TTest> _tests; |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 57 | ThriftTestClient client; |
| 58 | bool verbose; |
| 59 | |
| 60 | /// Adapted from TestClient.php |
| 61 | main(List<String> args) async { |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 62 | ArgResults results = _parseArgs(args); |
| 63 | |
| 64 | if (results == null) { |
| 65 | exit(TEST_UNKNOWN); |
| 66 | } |
| 67 | |
| 68 | verbose = results['verbose'] == true; |
| 69 | |
| 70 | await _initTestClient( |
| 71 | host: results['host'], |
| 72 | port: int.parse(results['port']), |
| 73 | transportType: results['transport'], |
| 74 | protocolType: results['protocol']).catchError((e) { |
| 75 | stdout.writeln('Error:'); |
| 76 | stdout.writeln('$e'); |
| 77 | if (e is Error) { |
| 78 | stdout.writeln('${e.stackTrace}'); |
| 79 | } |
| 80 | exit(TEST_UNKNOWN); |
| 81 | }); |
| 82 | |
| 83 | // run tests |
| 84 | _tests = _createTests(); |
| 85 | |
| 86 | int result = 0; |
| 87 | |
| 88 | for (TTest test in _tests) { |
| 89 | if (verbose) stdout.write('${test.name}... '); |
| 90 | try { |
| 91 | await test.func(); |
| 92 | if (verbose) stdout.writeln('success!'); |
| 93 | } catch (e) { |
| 94 | if (verbose) stdout.writeln('$e'); |
| 95 | result = result | test.errorCode; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | exit(result); |
| 100 | } |
| 101 | |
| 102 | ArgResults _parseArgs(List<String> args) { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 103 | var parser = new ArgParser(); |
| 104 | parser.addOption('host', defaultsTo: 'localhost', help: 'The server host'); |
| 105 | parser.addOption('port', defaultsTo: '9090', help: 'The port to connect to'); |
| 106 | parser.addOption('transport', |
| 107 | defaultsTo: 'buffered', |
Nobuaki Sukegawa | a6ab1f5 | 2015-11-28 15:04:39 +0900 | [diff] [blame] | 108 | allowed: ['buffered', 'framed', 'http'], |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 109 | help: 'The transport name', |
| 110 | allowedHelp: { |
| 111 | 'buffered': 'TBufferedTransport', |
| 112 | 'framed': 'TFramedTransport' |
| 113 | }); |
| 114 | parser.addOption('protocol', |
| 115 | defaultsTo: 'binary', |
Mark Erickson | b5f126f | 2016-02-29 15:27:59 -0600 | [diff] [blame] | 116 | allowed: ['binary', 'compact', 'json'], |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 117 | help: 'The protocol name', |
Mark Erickson | b5f126f | 2016-02-29 15:27:59 -0600 | [diff] [blame] | 118 | allowedHelp: { |
| 119 | 'binary': 'TBinaryProtocol', |
| 120 | 'compact': 'TCompactProtocol', |
| 121 | 'json': 'TJsonProtocol' |
| 122 | }); |
James E. King III | 98f379e | 2019-01-22 09:22:04 -0500 | [diff] [blame] | 123 | parser.addFlag('verbose', defaultsTo: true); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 124 | |
| 125 | ArgResults results; |
| 126 | try { |
| 127 | results = parser.parse(args); |
| 128 | } catch (e) { |
| 129 | stdout.writeln('$e\n'); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 130 | } |
| 131 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 132 | if (results == null) stdout.write(parser.usage); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 133 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 134 | return results; |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | TProtocolFactory getProtocolFactory(String protocolType) { |
| 138 | if (protocolType == 'binary') { |
| 139 | return new TBinaryProtocolFactory(); |
Mark Erickson | b5f126f | 2016-02-29 15:27:59 -0600 | [diff] [blame] | 140 | } else if (protocolType == 'compact') { |
| 141 | return new TCompactProtocolFactory(); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 142 | } else if (protocolType == 'json') { |
| 143 | return new TJsonProtocolFactory(); |
| 144 | } |
| 145 | |
| 146 | throw new ArgumentError.value(protocolType); |
| 147 | } |
| 148 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 149 | Future _initTestClient( |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 150 | {String host, int port, String transportType, String protocolType}) async { |
| 151 | TTransport transport; |
| 152 | var protocolFactory = getProtocolFactory(protocolType); |
| 153 | |
| 154 | if (transportType == 'http') { |
Mark Erickson | 56c1c64 | 2016-03-01 16:53:35 -0600 | [diff] [blame] | 155 | var httpClient = new http.IOClient(); |
| 156 | var uri = Uri.parse('http://$host:$port'); |
| 157 | var config = new THttpConfig(uri, {}); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 158 | transport = new THttpClientTransport(httpClient, config); |
| 159 | } else { |
| 160 | var socket = await Socket.connect(host, port); |
| 161 | transport = new TClientSocketTransport(new TTcpSocket(socket)); |
| 162 | if (transportType == 'framed') { |
| 163 | transport = new TFramedTransport(transport); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | var protocol = protocolFactory.getProtocol(transport); |
| 168 | client = new ThriftTestClient(protocol); |
| 169 | |
| 170 | await transport.open(); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 171 | } |
| 172 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 173 | List<TTest> _createTests() { |
| 174 | List<TTest> tests = []; |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 175 | |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 176 | var xtruct = new Xtruct() |
| 177 | ..string_thing = 'Zero' |
| 178 | ..byte_thing = 1 |
| 179 | ..i32_thing = -3 |
| 180 | ..i64_thing = -5; |
| 181 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 182 | tests.add(new TTest(TEST_BASETYPES, 'testVoid', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 183 | await client.testVoid(); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 184 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 185 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 186 | tests.add(new TTest(TEST_BASETYPES, 'testString', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 187 | var input = 'Test'; |
| 188 | var result = await client.testString(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 189 | if (result != input) throw new TTestError(result, input); |
| 190 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 191 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 192 | tests.add(new TTest(TEST_BASETYPES, 'testBool', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 193 | var input = true; |
| 194 | var result = await client.testBool(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 195 | if (result != input) throw new TTestError(result, input); |
| 196 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 197 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 198 | tests.add(new TTest(TEST_BASETYPES, 'testByte', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 199 | var input = 64; |
| 200 | var result = await client.testByte(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 201 | if (result != input) throw new TTestError(result, input); |
| 202 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 203 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 204 | tests.add(new TTest(TEST_BASETYPES, 'testI32', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 205 | var input = 2147483647; |
| 206 | var result = await client.testI32(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 207 | if (result != input) throw new TTestError(result, input); |
| 208 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 209 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 210 | tests.add(new TTest(TEST_BASETYPES, 'testI64', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 211 | var input = 9223372036854775807; |
| 212 | var result = await client.testI64(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 213 | if (result != input) throw new TTestError(result, input); |
| 214 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 215 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 216 | tests.add(new TTest(TEST_BASETYPES, 'testDouble', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 217 | var input = 3.1415926; |
| 218 | var result = await client.testDouble(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 219 | if (result != input) throw new TTestError(result, input); |
| 220 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 221 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 222 | tests.add(new TTest(TEST_BASETYPES, 'testBinary', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 223 | var utf8Codec = const Utf8Codec(); |
| 224 | var input = utf8Codec.encode('foo'); |
| 225 | var result = await client.testBinary(input); |
| 226 | var equality = const ListEquality(); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 227 | if (!equality.equals(result, input)) throw new TTestError(result, input); |
| 228 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 229 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 230 | tests.add(new TTest(TEST_CONTAINERS, 'testStruct', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 231 | var result = await client.testStruct(xtruct); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 232 | if ('$result' != '$xtruct') throw new TTestError(result, xtruct); |
| 233 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 234 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 235 | tests.add(new TTest(TEST_CONTAINERS, 'testNest', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 236 | var input = new Xtruct2() |
| 237 | ..byte_thing = 1 |
| 238 | ..struct_thing = xtruct |
| 239 | ..i32_thing = -3; |
| 240 | |
| 241 | var result = await client.testNest(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 242 | if ('$result' != '$input') throw new TTestError(result, input); |
| 243 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 244 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 245 | tests.add(new TTest(TEST_CONTAINERS, 'testMap', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 246 | Map<int, int> input = {1: -10, 2: -9, 3: -8, 4: -7, 5: -6}; |
| 247 | |
| 248 | var result = await client.testMap(input); |
| 249 | var equality = const MapEquality(); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 250 | if (!equality.equals(result, input)) throw new TTestError(result, input); |
| 251 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 252 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 253 | tests.add(new TTest(TEST_CONTAINERS, 'testSet', () async { |
Mark Erickson | 0d9b713 | 2016-12-13 22:20:03 -0600 | [diff] [blame] | 254 | var input = new Set<int>.from([-2, -1, 0, 1, 2]); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 255 | var result = await client.testSet(input); |
| 256 | var equality = const SetEquality(); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 257 | if (!equality.equals(result, input)) throw new TTestError(result, input); |
| 258 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 259 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 260 | tests.add(new TTest(TEST_CONTAINERS, 'testList', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 261 | var input = [-2, -1, 0, 1, 2]; |
| 262 | var result = await client.testList(input); |
| 263 | var equality = const ListEquality(); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 264 | if (!equality.equals(result, input)) throw new TTestError(result, input); |
| 265 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 266 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 267 | tests.add(new TTest(TEST_CONTAINERS, 'testEnum', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 268 | await _testEnum(Numberz.ONE); |
| 269 | await _testEnum(Numberz.TWO); |
| 270 | await _testEnum(Numberz.THREE); |
| 271 | await _testEnum(Numberz.FIVE); |
| 272 | await _testEnum(Numberz.EIGHT); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 273 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 274 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 275 | tests.add(new TTest(TEST_BASETYPES, 'testTypedef', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 276 | var input = 309858235082523; |
| 277 | var result = await client.testTypedef(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 278 | if (result != input) throw new TTestError(result, input); |
| 279 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 280 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 281 | tests.add(new TTest(TEST_CONTAINERS, 'testMapMap', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 282 | Map<int, Map<int, int>> result = await client.testMapMap(1); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 283 | if (result.isEmpty || result[result.keys.first].isEmpty) { |
| 284 | throw new TTestError(result, 'Map<int, Map<int, int>>'); |
| 285 | } |
| 286 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 287 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 288 | tests.add(new TTest(TEST_CONTAINERS, 'testInsanity', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 289 | var input = new Insanity(); |
| 290 | input.userMap = {Numberz.FIVE: 5000}; |
| 291 | input.xtructs = [xtruct]; |
| 292 | |
| 293 | Map<int, Map<int, Insanity>> result = await client.testInsanity(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 294 | if (result.isEmpty || result[result.keys.first].isEmpty) { |
| 295 | throw new TTestError(result, 'Map<int, Map<int, Insanity>>'); |
| 296 | } |
| 297 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 298 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 299 | tests.add(new TTest(TEST_CONTAINERS, 'testMulti', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 300 | var input = new Xtruct() |
| 301 | ..string_thing = 'Hello2' |
| 302 | ..byte_thing = 123 |
| 303 | ..i32_thing = 456 |
| 304 | ..i64_thing = 789; |
| 305 | |
| 306 | var result = await client.testMulti(input.byte_thing, input.i32_thing, |
| 307 | input.i64_thing, {1: 'one'}, Numberz.EIGHT, 5678); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 308 | if ('$result' != '$input') throw new TTestError(result, input); |
| 309 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 310 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 311 | tests.add(new TTest(TEST_EXCEPTIONS, 'testException', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 312 | try { |
| 313 | await client.testException('Xception'); |
Mark Erickson | 56c1c64 | 2016-03-01 16:53:35 -0600 | [diff] [blame] | 314 | } on Xception catch (_) { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 315 | return; |
| 316 | } |
| 317 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 318 | throw new TTestError(null, 'Xception'); |
| 319 | })); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 320 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 321 | tests.add(new TTest(TEST_EXCEPTIONS, 'testMultiException', () async { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 322 | try { |
| 323 | await client.testMultiException('Xception2', 'foo'); |
Mark Erickson | 56c1c64 | 2016-03-01 16:53:35 -0600 | [diff] [blame] | 324 | } on Xception2 catch (_) { |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 325 | return; |
| 326 | } |
| 327 | |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 328 | throw new TTestError(null, 'Xception2'); |
| 329 | })); |
| 330 | |
| 331 | return tests; |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | Future _testEnum(int input) async { |
| 335 | var result = await client.testEnum(input); |
Mark Erickson | 83072a6 | 2015-10-05 14:33:28 -0500 | [diff] [blame] | 336 | if (result != input) throw new TTestError(result, input); |
Mark Erickson | 932c470 | 2015-08-29 10:46:51 -0500 | [diff] [blame] | 337 | } |