Created a TweetStore parent project, updated twitter4j to 2.2 and switched to OAuth

This commit is contained in:
Andrew Phillips 2011-06-01 21:32:08 +02:00
parent 20b32e77a9
commit c29765d1d0
71 changed files with 603 additions and 627 deletions

View File

@ -1,313 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the
License.
====================================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-demos-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>jclouds-demo-gae-tweetstore</artifactId>
<packaging>war</packaging>
<name>JClouds TweetStore for Google App Engine</name>
<description>JClouds TweetStore for Google App Engine using Guice for Dependency Injection</description>
<properties>
<!--
note you must set the property ${appengine.sdk.root} to a valid
extraction of appengine-java-sdk
-->
<appengine.applicationid>jclouds-tweetstore</appengine.applicationid>
<appengine.sdk.version>1.4.2</appengine.sdk.version>
<devappserver.address>localhost</devappserver.address>
<devappserver.port>8088</devappserver.port>
<jclouds.tweetstore.blobstores>cloudfiles-us,aws-s3,azureblob</jclouds.tweetstore.blobstores>
<jclouds.tweetstore.container>jclouds-tweetstore</jclouds.tweetstore.container>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.1,)</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-s3</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudfiles-us</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>azureblob</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-gae</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>displaytag</groupId>
<artifactId>displaytag</artifactId>
<version>1.2</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>jstl</artifactId>
<groupId>javax.servlet</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>standard</artifactId>
<groupId>taglibs</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Google App Engine API -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-tools-sdk</artifactId>
<version>${appengine.sdk.version}</version>
<scope>test</scope>
</dependency>
<!-- Needed..??> -->
<!-- Google App Engine Runtime Dependencies -->
<!--dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_3.0_spec</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>jdo2-api</artifactId>
<version>2.3-eb</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>1.0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-jpa</artifactId>
<version>1.1.5</version>
<scope>runtime</scope>
</dependency-->
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/appengine</directory>
<targetPath>WEB-INF/</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>appengine.sdk.root</name>
<value>${appengine.sdk.root}</value>
</property>
<property>
<name>devappserver.address</name>
<value>${devappserver.address}</value>
</property>
<property>
<name>devappserver.port</name>
<value>${devappserver.port}</value>
</property>
<property>
<name>warfile</name>
<value>${project.build.directory}/${project.artifactId}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>test.twitter.identity</name>
<value>${test.twitter.identity}</value>
</property>
<property>
<name>test.twitter.credential</name>
<value>${test.twitter.credential}</value>
</property>
<property>
<name>test.azureblob.identity</name>
<value>${test.azureblob.identity}</value>
</property>
<property>
<name>test.azureblob.credential</name>
<value>${test.azureblob.credential}</value>
</property>
<property>
<name>test.cloudfiles-us.identity</name>
<value>${test.cloudfiles-us.identity}</value>
</property>
<property>
<name>test.cloudfiles-us.credential</name>
<value>${test.cloudfiles-us.credential}</value>
</property>
<property>
<name>test.aws-s3.identity</name>
<value>${test.aws-s3.identity}</value>
</property>
<property>
<name>test.aws-s3.credential</name>
<value>${test.aws-s3.credential}</value>
</property>
<property>
<name>appengine.sdk.root</name>
<value>${appengine.sdk.root}</value>
</property>
<property>
<name>devappserver.address</name>
<value>${devappserver.address}</value>
</property>
<property>
<name>devappserver.port</name>
<value>${devappserver.port}</value>
</property>
<property>
<name>jclouds.tweetstore.blobstores</name>
<value>${jclouds.tweetstore.blobstores}</value>
</property>
<property>
<name>jclouds.tweetstore.container</name>
<value>${jclouds.tweetstore.container}</value>
</property>
<property>
<name>warfile</name>
<value>${project.build.directory}/${project.artifactId}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -32,12 +32,9 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<name>jclouds demos project</name> <name>jclouds demos project</name>
<modules> <modules>
<module>gae-tweetstore</module>
<module>gae-tweetstore-spring</module>
<module>getpath</module> <module>getpath</module>
<module>googleappengine</module> <module>googleappengine</module>
<module>perftest</module> <module>perftest</module>
<module>runatcloud-tweetstore</module>
<module>speedtest-azurequeue</module> <module>speedtest-azurequeue</module>
<module>speedtest-sqs</module> <module>speedtest-sqs</module>
<module>simpledb</module> <module>simpledb</module>

View File

@ -24,7 +24,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.jclouds</groupId> <groupId>org.jclouds</groupId>
<artifactId>jclouds-demos-project</artifactId> <artifactId>jclouds-demos-tweetstore-project</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>jclouds-demo-gae-tweetstore-spring</artifactId> <artifactId>jclouds-demo-gae-tweetstore-spring</artifactId>
@ -41,46 +41,10 @@
<appengine.sdk.version>1.4.2</appengine.sdk.version> <appengine.sdk.version>1.4.2</appengine.sdk.version>
<devappserver.address>localhost</devappserver.address> <devappserver.address>localhost</devappserver.address>
<devappserver.port>8088</devappserver.port> <devappserver.port>8088</devappserver.port>
<jclouds.tweetstore.blobstores>cloudfiles-us,aws-s3,azureblob</jclouds.tweetstore.blobstores>
<jclouds.tweetstore.container>jclouds-tweetstore-spring</jclouds.tweetstore.container> <jclouds.tweetstore.container>jclouds-tweetstore-spring</jclouds.tweetstore.container>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.1,)</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-s3</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudfiles-us</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>azureblob</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency> <dependency>
<groupId>org.jclouds.driver</groupId> <groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-gae</artifactId> <artifactId>jclouds-gae</artifactId>
@ -102,42 +66,6 @@
<version>2.2</version> <version>2.2</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>displaytag</groupId>
<artifactId>displaytag</artifactId>
<version>1.2</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>standard</artifactId>
<groupId>taglibs</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>jstl</artifactId>
<groupId>javax.servlet</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Google App Engine API --> <!-- Google App Engine API -->
<dependency> <dependency>
@ -152,21 +80,9 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/appengine</directory>
<targetPath>WEB-INF/</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<executions> <executions>
@ -219,12 +135,20 @@
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
<name>test.twitter.identity</name> <name>test.twitter.consumer.identity</name>
<value>${test.twitter.identity}</value> <value>${test.twitter.gae-tweetstore-spring.consumer.identity}</value>
</property> </property>
<property> <property>
<name>test.twitter.credential</name> <name>test.twitter.consumer.credential</name>
<value>${test.twitter.credential}</value> <value>${test.twitter.gae-tweetstore-spring.consumer.credential}</value>
</property>
<property>
<name>test.twitter.access.identity</name>
<value>${test.twitter.gae-tweetstore-spring.access.identity}</value>
</property>
<property>
<name>test.twitter.access.credential</name>
<value>${test.twitter.gae-tweetstore-spring.access.credential}</value>
</property> </property>
<property> <property>
<name>test.azureblob.identity</name> <name>test.azureblob.identity</name>

View File

@ -1,38 +1,38 @@
/** /**
* *
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
* *
* ==================================================================== * ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.demo.tweetstore.config; package org.jclouds.demo.tweetstore.config;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.logging.Logger.LoggerFactory;
import org.jclouds.logging.jdk.JDKLogger; import org.jclouds.logging.jdk.JDKLogger;
/** /**
* Spring config that provides a logger. * Spring config that provides a logger.
* *
* @author Andrew Phillips * @author Andrew Phillips
*/ */
abstract class LoggingConfig { abstract class LoggingConfig {
private static final LoggerFactory FACTORY = new JDKLogger.JDKLoggerFactory(); private static final LoggerFactory FACTORY = new JDKLogger.JDKLoggerFactory();
protected final Logger logger; protected final Logger logger;
protected LoggingConfig() { protected LoggingConfig() {
logger = FACTORY.getLogger(this.getClass().getName()); logger = FACTORY.getLogger(this.getClass().getName());
} }
} }

View File

@ -55,7 +55,6 @@ import twitter4j.conf.ConfigurationBuilder;
import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory; import com.google.appengine.api.taskqueue.QueueFactory;
import com.google.appengine.api.taskqueue.TaskOptions.Builder;
import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;

View File

@ -1,38 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
==================================================================== ====================================================================
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==================================================================== ====================================================================
--> -->
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- the usual <context:annotation-config/> can't be used because the <!-- the usual <context:annotation-config/> can't be used because the
CommonAnnotationBeanPostProcessor causes a security exception in GAE when it CommonAnnotationBeanPostProcessor causes a security exception in GAE when it
tries to load javax.annotation.Resource --> tries to load javax.annotation.Resource -->
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<bean class="org.springframework.context.annotation.ConfigurationClassPostProcessor" /> <bean class="org.springframework.context.annotation.ConfigurationClassPostProcessor" />
<bean class="org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor"> <bean class="org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor">
<property name="initAnnotationType" value="javax.annotation.PostConstruct" /> <property name="initAnnotationType" value="javax.annotation.PostConstruct" />
<property name="destroyAnnotationType" value="javax.annotation.PreDestroy" /> <property name="destroyAnnotationType" value="javax.annotation.PreDestroy" />
</bean> </bean>
<bean class="org.jclouds.demo.tweetstore.config.SpringServletConfig" /> <bean class="org.jclouds.demo.tweetstore.config.SpringServletConfig" />
</beans> </beans>

View File

@ -78,7 +78,7 @@ public class TweetStoreLiveTest {
@BeforeTest @BeforeTest
void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
TwitterException { TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); container = getRequiredSystemProperty(PROPERTY_TWEETSTORE_CONTAINER);
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container);
props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores));
@ -98,10 +98,13 @@ public class TweetStoreLiveTest {
contexts.put(provider, factory.createContext(provider, wiring, props)); contexts.put(provider, factory.createContext(provider, wiring, props));
} }
Configuration twitterConf = new ConfigurationBuilder() Configuration conf = new ConfigurationBuilder()
.setUser(props.getProperty("twitter.identity")) .setOAuthConsumerKey(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY))
.setPassword(props.getProperty("twitter.credential")).build(); .setOAuthConsumerSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET))
Twitter client = new TwitterFactory(twitterConf).getInstance(); .setOAuthAccessToken(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN))
.setOAuthAccessTokenSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET))
.build();
Twitter client = new TwitterFactory(conf).getInstance();
StoreTweetsController controller = new StoreTweetsController(contexts, container, client); StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
ResponseList<Status> statuses = client.getMentions(); ResponseList<Status> statuses = client.getMentions();
@ -135,21 +138,29 @@ public class TweetStoreLiveTest {
} }
} }
private static String getRequiredSystemProperty(String key) {
return checkNotNull(System.getProperty(key), key);
}
private void addConfigurationForTwitter(Properties props) { private void addConfigurationForTwitter(Properties props) {
props.setProperty("twitter.identity", props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY,
checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity")); getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY));
props.setProperty("twitter.credential", props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET,
checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential")); getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET));
} props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET));
}
private void addCredentialsForBlobStores(Properties props) { private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) { for (String provider : blobstores) {
props.setProperty(provider + ".identity", props.setProperty(provider + ".identity",
checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity")); getRequiredSystemProperty("test." + provider + ".identity"));
props.setProperty(provider + ".credential", props.setProperty(provider + ".credential",
checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential")); getRequiredSystemProperty("test." + provider + ".credential"));
} }
} }
@BeforeTest @BeforeTest
@Parameters({ "warfile", "devappserver.address", "devappserver.port" }) @Parameters({ "warfile", "devappserver.address", "devappserver.port" })
@ -208,4 +219,11 @@ public class TweetStoreLiveTest {
String string = Strings2.toStringAndClose(i); String string = Strings2.toStringAndClose(i);
assert string.indexOf("Tweets in Clouds") >= 0 : string; assert string.indexOf("Tweets in Clouds") >= 0 : string;
} }
private static interface TwitterConstants {
static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity";
static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential";
static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity";
static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential";
}
} }

View File

@ -0,0 +1,236 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the
License.
====================================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-demos-tweetstore-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>jclouds-demo-gae-tweetstore</artifactId>
<packaging>war</packaging>
<name>JClouds TweetStore for Google App Engine</name>
<description>JClouds TweetStore for Google App Engine using Guice for Dependency Injection</description>
<properties>
<!--
note you must set the property ${appengine.sdk.root} to a valid
extraction of appengine-java-sdk
-->
<appengine.applicationid>jclouds-tweetstore</appengine.applicationid>
<appengine.sdk.version>1.4.2</appengine.sdk.version>
<devappserver.address>localhost</devappserver.address>
<devappserver.port>8088</devappserver.port>
<jclouds.tweetstore.container>jclouds-tweetstore</jclouds.tweetstore.container>
</properties>
<dependencies>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-gae</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
</dependency>
<!-- Google App Engine API -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-tools-sdk</artifactId>
<version>${appengine.sdk.version}</version>
<scope>test</scope>
</dependency>
<!-- Needed..??> -->
<!-- Google App Engine Runtime Dependencies -->
<!--dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_3.0_spec</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>jdo2-api</artifactId>
<version>2.3-eb</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>1.0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-jpa</artifactId>
<version>1.1.5</version>
<scope>runtime</scope>
</dependency-->
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>appengine.sdk.root</name>
<value>${appengine.sdk.root}</value>
</property>
<property>
<name>devappserver.address</name>
<value>${devappserver.address}</value>
</property>
<property>
<name>devappserver.port</name>
<value>${devappserver.port}</value>
</property>
<property>
<name>warfile</name>
<value>${project.build.directory}/${project.artifactId}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>test.twitter.consumer.identity</name>
<value>${test.twitter.gae-tweetstore.consumer.identity}</value>
</property>
<property>
<name>test.twitter.consumer.credential</name>
<value>${test.twitter.gae-tweetstore.consumer.credential}</value>
</property>
<property>
<name>test.twitter.access.identity</name>
<value>${test.twitter.gae-tweetstore.access.identity}</value>
</property>
<property>
<name>test.twitter.access.credential</name>
<value>${test.twitter.gae-tweetstore.access.credential}</value>
</property>
<property>
<name>test.azureblob.identity</name>
<value>${test.azureblob.identity}</value>
</property>
<property>
<name>test.azureblob.credential</name>
<value>${test.azureblob.credential}</value>
</property>
<property>
<name>test.cloudfiles-us.identity</name>
<value>${test.cloudfiles-us.identity}</value>
</property>
<property>
<name>test.cloudfiles-us.credential</name>
<value>${test.cloudfiles-us.credential}</value>
</property>
<property>
<name>test.aws-s3.identity</name>
<value>${test.aws-s3.identity}</value>
</property>
<property>
<name>test.aws-s3.credential</name>
<value>${test.aws-s3.credential}</value>
</property>
<property>
<name>appengine.sdk.root</name>
<value>${appengine.sdk.root}</value>
</property>
<property>
<name>devappserver.address</name>
<value>${devappserver.address}</value>
</property>
<property>
<name>devappserver.port</name>
<value>${devappserver.port}</value>
</property>
<property>
<name>jclouds.tweetstore.blobstores</name>
<value>${jclouds.tweetstore.blobstores}</value>
</property>
<property>
<name>jclouds.tweetstore.container</name>
<value>${jclouds.tweetstore.container}</value>
</property>
<property>
<name>warfile</name>
<value>${project.build.directory}/${project.artifactId}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -77,8 +77,7 @@ public class TweetStoreLiveTest {
@BeforeTest @BeforeTest
void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
TwitterException { TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), container = getRequiredSystemProperty(PROPERTY_TWEETSTORE_CONTAINER);
PROPERTY_TWEETSTORE_CONTAINER);
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container);
props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores));
@ -99,8 +98,11 @@ public class TweetStoreLiveTest {
} }
Configuration conf = new ConfigurationBuilder() Configuration conf = new ConfigurationBuilder()
.setUser(props.getProperty("twitter.identity")) .setOAuthConsumerKey(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY))
.setPassword(props.getProperty("twitter.credential")).build(); .setOAuthConsumerSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET))
.setOAuthAccessToken(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN))
.setOAuthAccessTokenSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET))
.build();
Twitter client = new TwitterFactory(conf).getInstance(); Twitter client = new TwitterFactory(conf).getInstance();
StoreTweetsController controller = new StoreTweetsController(contexts, container, client); StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
@ -140,6 +142,30 @@ public class TweetStoreLiveTest {
} }
} }
private static String getRequiredSystemProperty(String key) {
return checkNotNull(System.getProperty(key), key);
}
private void addConfigurationForTwitter(Properties props) {
props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET));
}
private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) {
props.setProperty(provider + ".identity",
getRequiredSystemProperty("test." + provider + ".identity"));
props.setProperty(provider + ".credential",
getRequiredSystemProperty("test." + provider + ".credential"));
}
}
@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 {
@ -148,22 +174,7 @@ public class TweetStoreLiveTest {
server = new GoogleDevServer(); server = new GoogleDevServer();
server.writePropertiesAndStartServer(address, port, warfile, props); server.writePropertiesAndStartServer(address, port, warfile, props);
} }
private void addConfigurationForTwitter(Properties props) {
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("test." + provider + ".identity"), "test." + provider + ".identity"));
props.setProperty(provider + ".credential",
checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential"));
}
}
@Test @Test
public void shouldPass() throws InterruptedException, IOException { public void shouldPass() throws InterruptedException, IOException {
InputStream i = url.openStream(); InputStream i = url.openStream();
@ -213,4 +224,11 @@ public class TweetStoreLiveTest {
String string = Strings2.toStringAndClose(i); String string = Strings2.toStringAndClose(i);
assert string.indexOf("Tweets in Clouds") >= 0 : string; assert string.indexOf("Tweets in Clouds") >= 0 : string;
} }
private static interface TwitterConstants {
static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity";
static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential";
static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity";
static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential";
}
} }

137
demos/tweetstore/pom.xml Normal file
View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
====================================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>jclouds-demos-project</artifactId>
<groupId>org.jclouds</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jclouds-demos-tweetstore-project</artifactId>
<packaging>pom</packaging>
<name>jclouds TweetStore demos project</name>
<modules>
<module>gae-tweetstore</module>
<module>gae-tweetstore-spring</module>
<module>runatcloud-tweetstore</module>
</modules>
<properties>
<jclouds.tweetstore.blobstores>cloudfiles-us,aws-s3,azureblob</jclouds.tweetstore.blobstores>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.2,)</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-s3</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudfiles-us</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>azureblob</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>displaytag</groupId>
<artifactId>displaytag</artifactId>
<version>1.2</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>jstl</artifactId>
<groupId>javax.servlet</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>standard</artifactId>
<groupId>taglibs</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MWAR-248 -->
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
<webResources>
<resource>
<directory>src/main/platform</directory>
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.jclouds</groupId> <groupId>org.jclouds</groupId>
<artifactId>jclouds-demos-project</artifactId> <artifactId>jclouds-demos-tweetstore-project</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>jclouds-demo-runatcloud-tweetstore</artifactId> <artifactId>jclouds-demo-runatcloud-tweetstore</artifactId>
@ -31,91 +31,19 @@
<description>jclouds TweetStore for CloudBees' RUN@cloud using Guice for Dependency Injection</description> <description>jclouds TweetStore for CloudBees' RUN@cloud using Guice for Dependency Injection</description>
<properties> <properties>
<bees.appid>tweetstore</bees.appid> <bees.appid>jclouds/tweetstore</bees.appid>
<bees.environment>run</bees.environment> <bees.environment>run</bees.environment>
<bees.address>localhost</bees.address> <bees.address>localhost</bees.address>
<bees.port>8088</bees.port> <bees.port>8088</bees.port>
<jclouds.tweetstore.blobstores>cloudfiles-us,aws-s3,azureblob</jclouds.tweetstore.blobstores> <jclouds.tweetstore.container>jclouds-tweetstore-runatcloud</jclouds.tweetstore.container>
<jclouds.tweetstore.container>jclouds-tweetstore-runatcloud</jclouds.tweetstore.container>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[2.1,)</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-s3</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudfiles-us</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>azureblob</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency> <dependency>
<groupId>com.google.inject.extensions</groupId> <groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId> <artifactId>guice-servlet</artifactId>
<version>3.0</version> <version>3.0</version>
</dependency> </dependency>
<dependency>
<groupId>displaytag</groupId>
<artifactId>displaytag</artifactId>
<version>1.2</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>jstl</artifactId>
<groupId>javax.servlet</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<artifactId>standard</artifactId>
<groupId>taglibs</groupId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- RUN@cloud API --> <!-- RUN@cloud API -->
<dependency> <dependency>
@ -140,7 +68,6 @@
</pluginRepositories> </pluginRepositories>
<build> <build>
<finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
@ -178,13 +105,19 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.cloudbees</groupId> <groupId>com.cloudbees</groupId>
<artifactId>bees-maven-plugin</artifactId> <artifactId>bees-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</plugin> <configuration>
<appid>${bees.appid}</appid>
<environment>${bees.environment}</environment>
<apikey>${bees.apikey}</apikey>
<secret>${bees.secret}</secret>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>
<profile> <profile>
@ -203,12 +136,20 @@
<configuration> <configuration>
<systemProperties> <systemProperties>
<property> <property>
<name>test.twitter.identity</name> <name>test.twitter.consumer.identity</name>
<value>${test.twitter.identity}</value> <value>${test.twitter.runatcloud-tweetstore.consumer.identity}</value>
</property> </property>
<property> <property>
<name>test.twitter.credential</name> <name>test.twitter.consumer.credential</name>
<value>${test.twitter.credential}</value> <value>${test.twitter.runatcloud-tweetstore.consumer.credential}</value>
</property>
<property>
<name>test.twitter.access.identity</name>
<value>${test.twitter.runatcloud-tweetstore.access.identity}</value>
</property>
<property>
<name>test.twitter.access.credential</name>
<value>${test.twitter.runatcloud-tweetstore.access.credential}</value>
</property> </property>
<property> <property>
<name>test.azureblob.identity</name> <name>test.azureblob.identity</name>

View File

@ -78,7 +78,7 @@ public class TweetStoreLiveTest {
@BeforeTest @BeforeTest
void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException,
TwitterException { TwitterException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); container = getRequiredSystemProperty(PROPERTY_TWEETSTORE_CONTAINER);
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container);
props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores));
@ -99,8 +99,11 @@ public class TweetStoreLiveTest {
} }
Configuration conf = new ConfigurationBuilder() Configuration conf = new ConfigurationBuilder()
.setUser(props.getProperty("twitter.identity")) .setOAuthConsumerKey(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY))
.setPassword(props.getProperty("twitter.credential")).build(); .setOAuthConsumerSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET))
.setOAuthAccessToken(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN))
.setOAuthAccessTokenSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET))
.build();
Twitter client = new TwitterFactory(conf).getInstance(); Twitter client = new TwitterFactory(conf).getInstance();
StoreTweetsController controller = new StoreTweetsController(contexts, container, client); StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
@ -140,6 +143,30 @@ public class TweetStoreLiveTest {
} }
} }
private static String getRequiredSystemProperty(String key) {
return checkNotNull(System.getProperty(key), key);
}
private void addConfigurationForTwitter(Properties props) {
props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN));
props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET,
getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET));
}
private void addCredentialsForBlobStores(Properties props) {
for (String provider : blobstores) {
props.setProperty(provider + ".identity",
getRequiredSystemProperty("test." + provider + ".identity"));
props.setProperty(provider + ".credential",
getRequiredSystemProperty("test." + provider + ".credential"));
}
}
@BeforeTest(dependsOnMethods = "clearAndCreateContainers") @BeforeTest(dependsOnMethods = "clearAndCreateContainers")
@Parameters({ "warfile", "bees.address", "bees.port", "bees.environment", "bees.basedir" }) @Parameters({ "warfile", "bees.address", "bees.port", "bees.environment", "bees.basedir" })
public void startDevAppServer(final String warfile, final String address, final String port, public void startDevAppServer(final String warfile, final String address, final String port,
@ -151,21 +178,6 @@ public class TweetStoreLiveTest {
serverBaseDirectory, props); serverBaseDirectory, props);
} }
private void addConfigurationForTwitter(Properties props) {
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("test." + provider + ".identity"), "test." + provider + ".identity"));
props.setProperty(provider + ".credential",
checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential"));
}
}
@Test @Test
public void shouldPass() throws InterruptedException, IOException { public void shouldPass() throws InterruptedException, IOException {
InputStream i = url.openStream(); InputStream i = url.openStream();
@ -215,4 +227,11 @@ public class TweetStoreLiveTest {
String string = Strings2.toStringAndClose(i); String string = Strings2.toStringAndClose(i);
assert string.indexOf("Tweets in Clouds") >= 0 : string; assert string.indexOf("Tweets in Clouds") >= 0 : string;
} }
private static interface TwitterConstants {
static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity";
static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential";
static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity";
static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential";
}
} }