Revision: 6803 Author: jlaba...@google.com Date: Tue Nov 10 10:55:44 2009 Log: Extended timeouts of HttpSuite tests to 15 seconds because they sometimes fail if the server is busy.
Patch by: jlabanca Review by: fabbott http://code.google.com/p/google-web-toolkit/source/detail?r=6803 Added: /trunk/user/test/com/google/gwt/http/client/RequestTestBase.java Modified: /trunk/user/test/com/google/gwt/http/client/HTTPRequestTest.java /trunk/user/test/com/google/gwt/http/client/RequestBuilderTest.java /trunk/user/test/com/google/gwt/http/client/RequestTest.java /trunk/user/test/com/google/gwt/http/client/ResponseTest.java ======================================= --- /dev/null +++ /trunk/user/test/com/google/gwt/http/client/RequestTestBase.java Tue Nov 10 10:55:44 2009 @@ -0,0 +1,39 @@ +/* + * Copyright 2009 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 + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.http.client; + +import com.google.gwt.junit.client.GWTTestCase; + +/** + * Base class for tests that send an http request. + */ +public abstract class RequestTestBase extends GWTTestCase { + /** + * The timeout for request tests. + */ + protected static final int REQUEST_TIMEOUT = 15000; + + /** + * Delay finishing a test while we wait for a response. This method should be + * used instead of {...@link #delayTestFinish(int)} so we can adjust timeouts for + * all Rpc tests at once. + * + * @see #delayTestFinish(int) + */ + protected final void delayTestFinishForRequest() { + delayTestFinish(REQUEST_TIMEOUT); + } +} ======================================= --- /trunk/user/test/com/google/gwt/http/client/HTTPRequestTest.java Wed Oct 28 09:10:53 2009 +++ /trunk/user/test/com/google/gwt/http/client/HTTPRequestTest.java Tue Nov 10 10:55:44 2009 @@ -16,7 +16,6 @@ package com.google.gwt.http.client; import com.google.gwt.core.client.GWT; -import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.user.client.HTTPRequest; import com.google.gwt.user.client.ResponseTextHandler; @@ -25,9 +24,7 @@ * */ @Deprecated -public class HTTPRequestTest extends GWTTestCase { - - private static final int TEST_TIMEOUT = 10000; +public class HTTPRequestTest extends RequestTestBase { private static String getTestBaseURL() { return GWT.getModuleBaseURL() + "testRequestBuilder/"; @@ -39,7 +36,7 @@ } public void testAsyncGet() { - delayTestFinish(TEST_TIMEOUT); + delayTestFinishForRequest(); HTTPRequest.asyncGet(getTestBaseURL() + "send_GET", new ResponseTextHandler() { public void onCompletion(String responseText) { @@ -50,7 +47,7 @@ } public void testAsyncPost() { - delayTestFinish(TEST_TIMEOUT); + delayTestFinishForRequest(); HTTPRequest.asyncPost(getTestBaseURL() + "simplePost", "method=test+request", new ResponseTextHandler() { public void onCompletion(String responseText) { ======================================= --- /trunk/user/test/com/google/gwt/http/client/RequestBuilderTest.java Mon Oct 26 18:35:41 2009 +++ /trunk/user/test/com/google/gwt/http/client/RequestBuilderTest.java Tue Nov 10 10:55:44 2009 @@ -18,13 +18,11 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.junit.DoNotRunWith; import com.google.gwt.junit.Platform; -import com.google.gwt.junit.client.GWTTestCase; /** * Test cases for the {...@link RequestBuilder} class. */ -public class RequestBuilderTest extends GWTTestCase { - private static final int TEST_FINISH_DELAY = 10000; +public class RequestBuilderTest extends RequestTestBase { public static final String SERVLET_GET_RESPONSE = "get"; public static final String SERVLET_POST_RESPONSE = "post"; @@ -176,7 +174,7 @@ * {...@link com.google.gwt.http.client.RequestBuilder#sendRequest(java.lang.String, com.google.gwt.http.client.RequestCallback)}. */ public void testSend_GET() throws RequestException { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "send_GET"); @@ -198,7 +196,7 @@ * Test method for {...@link com.google.gwt.http.client.RequestBuilder#send()}. */ public void testSend_POST() throws RequestException { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, getTestBaseURL() + "sendRequest_POST"); @@ -223,7 +221,7 @@ * {...@link com.google.gwt.http.client.RequestBuilder#sendRequest(java.lang.String, com.google.gwt.http.client.RequestCallback)}. */ public void testSendRequest_GET() throws RequestException { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "sendRequest_GET"); @@ -245,7 +243,7 @@ * {...@link com.google.gwt.http.client.RequestBuilder#sendRequest(java.lang.String, com.google.gwt.http.client.RequestCallback)}. */ public void testSendRequest_POST() throws RequestException { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, getTestBaseURL() + "sendRequest_POST"); @@ -338,7 +336,7 @@ } catch (IllegalArgumentException expected) { } - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "setRequestHeader"); @@ -370,7 +368,7 @@ * </ul> */ public void testSetTimeout_noTimeout() throws RequestException { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "setTimeout/noTimeout"); @@ -400,7 +398,7 @@ * </ul> */ public void testSetTimeout_timeout() throws RequestException { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "setTimeout/timeout"); ======================================= --- /trunk/user/test/com/google/gwt/http/client/RequestTest.java Wed Feb 18 05:39:02 2009 +++ /trunk/user/test/com/google/gwt/http/client/RequestTest.java Tue Nov 10 10:55:44 2009 @@ -16,19 +16,18 @@ package com.google.gwt.http.client; import com.google.gwt.core.client.GWT; -import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.xhr.client.XMLHttpRequest; /** * TODO: document me. */ -public class RequestTest extends GWTTestCase { - private static final int TEST_FINISH_DELAY = 10000; +public class RequestTest extends RequestTestBase { private static String getTestBaseURL() { return GWT.getModuleBaseURL() + "testRequest/"; } + @Override public String getModuleName() { return "com.google.gwt.http.RequestTest"; } @@ -37,7 +36,7 @@ * Test method for {...@link com.google.gwt.http.client.Request#cancel()}. */ public void testCancel() { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "/cancel"); @@ -64,7 +63,7 @@ /** * Test method for - * {...@link com.google.gwt.http.client.Request#Request(com.google.gwt.core.client.JavaScriptObject, int, com.google.gwt.http.client.RequestCallback)}. + * {...@link com.google.gwt.http.client.Request#Request(XMLHttpRequest, int, RequestCallback)}. */ public void testRequest() { RequestCallback callback = new RequestCallback() { @@ -107,7 +106,7 @@ * Test method for {...@link com.google.gwt.http.client.Request#isPending()}. */ public void testIsPending() { - // delayTestFinish(TEST_FINISH_DELAY); + // delayTestFinishForRequest(); RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, getTestBaseURL() + "isPending"); ======================================= --- /trunk/user/test/com/google/gwt/http/client/ResponseTest.java Sat Mar 10 10:11:51 2007 +++ /trunk/user/test/com/google/gwt/http/client/ResponseTest.java Tue Nov 10 10:55:44 2009 @@ -16,13 +16,11 @@ package com.google.gwt.http.client; import com.google.gwt.core.client.GWT; -import com.google.gwt.junit.client.GWTTestCase; /** * */ -public class ResponseTest extends GWTTestCase { - private static final int TEST_FINISH_DELAY = 10000; +public class ResponseTest extends RequestTestBase { private static RequestBuilder getHTTPRequestBuilder() { return getHTTPRequestBuilder(getTestBaseURL()); @@ -48,6 +46,7 @@ fail("Unexpected exception: " + exception.toString()); } + @Override public String getModuleName() { return "com.google.gwt.http.ResponseTest"; } @@ -154,7 +153,7 @@ } private void executeTest(RequestBuilder builder, RequestCallback callback) { - delayTestFinish(TEST_FINISH_DELAY); + delayTestFinishForRequest(); try { builder.sendRequest(null, callback); --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---