camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r743414 - in /camel/trunk/components: camel-atom/src/main/java/org/apache/camel/component/atom/ camel-atom/src/main/java/org/apache/camel/component/feed/ camel-atom/src/test/java/org/apache/camel/component/atom/ camel-rss/src/main/java/org/...
Date Wed, 11 Feb 2009 17:27:45 GMT
Author: davsclaus
Date: Wed Feb 11 17:27:44 2009
New Revision: 743414

URL: http://svn.apache.org/viewvc?rev=743414&view=rev
Log:
CAMEL-505: atom and rss endpoints can now be created by regular spring bean style.

Added:
    camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java
  (contents, props changed)
      - copied, changed from r743248, camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
    camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java
  (contents, props changed)
      - copied, changed from r743248, camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerTest.java
Modified:
    camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
    camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedCollection.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedStrategy.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/UpdatedDateFilter.java
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/dataformat/rss/RssDataFormat.java

Modified: camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
(original)
+++ camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
Wed Feb 11 17:27:44 2009
@@ -18,17 +18,12 @@
 
 import java.util.Date;
 
-import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
-import org.apache.camel.Consumer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.Producer;
 import org.apache.camel.component.feed.FeedComponent;
 import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.component.feed.FeedPollingConsumer;
-import org.apache.camel.impl.DefaultPollingEndpoint;
-import org.apache.camel.util.ObjectHelper;
 
 /**
  * An <a href="http://camel.apache.org/atom.html">Atom Endpoint</a>.
@@ -40,7 +35,10 @@
      * Header key for the {@link org.apache.abdera.model.Feed} object is stored on the in
message on the exchange.
      */
     public static final String HEADER_ATOM_FEED = "org.apache.camel.component.atom.feed";
-    
+
+    public AtomEndpoint() {
+    }
+
     public AtomEndpoint(String endpointUri, FeedComponent component, String feedUri) {
         super(endpointUri, component, feedUri);
     }

Modified: camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
(original)
+++ camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
Wed Feb 11 17:27:44 2009
@@ -37,18 +37,17 @@
     private boolean feedHeader = true;
     private boolean sortEntries;
 
+    public FeedEndpoint() {
+    }
+
     public FeedEndpoint(String endpointUri, FeedComponent component, String feedUri) {
         super(endpointUri, component);
         this.feedUri = feedUri;
-
-        ObjectHelper.notNull(feedUri, "feedUri property");
     }
 
     public FeedEndpoint(String endpointUri, String feedUri) {
         this(endpointUri);
         this.feedUri = feedUri;
-
-        ObjectHelper.notNull(feedUri, "feedUri property");
     }
 
     public FeedEndpoint(String endpointUri) {
@@ -64,6 +63,8 @@
     }
 
     public Consumer createConsumer(Processor processor) throws Exception {
+        ObjectHelper.notNull(feedUri, "feedUri");
+
         FeedPollingConsumer answer;
         if (isSplitEntries()) {
             answer = createEntryPollingConsumer(this, processor, filter, lastUpdate);
@@ -107,6 +108,11 @@
      */
     public abstract Exchange createExchange(Object feed, Object entry);
 
+    @Override
+    protected String createEndpointUri() {
+        return "atom:" + feedUri;
+    }
+
     // Properties
     //-------------------------------------------------------------------------
 

Copied: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java
(from r743248, camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java?p2=camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java&p1=camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java&r1=743248&r2=743414&rev=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
(original)
+++ camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java
Wed Feb 11 17:27:44 2009
@@ -16,53 +16,26 @@
  */
 package org.apache.camel.component.atom;
 
-import java.util.List;
-
-import org.apache.abdera.model.Feed;
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * Unit test for AtomPollingConsumer
  */
-public class AtomPollingConsumerTest extends ContextTestSupport {
-
-    public void testNoSplitEntries() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
-        mock.assertIsSatisfied();
-
-        Exchange exchange = mock.getExchanges().get(0);
-        Message in = exchange.getIn();
-        assertNotNull(in);
-        assertTrue(in.getBody() instanceof List);
-        assertTrue(in.getHeader(AtomEndpoint.HEADER_ATOM_FEED) instanceof Feed);
-
-        Feed feed = in.getHeader(AtomEndpoint.HEADER_ATOM_FEED, Feed.class);
-        assertEquals("James Strachan", feed.getAuthor().getName());
-
-        List entries = in.getBody(List.class);
-        assertEquals(7, entries.size());
-    }
-
-    public void testUsingAtomUriParameter() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result2");
-        mock.expectedMessageCount(1);
-        mock.assertIsSatisfied();
-    }
+public class AtomEndpointTest extends AtomPollingConsumerTest {
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("atom:file:src/test/data/feed.atom?splitEntries=false").to("mock:result");
+                AtomEndpoint atom = new AtomEndpoint();
+                atom.setCamelContext(context);
+                atom.setFeedUri("file:src/test/data/feed.atom");
+                atom.setSplitEntries(false);
+
+                context.addEndpoint("atomic", atom);
 
-                // this is a bit weird syntax that normally is not used using the feedUri
parameter
-                from("atom:?feedUri=file:src/test/data/feed.atom&splitEntries=false").to("mock:result2");
+                from("atomic").to("mock:result", "mock:result2");
             }
         };
     }
 
-}
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEndpointTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedCollection.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedCollection.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedCollection.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedCollection.java
Wed Feb 11 17:27:44 2009
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.rss;
 
 import com.sun.syndication.feed.synd.SyndFeed;

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedStrategy.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedStrategy.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/AggregateRssFeedStrategy.java
Wed Feb 11 17:27:44 2009
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.rss;
 
 import java.util.ArrayList;

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
Wed Feb 11 17:27:44 2009
@@ -18,16 +18,13 @@
 
 import java.util.Map;
 
-import org.apache.camel.Endpoint;
 import org.apache.camel.component.feed.FeedComponent;
 import org.apache.camel.component.feed.FeedEndpoint;
-import org.apache.camel.impl.DefaultComponent;
 
 /**
  * An <a href="http://camel.apache.org/rss.html">RSS Component</a>.
  * <p/>
  * Camel uses <a href="https://rome.dev.java.net/">ROME</a> as the RSS implementation.
 
- *
  */
 public class RssComponent extends FeedComponent {
 

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssDateComparator.java
Wed Feb 11 17:27:44 2009
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.rss;
 
 import java.util.Comparator;

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
Wed Feb 11 17:27:44 2009
@@ -19,18 +19,12 @@
 import java.util.Arrays;
 import java.util.Date;
 
-import com.sun.syndication.feed.synd.SyndEntry;
 import com.sun.syndication.feed.synd.SyndFeed;
-
-import org.apache.camel.Consumer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.Producer;
 import org.apache.camel.component.feed.FeedComponent;
 import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.component.feed.FeedPollingConsumer;
-import org.apache.camel.dataformat.rss.RssDataFormat;
-import org.apache.camel.impl.DefaultPollingEndpoint;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -43,8 +37,11 @@
      * Header key for the {@link com.sun.syndication.feed.synd.SyndFeed} object is stored
on the in message on the exchange.
      */
     public static final String HEADER_RSS_FEED = "org.apache.camel.component.rss.feed"; 
-    protected static final transient Log LOG = LogFactory.getLog(RssEndpoint.class);    
-        
+    protected static final transient Log LOG = LogFactory.getLog(RssEndpoint.class);
+
+    public RssEndpoint() {
+    }
+
     public RssEndpoint(String endpointUri, FeedComponent component, String feedUri) {
         super(endpointUri, component, feedUri);
     }
@@ -70,7 +67,7 @@
         SyndFeed newFeed;
         try {
             newFeed = (SyndFeed)((SyndFeed) feed).clone();
-            newFeed.setEntries(Arrays.asList(new Object[] {entry}));
+            newFeed.setEntries(Arrays.asList(entry));
         } catch (CloneNotSupportedException e) {
             LOG.debug("Could not create a new feed.", e);
             newFeed = null;

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
Wed Feb 11 17:27:44 2009
@@ -16,21 +16,17 @@
  */
 package org.apache.camel.component.rss;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 
 import com.sun.syndication.feed.synd.SyndFeed;
-
 import org.apache.camel.Processor;
 import org.apache.camel.component.feed.EntryFilter;
-import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.component.feed.FeedEntryPollingConsumer;
 
 
 /**
  * Consumer to poll RSS feeds and return each entry from the feed step by step.
- *
  */
 public class RssEntryPollingConsumer extends FeedEntryPollingConsumer {
 

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java
Wed Feb 11 17:27:44 2009
@@ -16,11 +16,6 @@
  */
 package org.apache.camel.component.rss;
 
-import java.io.IOException;
-
-import com.sun.syndication.feed.synd.SyndFeed;
-
-import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.feed.FeedPollingConsumer;
 

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/UpdatedDateFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/UpdatedDateFilter.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/UpdatedDateFilter.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/UpdatedDateFilter.java
Wed Feb 11 17:27:44 2009
@@ -42,7 +42,8 @@
 
     public boolean isValidEntry(FeedEndpoint endpoint, Object feed, Object entry) {     
  
         Date updated = ((SyndEntry)entry).getUpdatedDate();
-        if (updated == null) { // never been updated so get published date
+        if (updated == null) {
+            // never been updated so get published date
             updated = ((SyndEntry)entry).getPublishedDate();
         }
         if (updated == null) {

Modified: camel/trunk/components/camel-rss/src/main/java/org/apache/camel/dataformat/rss/RssDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/dataformat/rss/RssDataFormat.java?rev=743414&r1=743413&r2=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/main/java/org/apache/camel/dataformat/rss/RssDataFormat.java
(original)
+++ camel/trunk/components/camel-rss/src/main/java/org/apache/camel/dataformat/rss/RssDataFormat.java
Wed Feb 11 17:27:44 2009
@@ -18,16 +18,14 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.List;
 
-import com.sun.syndication.feed.synd.SyndEntry;
 import com.sun.syndication.feed.synd.SyndFeed;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 /**
  * RSS DataFormat
  * <p/>
@@ -49,7 +47,7 @@
         if (xml != null) {
             out.write(xml.getBytes());
         } else {
-            LOG.debug("Couldn't marshal RSS feed to XML.");
+            LOG.debug("Cannot marshal RSS feed to XML.");
         }
     }
 

Copied: camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java
(from r743248, camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java?p2=camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java&p1=camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerTest.java&r1=743248&r2=743414&rev=743414&view=diff
==============================================================================
--- camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerTest.java
(original)
+++ camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java
Wed Feb 11 17:27:44 2009
@@ -16,42 +16,30 @@
  */
 package org.apache.camel.component.rss;
 
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 
-import com.sun.syndication.feed.synd.SyndFeed;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-public class RssPollingConsumerTest extends ContextTestSupport {
 
-    public void testGrabbingListOfEntries() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMessageCount(1);
-        mock.assertIsSatisfied();
-
-        Exchange exchange = mock.getExchanges().get(0);
-        Message in = exchange.getIn();
-        assertNotNull(in);
-        assertTrue(in.getBody() instanceof SyndFeed);
-        assertTrue(in.getHeader(RssEndpoint.HEADER_RSS_FEED) instanceof SyndFeed);
-
-        SyndFeed feed = in.getHeader(RssEndpoint.HEADER_RSS_FEED, SyndFeed.class);
-        assertTrue(feed.getAuthor().contains("Jonathan Anstey"));
-
-        SyndFeed body = in.getBody(SyndFeed.class);
-        assertEquals(10, body.getEntries().size());
-    }
+public class RssEndpointTest extends RssPollingConsumerTest {
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("rss:file:src/test/data/rss20.xml?splitEntries=false&consumer.delay=100").to("mock:result");
+                RssEndpoint rss = new RssEndpoint();
+                rss.setCamelContext(context);
+                rss.setFeedUri("file:src/test/data/rss20.xml");
+                rss.setSplitEntries(false);
+
+                Map map = new HashMap();
+                map.put("delay", 100);
+                rss.setConsumerProperties(map);
+
+                context.addEndpoint("myrss", rss);
+
+                from("myrss").to("mock:result");
             }
         };
     }
 
-}
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEndpointTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 



Mime
View raw message