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

Unified Diff: pkg/http_server/test/http_body_test.dart

Issue 18438005: Move MimeMultipartTransformer and HttpBodyHandler to mime and http_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed _BufferList copy and MimeMultipartException reference in pub. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/http_server/test/http_body_test.dart
diff --git a/tests/standalone/io/http_body_test.dart b/pkg/http_server/test/http_body_test.dart
similarity index 80%
rename from tests/standalone/io/http_body_test.dart
rename to pkg/http_server/test/http_body_test.dart
index 2f5231b911a70e14ba290d13cbbaffa7af0339ae..e7c3f275f21be1034fa6998f8c1f4033fe65b441 100644
--- a/tests/standalone/io/http_body_test.dart
+++ b/pkg/http_server/test/http_body_test.dart
@@ -5,7 +5,8 @@
import 'dart:io';
import 'dart:utf';
-import 'package:expect/expect.dart';
+import 'package:http_server/http_server.dart';
+import 'package:unittest/unittest.dart';
void testHttpClientResponseBody() {
void test(String mimeType,
@@ -30,20 +31,17 @@ void testHttpClientResponseBody() {
.then((request) => request.close())
.then(HttpBodyHandler.processResponse)
.then((body) {
- if (shouldFail) Expect.fail("Error expected");
- Expect.equals(type, body.type);
- Expect.isNotNull(body.response);
+ if (shouldFail) throw "Error expected";
Bill Hesse 2013/07/12 11:43:33 expect(shouldFail, isFalse)
Anders Johnsen 2013/07/15 08:21:32 Done.
+ expect(body.type, equals(type));
+ expect(body.response, isNotNull);
switch (type) {
case "text":
- Expect.equals(expectedBody, body.body);
- break;
-
case "json":
- Expect.mapEquals(expectedBody, body.body);
+ expect(body.body, equals(expectedBody));
break;
default:
- Expect.fail("bad body type");
+ throw "bad body type";
Bill Hesse 2013/07/12 11:43:33 fail("bad body type");
Anders Johnsen 2013/07/15 08:21:32 Done.
}
}, onError: (error) {
if (!shouldFail) throw error;
@@ -95,52 +93,47 @@ void testHttpServerRequestBody() {
HttpServer.bind("127.0.0.1", 0).then((server) {
server.transform(new HttpBodyHandler(defaultEncoding: defaultEncoding))
.listen((body) {
- if (shouldFail) Expect.fail("Error expected");
- Expect.equals(type, body.type);
+ if (shouldFail) throw "Error expected";
Bill Hesse 2013/07/12 11:43:33 ditto
Anders Johnsen 2013/07/15 08:21:32 Done.
+ expect(body.type, equals(type));
switch (type) {
case "text":
- Expect.equals(body.contentType.mimeType, "text/plain");
- Expect.equals(expectedBody, body.body);
+ expect(body.contentType.mimeType, equals("text/plain"));
+ expect(body.body, equals(expectedBody));
break;
case "json":
- Expect.equals(body.contentType.mimeType, "application/json");
- Expect.mapEquals(expectedBody, body.body);
+ expect(body.contentType.mimeType, equals("application/json"));
+ expect(body.body, equals(expectedBody));
break;
case "binary":
- Expect.equals(body.contentType, null);
- Expect.listEquals(expectedBody, body.body);
+ expect(body.contentType, isNull);
+ expect(body.body, equals(expectedBody));
break;
case "form":
var mimeType = body.contentType.mimeType;
- Expect.isTrue(
- mimeType == 'multipart/form-data' ||
- mimeType == 'application/x-www-form-urlencoded');
- Expect.setEquals(expectedBody.keys.toSet(),
- body.body.keys.toSet());
+ expect(mimeType,
+ anyOf(equals('multipart/form-data'),
+ equals('application/x-www-form-urlencoded')));
+ expect(body.body.keys.toSet(),
+ equals(expectedBody.keys.toSet()));
for (var key in expectedBody.keys) {
Bill Hesse 2013/07/12 11:43:33 var found = body.body[key]; var expected = expecte
Anders Johnsen 2013/07/15 08:21:32 Done.
if (body.body[key] is HttpBodyFileUpload) {
- Expect.equals(expectedBody[key]['contentType'],
- body.body[key].contentType.toString());
- Expect.equals(expectedBody[key]['filename'],
- body.body[key].filename);
- if (body.body[key].content is String) {
- Expect.equals(expectedBody[key]['content'],
- body.body[key].content);
- } else {
- Expect.listEquals(expectedBody[key]['content'],
- body.body[key].content);
- }
+ expect(body.body[key].contentType.toString(),
+ equals(expectedBody[key]['contentType']));
+ expect(body.body[key].filename,
+ equals(expectedBody[key]['filename']));
+ expect(body.body[key].content,
+ equals(expectedBody[key]['content']));
} else {
- Expect.equals(expectedBody[key], body.body[key]);
+ expect(body.body[key], equals(expectedBody[key]));
}
}
break;
default:
- Expect.fail("bad body type");
+ throw "bad body type";
}
body.response.close();
}, onError: (error) {
@@ -159,7 +152,7 @@ void testHttpServerRequestBody() {
})
.then((response) {
if (shouldFail) {
- Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode);
+ expect(response.statusCode, equals(HttpStatus.BAD_REQUEST));
}
response.fold(null, (x, y) {});
client.close();

Powered by Google App Engine
This is Rietveld 408576698