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:27:08 UTC

[1/2] git commit: CAMEL-7066 Supported to setting the proxy from camel-twitter uri

Updated Branches:
  refs/heads/camel-2.11.x 6250b4826 -> 57dde3c8c
  refs/heads/camel-2.12.x 81e557402 -> 25930b8d8


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/25930b8d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/25930b8d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/25930b8d

Branch: refs/heads/camel-2.12.x
Commit: 25930b8d8b042d44dcb9ef70e5ea32a4f65a51ba
Parents: 81e5574
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:15:24 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/25930b8d/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/25930b8d/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());
+    }
 }


[2/2] git commit: CAMEL-7066 Supported to setting the proxy from camel-twitter uri

Posted by ni...@apache.org.
CAMEL-7066 Supported to setting the proxy from camel-twitter uri

Conflicts:
	components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterConfiguration.java


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/57dde3c8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/57dde3c8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/57dde3c8

Branch: refs/heads/camel-2.11.x
Commit: 57dde3c8c4458db62e8505b25cb4d41ffb2a7d28
Parents: 6250b48
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:26:39 2013 +0800

----------------------------------------------------------------------
 .../component/twitter/TwitterConfiguration.java | 55 ++++++++++++++++++++
 .../component/twitter/UriConfigurationTest.java | 12 +++++
 2 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/57dde3c8/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 fc26ab7..934473b 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
@@ -93,7 +93,16 @@ public class TwitterConfiguration {
     private Integer count;
     
     private Date parsedDate;
+
     private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    
+    private String httpProxyHost;
+
+    private String httpProxyUser;
+
+    private String httpProxyPassword;
+
+    private Integer httpProxyPort;
 
     /**
      * Singleton, on demand instances of Twitter4J's Twitter & TwitterStream.
@@ -126,11 +135,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();
     }
 
@@ -297,6 +320,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/57dde3c8/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 59a8300..b59acc8 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 {
         Assert.assertEquals(new Integer(50), twitterEndpoint.getProperties().getCount());
         Assert.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());
+    }
 }