| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:io"; | 6 import "dart:io"; |
| 7 import "dart:isolate"; | 7 import "dart:isolate"; |
| 8 | 8 |
| 9 void testListenOn() { | 9 void testListenOn() { |
| 10 ServerSocket socket; | 10 ServerSocket socket; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 }) | 22 }) |
| 23 .then((response) { | 23 .then((response) { |
| 24 response.listen( | 24 response.listen( |
| 25 (_) {}, | 25 (_) {}, |
| 26 onDone: () { | 26 onDone: () { |
| 27 client.close(); | 27 client.close(); |
| 28 clientPort.close(); | 28 clientPort.close(); |
| 29 onDone(); | 29 onDone(); |
| 30 }); | 30 }); |
| 31 }) | 31 }) |
| 32 .catchError((error) { | 32 .catchError((e) { |
| 33 Expect.fail("Unexpected error in Http Client: $error"); | 33 String msg = "Unexpected error in Http Client: $e"; |
| 34 var trace = getAttachedStackTrace(e); |
| 35 if (trace != null) msg += "\nStackTrace: $trace"; |
| 36 Expect.fail(msg); |
| 34 }); | 37 }); |
| 35 } | 38 } |
| 36 | 39 |
| 37 // Test two connection after each other. | 40 // Test two connection after each other. |
| 38 ServerSocket.bind().then((s) { | 41 ServerSocket.bind().then((s) { |
| 39 socket = s; | 42 socket = s; |
| 40 server = new HttpServer.listenOn(socket); | 43 server = new HttpServer.listenOn(socket); |
| 41 ReceivePort serverPort = new ReceivePort(); | 44 ReceivePort serverPort = new ReceivePort(); |
| 42 server.listen((HttpRequest request) { | 45 server.listen((HttpRequest request) { |
| 43 request.listen( | 46 request.listen( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 Expect.throws(() => server.port); | 57 Expect.throws(() => server.port); |
| 55 socket.close(); | 58 socket.close(); |
| 56 }); | 59 }); |
| 57 }); | 60 }); |
| 58 }); | 61 }); |
| 59 } | 62 } |
| 60 | 63 |
| 61 void main() { | 64 void main() { |
| 62 testListenOn(); | 65 testListenOn(); |
| 63 } | 66 } |
| OLD | NEW |