mirror of https://github.com/apache/jclouds.git
Issue 26
git-svn-id: http://jclouds.googlecode.com/svn/trunk@822 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
834177f9fc
commit
950e56e327
|
@ -72,108 +72,4 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- note that the groups/excluded groups don't work due to some problem
|
||||
in surefire or testng. instead, we have to exclude via file path
|
||||
<groups>integration</groups>
|
||||
<excludedGroups>unit,performance,live</excludedGroups> -->
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest.java</include>
|
||||
</includes>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.url</name>
|
||||
<value>${jclouds.s3.httpstream.url}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.md5</name>
|
||||
<value>${jclouds.s3.httpstream.md5}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!-- note that the groups/excluded groups don't work due to some problem
|
||||
in surefire or testng. instead, we have to exclude via file path
|
||||
<groups>unit,performance</groups>
|
||||
<excludedGroups>integration,live</excludedGroups> -->
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- note that the groups/excluded groups don't work due to some problem
|
||||
in surefire or testng. instead, we have to exclude via file path
|
||||
<groups>live,integration</groups>
|
||||
<excludedGroups>unit,performance</excludedGroups> -->
|
||||
<excludes>
|
||||
<exclude>none</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest.java</include>
|
||||
<include>**/*LiveTest.java</include>
|
||||
</includes>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jclouds.aws.accesskeyid</name>
|
||||
<value>${jclouds.aws.accesskeyid}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.aws.secretaccesskey</name>
|
||||
<value>${jclouds.aws.secretaccesskey}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.url</name>
|
||||
<value>${jclouds.s3.httpstream.url}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.md5</name>
|
||||
<value>${jclouds.s3.httpstream.md5}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
104
aws/s3/pom.xml
104
aws/s3/pom.xml
|
@ -43,4 +43,108 @@
|
|||
<module>extensions</module>
|
||||
<module>samples</module>
|
||||
</modules>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- note that the groups/excluded groups don't work due to some problem
|
||||
in surefire or testng. instead, we have to exclude via file path
|
||||
<groups>integration</groups>
|
||||
<excludedGroups>unit,performance,live</excludedGroups> -->
|
||||
<excludes>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest.java</include>
|
||||
</includes>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.url</name>
|
||||
<value>${jclouds.s3.httpstream.url}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.md5</name>
|
||||
<value>${jclouds.s3.httpstream.md5}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!-- note that the groups/excluded groups don't work due to some problem
|
||||
in surefire or testng. instead, we have to exclude via file path
|
||||
<groups>unit,performance</groups>
|
||||
<excludedGroups>integration,live</excludedGroups> -->
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- note that the groups/excluded groups don't work due to some problem
|
||||
in surefire or testng. instead, we have to exclude via file path
|
||||
<groups>live,integration</groups>
|
||||
<excludedGroups>unit,performance</excludedGroups> -->
|
||||
<excludes>
|
||||
<exclude>none</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest.java</include>
|
||||
<include>**/*LiveTest.java</include>
|
||||
</includes>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jclouds.aws.accesskeyid</name>
|
||||
<value>${jclouds.aws.accesskeyid}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.aws.secretaccesskey</name>
|
||||
<value>${jclouds.aws.secretaccesskey}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.url</name>
|
||||
<value>${jclouds.s3.httpstream.url}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.s3.httpstream.md5</name>
|
||||
<value>${jclouds.s3.httpstream.md5}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -41,11 +41,9 @@
|
|||
|
||||
<properties>
|
||||
<!-- note you must set the property ${appengine.home} to a valid extraction of appengine-java-sdk -->
|
||||
<appengine.home>/Users/adriancole/Desktop/appengine-java-sdk-1.2.0</appengine.home>
|
||||
<appengine.home>/Users/adriancole/Desktop/appengine-java-sdk-1.2.1</appengine.home>
|
||||
<devappserver.address>localhost</devappserver.address>
|
||||
<devappserver.port>8088</devappserver.port>
|
||||
<jclouds.aws.accesskeyid></jclouds.aws.accesskeyid>
|
||||
<jclouds.aws.secretaccesskey></jclouds.aws.secretaccesskey>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -95,7 +93,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-tools-api</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${appengine.home}/lib/appengine-tools-api.jar</systemPath>
|
||||
</dependency>
|
||||
|
@ -103,12 +101,10 @@
|
|||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<testSourceDirectory>src/it/java</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
|
@ -117,16 +113,7 @@
|
|||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<testClassesDirectory>target/test-classes</testClassesDirectory>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jclouds.aws.accesskeyid</name>
|
||||
<value>${jclouds.aws.accesskeyid}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.aws.secretaccesskey</name>
|
||||
<value>${jclouds.aws.secretaccesskey}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>appengine.home</name>
|
||||
<value>${appengine.home}</value>
|
||||
|
@ -157,12 +144,58 @@
|
|||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!-- fool default surefire execution in 'test' to not find any test classes -->
|
||||
<testClassesDirectory>target/classes</testClassesDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>jclouds.aws.accesskeyid</name>
|
||||
<value>${jclouds.aws.accesskeyid}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.aws.secretaccesskey</name>
|
||||
<value>${jclouds.aws.secretaccesskey}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>appengine.home</name>
|
||||
<value>${appengine.home}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>devappserver.address</name>
|
||||
<value>${devappserver.address}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>devappserver.port</name>
|
||||
<value>${devappserver.port}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>warfile</name>
|
||||
<value>${project.build.directory}/${project.artifactId}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -23,28 +23,26 @@
|
|||
*/
|
||||
package org.jclouds.samples.googleappengine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import org.jclouds.aws.s3.S3Context;
|
||||
import org.jclouds.aws.s3.S3ResponseException;
|
||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jclouds.aws.s3.S3Context;
|
||||
import org.jclouds.aws.s3.S3ResponseException;
|
||||
import org.jclouds.aws.s3.domain.S3Bucket;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Shows an example of how to use @{link S3Connection} injected with Guice.
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
|
@ -59,32 +57,32 @@ public class JCloudsServlet extends HttpServlet {
|
|||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest httpServletRequest,
|
||||
HttpServletResponse httpServletResponse) throws ServletException,
|
||||
IOException {
|
||||
httpServletResponse.setContentType("text/plain");
|
||||
Writer writer = httpServletResponse.getWriter();
|
||||
try {
|
||||
List<S3Bucket.Metadata> myBuckets = context.getConnection()
|
||||
.listOwnedBuckets().get(10, TimeUnit.SECONDS);
|
||||
writer.write("List:\n");
|
||||
for (S3Bucket.Metadata bucket : myBuckets) {
|
||||
writer.write(String.format(" %1$s", bucket));
|
||||
try {
|
||||
writer.write(String.format(": %1$s entries%n", context
|
||||
.createInputStreamMap(bucket.getName()).size()));
|
||||
} catch (S3ResponseException e) {
|
||||
String message = String.format(
|
||||
": unable to list entries due to: %1$s%n", e
|
||||
.getError().getCode());
|
||||
writer.write(message);
|
||||
logger.warn(e, "message");
|
||||
}
|
||||
HttpServletResponse httpServletResponse) throws ServletException,
|
||||
IOException {
|
||||
httpServletResponse.setContentType("text/plain");
|
||||
Writer writer = httpServletResponse.getWriter();
|
||||
try {
|
||||
List<S3Bucket.Metadata> myBuckets = context.getConnection()
|
||||
.listOwnedBuckets().get(10, TimeUnit.SECONDS);
|
||||
writer.write("List:\n");
|
||||
for (S3Bucket.Metadata bucket : myBuckets) {
|
||||
writer.write(String.format(" %1$s", bucket));
|
||||
try {
|
||||
writer.write(String.format(": %1$s entries%n", context
|
||||
.createInputStreamMap(bucket.getName()).size()));
|
||||
} catch (S3ResponseException e) {
|
||||
String message = String.format(
|
||||
": unable to list entries due to: %1$s%n", e
|
||||
.getError().getCode());
|
||||
writer.write(message);
|
||||
logger.warn(e, "message");
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
|
@ -23,12 +23,10 @@
|
|||
*/
|
||||
package org.jclouds.samples.googleappengine.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.aws.s3.S3Context;
|
||||
import org.jclouds.aws.s3.S3ContextFactory;
|
||||
|
@ -36,17 +34,15 @@ import org.jclouds.aws.s3.reference.S3Constants;
|
|||
import org.jclouds.gae.config.URLFetchServiceClientModule;
|
||||
import org.jclouds.samples.googleappengine.JCloudsServlet;
|
||||
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Setup Logging and create Injector for use in testing S3.
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class GuiceServletConfig extends GuiceServletContextListener {
|
||||
@Inject
|
||||
|
@ -56,45 +52,45 @@ public class GuiceServletConfig extends GuiceServletContextListener {
|
|||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
Properties props = loadJCloudsProperties(servletContextEvent);
|
||||
this.accessKeyId = props
|
||||
.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
|
||||
this.secretAccessKey = props
|
||||
.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
|
||||
super.contextInitialized(servletContextEvent);
|
||||
Properties props = loadJCloudsProperties(servletContextEvent);
|
||||
this.accessKeyId = props
|
||||
.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
|
||||
this.secretAccessKey = props
|
||||
.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
|
||||
super.contextInitialized(servletContextEvent);
|
||||
}
|
||||
|
||||
private Properties loadJCloudsProperties(
|
||||
ServletContextEvent servletContextEvent) {
|
||||
InputStream input = servletContextEvent.getServletContext()
|
||||
.getResourceAsStream("/WEB-INF/jclouds.properties");
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
props.load(input);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(input);
|
||||
}
|
||||
return props;
|
||||
ServletContextEvent servletContextEvent) {
|
||||
InputStream input = servletContextEvent.getServletContext()
|
||||
.getResourceAsStream("/WEB-INF/jclouds.properties");
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
props.load(input);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(input);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return S3ContextFactory.createInjector(accessKeyId, secretAccessKey,
|
||||
false, new URLFetchServiceClientModule(),
|
||||
new ServletModule() {
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
serve("*.s3").with(JCloudsServlet.class);
|
||||
requestInjection(this);
|
||||
}
|
||||
});
|
||||
return S3ContextFactory.createInjector(accessKeyId, secretAccessKey,
|
||||
false, new URLFetchServiceClientModule(),
|
||||
new ServletModule() {
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
serve("*.s3").with(JCloudsServlet.class);
|
||||
requestInjection(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
context.close();
|
||||
super.contextDestroyed(servletContextEvent);
|
||||
context.close();
|
||||
super.contextDestroyed(servletContextEvent);
|
||||
}
|
||||
}
|
|
@ -24,12 +24,6 @@
|
|||
package org.jclouds.samples.googleappengine.functest;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.aws.s3.reference.S3Constants;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -37,65 +31,74 @@ import org.testng.annotations.Optional;
|
|||
import org.testng.annotations.Parameters;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* Starts up the Google App Engine for Java Development environment and deploys
|
||||
* an application which tests S3.
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Test(groups = "integration", enabled = true, sequential = true, testName = "functionalTests")
|
||||
public class GoogleAppEngineTest extends BaseGoogleAppEngineTest {
|
||||
@Test(groups = "live", sequential = true, testName = "functionalTests")
|
||||
public class GoogleAppEngineLiveTest {
|
||||
|
||||
GoogleDevServer server;
|
||||
private static final String sysAWSAccessKeyId = System
|
||||
.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
|
||||
.getProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID);
|
||||
private static final String sysAWSSecretAccessKey = System
|
||||
.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
|
||||
.getProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY);
|
||||
private URL url;
|
||||
|
||||
@BeforeTest
|
||||
@Parameters( { "warfile", "devappserver.address", "devappserver.port",
|
||||
S3Constants.PROPERTY_AWS_ACCESSKEYID,
|
||||
S3Constants.PROPERTY_AWS_SECRETACCESSKEY })
|
||||
@Parameters({"warfile", "devappserver.address", "devappserver.port",
|
||||
S3Constants.PROPERTY_AWS_ACCESSKEYID,
|
||||
S3Constants.PROPERTY_AWS_SECRETACCESSKEY})
|
||||
public void startDevAppServer(final String warfile, final String address,
|
||||
final String port, @Optional String AWSAccessKeyId,
|
||||
@Optional String AWSSecretAccessKey) throws Exception {
|
||||
AWSAccessKeyId = AWSAccessKeyId != null ? AWSAccessKeyId
|
||||
: sysAWSAccessKeyId;
|
||||
AWSSecretAccessKey = AWSSecretAccessKey != null ? AWSSecretAccessKey
|
||||
: sysAWSSecretAccessKey;
|
||||
final String port, @Optional String AWSAccessKeyId,
|
||||
@Optional String AWSSecretAccessKey) throws Exception {
|
||||
url = new URL(String.format("http://%1$s:%2$s", address, port));
|
||||
|
||||
checkNotNull(AWSAccessKeyId, "AWSAccessKeyId");
|
||||
checkNotNull(AWSSecretAccessKey, "AWSSecretAccessKey");
|
||||
AWSAccessKeyId = AWSAccessKeyId != null ? AWSAccessKeyId
|
||||
: sysAWSAccessKeyId;
|
||||
AWSSecretAccessKey = AWSSecretAccessKey != null ? AWSSecretAccessKey
|
||||
: sysAWSSecretAccessKey;
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put(S3Constants.PROPERTY_AWS_ACCESSKEYID, AWSAccessKeyId);
|
||||
props.put(S3Constants.PROPERTY_AWS_SECRETACCESSKEY, AWSSecretAccessKey);
|
||||
writePropertiesAndStartServer(address, port, warfile, props);
|
||||
checkNotNull(AWSAccessKeyId, "AWSAccessKeyId");
|
||||
checkNotNull(AWSSecretAccessKey, "AWSSecretAccessKey");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put(S3Constants.PROPERTY_AWS_ACCESSKEYID, AWSAccessKeyId);
|
||||
props.put(S3Constants.PROPERTY_AWS_SECRETACCESSKEY, AWSSecretAccessKey);
|
||||
server = new GoogleDevServer();
|
||||
server.writePropertiesAndStartServer(address, port, warfile, props);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPass() throws InterruptedException, IOException {
|
||||
InputStream i = url.openStream();
|
||||
String string = IOUtils.toString(i);
|
||||
assert string.indexOf("Hello World!") >= 0 : string;
|
||||
InputStream i = url.openStream();
|
||||
String string = IOUtils.toString(i);
|
||||
assert string.indexOf("Hello World!") >= 0 : string;
|
||||
}
|
||||
|
||||
@Test(invocationCount = 5, enabled = true)
|
||||
public void testGuiceJCloudsSerial() throws InterruptedException,
|
||||
IOException {
|
||||
URL gurl = new URL(url, "/guice/listbuckets.s3");
|
||||
InputStream i = gurl.openStream();
|
||||
String string = IOUtils.toString(i);
|
||||
assert string.indexOf("List") >= 0 : string;
|
||||
IOException {
|
||||
URL gurl = new URL(url, "/guice/listbuckets.s3");
|
||||
InputStream i = gurl.openStream();
|
||||
String string = IOUtils.toString(i);
|
||||
assert string.indexOf("List") >= 0 : string;
|
||||
}
|
||||
|
||||
@Test(invocationCount = 50, enabled = true, threadPoolSize = 10)
|
||||
public void testGuiceJCloudsParallel() throws InterruptedException,
|
||||
IOException {
|
||||
URL gurl = new URL(url, "/guice/listbuckets.s3");
|
||||
InputStream i = gurl.openStream();
|
||||
String string = IOUtils.toString(i);
|
||||
assert string.indexOf("List") >= 0 : string;
|
||||
IOException {
|
||||
URL gurl = new URL(url, "/guice/listbuckets.s3");
|
||||
InputStream i = gurl.openStream();
|
||||
String string = IOUtils.toString(i);
|
||||
assert string.indexOf("List") >= 0 : string;
|
||||
}
|
||||
}
|
|
@ -23,53 +23,48 @@
|
|||
*/
|
||||
package org.jclouds.samples.googleappengine.functest;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import com.google.appengine.tools.KickStart;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.testng.annotations.AfterTest;
|
||||
|
||||
import com.google.appengine.tools.KickStart;
|
||||
|
||||
/**
|
||||
* Basic functionality to start a local google app engine instance.
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public abstract class BaseGoogleAppEngineTest {
|
||||
public class GoogleDevServer {
|
||||
|
||||
Thread server;
|
||||
URL url;
|
||||
|
||||
protected void writePropertiesAndStartServer(final String address,
|
||||
final String port, final String warfile, Properties props)
|
||||
throws IOException, FileNotFoundException, InterruptedException {
|
||||
url = new URL(String.format("http://%1$s:%2$s", address, port));
|
||||
public void writePropertiesAndStartServer(final String address,
|
||||
final String port, final String warfile, Properties props)
|
||||
throws IOException, InterruptedException {
|
||||
String filename = String.format(
|
||||
"%1$s/WEB-INF/jclouds.properties", warfile);
|
||||
System.err.println("file: " + filename);
|
||||
props.store(new FileOutputStream(filename), "test");
|
||||
assert new File(filename).exists();
|
||||
this.server = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
KickStart
|
||||
.main(new String[]{
|
||||
"com.google.appengine.tools.development.DevAppServerMain",
|
||||
"--disable_update_check", "-a", address, "-p",
|
||||
port, warfile});
|
||||
|
||||
props.store(new FileOutputStream(String.format(
|
||||
"%1$s/WEB-INF/jclouds.properties", warfile)), "test");
|
||||
this.server = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
KickStart
|
||||
.main(new String[] {
|
||||
"com.google.appengine.tools.development.DevAppServerMain",
|
||||
"--disable_update_check", "-a", address, "-p",
|
||||
port, warfile });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
server.start();
|
||||
Thread.sleep(7 * 1000);
|
||||
});
|
||||
server.start();
|
||||
Thread.sleep(10 * 1000);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@AfterTest
|
||||
public void stopDevAppServer() throws Exception {
|
||||
server.stop();
|
||||
public void stop() throws Exception {
|
||||
server.stop();
|
||||
}
|
||||
|
||||
}
|
|
@ -50,18 +50,18 @@
|
|||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-api</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-api-stubs</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-local-runtime</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue