Formatting.

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2572 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
sharedocs1@gmail.com 2010-01-02 18:56:21 +00:00
parent 71ddcd5c87
commit 51b5f2583e
1 changed files with 120 additions and 118 deletions

View File

@ -58,8 +58,8 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
* Starts up the Google App Engine for Java Development environment and deploys an application which * Starts up the Google App Engine for Java Development environment and deploys
* tests accesses twitter and blobstores. * an application which tests accesses twitter and blobstores.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -73,12 +73,12 @@ public class TweetStoreLiveTest {
@BeforeTest @BeforeTest
@Parameters( { "warfile", "devappserver.address", "devappserver.port" }) @Parameters( { "warfile", "devappserver.address", "devappserver.port" })
public void startDevAppServer(final String warfile, final String address, final String port) public void startDevAppServer(final String warfile, final String address,
throws Exception { final String port) throws Exception {
url = new URL(String.format("http://%s:%s", address, port)); url = new URL(String.format("http://%s:%s", address, port));
Properties props = new Properties(); Properties props = new Properties();
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System props.setProperty(PROPERTY_TWEETSTORE_CONTAINER,
.getProperty(PROPERTY_TWEETSTORE_CONTAINER))); checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS,
// WATCH THIS.. when adding a new context, you must update the string // WATCH THIS.. when adding a new context, you must update the string
String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(),
@ -87,49 +87,50 @@ public class TweetStoreLiveTest {
props = new TwitterPropertiesBuilder(props).withCredentials( props = new TwitterPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER),
System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build(); System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD))
.build();
props = new S3PropertiesBuilder(props) props = new S3PropertiesBuilder(props).withCredentials(
.withCredentials( checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID),
checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY))
PROPERTY_AWS_ACCESSKEYID), .build();
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY,
PROPERTY_AWS_SECRETACCESSKEY)).build();
props = new CloudFilesPropertiesBuilder(props).withCredentials( props = new CloudFilesPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER),
System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)).build(); System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY))
.build();
props = new AzureBlobPropertiesBuilder(props).withCredentials( props = new AzureBlobPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT),
PROPERTY_AZURESTORAGE_ACCOUNT), System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY))
System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)).build(); .build();
server = new GoogleDevServer(); server = new GoogleDevServer();
server.writePropertiesAndStartServer(address, port, warfile, props); server.writePropertiesAndStartServer(address, port, warfile, props);
} }
@BeforeClass @BeforeClass
void clearAndCreateContainers() throws InterruptedException, ExecutionException, void clearAndCreateContainers() throws InterruptedException,
TimeoutException { ExecutionException, TimeoutException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
BlobStoreContext<?, ?> s3Context = S3BlobStoreContextFactory.createContext(checkNotNull( BlobStoreContext<?, ?> s3Context = S3BlobStoreContextFactory.createContext(
System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID),
.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY));
BlobStoreContext<?, ?> cfContext = CloudFilesBlobStoreContextFactory.createContext( BlobStoreContext<?, ?> cfContext = CloudFilesBlobStoreContextFactory.createContext(
checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER),
System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY));
BlobStoreContext<?, ?> azContext = AzureBlobStoreContextFactory.createContext(checkNotNull( BlobStoreContext<?, ?> azContext = AzureBlobStoreContextFactory.createContext(
System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT),
System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY));
this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); this.contexts = ImmutableSet.of(s3Context, cfContext, azContext);
boolean deleted = false; boolean deleted = false;
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
if (context.getBlobStore().containerExists(container)) { if (context.getBlobStore().containerExists(container)) {
System.err.printf("deleting container %s at %s%n", container, context.getEndPoint()); System.err.printf("deleting container %s at %s%n", container,
context.getEndPoint());
context.getBlobStore().deleteContainer(container); context.getBlobStore().deleteContainer(container);
deleted = true; deleted = true;
} }
@ -139,7 +140,8 @@ public class TweetStoreLiveTest {
Thread.sleep(30000); Thread.sleep(30000);
} }
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
System.err.printf("creating container %s at %s%n", container, context.getEndPoint()); System.err.printf("creating container %s at %s%n", container,
context.getEndPoint());
context.getBlobStore().createContainer(container); context.getBlobStore().createContainer(container);
} }
if (deleted) { if (deleted) {
@ -166,7 +168,8 @@ public class TweetStoreLiveTest {
for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { for (String context : new String[] { "S3", "Azure", "CloudFiles" }) {
System.out.println("storing at context: " + context); System.out.println("storing at context: " + context);
HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); HttpURLConnection connection = (HttpURLConnection) gurl
.openConnection();
connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); connection.addRequestProperty("X-AppEngine-QueueName", "twitter");
connection.addRequestProperty("context", context); connection.addRequestProperty("context", context);
InputStream i = connection.getInputStream(); InputStream i = connection.getInputStream();
@ -178,7 +181,6 @@ public class TweetStoreLiveTest {
System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); System.err.println("sleeping 10 seconds to allow for eventual consistency delay");
Thread.sleep(10000); Thread.sleep(10000);
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint();
} }
} }