| OLD | NEW |
| 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 Loading... |
| 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'}); |
| OLD | NEW |