camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1427776 - in /camel/trunk: components/camel-twitter/ components/camel-twitter/src/main/java/org/apache/camel/component/twitter/ components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/ components/camel-twi...
Date Wed, 02 Jan 2013 13:00:39 GMT
Author: davsclaus
Date: Wed Jan  2 13:00:38 2013
New Revision: 1427776

URL: http://svn.apache.org/viewvc?rev=1427776&view=rev
Log:
CAMEL-5921: Upgraded to twitter4j 3.0.x in camel-twitter. This requires some code changes.
And some code to be removed that is no longer supported in the API.

Removed:
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/trends/DailyTrendConsumer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/trends/WeeklyTrendConsumer.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/DailyTrendDirectTest.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/DailyTrendPollingTest.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/PublicTimeLineDirectTest.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/PublicTimeLinePollingTest.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/WeeklyTrendDirectTest.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/WeeklyTrendPollingTest.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/mocks/
Modified:
    camel/trunk/components/camel-twitter/pom.xml
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/SearchProducer.java
    camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterConverter.java
    camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java
    camel/trunk/parent/pom.xml

Modified: camel/trunk/components/camel-twitter/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/pom.xml?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/pom.xml (original)
+++ camel/trunk/components/camel-twitter/pom.xml Wed Jan  2 13:00:38 2013
@@ -66,11 +66,6 @@
          <artifactId>slf4j-log4j12</artifactId>
          <scope>test</scope>
       </dependency>
-      <dependency>
-         <groupId>org.easymock</groupId>
-         <artifactId>easymock</artifactId>
-         <scope>test</scope>
-      </dependency>
 
    </dependencies>
    

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
Wed Jan  2 13:00:38 2013
@@ -25,15 +25,11 @@ import org.apache.camel.component.twitte
 import org.apache.camel.component.twitter.consumer.streaming.SampleConsumer;
 import org.apache.camel.component.twitter.consumer.timeline.HomeConsumer;
 import org.apache.camel.component.twitter.consumer.timeline.MentionsConsumer;
-import org.apache.camel.component.twitter.consumer.timeline.PublicConsumer;
 import org.apache.camel.component.twitter.consumer.timeline.RetweetsConsumer;
 import org.apache.camel.component.twitter.consumer.timeline.UserConsumer;
-import org.apache.camel.component.twitter.consumer.trends.DailyTrendConsumer;
-import org.apache.camel.component.twitter.consumer.trends.WeeklyTrendConsumer;
 import org.apache.camel.component.twitter.data.ConsumerType;
 import org.apache.camel.component.twitter.data.StreamingType;
 import org.apache.camel.component.twitter.data.TimelineType;
-import org.apache.camel.component.twitter.data.TrendsType;
 import org.apache.camel.component.twitter.producer.DirectMessageProducer;
 import org.apache.camel.component.twitter.producer.SearchProducer;
 import org.apache.camel.component.twitter.producer.UserProducer;
@@ -105,8 +101,6 @@ public final class Twitter4JFactory {
                         return new HomeConsumer(te);
                     case MENTIONS:
                         return new MentionsConsumer(te);
-                    case PUBLIC:
-                        return new PublicConsumer(te);
                     case RETWEETSOFME:
                         return new RetweetsConsumer(te);
                     case USER:
@@ -120,25 +114,13 @@ public final class Twitter4JFactory {
                     }
                 }
                 break;
-            case TRENDS:
-                if (uriSplit.length > 1) {
-                    switch (TrendsType.fromUri(uriSplit[1])) {
-                    case DAILY:
-                        return new DailyTrendConsumer(te);
-                    case WEEKLY:
-                        return new WeeklyTrendConsumer(te);
-                    default:
-                        break;
-                    }
-                }
-                break;
             default:
                 break;
             }
         }
 
-        LOG.warn("A consumer type was not provided (or an incorrect pairing was used).  Defaulting
to Public Timeline!");
-        return new PublicConsumer(te);
+        throw new IllegalArgumentException("Cannot create any consumer with uri " + uri
+                + ". A consumer type was not provided (or an incorrect pairing was used).");
     }
 
     public static DefaultProducer getProducer(TwitterEndpoint te, String uri) throws IllegalArgumentException
{

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
Wed Jan  2 13:00:38 2013
@@ -25,7 +25,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import twitter4j.Query;
 import twitter4j.QueryResult;
-import twitter4j.Tweet;
+import twitter4j.Status;
 import twitter4j.TwitterException;
 
 /**
@@ -39,7 +39,7 @@ public class SearchConsumer extends Twit
         super(te);
     }
 
-    public List<Tweet> pollConsume() throws TwitterException {
+    public List<Status> pollConsume() throws TwitterException {
         String keywords = te.getProperties().getKeywords();
         Query query = new Query(keywords);
         if (te.getProperties().isFilterOld()) {
@@ -49,7 +49,7 @@ public class SearchConsumer extends Twit
         return search(query);
     }
 
-    public List<Tweet> directConsume() throws TwitterException {
+    public List<Status> directConsume() throws TwitterException {
         String keywords = te.getProperties().getKeywords();
         if (keywords == null || keywords.trim().length() == 0) {
             return Collections.emptyList();
@@ -58,12 +58,12 @@ public class SearchConsumer extends Twit
         return search(new Query(keywords));
     }
 
-    private List<Tweet> search(Query query) throws TwitterException {
+    private List<Status> search(Query query) throws TwitterException {
         QueryResult qr = te.getProperties().getTwitter().search(query);
-        List<Tweet> tweets = qr.getTweets();
+        List<Status> tweets = qr.getTweets();
 
         if (te.getProperties().isFilterOld()) {
-            for (Tweet t : tweets) {
+            for (Status t : tweets) {
                 checkLastId(t.getId());
             }
         }

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
Wed Jan  2 13:00:38 2013
@@ -17,8 +17,8 @@
 package org.apache.camel.component.twitter.consumer.streaming;
 
 import org.apache.camel.component.twitter.TwitterEndpoint;
-
 import twitter4j.FilterQuery;
+import twitter4j.StallWarning;
 
 /**
  * Consumes the filter stream
@@ -29,10 +29,16 @@ public class FilterConsumer extends Stre
         super(te);
     }
 
+    @Override
     protected void startStreaming() {
         twitterStream.filter(createFilter(te));
     }
 
+    @Override
+    public void onStallWarning(StallWarning stallWarning) {
+        // noop
+    }
+
     private FilterQuery createFilter(TwitterEndpoint te) {
         FilterQuery filterQuery = new FilterQuery();
         String allLocationsString = te.getProperties().getLocations();
@@ -66,7 +72,6 @@ public class FilterConsumer extends Stre
             throw new IllegalArgumentException("At least one filter parameter is required");
         }
 
-        filterQuery.setIncludeEntities(true);
         return filterQuery;
     }
 }

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
Wed Jan  2 13:00:38 2013
@@ -17,6 +17,7 @@
 package org.apache.camel.component.twitter.consumer.streaming;
 
 import org.apache.camel.component.twitter.TwitterEndpoint;
+import twitter4j.StallWarning;
 
 /**
  * Consumes the sample stream
@@ -27,7 +28,13 @@ public class SampleConsumer extends Stre
         super(te);
     }
 
+    @Override
     protected void startStreaming() {
         twitterStream.sample();
     }
+
+    @Override
+    public void onStallWarning(StallWarning stallWarning) {
+        // noop
+    }
 }

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
Wed Jan  2 13:00:38 2013
@@ -35,7 +35,7 @@ public class MentionsConsumer extends Tw
     }
 
     public List<Status> pollConsume() throws TwitterException {
-        List<Status> list = te.getProperties().getTwitter().getMentions(new Paging(lastId));
+        List<Status> list = te.getProperties().getTwitter().getMentionsTimeline(new
Paging(lastId));
         for (Status s : list) {
             checkLastId(s.getId());
         }
@@ -43,6 +43,6 @@ public class MentionsConsumer extends Tw
     }
 
     public List<Status> directConsume() throws TwitterException {
-        return te.getProperties().getTwitter().getMentions();
+        return te.getProperties().getTwitter().getMentionsTimeline();
     }
 }

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
Wed Jan  2 13:00:38 2013
@@ -16,10 +16,9 @@
  */
 package org.apache.camel.component.twitter.data;
 
-
 public enum ConsumerType {
 
-    TIMELINE, SEARCH, TRENDS, DIRECTMESSAGE, STREAMING, UNKNOWN;
+    TIMELINE, SEARCH, DIRECTMESSAGE, STREAMING, UNKNOWN;
 
     public static ConsumerType fromUri(String uri) {
         for (ConsumerType consumerType : ConsumerType.values()) {

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/SearchProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/SearchProducer.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/SearchProducer.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/SearchProducer.java
Wed Jan  2 13:00:38 2013
@@ -22,10 +22,9 @@ import org.apache.camel.CamelExchangeExc
 import org.apache.camel.Exchange;
 import org.apache.camel.component.twitter.TwitterConstants;
 import org.apache.camel.component.twitter.TwitterEndpoint;
-
 import twitter4j.Query;
 import twitter4j.QueryResult;
-import twitter4j.Tweet;
+import twitter4j.Status;
 import twitter4j.Twitter;
 
 public class SearchProducer extends Twitter4JProducer {
@@ -56,9 +55,9 @@ public class SearchProducer extends Twit
         Twitter twitter = te.getProperties().getTwitter();
         log.debug("Searching twitter with keywords: {}", keywords);
         QueryResult results = twitter.search(query);
-        List<Tweet> list = results.getTweets();
+        List<Status> list = results.getTweets();
 
-        for (Tweet t : list) {
+        for (Status t : list) {
             long newId = t.getId();
             if (newId > lastId) {
                 lastId = newId;

Modified: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterConverter.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterConverter.java
(original)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterConverter.java
Wed Jan  2 13:00:38 2013
@@ -19,12 +19,10 @@ package org.apache.camel.component.twitt
 import java.text.ParseException;
 
 import org.apache.camel.Converter;
-
 import twitter4j.DirectMessage;
 import twitter4j.Status;
 import twitter4j.Trend;
 import twitter4j.Trends;
-import twitter4j.Tweet;
 
 /**
  * Utility for converting between Twitter4J and camel-twitter data layers.
@@ -45,14 +43,6 @@ public final class TwitterConverter {
     }
 
     @Converter
-    public static String toString(Tweet tweet) throws ParseException {
-        StringBuilder s = new StringBuilder();
-        s.append(tweet.getCreatedAt()).append(" (").append(tweet.getFromUser()).append(")
");
-        s.append(tweet.getText());
-        return s.toString();
-    }
-
-    @Converter
     public static String toString(DirectMessage dm) throws ParseException {
         StringBuilder s = new StringBuilder();
         s.append(dm.getCreatedAt()).append(" (").append(dm.getSenderScreenName()).append(")
");

Modified: camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java
(original)
+++ camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchByExchangeDirectTest.java
Wed Jan  2 13:00:38 2013
@@ -18,7 +18,6 @@ package org.apache.camel.component.twitt
 
 import java.util.List;
 
-import junit.framework.Assert;
 import org.apache.camel.Exchange;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
@@ -84,7 +83,7 @@ public class SearchByExchangeDirectTest 
         templateDouble.sendBodyAndHeader(null, TwitterConstants.TWITTER_KEYWORDS, "java");
 
         // due race condition
-        Assert.assertTrue(mock.getReceivedCounter() >= total);
+        assertTrue(mock.getReceivedCounter() >= total);
     }
 
     protected RouteBuilder createRouteBuilder() {

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1427776&r1=1427775&r2=1427776&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Wed Jan  2 13:00:38 2013
@@ -324,8 +324,8 @@
     <tagsoup-bundle-version>1.2_5</tagsoup-bundle-version>
     <tagsoup-version>1.2.1</tagsoup-version>
     <testng-version>6.8</testng-version>
-    <twitter4j-bundle-version>2.2.5_2</twitter4j-bundle-version>
-    <twitter4j-version>2.2.5</twitter4j-version>
+    <twitter4j-bundle-version>3.0.1_1</twitter4j-bundle-version>
+    <twitter4j-version>3.0.3</twitter4j-version>
     <urlrewritefilter-version>4.0.4</urlrewritefilter-version>
     <velocity-bundle-version>1.7_5</velocity-bundle-version>
     <velocity-tools-version>2.0</velocity-tools-version>



Mime
View raw message