You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/13 08:13:54 UTC
git commit: CAMEL-7066 Supported to setting the proxy from
camel-twitter uri
Updated Branches:
refs/heads/master 24fd3b64d -> 558174947
CAMEL-7066 Supported to setting the proxy from camel-twitter uri
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55817494
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55817494
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55817494
Branch: refs/heads/master
Commit: 558174947631a7e6bb3661bfa2e5fd1d277ed083
Parents: 24fd3b6
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Dec 13 15:12:38 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Dec 13 15:12:38 2013 +0800
----------------------------------------------------------------------
.../component/twitter/TwitterConfiguration.java | 58 ++++++++++++++++++++
.../component/twitter/UriConfigurationTest.java | 12 ++++
2 files changed, 70 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/55817494/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
index f2df043..0acb20d 100644
--- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
+++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java
@@ -116,6 +116,18 @@ public class TwitterConfiguration {
*/
@UriParam
private Integer numberOfPages = new Integer(1);
+
+ @UriParam
+ private String httpProxyHost;
+
+ @UriParam
+ private String httpProxyUser;
+
+ @UriParam
+ private String httpProxyPassword;
+
+ @UriParam
+ private Integer httpProxyPort;
/**
* Singleton, on demand instances of Twitter4J's Twitter & TwitterStream.
@@ -143,11 +155,25 @@ public class TwitterConfiguration {
* @return Configuration
*/
public Configuration getConfiguration() {
+ checkComplete();
ConfigurationBuilder confBuilder = new ConfigurationBuilder();
confBuilder.setOAuthConsumerKey(consumerKey);
confBuilder.setOAuthConsumerSecret(consumerSecret);
confBuilder.setOAuthAccessToken(accessToken);
confBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
+ if (getHttpProxyHost() != null) {
+ confBuilder.setHttpProxyHost(getHttpProxyHost());
+ }
+ if (getHttpProxyUser() != null) {
+ confBuilder.setHttpProxyHost(getHttpProxyUser());
+ }
+ if (getHttpProxyPassword() != null) {
+ confBuilder.setHttpProxyHost(getHttpProxyPassword());
+ }
+ if (httpProxyPort != null) {
+ confBuilder.setHttpProxyPort(httpProxyPort);
+ }
+
return confBuilder.build();
}
@@ -315,6 +341,38 @@ public class TwitterConfiguration {
public void setNumberOfPages(Integer numberOfPages) {
this.numberOfPages = numberOfPages;
}
+
+ public void setHttpProxyHost(String httpProxyHost) {
+ this.httpProxyHost = httpProxyHost;
+ }
+
+ public String getHttpProxyHost() {
+ return httpProxyHost;
+ }
+
+ public void setHttpProxyUser(String httpProxyUser) {
+ this.httpProxyUser = httpProxyUser;
+ }
+
+ public String getHttpProxyUser() {
+ return httpProxyUser;
+ }
+
+ public void setHttpProxyPassword(String httpProxyPassword) {
+ this.httpProxyPassword = httpProxyPassword;
+ }
+
+ public String getHttpProxyPassword() {
+ return httpProxyPassword;
+ }
+
+ public void setHttpProxyPort(int httpProxyPort) {
+ this.httpProxyPort = httpProxyPort;
+ }
+
+ public int getHttpProxyPort() {
+ return httpProxyPort;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/55817494/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UriConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UriConfigurationTest.java b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UriConfigurationTest.java
index 9c6d124..a003032 100644
--- a/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UriConfigurationTest.java
+++ b/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UriConfigurationTest.java
@@ -48,4 +48,16 @@ public class UriConfigurationTest extends Assert {
assertEquals(new Integer(50), twitterEndpoint.getProperties().getCount());
assertEquals(new Integer(2), twitterEndpoint.getProperties().getNumberOfPages());
}
+
+ @Test
+ public void testHttpProxySetting() throws Exception {
+ Endpoint endpoint = context.getEndpoint("twitter:todo/todo?httpProxyHost=example.com&httpProxyPort=3338&httpProxyUser=test&httpProxyPassword=pwd");
+ assertTrue("Endpoint not a TwitterEndpoint: " + endpoint, endpoint instanceof TwitterEndpoint);
+ TwitterEndpoint twitterEndpoint = (TwitterEndpoint) endpoint;
+
+ assertEquals("example.com", twitterEndpoint.getProperties().getHttpProxyHost());
+ assertEquals(3338, twitterEndpoint.getProperties().getHttpProxyPort());
+ assertEquals("test", twitterEndpoint.getProperties().getHttpProxyUser());
+ assertEquals("pwd", twitterEndpoint.getProperties().getHttpProxyPassword());
+ }
}