| 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 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 expect(channel.notificationsReceived[1].event, SERVER_ERROR); | 106 expect(channel.notificationsReceived[1].event, SERVER_ERROR); |
| 107 }); | 107 }); |
| 108 } | 108 } |
| 109 | 109 |
| 110 static SocketServer _createSocketServer() { | 110 static SocketServer _createSocketServer() { |
| 111 PhysicalResourceProvider resourceProvider = | 111 PhysicalResourceProvider resourceProvider = |
| 112 PhysicalResourceProvider.INSTANCE; | 112 PhysicalResourceProvider.INSTANCE; |
| 113 ServerPlugin serverPlugin = new ServerPlugin(); | 113 ServerPlugin serverPlugin = new ServerPlugin(); |
| 114 ExtensionManager manager = new ExtensionManager(); | 114 ExtensionManager manager = new ExtensionManager(); |
| 115 manager.processPlugins([serverPlugin]); | 115 manager.processPlugins([serverPlugin]); |
| 116 SdkCreator sdkCreator = (_) => new FolderBasedDartSdk(resourceProvider, | |
| 117 FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)); | |
| 118 return new SocketServer( | 116 return new SocketServer( |
| 119 new AnalysisServerOptions(), | 117 new AnalysisServerOptions(), |
| 120 new DartSdkManager('', false, sdkCreator), | 118 new DartSdkManager('', false), |
| 121 sdkCreator(null), | 119 new FolderBasedDartSdk(resourceProvider, |
| 120 FolderBasedDartSdk.defaultSdkDirectory(resourceProvider)), |
| 122 InstrumentationService.NULL_SERVICE, | 121 InstrumentationService.NULL_SERVICE, |
| 123 serverPlugin, | 122 serverPlugin, |
| 124 null, | 123 null, |
| 125 null, | 124 null, |
| 126 false); | 125 false); |
| 127 } | 126 } |
| 128 } | 127 } |
| 129 | 128 |
| 130 class _MockRequestHandler implements RequestHandler { | 129 class _MockRequestHandler implements RequestHandler { |
| 131 final bool futureException; | 130 final bool futureException; |
| 132 | 131 |
| 133 _MockRequestHandler(this.futureException); | 132 _MockRequestHandler(this.futureException); |
| 134 | 133 |
| 135 @override | 134 @override |
| 136 Response handleRequest(Request request) { | 135 Response handleRequest(Request request) { |
| 137 if (futureException) { | 136 if (futureException) { |
| 138 new Future(throwException); | 137 new Future(throwException); |
| 139 return new Response(request.id); | 138 return new Response(request.id); |
| 140 } | 139 } |
| 141 throw 'mock request exception'; | 140 throw 'mock request exception'; |
| 142 } | 141 } |
| 143 | 142 |
| 144 void throwException() { | 143 void throwException() { |
| 145 throw 'mock future exception'; | 144 throw 'mock future exception'; |
| 146 } | 145 } |
| 147 } | 146 } |
| OLD | NEW |