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

Unified Diff: tests/standalone/io/http_server_early_server_close_test.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/http_server_early_server_close_test.dart
diff --git a/tests/standalone/io/http_server_early_server_close_test.dart b/tests/standalone/io/http_server_early_server_close_test.dart
index 76092579a13fb429b85920dbef5a83a5161ac3b2..79f12546780e74ab4070d5e5e934efcddd04b613 100644
--- a/tests/standalone/io/http_server_early_server_close_test.dart
+++ b/tests/standalone/io/http_server_early_server_close_test.dart
@@ -7,39 +7,38 @@ import "dart:io";
import "dart:isolate";
class Server {
- Server() {
- HttpServer server = new HttpServer();
- server.listen("127.0.0.1", 0);
- port = server.port;
- server.defaultRequestHandler =
- (HttpRequest request, HttpResponse response) {
- Timer.run(server.close);
- };
- server.onError = (e) {
- Expect.fail("No server errors expected: $e");
- };
+ static Future<int> start() {
+ return HttpServer.bind("127.0.0.1", 0).then((server) {
+ server.listen((HttpRequest request) {
+ Timer.run(server.close);
+ }, onError: (e) {
+ Expect.fail("No server errors expected: $e");
+ });
+ return server.port;
+ });
}
- int port;
}
class Client {
Client(int port) {
ReceivePort r = new ReceivePort();
HttpClient client = new HttpClient();
- HttpClientConnection c = client.get("127.0.0.1", port, "/");
- c.onRequest = (HttpClientRequest request) {
- request.outputStream.close();
- };
- c.onResponse = (HttpClientResponse response) {
- Expect.fail("Response should not be given, as not data was returned.");
- };
- c.onError = (e) {
- r.close();
- };
+ client.get("127.0.0.1", port, "/")
+ .then((HttpClientRequest request) {
+ return request.close();
+ })
+ .then((HttpClientResponse response) {
+ Expect.fail(
+ "Response should not be given, as not data was returned.");
+ })
+ .catchError((e) {
+ r.close();
+ });
}
}
main() {
- Server server = new Server();
- new Client(server.port);
+ Server.start().then((port) {
+ new Client(port);
+ });
}
« no previous file with comments | « tests/standalone/io/http_server_early_client_close_test.dart ('k') | tests/standalone/io/http_server_handler_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698