Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: runtime/observatory/tests/service/malformed_test.dart

Issue 1120133002: Rework error handling in the service protocol and in Observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override
5 5
6 import 'package:observatory/service_io.dart'; 6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'test_helper.dart'; 8 import 'test_helper.dart';
9 9
10 var tests = [ 10 var tests = [
11 (Isolate isolate) async { 11 (Isolate isolate) async {
12 await isolate.invokeRpc('_respondWithMalformedObject', {}).then((result) { 12 bool caughtException;
13 try {
14 await isolate.invokeRpc('_respondWithMalformedObject', {});
13 expect(false, isTrue, reason:'Unreachable'); 15 expect(false, isTrue, reason:'Unreachable');
14 }).catchError((ServiceException exception) { 16 } on MalformedResponseRpcException catch (e) {
15 expect(exception.kind, equals('ResponseFormatException')); 17 caughtException = true;
16 expect(exception.message, 18 expect(e.message, equals("Response is missing the 'type' field"));
17 startsWith("Response is missing the 'type' field")); 19 }
18 }); 20 expect(caughtException, isTrue);
19 }, 21 },
20 22
21 // Do this test last... it kills the vm connection. 23 // Do this test last... it kills the vm connection.
22 (Isolate isolate) async { 24 (Isolate isolate) async {
23 await isolate.invokeRpc('_respondWithMalformedJson', {}).then((result) { 25 bool caughtException;
26 try {
27 await isolate.invokeRpc('_respondWithMalformedJson', {});
24 expect(false, isTrue, reason:'Unreachable'); 28 expect(false, isTrue, reason:'Unreachable');
25 }).catchError((ServiceException exception) { 29 } on NetworkRpcException catch (e) {
26 expect(exception.kind, equals('ConnectionClosed')); 30 caughtException = true;
27 expect(exception.message, startsWith('Error decoding JSON message')); 31 expect(e.message,
28 }); 32 startsWith("Canceling request: "
33 "Connection saw corrupt JSON message: "
34 "FormatException: Unexpected character"));
35 }
36 expect(caughtException, isTrue);
29 }, 37 },
30 ]; 38 ];
31 39
32 main(args) => runIsolateTests(args, tests); 40 main(args) => runIsolateTests(args, tests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698