reorganized twitter

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2239 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-11-09 06:32:44 +00:00
parent 59cd117fdf
commit b3e27b15e2
20 changed files with 54 additions and 100 deletions

View File

@ -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>

View File

@ -1,44 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
$HeadURL$
$Revision$
$Date$
<!--
$HeadURL$ $Revision$ $Date$ Copyright (C) 2009 Adrian Cole
<adrian@jclouds.org>
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
====================================================================
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">
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>
<artifactId>jclouds-project</artifactId>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jclouds-twitter-project</artifactId>
<packaging>pom</packaging>
<name>jclouds twitter</name>
<modules>
<module>core</module>
</modules>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-twitter</artifactId>
<name>jclouds twitter core</name>
<packaging>jar</packaging>
<description>jclouds components to access twitter</description>
<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>
<jclouds.test.user>${jclouds.twitter.user}</jclouds.test.user>
<jclouds.test.key>${jclouds.twitter.password}</jclouds.test.key>
@ -57,10 +58,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>test</scope>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>

View File

@ -32,8 +32,8 @@ import org.jclouds.rest.RestContext;
import com.google.inject.Module;
/**
* Creates {@link RestContext<TwitterClient>} instances based on the most commonly requested
* arguments.
* Creates {@link RestContext} for {@link TwitterClient} instances based on the most commonly
* requested arguments.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
@ -42,13 +42,14 @@ import com.google.inject.Module;
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole
* @see RestContext<TwitterClient>
* @see RestContext
* @see TwitterClient
*/
public class TwitterContextFactory {
public static RestContext<TwitterClient> createContext(String user, String key,
public static RestContext<TwitterClient> createContext(String user, String password,
Module... modules) {
return new TwitterContextBuilder(new TwitterPropertiesBuilder(user, key).build())
return new TwitterContextBuilder(new TwitterPropertiesBuilder(user, password).build())
.withModules(modules).buildContext();
}

View File

@ -57,7 +57,7 @@ public class TwitterPropertiesBuilder extends HttpPropertiesBuilder {
public TwitterPropertiesBuilder withCredentials(String id, String secret) {
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;
}

View File

@ -39,7 +39,7 @@ import com.google.gson.Gson;
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
*/

View File

@ -58,7 +58,7 @@ public class TwitterClientTest extends RestClientTest<TwitterClient> {
Method method = TwitterClient.class.getMethod("getMyMentions");
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, "");
assertEntityEquals(httpMethod, null);
@ -87,7 +87,7 @@ public class TwitterClientTest extends RestClientTest<TwitterClient> {
@Override
protected void configure() {
bind(URI.class).annotatedWith(Twitter.class).toInstance(
URI.create("http://localhost/tweettest"));
URI.create("http://twitter.com"));
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
public Logger getLogger(String category) {
return Logger.NULL;

View File

@ -46,7 +46,7 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "cloudfiles.TwitterContextBuilderTest")
@Test(groups = "unit", testName = "twitter.TwitterContextBuilderTest")
public class TwitterContextBuilderTest {
public void testNewBuilder() {
@ -54,15 +54,15 @@ public class TwitterContextBuilderTest {
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_ENDPOINT),
"http://twitter.com");
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_USER),
"id");
"user");
assertEquals(builder.getProperties().getProperty(TwitterConstants.PROPERTY_TWITTER_PASSWORD),
"secret");
"password");
}
public void testBuildContext() {
RestContext<TwitterClient> context = newBuilder().buildContext();
assertEquals(context.getClass(), RestContextImpl.class);
assertEquals(context.getAccount(), "id");
assertEquals(context.getAccount(), "user");
assertEquals(context.getEndPoint(), URI.create("http://twitter.com"));
}
@ -82,8 +82,8 @@ public class TwitterContextBuilderTest {
}
private TwitterContextBuilder newBuilder() {
TwitterContextBuilder builder = new TwitterContextBuilder(new TwitterPropertiesBuilder("id",
"secret").build());
TwitterContextBuilder builder = new TwitterContextBuilder(new TwitterPropertiesBuilder("user",
"password").build());
return builder;
}

View File

@ -58,7 +58,7 @@ public class TwitterContextModuleTest {
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_USER)).to(
"user");
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_PASSWORD))
.to("key");
.to("password");
bindConstant().annotatedWith(Jsr330.named(TwitterConstants.PROPERTY_TWITTER_ENDPOINT))
.to("http://localhost");
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {