integration tests for gae

git-svn-id: http://jclouds.googlecode.com/svn/trunk@394 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-05-05 18:37:03 +00:00
parent 31da8c19f2
commit 23b956f894
6 changed files with 57 additions and 18 deletions

View File

@ -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<String>() {

View File

@ -52,6 +52,18 @@
<artifactId>appengine-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-local-runtime</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId>
@ -63,6 +75,21 @@
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -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) {

View File

@ -34,7 +34,7 @@
<relativePath>../../project/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jclouds-samples-googleappengine</artifactId>
<artifactId>jclouds-gae-s3-example</artifactId>
<packaging>war</packaging>
<name>JClouds Sample for Google App Engine</name>
<description>JClouds Sample for Google App Engine</description>

View File

@ -25,6 +25,6 @@
-->
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>application-id</application>
<application>jclouds-s3-example</application>
<version>1</version>
</appengine-web-app>

View File

@ -28,7 +28,7 @@
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<display-name>Archetype Created Web Application</display-name>
<display-name>jclouds-s3-example</display-name>
<!-- Servlets -->
<filter>