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

Side by Side Diff: pkg/analysis_server/test/protocol_test.dart

Issue 237793002: Fix race condition with "server already started" error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 4
5 library test.protocol; 5 library test.protocol;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 20 matching lines...) Expand all
31 test('toJson', RequestTest.toJson); 31 test('toJson', RequestTest.toJson);
32 test('toJson_withParams', RequestTest.toJson_withParams); 32 test('toJson_withParams', RequestTest.toJson_withParams);
33 }); 33 });
34 group('RequestError', () { 34 group('RequestError', () {
35 test('create', RequestErrorTest.create); 35 test('create', RequestErrorTest.create);
36 test('create_methodNotFound', RequestErrorTest.create_methodNotFound); 36 test('create_methodNotFound', RequestErrorTest.create_methodNotFound);
37 test('create_invalidParameters', RequestErrorTest.create_invalidParameters); 37 test('create_invalidParameters', RequestErrorTest.create_invalidParameters);
38 test('create_invalidRequest', RequestErrorTest.create_invalidRequest); 38 test('create_invalidRequest', RequestErrorTest.create_invalidRequest);
39 test('create_internalError', RequestErrorTest.create_internalError); 39 test('create_internalError', RequestErrorTest.create_internalError);
40 test('create_parseError', RequestErrorTest.create_parseError); 40 test('create_parseError', RequestErrorTest.create_parseError);
41 test('create_serverAlreadyStarted',
42 RequestErrorTest.create_serverAlreadyStarted);
41 test('fromJson', RequestErrorTest.fromJson); 43 test('fromJson', RequestErrorTest.fromJson);
42 test('toJson', RequestErrorTest.toJson); 44 test('toJson', RequestErrorTest.toJson);
43 }); 45 });
44 group('Response', () { 46 group('Response', () {
45 test('create_contextDoesNotExist', ResponseTest.create_contextDoesNotExist); 47 test('create_contextDoesNotExist', ResponseTest.create_contextDoesNotExist);
46 test('create_invalidRequestFormat', ResponseTest.create_invalidRequestFormat ); 48 test('create_invalidRequestFormat', ResponseTest.create_invalidRequestFormat );
47 test('create_missingRequiredParameter', ResponseTest.create_missingRequiredP arameter); 49 test('create_missingRequiredParameter', ResponseTest.create_missingRequiredP arameter);
48 test('create_unknownAnalysisOption', ResponseTest.create_unknownAnalysisOpti on); 50 test('create_unknownAnalysisOption', ResponseTest.create_unknownAnalysisOpti on);
49 test('create_unknownRequest', ResponseTest.create_unknownRequest); 51 test('create_unknownRequest', ResponseTest.create_unknownRequest);
50 test('setResult', ResponseTest.setResult); 52 test('setResult', ResponseTest.setResult);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 expect(error.code, RequestError.CODE_INVALID_REQUEST); 233 expect(error.code, RequestError.CODE_INVALID_REQUEST);
232 expect(error.message, "Invalid request"); 234 expect(error.message, "Invalid request");
233 } 235 }
234 236
235 static void create_internalError() { 237 static void create_internalError() {
236 RequestError error = new RequestError.internalError(); 238 RequestError error = new RequestError.internalError();
237 expect(error.code, RequestError.CODE_INTERNAL_ERROR); 239 expect(error.code, RequestError.CODE_INTERNAL_ERROR);
238 expect(error.message, "Internal error"); 240 expect(error.message, "Internal error");
239 } 241 }
240 242
243 static void create_serverAlreadyStarted() {
244 RequestError error = new RequestError.serverAlreadyStarted();
245 expect(error.code, RequestError.CODE_SERVER_ALREADY_STARTED);
246 expect(error.message, "Server already started");
247 }
248
241 static void fromJson() { 249 static void fromJson() {
242 var json = { 250 var json = {
243 RequestError.CODE: RequestError.CODE_PARSE_ERROR, 251 RequestError.CODE: RequestError.CODE_PARSE_ERROR,
244 RequestError.MESSAGE: 'foo', 252 RequestError.MESSAGE: 'foo',
245 RequestError.DATA: {'ints': [1, 2, 3]} 253 RequestError.DATA: {'ints': [1, 2, 3]}
246 }; 254 };
247 RequestError error = new RequestError.fromJson(json); 255 RequestError error = new RequestError.fromJson(json);
248 expect(error.code, RequestError.CODE_PARSE_ERROR); 256 expect(error.code, RequestError.CODE_PARSE_ERROR);
249 expect(error.message, "foo"); 257 expect(error.message, "foo");
250 expect(error.data['ints'], [1, 2, 3]); 258 expect(error.data['ints'], [1, 2, 3]);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 original.setResult('foo', 'bar'); 358 original.setResult('foo', 'bar');
351 Response response = new Response.fromJson(original.toJson()); 359 Response response = new Response.fromJson(original.toJson());
352 expect(response.id, equals('myId')); 360 expect(response.id, equals('myId'));
353 Map<String, Object> result = response.result; 361 Map<String, Object> result = response.result;
354 expect(result.length, equals(1)); 362 expect(result.length, equals(1));
355 expect(result['foo'], equals('bar')); 363 expect(result['foo'], equals('bar'));
356 } 364 }
357 } 365 }
358 366
359 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); 367 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>());
OLDNEW
« pkg/analysis_server/lib/http_server.dart ('K') | « pkg/analysis_server/lib/src/protocol.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698