| OLD | NEW |
| 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 | 4 |
| 5 library test.socket.server; | 5 library test.socket.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'mocks.dart'; | 9 import 'mocks.dart'; |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 expect(response.error.code, equals( | 62 expect(response.error.code, equals( |
| 63 RequestErrorCode.SERVER_ALREADY_STARTED)); | 63 RequestErrorCode.SERVER_ALREADY_STARTED)); |
| 64 channel2.expectMsgCount(responseCount: 2); | 64 channel2.expectMsgCount(responseCount: 2); |
| 65 }); | 65 }); |
| 66 } | 66 } |
| 67 | 67 |
| 68 static Future requestHandler_exception() { | 68 static Future requestHandler_exception() { |
| 69 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); | 69 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); |
| 70 MockServerChannel channel = new MockServerChannel(); | 70 MockServerChannel channel = new MockServerChannel(); |
| 71 server.createAnalysisServer(channel); | 71 server.createAnalysisServer(channel); |
| 72 channel.expectMsgCount(notificationCount: 1); |
| 73 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); |
| 72 _MockRequestHandler handler = new _MockRequestHandler(false); | 74 _MockRequestHandler handler = new _MockRequestHandler(false); |
| 73 server.analysisServer.handlers = [handler]; | 75 server.analysisServer.handlers = [handler]; |
| 74 var request = new ServerGetVersionParams().toRequest('0'); | 76 var request = new ServerGetVersionParams().toRequest('0'); |
| 75 return channel.sendRequest(request).then((Response response) { | 77 return channel.sendRequest(request).then((Response response) { |
| 76 expect(response.id, equals('0')); | 78 expect(response.id, equals('0')); |
| 77 expect(response.error, isNotNull); | 79 expect(response.error, isNotNull); |
| 78 expect(response.error.code, equals(RequestErrorCode.SERVER_ERROR)); | 80 expect(response.error.code, equals(RequestErrorCode.SERVER_ERROR)); |
| 79 channel.expectMsgCount(responseCount: 1, notificationCount: 2); | 81 expect(response.error.message, equals('mock request exception')); |
| 80 expect(channel.notificationsReceived[1].event, SERVER_ERROR); | 82 expect(response.error.stackTrace, isNotNull); |
| 83 expect(response.error.stackTrace, isNot(isEmpty)); |
| 84 channel.expectMsgCount(responseCount: 1, notificationCount: 1); |
| 81 }); | 85 }); |
| 82 } | 86 } |
| 83 | 87 |
| 84 static Future requestHandler_futureException() { | 88 static Future requestHandler_futureException() { |
| 85 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); | 89 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); |
| 86 MockServerChannel channel = new MockServerChannel(); | 90 MockServerChannel channel = new MockServerChannel(); |
| 87 server.createAnalysisServer(channel); | 91 server.createAnalysisServer(channel); |
| 88 _MockRequestHandler handler = new _MockRequestHandler(true); | 92 _MockRequestHandler handler = new _MockRequestHandler(true); |
| 89 server.analysisServer.handlers = [handler]; | 93 server.analysisServer.handlers = [handler]; |
| 90 var request = new ServerGetVersionParams().toRequest('0'); | 94 var request = new ServerGetVersionParams().toRequest('0'); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 new Future(throwException); | 112 new Future(throwException); |
| 109 return new Response(request.id); | 113 return new Response(request.id); |
| 110 } | 114 } |
| 111 throw 'mock request exception'; | 115 throw 'mock request exception'; |
| 112 } | 116 } |
| 113 | 117 |
| 114 void throwException() { | 118 void throwException() { |
| 115 throw 'mock future exception'; | 119 throw 'mock future exception'; |
| 116 } | 120 } |
| 117 } | 121 } |
| OLD | NEW |