Fixes the RequestBuilderTest unit test which was broken on Safari 2.0.4. On Safari, 2.0.4, if an HTTP response does not have a body, the XmlHttpRequest.status field will have an undefined value.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1982 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/test/com/google/gwt/http/client/RequestBuilderTest.java b/user/test/com/google/gwt/http/client/RequestBuilderTest.java
index c38591f..0d02cea 100644
--- a/user/test/com/google/gwt/http/client/RequestBuilderTest.java
+++ b/user/test/com/google/gwt/http/client/RequestBuilderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -84,7 +84,7 @@
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// should never get here
- fail("HTTPRequest timed out");
+ fail(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
@@ -127,7 +127,7 @@
getTestBaseURL() + "sendRequest_GET");
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
- fail();
+ fail(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
@@ -149,7 +149,7 @@
builder.setHeader("Content-Type", "application/x-www-form-urlencoded");
builder.sendRequest("method=test+request", new RequestCallback() {
public void onError(Request request, Throwable exception) {
- fail("HTTPRequest timed out");
+ fail(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
@@ -229,7 +229,7 @@
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
- fail("HTTPRequest timed out");
+ fail(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
@@ -258,7 +258,7 @@
builder.setTimeoutMillis(10000);
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
- fail("Test timed out");
+ fail(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
diff --git a/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java b/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java
index 6f144e8..38b93dd 100644
--- a/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java
+++ b/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -87,7 +87,18 @@
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
String parameter = request.getParameter("method");
if ("test request".equals(parameter)) {
- response.setStatus(HttpServletResponse.SC_OK);
+ try {
+ /*
+ * On Safari 2.0.4, if the HTTP response does not include any response
+ * text the status message will be undefined. So, we make sure that the
+ * post returns some data. See
+ * http://bugs.webkit.org/show_bug.cgi?id=3810.
+ */
+ response.getWriter().println("Hello");
+ response.setStatus(HttpServletResponse.SC_OK);
+ } catch (IOException e) {
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
} else {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}