From 4dbcbfc7a633b2abfb1db97d3c070ef15141c973 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 8 Nov 2010 10:03:03 +0100 Subject: [PATCH] updated google appengine tweetstore tests --- demos/gae-tweetstore-spring/pom.xml | 40 +++++++++---------- .../config/SpringServletConfig.java | 10 ++--- .../integration/TweetStoreLiveTest.java | 36 +++++++++-------- .../tweetstore/config/GuiceServletConfig.java | 2 +- .../integration/TweetStoreLiveTest.java | 33 +++++++-------- 5 files changed, 62 insertions(+), 59 deletions(-) diff --git a/demos/gae-tweetstore-spring/pom.xml b/demos/gae-tweetstore-spring/pom.xml index 33825908e0..bc2fa22aa5 100644 --- a/demos/gae-tweetstore-spring/pom.xml +++ b/demos/gae-tweetstore-spring/pom.xml @@ -255,44 +255,44 @@ - twitter.identity - ${jclouds.twitter.user} + test.twitter.identity + ${test.twitter.identity} - twitter.credential - ${jclouds.twitter.password} + test.twitter.credential + ${test.twitter.credential} - azureblob.identity - ${jclouds.azure.storage.account} + test.azureblob.identity + ${test.azureblob.identity} - azureblob.credential - ${jclouds.azure.storage.key} + test.azureblob.credential + ${test.azureblob.credential} - cloudfiles.identity - ${jclouds.rackspace.user} + test.cloudfiles.identity + ${test.cloudfiles.identity} - cloudfiles.credential - ${jclouds.rackspace.key} + test.cloudfiles.credential + ${test.cloudfiles.credential} - googlestorage.identity - ${jclouds.googlestorage.accesskeyid} + test.googlestorage.identity + ${test.googlestorage.identity} - googlestorage.credential - ${jclouds.googlestorage.secretaccesskey} + test.googlestorage.credential + ${test.googlestorage.credential} - s3.identity - ${jclouds.aws.accesskeyid} + test.s3.identity + ${test.s3.identity} - s3.credential - ${jclouds.aws.secretaccesskey} + test.s3.credential + ${test.s3.credential} appengine.home diff --git a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index cdfebf94a3..fb11dccccd 100644 --- a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -89,8 +89,8 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA Set modules = ImmutableSet. of(googleModule); // shared across all blobstores and used to retrieve tweets try { - twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props - .getProperty("credential")); + twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), + props.getProperty("twitter.credential")); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); } @@ -100,7 +100,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); for (String hint : Splitter.on(',').split( - checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) { + checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) { providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); } @@ -111,7 +111,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA queue.add(url("/store/do").header("context", name).method(Method.GET)); } logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient, - container, providerTypeToBlobStoreMap.keySet()); + container, providerTypeToBlobStoreMap.keySet()); } private Properties loadJCloudsProperties() { @@ -139,7 +139,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA @Bean public AddTweetsController addTweetsController() { AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap, - serviceToStoredTweetStatuses()); + serviceToStoredTweetStatuses()); injectServletConfig(controller); return controller; } diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 79c9a43a4a..77a693d46c 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -27,9 +27,9 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -70,16 +70,17 @@ public class TweetStoreLiveTest { private String container; private static final String blobs = System.getProperty("jclouds.tweetstore.blobstores", - "cloudfiles,googlestorage,s3,azureblob"); + "cloudfiles,googlestorage,s3,azureblob"); private static final Iterable blobstores = Splitter.on(',').split(blobs); private static final Properties props = new Properties(); @BeforeTest - void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException { + void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, + TwitterException { container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), - PROPERTY_TWEETSTORE_CONTAINER)); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, + checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); @@ -98,8 +99,8 @@ public class TweetStoreLiveTest { contexts.put(provider, factory.createContext(provider, wiring, props)); } - Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props - .getProperty("twitter.credential")); + Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), + props.getProperty("twitter.credential")); StoreTweetsController controller = new StoreTweetsController(contexts, container, client); ResponseList statuses = client.getMentions(); @@ -108,7 +109,7 @@ public class TweetStoreLiveTest { for (BlobStoreContext context : contexts.values()) { if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() - .getEndpoint()); + .getEndpoint()); context.getBlobStore().deleteContainer(container); deleted = true; } @@ -119,7 +120,7 @@ public class TweetStoreLiveTest { } for (BlobStoreContext context : contexts.values()) { System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() - .getEndpoint()); + .getEndpoint()); context.getBlobStore().createContainerInLocation(null, container); } if (deleted) { @@ -134,22 +135,23 @@ public class TweetStoreLiveTest { } private void addConfigurationForTwitter(Properties props) { - props.setProperty("twitter.identity", checkNotNull(System.getProperty("twitter.identity"), "twitter.identity")); - props.setProperty("twitter.credential", checkNotNull(System.getProperty("twitter.credential"), - "twitter.credential")); + props.setProperty("twitter.identity", + checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity")); + props.setProperty("twitter.credential", + checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential")); } private void addCredentialsForBlobStores(Properties props) { for (String provider : blobstores) { - props.setProperty(provider + ".identity", checkNotNull(System.getProperty(provider + ".identity"), provider - + ".identity")); - props.setProperty(provider + ".credential", checkNotNull(System.getProperty(provider + ".credential"), - provider + ".credential")); + props.setProperty(provider + ".identity", + checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity")); + props.setProperty(provider + ".credential", + checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential")); } } @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) throws Exception { url = new URL(String.format("http://%s:%s", address, port)); server = new GoogleDevServer(); diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index cbd5dd0538..5c06ae6ee8 100755 --- a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -79,7 +79,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { // shared across all blobstores and used to retrieve tweets try { twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props - .getProperty("credential")); + .getProperty("twitter.credential")); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); } 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 a6e0700e32..1ac1f1d10f 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 @@ -27,9 +27,9 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -57,8 +57,8 @@ import com.google.common.collect.Maps; import com.google.inject.Module; /** - * 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 */ @@ -75,11 +75,12 @@ public class TweetStoreLiveTest { private static final Properties props = new Properties(); @BeforeTest - void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException { + void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, + TwitterException { container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), - PROPERTY_TWEETSTORE_CONTAINER)); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, + checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); @@ -98,8 +99,8 @@ public class TweetStoreLiveTest { contexts.put(provider, factory.createContext(provider, wiring, props)); } - Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props - .getProperty("twitter.credential")); + Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), + props.getProperty("twitter.credential")); StoreTweetsController controller = new StoreTweetsController(contexts, container, client); ResponseList statuses = client.getMentions(); @@ -139,7 +140,7 @@ public class TweetStoreLiveTest { } @BeforeTest(dependsOnMethods = "clearAndCreateContainers") - @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) + @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)); @@ -148,17 +149,17 @@ public class TweetStoreLiveTest { } private void addConfigurationForTwitter(Properties props) { - props.setProperty("twitter.identity", checkNotNull(System.getProperty("twitter.identity"), "twitter.identity")); - props.setProperty("twitter.credential", checkNotNull(System.getProperty("twitter.credential"), - "twitter.credential")); + props.setProperty("twitter.identity", checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity")); + props.setProperty("twitter.credential", + checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential")); } private void addCredentialsForBlobStores(Properties props) { for (String provider : blobstores) { - props.setProperty(provider + ".identity", checkNotNull(System.getProperty(provider + ".identity"), provider - + ".identity")); - props.setProperty(provider + ".credential", checkNotNull(System.getProperty(provider + ".credential"), - provider + ".credential")); + props.setProperty(provider + ".identity", + checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity")); + props.setProperty(provider + ".credential", + checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential")); } }