updated google appengine tweetstore tests

This commit is contained in:
Adrian Cole 2010-11-08 10:03:03 +01:00
parent a0fbeb96e7
commit 4dbcbfc7a6
5 changed files with 62 additions and 59 deletions

View File

@ -255,44 +255,44 @@
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
<name>twitter.identity</name> <name>test.twitter.identity</name>
<value>${jclouds.twitter.user}</value> <value>${test.twitter.identity}</value>
</property> </property>
<property> <property>
<name>twitter.credential</name> <name>test.twitter.credential</name>
<value>${jclouds.twitter.password}</value> <value>${test.twitter.credential}</value>
</property> </property>
<property> <property>
<name>azureblob.identity</name> <name>test.azureblob.identity</name>
<value>${jclouds.azure.storage.account}</value> <value>${test.azureblob.identity}</value>
</property> </property>
<property> <property>
<name>azureblob.credential</name> <name>test.azureblob.credential</name>
<value>${jclouds.azure.storage.key}</value> <value>${test.azureblob.credential}</value>
</property> </property>
<property> <property>
<name>cloudfiles.identity</name> <name>test.cloudfiles.identity</name>
<value>${jclouds.rackspace.user}</value> <value>${test.cloudfiles.identity}</value>
</property> </property>
<property> <property>
<name>cloudfiles.credential</name> <name>test.cloudfiles.credential</name>
<value>${jclouds.rackspace.key}</value> <value>${test.cloudfiles.credential}</value>
</property> </property>
<property> <property>
<name>googlestorage.identity</name> <name>test.googlestorage.identity</name>
<value>${jclouds.googlestorage.accesskeyid}</value> <value>${test.googlestorage.identity}</value>
</property> </property>
<property> <property>
<name>googlestorage.credential</name> <name>test.googlestorage.credential</name>
<value>${jclouds.googlestorage.secretaccesskey}</value> <value>${test.googlestorage.credential}</value>
</property> </property>
<property> <property>
<name>s3.identity</name> <name>test.s3.identity</name>
<value>${jclouds.aws.accesskeyid}</value> <value>${test.s3.identity}</value>
</property> </property>
<property> <property>
<name>s3.credential</name> <name>test.s3.credential</name>
<value>${jclouds.aws.secretaccesskey}</value> <value>${test.s3.credential}</value>
</property> </property>
<property> <property>
<name>appengine.home</name> <name>appengine.home</name>

View File

@ -89,8 +89,8 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
Set<Module> modules = ImmutableSet.<Module> of(googleModule); Set<Module> modules = ImmutableSet.<Module> of(googleModule);
// shared across all blobstores and used to retrieve tweets // shared across all blobstores and used to retrieve tweets
try { try {
twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
.getProperty("credential")); props.getProperty("twitter.credential"));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
} }

View File

@ -27,9 +27,9 @@ import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -75,11 +75,12 @@ public class TweetStoreLiveTest {
private static final Properties props = new Properties(); private static final Properties props = new Properties();
@BeforeTest @BeforeTest
void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException { void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), props.setProperty(PROPERTY_TWEETSTORE_CONTAINER,
PROPERTY_TWEETSTORE_CONTAINER)); checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); 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)); contexts.put(provider, factory.createContext(provider, wiring, props));
} }
Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
.getProperty("twitter.credential")); props.getProperty("twitter.credential"));
StoreTweetsController controller = new StoreTweetsController(contexts, container, client); StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
ResponseList<Status> statuses = client.getMentions(); ResponseList<Status> statuses = client.getMentions();
@ -134,22 +135,23 @@ public class TweetStoreLiveTest {
} }
private void addConfigurationForTwitter(Properties props) { private void addConfigurationForTwitter(Properties props) {
props.setProperty("twitter.identity", checkNotNull(System.getProperty("twitter.identity"), "twitter.identity")); props.setProperty("twitter.identity",
props.setProperty("twitter.credential", checkNotNull(System.getProperty("twitter.credential"), checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity"));
"twitter.credential")); props.setProperty("twitter.credential",
checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential"));
} }
private void addCredentialsForBlobStores(Properties props) { private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) { for (String provider : blobstores) {
props.setProperty(provider + ".identity", checkNotNull(System.getProperty(provider + ".identity"), provider props.setProperty(provider + ".identity",
+ ".identity")); checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"));
props.setProperty(provider + ".credential", checkNotNull(System.getProperty(provider + ".credential"), props.setProperty(provider + ".credential",
provider + ".credential")); checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential"));
} }
} }
@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) throws Exception { public void startDevAppServer(final String warfile, final String address, 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));
server = new GoogleDevServer(); server = new GoogleDevServer();

View File

@ -79,7 +79,7 @@ public class GuiceServletConfig extends GuiceServletContextListener {
// shared across all blobstores and used to retrieve tweets // shared across all blobstores and used to retrieve tweets
try { try {
twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
.getProperty("credential")); .getProperty("twitter.credential"));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
} }

View File

@ -27,9 +27,9 @@ import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -57,8 +57,8 @@ import com.google.common.collect.Maps;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
* Starts up the Google App Engine for Java Development environment and deploys * Starts up the Google App Engine for Java Development environment and deploys an application which
* an application which tests accesses twitter and blobstores. * tests accesses twitter and blobstores.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -75,11 +75,12 @@ public class TweetStoreLiveTest {
private static final Properties props = new Properties(); private static final Properties props = new Properties();
@BeforeTest @BeforeTest
void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException { void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), props.setProperty(PROPERTY_TWEETSTORE_CONTAINER,
PROPERTY_TWEETSTORE_CONTAINER)); checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); 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)); contexts.put(provider, factory.createContext(provider, wiring, props));
} }
Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
.getProperty("twitter.credential")); props.getProperty("twitter.credential"));
StoreTweetsController controller = new StoreTweetsController(contexts, container, client); StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
ResponseList<Status> statuses = client.getMentions(); ResponseList<Status> statuses = client.getMentions();
@ -139,7 +140,7 @@ public class TweetStoreLiveTest {
} }
@BeforeTest(dependsOnMethods = "clearAndCreateContainers") @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 { public void startDevAppServer(final String warfile, final String address, 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));
@ -148,17 +149,17 @@ public class TweetStoreLiveTest {
} }
private void addConfigurationForTwitter(Properties props) { private void addConfigurationForTwitter(Properties props) {
props.setProperty("twitter.identity", checkNotNull(System.getProperty("twitter.identity"), "twitter.identity")); props.setProperty("twitter.identity", checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity"));
props.setProperty("twitter.credential", checkNotNull(System.getProperty("twitter.credential"), props.setProperty("twitter.credential",
"twitter.credential")); checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential"));
} }
private void addCredentialsForBlobStores(Properties props) { private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) { for (String provider : blobstores) {
props.setProperty(provider + ".identity", checkNotNull(System.getProperty(provider + ".identity"), provider props.setProperty(provider + ".identity",
+ ".identity")); checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"));
props.setProperty(provider + ".credential", checkNotNull(System.getProperty(provider + ".credential"), props.setProperty(provider + ".credential",
provider + ".credential")); checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential"));
} }
} }