OLD | NEW |
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 library test_utils; | 5 library test_utils; |
6 | 6 |
| 7 import 'dart:async'; |
7 import 'dart:io'; | 8 import 'dart:io'; |
8 import 'dart:json' as json; | 9 import 'dart:json' as json; |
9 import 'dart:uri'; | 10 import 'dart:uri'; |
10 | 11 |
11 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
12 import 'package:http/http.dart' as http; | 13 import 'package:http/http.dart' as http; |
13 import 'package:http/src/utils.dart'; | 14 import 'package:http/src/utils.dart'; |
14 | 15 |
15 /// The current server instance. | 16 /// The current server instance. |
16 HttpServer _server; | 17 HttpServer _server; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 98 |
98 _server.listen("127.0.0.1", 0); | 99 _server.listen("127.0.0.1", 0); |
99 } | 100 } |
100 | 101 |
101 /// Stops the current HTTP server. | 102 /// Stops the current HTTP server. |
102 void stopServer() { | 103 void stopServer() { |
103 _server.close(); | 104 _server.close(); |
104 _server = null; | 105 _server = null; |
105 } | 106 } |
106 | 107 |
| 108 // TODO(nweiz): remove this once issue 7785 is fixed. |
| 109 /// Buffers all input from an InputStream and returns it as a future. |
| 110 Future<List<int>> consumeInputStream(InputStream stream) => |
| 111 new http.ByteStream(wrapInputStream(stream)).toBytes(); |
| 112 |
107 /// A matcher that matches JSON that parses to a value that matches the inner | 113 /// A matcher that matches JSON that parses to a value that matches the inner |
108 /// matcher. | 114 /// matcher. |
109 Matcher parse(matcher) => new _Parse(matcher); | 115 Matcher parse(matcher) => new _Parse(matcher); |
110 | 116 |
111 class _Parse extends BaseMatcher { | 117 class _Parse extends BaseMatcher { |
112 final Matcher _matcher; | 118 final Matcher _matcher; |
113 | 119 |
114 _Parse(this._matcher); | 120 _Parse(this._matcher); |
115 | 121 |
116 bool matches(item, MatchState matchState) { | 122 bool matches(item, MatchState matchState) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 const Matcher throwsRedirectLimitExceededException = | 171 const Matcher throwsRedirectLimitExceededException = |
166 const Throws(isRedirectLimitExceededException); | 172 const Throws(isRedirectLimitExceededException); |
167 | 173 |
168 class _RedirectLimitExceededException extends TypeMatcher { | 174 class _RedirectLimitExceededException extends TypeMatcher { |
169 const _RedirectLimitExceededException() : | 175 const _RedirectLimitExceededException() : |
170 super("RedirectLimitExceededException"); | 176 super("RedirectLimitExceededException"); |
171 | 177 |
172 bool matches(item, MatchState matchState) => | 178 bool matches(item, MatchState matchState) => |
173 item is RedirectLimitExceededException; | 179 item is RedirectLimitExceededException; |
174 } | 180 } |
OLD | NEW |