From 51b5f2583e66ca5f4189ec2eea21b72790fcb5f3 Mon Sep 17 00:00:00 2001 From: "sharedocs1@gmail.com" Date: Sat, 2 Jan 2010 18:56:21 +0000 Subject: [PATCH] Formatting. git-svn-id: http://jclouds.googlecode.com/svn/trunk@2572 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../integration/TweetStoreLiveTest.java | 238 +++++++++--------- 1 file changed, 120 insertions(+), 118 deletions(-) diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 1bad9dc116..6460624dfb 100755 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -58,144 +58,146 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * Starts up the Google App Engine for Java Development environment and deploys an application which - * tests accesses twitter and blobstores. + * Starts up the Google App Engine for Java Development environment and deploys + * an application which tests accesses twitter and blobstores. * * @author Adrian Cole */ @Test(groups = "live", sequential = true, testName = "functionalTests") public class TweetStoreLiveTest { - GoogleDevServer server; - private URL url; - private ImmutableSet> contexts; - private String container; + GoogleDevServer server; + private URL url; + private ImmutableSet> contexts; + private String container; - @BeforeTest - @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) - public void startDevAppServer(final String warfile, final String address, final String port) - throws Exception { - url = new URL(String.format("http://%s:%s", address, port)); - Properties props = new Properties(); - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System - .getProperty(PROPERTY_TWEETSTORE_CONTAINER))); - props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, - // WATCH THIS.. when adding a new context, you must update the string - String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), - CloudFilesBlobStoreContextBuilder.class.getName(), - AzureBlobStoreContextBuilder.class.getName())); + @BeforeTest + @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) + public void startDevAppServer(final String warfile, final String address, + final String port) throws Exception { + url = new URL(String.format("http://%s:%s", address, port)); + Properties props = new Properties(); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, + checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); + props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, + // WATCH THIS.. when adding a new context, you must update the string + String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), + CloudFilesBlobStoreContextBuilder.class.getName(), + AzureBlobStoreContextBuilder.class.getName())); - props = new TwitterPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), - System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build(); + props = new TwitterPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), + System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)) + .build(); - props = new S3PropertiesBuilder(props) - .withCredentials( - checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), - PROPERTY_AWS_ACCESSKEYID), - System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, - PROPERTY_AWS_SECRETACCESSKEY)).build(); + props = new S3PropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), + System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)) + .build(); - props = new CloudFilesPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), - System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)).build(); + props = new CloudFilesPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)) + .build(); - props = new AzureBlobPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), - PROPERTY_AZURESTORAGE_ACCOUNT), - System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)).build(); + props = new AzureBlobPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), + System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)) + .build(); - server = new GoogleDevServer(); - server.writePropertiesAndStartServer(address, port, warfile, props); - } + server = new GoogleDevServer(); + server.writePropertiesAndStartServer(address, port, warfile, props); + } - @BeforeClass - void clearAndCreateContainers() throws InterruptedException, ExecutionException, - TimeoutException { - container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext(checkNotNull( - System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System - .getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); + @BeforeClass + void clearAndCreateContainers() throws InterruptedException, + ExecutionException, TimeoutException { + container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); + BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext( + checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), + System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); - BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), - System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); + BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); - BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext(checkNotNull( - System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), - System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); + BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext( + checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), + System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); - this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); - boolean deleted = false; - for (BlobStoreContext context : contexts) { - if (context.getBlobStore().containerExists(container)) { - System.err.printf("deleting container %s at %s%n", container, context.getEndPoint()); - context.getBlobStore().deleteContainer(container); - deleted = true; - } - } - if (deleted) { - System.err.println("sleeping 30 seconds to allow containers to clear"); - Thread.sleep(30000); - } - for (BlobStoreContext context : contexts) { - System.err.printf("creating container %s at %s%n", container, context.getEndPoint()); - context.getBlobStore().createContainer(container); - } - if (deleted) { - System.err.println("sleeping 5 seconds to allow containers to create"); - Thread.sleep(30000); - } - } + this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); + boolean deleted = false; + for (BlobStoreContext context : contexts) { + if (context.getBlobStore().containerExists(container)) { + System.err.printf("deleting container %s at %s%n", container, + context.getEndPoint()); + context.getBlobStore().deleteContainer(container); + deleted = true; + } + } + if (deleted) { + System.err.println("sleeping 30 seconds to allow containers to clear"); + Thread.sleep(30000); + } + for (BlobStoreContext context : contexts) { + System.err.printf("creating container %s at %s%n", container, + context.getEndPoint()); + context.getBlobStore().createContainer(container); + } + if (deleted) { + System.err.println("sleeping 5 seconds to allow containers to create"); + Thread.sleep(30000); + } + } - @Test - public void shouldPass() throws InterruptedException, IOException { - InputStream i = url.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Welcome") >= 0 : string; - } + @Test + public void shouldPass() throws InterruptedException, IOException { + InputStream i = url.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Welcome") >= 0 : string; + } - @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) - public void shouldFail() throws InterruptedException, IOException { - new URL(url, "/store/do").openStream(); - } + @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) + public void shouldFail() throws InterruptedException, IOException { + new URL(url, "/store/do").openStream(); + } - @Test(dependsOnMethods = "shouldFail") - public void testPrimeContainers() throws IOException, InterruptedException { - URL gurl = new URL(url, "/store/do"); + @Test(dependsOnMethods = "shouldFail") + public void testPrimeContainers() throws IOException, InterruptedException { + URL gurl = new URL(url, "/store/do"); - for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { - System.out.println("storing at context: " + context); - HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); - connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); - connection.addRequestProperty("context", context); - InputStream i = connection.getInputStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Done!") >= 0 : string; - connection.disconnect(); - } + for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { + System.out.println("storing at context: " + context); + HttpURLConnection connection = (HttpURLConnection) gurl + .openConnection(); + connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); + connection.addRequestProperty("context", context); + InputStream i = connection.getInputStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Done!") >= 0 : string; + connection.disconnect(); + } - System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); - Thread.sleep(10000); - for (BlobStoreContext context : contexts) { + System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); + Thread.sleep(10000); + for (BlobStoreContext context : contexts) { + assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); + } + } - assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); - } - } + @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") + public void testSerial() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } - @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") - public void testSerial() throws InterruptedException, IOException { - URL gurl = new URL(url, "/tweets/get"); - InputStream i = gurl.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Tweets in Clouds") >= 0 : string; - } - - @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) - public void testParallel() throws InterruptedException, IOException { - URL gurl = new URL(url, "/tweets/get"); - InputStream i = gurl.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Tweets in Clouds") >= 0 : string; - } -} + @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) + public void testParallel() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } +} \ No newline at end of file