mirror of https://github.com/apache/jclouds.git
updated google appengine tweetstore tests
This commit is contained in:
parent
a0fbeb96e7
commit
4dbcbfc7a6
|
@ -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>
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
|
||||||
// instantiate and store references to all blobstores by provider name
|
// instantiate and store references to all blobstores by provider name
|
||||||
providerTypeToBlobStoreMap = Maps.newHashMap();
|
providerTypeToBlobStoreMap = Maps.newHashMap();
|
||||||
for (String hint : Splitter.on(',').split(
|
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));
|
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));
|
queue.add(url("/store/do").header("context", name).method(Method.GET));
|
||||||
}
|
}
|
||||||
logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient,
|
logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient,
|
||||||
container, providerTypeToBlobStoreMap.keySet());
|
container, providerTypeToBlobStoreMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Properties loadJCloudsProperties() {
|
private Properties loadJCloudsProperties() {
|
||||||
|
@ -139,7 +139,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA
|
||||||
@Bean
|
@Bean
|
||||||
public AddTweetsController addTweetsController() {
|
public AddTweetsController addTweetsController() {
|
||||||
AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap,
|
AddTweetsController controller = new AddTweetsController(providerTypeToBlobStoreMap,
|
||||||
serviceToStoredTweetStatuses());
|
serviceToStoredTweetStatuses());
|
||||||
injectServletConfig(controller);
|
injectServletConfig(controller);
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -70,16 +70,17 @@ public class TweetStoreLiveTest {
|
||||||
private String container;
|
private String container;
|
||||||
|
|
||||||
private static final String blobs = System.getProperty("jclouds.tweetstore.blobstores",
|
private static final String blobs = System.getProperty("jclouds.tweetstore.blobstores",
|
||||||
"cloudfiles,googlestorage,s3,azureblob");
|
"cloudfiles,googlestorage,s3,azureblob");
|
||||||
private static final Iterable<String> blobstores = Splitter.on(',').split(blobs);
|
private static final Iterable<String> blobstores = Splitter.on(',').split(blobs);
|
||||||
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();
|
||||||
|
@ -108,7 +109,7 @@ public class TweetStoreLiveTest {
|
||||||
for (BlobStoreContext context : contexts.values()) {
|
for (BlobStoreContext context : contexts.values()) {
|
||||||
if (context.getBlobStore().containerExists(container)) {
|
if (context.getBlobStore().containerExists(container)) {
|
||||||
System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext()
|
System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext()
|
||||||
.getEndpoint());
|
.getEndpoint());
|
||||||
context.getBlobStore().deleteContainer(container);
|
context.getBlobStore().deleteContainer(container);
|
||||||
deleted = true;
|
deleted = true;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,7 @@ public class TweetStoreLiveTest {
|
||||||
}
|
}
|
||||||
for (BlobStoreContext context : contexts.values()) {
|
for (BlobStoreContext context : contexts.values()) {
|
||||||
System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext()
|
System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext()
|
||||||
.getEndpoint());
|
.getEndpoint());
|
||||||
context.getBlobStore().createContainerInLocation(null, container);
|
context.getBlobStore().createContainerInLocation(null, container);
|
||||||
}
|
}
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue