You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/09/19 09:58:21 UTC

svn commit: r998608 - in /camel/trunk/components/camel-rss/src: main/java/org/apache/camel/component/rss/RssComponent.java test/java/org/apache/camel/component/rss/RssUriEncodingIssueTest.java

Author: davsclaus
Date: Sun Sep 19 07:58:20 2010
New Revision: 998608

URL: http://svn.apache.org/viewvc?rev=998608&view=rev
Log:
CAMEL-3114: Fixed rss component bug with uri encoding.

Added:
    camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssUriEncodingIssueTest.java
Modified:
    camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java

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=998608&r1=998607&r2=998608&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 Sun Sep 19 07:58:20 2010
@@ -16,13 +16,12 @@
  */
 package org.apache.camel.component.rss;
 
-import java.net.URI;
+import java.util.LinkedHashMap;
 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.util.CastUtils;
 import org.apache.camel.util.URISupport;
 
 /**
@@ -48,8 +47,9 @@ public class RssComponent extends FeedCo
         // for the http feed
         String feedUri;
         if (!parameters.isEmpty()) {
-            URI remainingUri = URISupport.createRemainingURI(new URI(remaining), CastUtils.cast(parameters));
-            feedUri = remainingUri.toString();
+            Map<Object, Object> options = new LinkedHashMap<Object, Object>(parameters);
+            String query = URISupport.createQueryString(options);
+            feedUri = remaining + "?" + query;
         } else {
             feedUri = remaining;
         }

Added: camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssUriEncodingIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssUriEncodingIssueTest.java?rev=998608&view=auto
==============================================================================
--- camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssUriEncodingIssueTest.java (added)
+++ camel/trunk/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssUriEncodingIssueTest.java Sun Sep 19 07:58:20 2010
@@ -0,0 +1,44 @@
+/**
+ * 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 org.apache.camel.Exchange;
+import org.apache.camel.PollingConsumer;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+@Ignore("Must be online")
+public class RssUriEncodingIssueTest extends CamelTestSupport {
+
+    @Test
+    public void testUriIssue() throws Exception {
+        String uri = "rss:http://api.flickr.com/services/feeds/photos_public.gne?id=23353282@N05&tags=lowlands&lang=en-us&format=rss_200";
+
+        PollingConsumer consumer = context.getEndpoint(uri).createPollingConsumer();
+        consumer.start();
+        Exchange exchange = consumer.receive();
+        log.info("Receive " + exchange);
+        assertNotNull(exchange);
+        assertNotNull(exchange.getIn().getBody());
+        consumer.stop();
+    }
+
+}