Author: janstey
Date: Thu Dec 4 12:34:32 2008
New Revision: 723427
URL: http://svn.apache.org/viewvc?rev=723427&view=rev
Log:
CAMEL-1101 - Add option to disable feed object getting added as a header.
Added:
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithFeedHeaderDisabledTest.java
(with props)
Modified:
activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
Modified:
activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java?rev=723427&r1=723426&r2=723427&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
(original)
+++
activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
Thu Dec 4 12:34:32 2008
@@ -34,6 +34,7 @@
protected boolean splitEntries = true;
protected Date lastUpdate;
protected boolean filter = true;
+ private boolean feedHeader = true;
public FeedEndpoint(String endpointUri, FeedComponent component, String
feedUri) {
super(endpointUri, component);
@@ -82,7 +83,9 @@
protected Exchange createExchangeWithFeedHeader(Object feed, String
header) {
Exchange exchange = createExchange();
- exchange.getIn().setHeader(header, feed);
+ if (isFeedHeader()) {
+ exchange.getIn().setHeader(header, feed);
+ }
return exchange;
}
@@ -149,6 +152,17 @@
this.filter = filter;
}
+ /**
+ * Sets whether to add the feed object as a header
+ */
+ public void setFeedHeader(boolean feedHeader) {
+ this.feedHeader = feedHeader;
+ }
+
+ public boolean isFeedHeader() {
+ return feedHeader;
+ }
+
// Implementation methods
//-------------------------------------------------------------------------
Added:
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithFeedHeaderDisabledTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithFeedHeaderDisabledTest.java?rev=723427&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithFeedHeaderDisabledTest.java
(added)
+++
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithFeedHeaderDisabledTest.java
Thu Dec 4 12:34:32 2008
@@ -0,0 +1,50 @@
+/**
+ * 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.rss;
+
+import java.util.List;
+
+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 RssPollingConsumerWithFeedHeaderDisabledTest extends
ContextTestSupport {
+
+ public void testNoFeedInHeader() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.assertIsSatisfied();
+
+ Exchange exchange = mock.getExchanges().get(0);
+ Message in = exchange.getIn();
+ assertNotNull(in);
+ assertNull(in.getHeader(RssEndpoint.HEADER_RSS_FEED));
+ }
+
+ 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&feedHeader=false").to("mock:result");
+ }
+ };
+ }
+
+}
Propchange:
activemq/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithFeedHeaderDisabledTest.java
------------------------------------------------------------------------------
svn:eol-style = native