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

Side by Side Diff: tests/standalone/io/http_server_early_server_close_test.dart

Issue 14251006: Remove AsyncError with Expando. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebuild DOM and rebase. Created 7 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "dart:async"; 6 import "dart:async";
7 import "dart:io"; 7 import "dart:io";
8 import "dart:isolate"; 8 import "dart:isolate";
9 9
10 class Server { 10 class Server {
11 static Future<int> start() { 11 static Future<int> start() {
12 return HttpServer.bind("127.0.0.1", 0).then((server) { 12 return HttpServer.bind("127.0.0.1", 0).then((server) {
13 server.listen((HttpRequest request) { 13 server.listen((HttpRequest request) {
14 Timer.run(server.close); 14 Timer.run(server.close);
15 }, onError: (e) { 15 }, onError: (e) {
16 Expect.fail("No server errors expected: $e"); 16 String msg = "No server errors expected: $e";
17 var trace = getAttachedStackTrace(e);
18 if (trace != null) msg += "\nStackTrace: $trace";
19 Expect.fail(msg);
17 }); 20 });
18 return server.port; 21 return server.port;
19 }); 22 });
20 } 23 }
21 } 24 }
22 25
23 class Client { 26 class Client {
24 Client(int port) { 27 Client(int port) {
25 ReceivePort r = new ReceivePort(); 28 ReceivePort r = new ReceivePort();
26 HttpClient client = new HttpClient(); 29 HttpClient client = new HttpClient();
27 client.get("127.0.0.1", port, "/") 30 client.get("127.0.0.1", port, "/")
28 .then((HttpClientRequest request) { 31 .then((HttpClientRequest request) {
29 return request.close(); 32 return request.close();
30 }) 33 })
31 .then((HttpClientResponse response) { 34 .then((HttpClientResponse response) {
32 Expect.fail( 35 Expect.fail(
33 "Response should not be given, as not data was returned."); 36 "Response should not be given, as not data was returned.");
34 }) 37 })
35 .catchError((e) { 38 .catchError((e) {
36 r.close(); 39 r.close();
37 }); 40 });
38 } 41 }
39 } 42 }
40 43
41 main() { 44 main() {
42 Server.start().then((port) { 45 Server.start().then((port) {
43 new Client(port); 46 new Client(port);
44 }); 47 });
45 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698