camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r656106 - in /activemq/camel/trunk/components/camel-atom/src: main/java/org/apache/camel/component/atom/ test/java/org/apache/camel/component/atom/
Date Wed, 14 May 2008 05:20:43 GMT
Author: davsclaus
Date: Tue May 13 22:20:42 2008
New Revision: 656106

URL: http://svn.apache.org/viewvc?rev=656106&view=rev
Log:
CAMEL-504: Refactor for camel-atom (work in progress) needs a few more unit tests to cover
some of the new options

Added:
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java
  (with props)
    activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
  (with props)
Modified:
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomProducer.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/EntryFilter.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/UpdatedDateFilter.java

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
Tue May 13 22:20:42 2008
@@ -27,7 +27,9 @@
  * @version $Revision$
  */
 public class AtomComponent extends DefaultComponent {
+
     protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws
Exception {
         return new AtomEndpoint(uri, this, remaining);
     }
+
 }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
Tue May 13 22:20:42 2008
@@ -16,19 +16,10 @@
  */
 package org.apache.camel.component.atom;
 
-import java.io.BufferedOutputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Document;
+import java.util.Date;
+
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.Parser;
 import org.apache.camel.Exchange;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Producer;
@@ -40,19 +31,30 @@
  *
  * @version $Revision$
  */
-public class AtomEndpoint extends DefaultPollingEndpoint {
-    private Factory atomFactory;
+public class AtomEndpoint extends DefaultPollingEndpoint<Exchange> {
+
+    /**
+     * 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";
+
     private String atomUri;
     private boolean splitEntries = true;
+    private Date lastUpdate;
+    private boolean filter = true;
 
     public AtomEndpoint(String endpointUri, AtomComponent component, String atomUri) {
         super(endpointUri, component);
         this.atomUri = atomUri;
+
+        ObjectHelper.notNull(atomUri, "atomUri property");
     }
 
     public AtomEndpoint(String endpointUri, String atomUri) {
         this(endpointUri);
         this.atomUri = atomUri;
+
+        ObjectHelper.notNull(atomUri, "atomUri property");
     }
 
     public AtomEndpoint(String endpointUri) {
@@ -63,50 +65,48 @@
         return true;
     }
 
-    public Producer createProducer() throws Exception {
-        validate();
-        return new AtomProducer(this);
+    public Producer<Exchange> createProducer() throws Exception {
+        throw new UnsupportedOperationException("AtomProducer is not implemented");
     }
 
     @Override
-    public PollingConsumer createPollingConsumer() throws Exception {
-        validate();
+    public PollingConsumer<Exchange> createPollingConsumer() throws Exception {
         if (isSplitEntries()) {
-            return new AtomEntryPollingConsumer(this);
+            return new AtomEntryPollingConsumer(this, filter, lastUpdate);
         } else {
             return new AtomPollingConsumer(this);
         }
     }
 
-    public Document<Feed> parseDocument() throws Exception {
-        String uri = getAtomUri();
-        InputStream in = new URL(uri).openStream();
-        return createAtomParser().parse(in, uri);
-    }
-
-    public OutputStream createProducerOutputStream() throws FileNotFoundException {
-        return new BufferedOutputStream(new FileOutputStream(getAtomUri()));
+    /**
+     * Creates an Exchange with the entries as the in body.
+     *
+     * @param feed   the atom feed
+     * @return the created exchange
+     */
+    public Exchange createExchange(Feed feed) {
+        Exchange exchange = createExchange();
+        exchange.getIn().setBody(feed.getEntries());
+        exchange.getIn().setHeader(HEADER_ATOM_FEED, feed);
+        return exchange;
     }
 
-    public Exchange createExchange(Document<Feed> document, Entry entry) {
+    /**
+     * Creates an Exchange with the given entry as the in body.
+     *
+     * @param feed   the atom feed
+     * @param entry  the entry as the in body
+     * @return the created exchange
+     */
+    public Exchange createExchange(Feed feed, Entry entry) {
         Exchange exchange = createExchange();
         exchange.getIn().setBody(entry);
-        exchange.setProperty("CamelAtomFeed", document);
+        exchange.getIn().setHeader(HEADER_ATOM_FEED, feed);
         return exchange;
     }
 
     // Properties
     //-------------------------------------------------------------------------
-    public Factory getAtomFactory() {
-        if (atomFactory == null) {
-            atomFactory = createAtomFactory();
-        }
-        return atomFactory;
-    }
-
-    public void setAtomFactory(Factory atomFactory) {
-        this.atomFactory = atomFactory;
-    }
 
     public String getAtomUri() {
         return atomUri;
@@ -128,21 +128,30 @@
         this.splitEntries = splitEntries;
     }
 
-    // Implementation methods
-    //-------------------------------------------------------------------------
+    public Date getLastUpdate() {
+        return lastUpdate;
+    }
 
     /**
-     * Validates the endpoint is configured properly
+     * Sets the timestamp to be used for filtering entries from the atom feeds.
+     * This options is only in conjunction with the splitEntries.
      */
-    protected void validate() {
-        ObjectHelper.notNull(getAtomUri(), "atomUri property");
+    public void setLastUpdate(Date lastUpdate) {
+        this.lastUpdate = lastUpdate;
     }
 
-    protected Factory createAtomFactory() {
-        return Abdera.getNewFactory();
+    public boolean isFilter() {
+        return filter;
     }
 
-    protected Parser createAtomParser() {
-        return Abdera.getNewParser();
+    /**
+     * Sets wether to use filtering or not of the entries.
+     */
+    public void setFilter(boolean filter) {
+        this.filter = filter;
     }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+
 }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
Tue May 13 22:20:42 2008
@@ -16,40 +16,56 @@
  */
 package org.apache.camel.component.atom;
 
+import java.io.IOException;
 import java.util.List;
+import java.util.Date;
 
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.ParseException;
 import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.PollingConsumerSupport;
 
 /**
+ * Consumer to poll atom feeds and return each entry from the feed step by step.
+ *
  * @version $Revision$
  */
-public class AtomEntryPollingConsumer extends PollingConsumerSupport {
+public class AtomEntryPollingConsumer extends PollingConsumerSupport<Exchange> {
     private final AtomEndpoint endpoint;
     private Document<Feed> document;
     private int entryIndex;
-    private EntryFilter entryFilter = new UpdatedDateFilter();
+    private EntryFilter entryFilter;
     private List<Entry> list;
 
-    public AtomEntryPollingConsumer(AtomEndpoint endpoint) {
+    public AtomEntryPollingConsumer(AtomEndpoint endpoint, boolean filter, Date lastUpdate)
{
         super(endpoint);
         this.endpoint = endpoint;
+        if (filter) {
+            entryFilter = new UpdatedDateFilter(lastUpdate);
+        }
     }
 
     public Exchange receiveNoWait() {
         try {
             getDocument();
+            Feed feed = document.getRoot();
 
             while (hasNextEntry()) {
                 Entry entry = list.get(entryIndex--);
-                if (entryFilter.isValidEntry(endpoint, document, entry)) {
-                    return endpoint.createExchange(document, entry);
+
+                boolean valid = true;
+                if (entryFilter != null) {
+                    valid = entryFilter.isValidEntry(endpoint, document, entry);
+                }
+                if (valid) {
+                    return endpoint.createExchange(feed, entry);
                 }
             }
+
+            // reset document to be able to poll again
             document = null;
             return null;
         } catch (Exception e) {
@@ -65,36 +81,23 @@
         return receiveNoWait();
     }
 
-    // Properties
-    //-------------------------------------------------------------------------
-
-    public EntryFilter getEntryFilter() {
-        return entryFilter;
-    }
-
-    public void setEntryFilter(EntryFilter entryFilter) {
-        this.entryFilter = entryFilter;
-    }
-
-    // Implementation methods
-    //-------------------------------------------------------------------------
-
     protected void doStart() throws Exception {
     }
 
     protected void doStop() throws Exception {
     }
 
-    public Document<Feed> getDocument() throws Exception {
+    private Document<Feed> getDocument() throws IOException, ParseException {
         if (document == null) {
-            document = endpoint.parseDocument();
+            document = AtomUtils.parseDocument(endpoint.getAtomUri());
             list = document.getRoot().getEntries();
             entryIndex = list.size() - 1;
         }
         return document;
     }
 
-    protected boolean hasNextEntry() {
+    private boolean hasNextEntry() {
         return entryIndex >= 0;
     }
+
 }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
Tue May 13 22:20:42 2008
@@ -23,9 +23,11 @@
 import org.apache.camel.impl.PollingConsumerSupport;
 
 /**
+ * Consumer to poll atom feeds and return the full feed.
+ *
  * @version $Revision$
  */
-public class AtomPollingConsumer extends PollingConsumerSupport {
+public class AtomPollingConsumer extends PollingConsumerSupport<Exchange> {
     private final AtomEndpoint endpoint;
 
     public AtomPollingConsumer(AtomEndpoint endpoint) {
@@ -35,10 +37,9 @@
 
     public Exchange receiveNoWait() {
         try {
-            Document<Feed> document = endpoint.parseDocument();
-            Exchange exchange = endpoint.createExchange();
-            exchange.getIn().setBody(document);
-            return exchange;
+            Document<Feed> document = AtomUtils.parseDocument(endpoint.getAtomUri());
+            Feed feed = document.getRoot();
+            return endpoint.createExchange(feed);
         } catch (Exception e) {
             throw new RuntimeCamelException(e);
         }
@@ -57,4 +58,5 @@
 
     protected void doStop() throws Exception {
     }
+    
 }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomProducer.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomProducer.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomProducer.java
Tue May 13 22:20:42 2008
@@ -16,20 +16,14 @@
  */
 package org.apache.camel.component.atom;
 
-import java.io.OutputStream;
-import java.util.Date;
-
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.util.ExchangeHelper;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
+ * AtomProducer is currently not implemented
+ *
  * @version $Revision$
  */
 public class AtomProducer extends DefaultProducer {
@@ -42,40 +36,7 @@
     }
 
     public void process(Exchange exchange) throws Exception {
-        Document<Feed> document = getDocument(exchange);
-
-        // now lets write the document...
-        OutputStream out = endpoint.createProducerOutputStream();
-        try {
-            document.writeTo(out);
-        } finally {
-            ObjectHelper.close(out, "Atom document output stream", LOG);
-        }
+        throw new UnsupportedOperationException("AtomProducer is not implemented");
     }
 
-    protected Document<Feed> getDocument(Exchange exchange) throws Exception {
-        Document<Feed> document = endpoint.parseDocument();
-        Feed root = document.getRoot();
-        Entry entry = root.addEntry();
-        entry.setPublished(ExchangeHelper.getExchangeProperty(exchange, "org.apache.camel.atom.published",
Date.class, new Date()));
-
-        String id = exchange.getProperty("org.apache.camel.atom.id", String.class);
-        if (id != null) {
-            entry.setId(id);
-        }
-        String content = exchange.getProperty("org.apache.camel.atom.content", String.class);
-        if (content != null) {
-            entry.setContent(content);
-        }
-        String summary = exchange.getProperty("org.apache.camel.atom.summary", String.class);
-        if (summary != null) {
-            entry.setSummary(summary);
-        }
-        String title = exchange.getProperty("org.apache.camel.atom.title", String.class);
-        if (title != null) {
-            entry.setTitle(title);
-        }
-        // TODO categories, authors etc
-        return document;
-    }
 }

Added: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java?rev=656106&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java
(added)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java
Tue May 13 22:20:42 2008
@@ -0,0 +1,54 @@
+/**
+ * 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
+ *
+ * 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.
+ */
+package org.apache.camel.component.atom;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+
+/**
+ * Atom utilities.
+ */
+public class AtomUtils {
+
+    /**
+     * Gets the Atom parser.
+     */
+    public static Parser getAtomParser() {
+        return Abdera.getInstance().getParser();
+    }
+
+    /**
+     * Parses the given uri and returns the response as a atom feed document.
+     *  
+     * @param uri the uri for the atom feed.
+     * @return  the document
+     * @throws IOException is thrown if error reading from the uri
+     * @throws ParseException is thrown if the parsing failed
+     */
+    public static Document<Feed> parseDocument(String uri) throws IOException, ParseException
{
+        InputStream in = new URL(uri).openStream();
+        return getAtomParser().parse(in);
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/EntryFilter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/EntryFilter.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/EntryFilter.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/EntryFilter.java
Tue May 13 22:20:42 2008
@@ -21,8 +21,21 @@
 import org.apache.abdera.model.Feed;
 
 /**
+ * Filter used by the {@link org.apache.camel.component.atom.AtomEntryPollingConsumer} to
filter entries
+ * from the feed.
+ *
  * @version $Revision$
  */
 public interface EntryFilter {
+
+    /**
+     * Tests to be used as filtering the feed for only entries of interest, such as only
new entries, etc.
+     *
+     * @param endpoint  the endpoint
+     * @param feed      the Atom feed
+     * @param entry     the given entry to filter
+     * @return  <tt>true</tt> to include the entry, <ff>false</tt>
to skip it
+     */
     boolean isValidEntry(AtomEndpoint endpoint, Document<Feed> feed, Entry entry);
+
 }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/UpdatedDateFilter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/UpdatedDateFilter.java?rev=656106&r1=656105&r2=656106&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/UpdatedDateFilter.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/UpdatedDateFilter.java
Tue May 13 22:20:42 2008
@@ -31,38 +31,33 @@
  * @version $Revision$
  */
 public class UpdatedDateFilter implements EntryFilter {
+
     private static final transient Log LOG = LogFactory.getLog(UpdatedDateFilter.class);
-    private Date lastTime;
+    private Date lastUpdate;
+
+    public UpdatedDateFilter(Date lastUpdate) {
+        this.lastUpdate = lastUpdate;
+    }
 
     public boolean isValidEntry(AtomEndpoint endpoint, Document<Feed> feed, Entry entry)
{
-        Date updated = getUpdated(endpoint, feed, entry);
+        Date updated = entry.getUpdated();
         if (updated == null) {
-            warnNoUpdatedTime(endpoint, feed, entry);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("No updated time for entry so assuming its valid: entry=[" + entry
+ "]");
+            }
             return true;
         }
-        if (lastTime != null) {
-            if (lastTime.after(updated)) {
+        if (lastUpdate != null) {
+            if (lastUpdate.after(updated)) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Entry is older than lastupdate=[" + lastUpdate
+                        + "], no valid entry=[" + entry + "]");
+                }
                 return false;
             }
         }
-        lastTime = updated;
+        lastUpdate = updated;
         return true;
     }
 
-    protected Date getUpdated(AtomEndpoint endpoint, Document<Feed> feed, Entry entry)
{
-        Date answer = entry.getUpdated();
-        if (answer == null) {
-            answer = entry.getEdited();
-
-            // TODO is this valid?
-            if (answer == null) {
-                answer = entry.getPublished();
-            }
-        }
-        return answer;
-    }
-
-    protected void warnNoUpdatedTime(AtomEndpoint endpoint, Document<Feed> feed, Entry
entry) {
-        LOG.warn("No updated time for entry so assuming new: " + entry);
-    }
 }

Added: activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java?rev=656106&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
(added)
+++ activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
Tue May 13 22:20:42 2008
@@ -0,0 +1,44 @@
+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());
+
+    }
+
+    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");
+            }
+        };
+    }
+
+}

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

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



Mime
View raw message