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

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

Issue 10919061: Fix flaky http test and reenable on buildbots. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 #import("dart:isolate"); 10 #import("dart:isolate");
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]); 135 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]);
136 Expect.equals("www.dartlang.org", request.headers.host); 136 Expect.equals("www.dartlang.org", request.headers.host);
137 Expect.equals(1234, request.headers.port); 137 Expect.equals(1234, request.headers.port);
138 response.statusCode = HttpStatus.OK; 138 response.statusCode = HttpStatus.OK;
139 response.outputStream.close(); 139 response.outputStream.close();
140 } 140 }
141 141
142 void init() { 142 void init() {
143 // Setup request handlers. 143 // Setup request handlers.
144 _requestHandlers = new Map(); 144 _requestHandlers = new Map();
145 _requestHandlers["/echo"] = (HttpRequest request, HttpResponse response) { 145 _requestHandlers["/echo"] = _echoHandler;
146 _echoHandler(request, response); 146 _requestHandlers["/0123456789"] = _zeroToTenHandler;
147 }; 147 _requestHandlers["/reasonformoving"] = _reasonForMovingHandler;
148 _requestHandlers["/0123456789"] = 148 _requestHandlers["/host"] = _hostHandler;
149 (HttpRequest request, HttpResponse response) {
150 _zeroToTenHandler(request, response);
151 };
152 _requestHandlers["/reasonformoving"] =
153 (HttpRequest request, HttpResponse response) {
154 _reasonForMovingHandler(request, response);
155 };
156 _requestHandlers["/host"] =
157 (HttpRequest request, HttpResponse response) {
158 _hostHandler(request, response);
159 };
160 } 149 }
161 150
162 void dispatch(var message, SendPort replyTo) { 151 void dispatch(var message, SendPort replyTo) {
163 if (message.isStart) { 152 if (message.isStart) {
164 _server = new HttpServer(); 153 _server = new HttpServer();
165 try { 154 try {
166 _server.listen("127.0.0.1", 0); 155 _server.listen("127.0.0.1", 0);
167 _server.defaultRequestHandler = (HttpRequest req, HttpResponse rsp) { 156 _server.defaultRequestHandler = _requestReceivedHandler;
168 _requestReceivedHandler(req, rsp);
169 };
170 replyTo.send(new TestServerStatus.started(_server.port), null); 157 replyTo.send(new TestServerStatus.started(_server.port), null);
171 } catch (e) { 158 } catch (e) {
172 replyTo.send(new TestServerStatus.error(), null); 159 replyTo.send(new TestServerStatus.error(), null);
173 } 160 }
174 } else if (message.isStop) { 161 } else if (message.isStop) {
175 _server.close(); 162 _server.close();
176 port.close(); 163 port.close();
177 replyTo.send(new TestServerStatus.stopped(), null); 164 replyTo.send(new TestServerStatus.stopped(), null);
178 } else if (message.isChunkedEncoding) { 165 } else if (message.isChunkedEncoding) {
179 _chunkedEncoding = true; 166 _chunkedEncoding = true;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 261 }
275 262
276 void test404() { 263 void test404() {
277 TestServerMain testServerMain = new TestServerMain(); 264 TestServerMain testServerMain = new TestServerMain();
278 testServerMain.setServerStartedHandler((int port) { 265 testServerMain.setServerStartedHandler((int port) {
279 HttpClient httpClient = new HttpClient(); 266 HttpClient httpClient = new HttpClient();
280 HttpClientConnection conn = 267 HttpClientConnection conn =
281 httpClient.get("127.0.0.1", port, "/thisisnotfound"); 268 httpClient.get("127.0.0.1", port, "/thisisnotfound");
282 conn.onResponse = (HttpClientResponse response) { 269 conn.onResponse = (HttpClientResponse response) {
283 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode); 270 Expect.equals(HttpStatus.NOT_FOUND, response.statusCode);
284 httpClient.shutdown(); 271 var body = new StringBuffer();
285 testServerMain.shutdown(); 272 var stream = response.inputStream;
273 stream.onData = () => body.add(new String.fromCharCodes(stream.read()));
274 stream.onClosed = () {
275 Expect.equals("Page not found", body.toString());
276 httpClient.shutdown();
277 testServerMain.shutdown();
278 };
286 }; 279 };
287 }); 280 });
288 testServerMain.start(); 281 testServerMain.start();
289 } 282 }
290 283
291 void testReasonPhrase() { 284 void testReasonPhrase() {
292 TestServerMain testServerMain = new TestServerMain(); 285 TestServerMain testServerMain = new TestServerMain();
293 testServerMain.setServerStartedHandler((int port) { 286 testServerMain.setServerStartedHandler((int port) {
294 HttpClient httpClient = new HttpClient(); 287 HttpClient httpClient = new HttpClient();
295 HttpClientConnection conn = 288 HttpClientConnection conn =
296 httpClient.get("127.0.0.1", port, "/reasonformoving"); 289 httpClient.get("127.0.0.1", port, "/reasonformoving");
297 conn.followRedirects = false; 290 conn.followRedirects = false;
298 conn.onResponse = (HttpClientResponse response) { 291 conn.onResponse = (HttpClientResponse response) {
299 Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode); 292 Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode);
300 Expect.equals("Don't come looking here any more", response.reasonPhrase); 293 Expect.equals("Don't come looking here any more", response.reasonPhrase);
301 httpClient.shutdown(); 294 var stream = response.inputStream;
302 testServerMain.shutdown(); 295 stream.onData = () => Expect.fail("No data expected");
296 stream.onClosed = () {
297 httpClient.shutdown();
298 testServerMain.shutdown();
299 };
303 }; 300 };
304 }); 301 });
305 testServerMain.start(); 302 testServerMain.start();
306 } 303 }
307 304
308 void main() { 305 void main() {
309 testStartStop(); 306 testStartStop();
310 testGET(); 307 testGET();
311 testPOST(true); 308 testPOST(true);
312 testPOST(false); 309 testPOST(false);
313 test404(); 310 test404();
314 testReasonPhrase(); 311 testReasonPhrase();
315 } 312 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698