mirror of https://github.com/apache/jclouds.git
reorganized twitter
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2239 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
59cd117fdf
commit
b3e27b15e2
|
@ -1,48 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
$HeadURL$
|
|
||||||
$Revision$
|
|
||||||
$Date$
|
|
||||||
|
|
||||||
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
|
|
||||||
|
|
||||||
====================================================================
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you 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.html
|
|
||||||
|
|
||||||
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>
|
|
||||||
<groupId>org.jclouds</groupId>
|
|
||||||
<artifactId>jclouds-twitter-project</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>org.jclouds</groupId>
|
|
||||||
<artifactId>jclouds-twitter</artifactId>
|
|
||||||
<name>jclouds twitter core</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<description>jclouds core components to access twitter</description>
|
|
||||||
|
|
||||||
<scm>
|
|
||||||
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk//twitter/core</connection>
|
|
||||||
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk//twitter/core</developerConnection>
|
|
||||||
<url>http://jclouds.googlecode.com/svn/trunk//twitter/core</url>
|
|
||||||
</scm>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,44 +1,45 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
$HeadURL$
|
$HeadURL$ $Revision$ $Date$ Copyright (C) 2009 Adrian Cole
|
||||||
$Revision$
|
<adrian@jclouds.org>
|
||||||
$Date$
|
|
||||||
|
|
||||||
Copyright (C) 2009 Adrian Cole <adrian@jclouds.org>
|
====================================================================
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one or
|
||||||
|
more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information regarding
|
||||||
|
copyright ownership. The ASF licenses this file to you 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.html Unless required
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
by applicable law or agreed to in writing, software distributed
|
||||||
or more contributor license agreements. See the NOTICE file
|
under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
distributed with this work for additional information
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
regarding copyright ownership. The ASF licenses this file
|
See the License for the specific language governing permissions
|
||||||
to you under the Apache License, Version 2.0 (the
|
and limitations under the License.
|
||||||
"License"); you may not use this file except in compliance
|
====================================================================
|
||||||
with the License. You may obtain a copy of the License at
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
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>
|
<parent>
|
||||||
<artifactId>jclouds-project</artifactId>
|
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-project</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>jclouds-twitter-project</artifactId>
|
<groupId>org.jclouds</groupId>
|
||||||
<packaging>pom</packaging>
|
<artifactId>jclouds-twitter</artifactId>
|
||||||
<name>jclouds twitter</name>
|
<name>jclouds twitter core</name>
|
||||||
<modules>
|
<packaging>jar</packaging>
|
||||||
<module>core</module>
|
<description>jclouds components to access twitter</description>
|
||||||
</modules>
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/twitter</connection>
|
||||||
|
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/twitter</developerConnection>
|
||||||
|
<url>http://jclouds.googlecode.com/svn/trunk/twitter</url>
|
||||||
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<jclouds.test.user>${jclouds.twitter.user}</jclouds.test.user>
|
<jclouds.test.user>${jclouds.twitter.user}</jclouds.test.user>
|
||||||
<jclouds.test.key>${jclouds.twitter.password}</jclouds.test.key>
|
<jclouds.test.key>${jclouds.twitter.password}</jclouds.test.key>
|
||||||
|
@ -57,10 +58,10 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.14</version>
|
<version>1.2.14</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.jclouds.rest.RestContext;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link RestContext<TwitterClient>} instances based on the most commonly requested
|
* Creates {@link RestContext} for {@link TwitterClient} instances based on the most commonly
|
||||||
* arguments.
|
* requested arguments.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -42,13 +42,14 @@ import com.google.inject.Module;
|
||||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see RestContext<TwitterClient>
|
* @see RestContext
|
||||||
|
* @see TwitterClient
|
||||||
*/
|
*/
|
||||||
public class TwitterContextFactory {
|
public class TwitterContextFactory {
|
||||||
|
|
||||||
public static RestContext<TwitterClient> createContext(String user, String key,
|
public static RestContext<TwitterClient> createContext(String user, String password,
|
||||||
Module... modules) {
|
Module... modules) {
|
||||||
return new TwitterContextBuilder(new TwitterPropertiesBuilder(user, key).build())
|
return new TwitterContextBuilder(new TwitterPropertiesBuilder(user, password).build())
|
||||||
.withModules(modules).buildContext();
|
.withModules(modules).buildContext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class TwitterPropertiesBuilder extends HttpPropertiesBuilder {
|
||||||
|
|
||||||
public TwitterPropertiesBuilder withCredentials(String id, String secret) {
|
public TwitterPropertiesBuilder withCredentials(String id, String secret) {
|
||||||
properties.setProperty(PROPERTY_TWITTER_USER, checkNotNull(id, "user"));
|
properties.setProperty(PROPERTY_TWITTER_USER, checkNotNull(id, "user"));
|
||||||
properties.setProperty(PROPERTY_TWITTER_PASSWORD, checkNotNull(secret, "key"));
|
properties.setProperty(PROPERTY_TWITTER_PASSWORD, checkNotNull(secret, "password"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This parses {@link Status} from a gson string.
|
* This parses {@link Status} from a json string.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
|
@ -58,7 +58,7 @@ public class TwitterClientTest extends RestClientTest<TwitterClient> {
|
||||||
Method method = TwitterClient.class.getMethod("getMyMentions");
|
Method method = TwitterClient.class.getMethod("getMyMentions");
|
||||||
GeneratedHttpRequest<TwitterClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<TwitterClient> httpMethod = processor.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://localhost/tweettest/statuses/mentions.json HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://twitter.com/statuses/mentions.json HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertEntityEquals(httpMethod, null);
|
assertEntityEquals(httpMethod, null);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class TwitterClientTest extends RestClientTest<TwitterClient> {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(URI.class).annotatedWith(Twitter.class).toInstance(
|
bind(URI.class).annotatedWith(Twitter.class).toInstance(
|
||||||
URI.create("http://localhost/tweettest"));
|
URI.create("http://twitter.com"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
public Logger getLogger(String category) {
|
public Logger getLogger(String category) {
|
||||||
return Logger.NULL;
|
return Logger.NULL;
|
|
@ -46,7 +46,7 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "cloudfiles.TwitterContextBuilderTest")
|
@Test(groups = "unit", testName = "twitter.TwitterContextBuilderTest")
|
||||||
public class TwitterContextBuilderTest {
|
public class TwitterContextBuilderTest {
|
||||||
|
|
||||||
public void testNewBuilder() {
|
public void testNewBuilder() {
|
||||||
|
@ -54,15 +54,15 @@ public class TwitterContextBuilderTest {
|
||||||
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_ENDPOINT),
|
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_ENDPOINT),
|
||||||
"http://twitter.com");
|
"http://twitter.com");
|
||||||
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_USER),
|
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_USER),
|
||||||
"id");
|
"user");
|
||||||
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_PASSWORD),
|
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_PASSWORD),
|
||||||
"secret");
|
"password");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBuildContext() {
|
public void testBuildContext() {
|
||||||
RestContext<TwitterClient> context = newBuilder().buildContext();
|
RestContext<TwitterClient> context = newBuilder().buildContext();
|
||||||
assertEquals(context.getClass(), RestContextImpl.class);
|
assertEquals(context.getClass(), RestContextImpl.class);
|
||||||
assertEquals(context.getAccount(), "id");
|
assertEquals(context.getAccount(), "user");
|
||||||
assertEquals(context.getEndPoint(), URI.create("http://twitter.com"));
|
assertEquals(context.getEndPoint(), URI.create("http://twitter.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ public class TwitterContextBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TwitterContextBuilder newBuilder() {
|
private TwitterContextBuilder newBuilder() {
|
||||||
TwitterContextBuilder builder = new TwitterContextBuilder(new TwitterPropertiesBuilder("id",
|
TwitterContextBuilder builder = new TwitterContextBuilder(new TwitterPropertiesBuilder("user",
|
||||||
"secret").build());
|
"password").build());
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class TwitterContextModuleTest {
|
||||||
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_USER)).to(
|
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_USER)).to(
|
||||||
"user");
|
"user");
|
||||||
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_PASSWORD))
|
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_PASSWORD))
|
||||||
.to("key");
|
.to("password");
|
||||||
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_ENDPOINT))
|
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_ENDPOINT))
|
||||||
.to("http://localhost");
|
.to("http://localhost");
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
Loading…
Reference in New Issue