From 23b956f89448e8b7cb52531a6f2331a9ee22520f Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Tue, 5 May 2009 18:37:03 +0000 Subject: [PATCH] integration tests for gae git-svn-id: http://jclouds.googlecode.com/svn/trunk@394 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../http/BaseHttpFutureCommandClientTest.java | 18 ++++++------- gae/pom.xml | 27 +++++++++++++++++++ .../jclouds/gae/URLFetchServiceClient.java | 24 ++++++++++++----- samples/googleappengine/pom.xml | 2 +- .../src/main/webapp/WEB-INF/appengine-web.xml | 2 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- 6 files changed, 57 insertions(+), 18 deletions(-) diff --git a/core/src/test/java/org/jclouds/http/BaseHttpFutureCommandClientTest.java b/core/src/test/java/org/jclouds/http/BaseHttpFutureCommandClientTest.java index 8df93aa13f..cd589562dd 100644 --- a/core/src/test/java/org/jclouds/http/BaseHttpFutureCommandClientTest.java +++ b/core/src/test/java/org/jclouds/http/BaseHttpFutureCommandClientTest.java @@ -49,8 +49,8 @@ import org.mortbay.jetty.Handler; import org.mortbay.jetty.Request; import org.mortbay.jetty.Server; import org.mortbay.jetty.handler.AbstractHandler; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -77,7 +77,7 @@ public abstract class BaseHttpFutureCommandClientTest { protected Injector injector; private Closer closer; - @BeforeClass + @BeforeTest @Parameters( { "test-jetty-port" }) public void setUpJetty(@Optional("8123") final int testPort) throws Exception { @@ -152,14 +152,14 @@ public abstract class BaseHttpFutureCommandClientTest { protected abstract Module createClientModule(); - @AfterClass + @AfterTest public void tearDownJetty() throws Exception { closer.close(); server.stop(); } @Test(invocationCount = 500, timeOut = 1500) - void testRequestFilter() throws MalformedURLException, ExecutionException, + public void testRequestFilter() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException { GetString get = factory.createGetString("/"); get.getRequest().getHeaders().put("filterme", "filterme"); @@ -170,7 +170,7 @@ public abstract class BaseHttpFutureCommandClientTest { } @Test(invocationCount = 500, timeOut = 1500) - void testGetStringWithHeader() throws MalformedURLException, + public void testGetStringWithHeader() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException { GetString get = factory.createGetString("/"); get.getRequest().getHeaders().put("test", "test"); @@ -181,7 +181,7 @@ public abstract class BaseHttpFutureCommandClientTest { } @Test(invocationCount = 500, timeOut = 1500) - void testGetString() throws MalformedURLException, ExecutionException, + public void testGetString() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException { GetString get = factory.createGetString("/"); assert get != null; @@ -192,7 +192,7 @@ public abstract class BaseHttpFutureCommandClientTest { } @Test(invocationCount = 500, timeOut = 1500) - void testHead() throws MalformedURLException, ExecutionException, + public void testHead() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException { Head head = factory.createHead("/"); assert head != null; @@ -201,7 +201,7 @@ public abstract class BaseHttpFutureCommandClientTest { } @Test(invocationCount = 500, timeOut = 1500) - void testGetAndParseSax() throws MalformedURLException, ExecutionException, + public void testGetAndParseSax() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException { GetAndParseSax getAndParseSax = factory.createGetAndParseSax("/", new ParseSax.HandlerWithResult() { diff --git a/gae/pom.xml b/gae/pom.xml index 5f434c8e79..134487597e 100644 --- a/gae/pom.xml +++ b/gae/pom.xml @@ -52,6 +52,18 @@ appengine-api 1.2.0 + + com.google.appengine + appengine-api-stubs + 1.2.0 + test + + + com.google.appengine + appengine-local-runtime + 1.2.0 + test + ${project.groupId} jclouds-core @@ -63,6 +75,21 @@ ${project.version} test-jar test + + + org.mortbay.jetty + jetty + + + + + org.apache.geronimo.specs + geronimo-servlet_2.5_spec + 1.2 + provided + + + diff --git a/gae/src/main/java/org/jclouds/gae/URLFetchServiceClient.java b/gae/src/main/java/org/jclouds/gae/URLFetchServiceClient.java index 3031f0f036..509ea1d836 100644 --- a/gae/src/main/java/org/jclouds/gae/URLFetchServiceClient.java +++ b/gae/src/main/java/org/jclouds/gae/URLFetchServiceClient.java @@ -90,12 +90,24 @@ public class URLFetchServiceClient implements HttpFutureCommandClient { for (HttpRequestFilter filter : getRequestFilters()) { filter.filter(request); } - logger.trace("%1s - converting request %2s", target, request); - HTTPRequest gaeRequest = convert(request); - logger.trace("%1s - submitting request %2s", target, gaeRequest); - gaeResponse = this.urlFetchService.fetch(gaeRequest); - logger.trace("%1s - received response %2s", target, gaeResponse); - HttpResponse response = convert(gaeResponse); + HttpResponse response = null; + for (;;) { + logger.trace("%1s - converting request %2s", target, request); + HTTPRequest gaeRequest = convert(request); + logger + .trace("%1s - submitting request %2s", target, + gaeRequest); + gaeResponse = this.urlFetchService.fetch(gaeRequest); + logger + .trace("%1s - received response %2s", target, + gaeResponse); + response = convert(gaeResponse); + if (response.getStatusCode() >= 500) { + continue; + } + break; + + } operation.getResponseFuture().setResponse(response); operation.getResponseFuture().run(); } catch (Exception e) { diff --git a/samples/googleappengine/pom.xml b/samples/googleappengine/pom.xml index b6371e5852..1395cc53e5 100644 --- a/samples/googleappengine/pom.xml +++ b/samples/googleappengine/pom.xml @@ -34,7 +34,7 @@ ../../project/pom.xml 4.0.0 - jclouds-samples-googleappengine + jclouds-gae-s3-example war JClouds Sample for Google App Engine JClouds Sample for Google App Engine diff --git a/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml b/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml index 0a16ea656f..565444e69c 100644 --- a/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml +++ b/samples/googleappengine/src/main/webapp/WEB-INF/appengine-web.xml @@ -25,6 +25,6 @@ --> - application-id + jclouds-s3-example 1 diff --git a/samples/googleappengine/src/main/webapp/WEB-INF/web.xml b/samples/googleappengine/src/main/webapp/WEB-INF/web.xml index 1c685ac271..83a65fefcb 100644 --- a/samples/googleappengine/src/main/webapp/WEB-INF/web.xml +++ b/samples/googleappengine/src/main/webapp/WEB-INF/web.xml @@ -28,7 +28,7 @@ "http://java.sun.com/dtd/web-app_2_3.dtd"> - Archetype Created Web Application + jclouds-s3-example