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.pipeline_test; | 5 library shelf.pipeline_test; |
6 | 6 |
7 import 'package:shelf/shelf.dart'; | 7 import 'package:shelf/shelf.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 | 9 |
10 import 'test_util.dart'; | 10 import 'test_util.dart'; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 var middlewareB = createMiddleware(requestHandler: (request) { | 64 var middlewareB = createMiddleware(requestHandler: (request) { |
65 expect(accessLocation, 1); | 65 expect(accessLocation, 1); |
66 accessLocation = 2; | 66 accessLocation = 2; |
67 return null; | 67 return null; |
68 }, responseHandler: (response) { | 68 }, responseHandler: (response) { |
69 expect(accessLocation, 3); | 69 expect(accessLocation, 3); |
70 accessLocation = 4; | 70 accessLocation = 4; |
71 return response; | 71 return response; |
72 }); | 72 }); |
73 | 73 |
74 var innerPipeline = const Pipeline() | 74 var innerPipeline = |
75 .addMiddleware(middlewareA) | 75 const Pipeline().addMiddleware(middlewareA).addMiddleware(middlewareB); |
76 .addMiddleware(middlewareB); | |
77 | 76 |
78 var handler = const Pipeline() | 77 var handler = const Pipeline() |
79 .addMiddleware(innerPipeline.middleware) | 78 .addMiddleware(innerPipeline.middleware) |
80 .addHandler((request) { | 79 .addHandler((request) { |
81 expect(accessLocation, 2); | 80 expect(accessLocation, 2); |
82 accessLocation = 3; | 81 accessLocation = 3; |
83 return syncHandler(request); | 82 return syncHandler(request); |
84 }); | 83 }); |
85 | 84 |
86 return makeSimpleRequest(handler).then((response) { | 85 return makeSimpleRequest(handler).then((response) { |
87 expect(response, isNotNull); | 86 expect(response, isNotNull); |
88 expect(accessLocation, 5); | 87 expect(accessLocation, 5); |
89 }); | 88 }); |
90 }); | 89 }); |
91 } | 90 } |
OLD | NEW |