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

Side by Side Diff: pkg/shelf/test/create_middleware_test.dart

Issue 260933004: Support Request hijacking in Shelf, using a similar API to Rack. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 7 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 | « pkg/shelf/pubspec.yaml ('k') | pkg/shelf/test/hijack_test.dart » ('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) 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 shelf.create_middleware_test; 5 library shelf.create_middleware_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:shelf/shelf.dart'; 9 import 'package:shelf/shelf.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 throw error; 195 throw error;
196 }); 196 });
197 197
198 var handler = const Pipeline().addMiddleware(middleware) 198 var handler = const Pipeline().addMiddleware(middleware)
199 .addHandler((request) { 199 .addHandler((request) {
200 throw 'bad handler'; 200 throw 'bad handler';
201 }); 201 });
202 202
203 expect(makeSimpleRequest(handler), throwsA('bad handler')); 203 expect(makeSimpleRequest(handler), throwsA('bad handler'));
204 }); 204 });
205
206 test("doesn't handle HijackException", () {
207 var middleware = createMiddleware(errorHandler: (error, stack) {
208 expect(false, "error handler shouldn't be called");
209 });
210
211 var handler = const Pipeline().addMiddleware(middleware)
212 .addHandler((request) => throw const HijackException());
213
214 expect(makeSimpleRequest(handler),
215 throwsA(new isInstanceOf<HijackException>()));
216 });
205 }); 217 });
206 } 218 }
207 219
208 _failHandler(Request request) => fail('should never get here'); 220 _failHandler(Request request) => fail('should never get here');
209 221
210 final Response _middlewareResponse = 222 final Response _middlewareResponse =
211 new Response.ok('middleware content', headers: {'from': 'middleware'}); 223 new Response.ok('middleware content', headers: {'from': 'middleware'});
OLDNEW
« no previous file with comments | « pkg/shelf/pubspec.yaml ('k') | pkg/shelf/test/hijack_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698