Repository: camel Updated Branches: refs/heads/master 5d9a2d99f -> 00bef4ef0
Fixed CS Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/52fdb92d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/52fdb92d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/52fdb92d Branch: refs/heads/master Commit: 52fdb92dbec8b8cfedfde7b06267b9457dc850e0 Parents: 5d9a2d9 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Jul 29 12:37:22 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Jul 29 12:37:22 2015 +0200 ---------------------------------------------------------------------- components/camel-atom/pom.xml | 30 ++++- .../atom/AtomEntryPollingConsumer.java | 23 ++-- .../component/atom/AtomPollingConsumer.java | 10 +- .../apache/camel/component/atom/AtomUtils.java | 20 ++- .../camel/component/feed/FeedEndpoint.java | 34 +++++ .../atom/AtomEntryPollingConsumerTest.java | 5 +- ...omEntryPollingConsumerWithBasicAuthTest.java | 51 ++++++++ .../camel/component/atom/AtomEntrySortTest.java | 15 +-- .../atom/AtomHttpNoCamelParametersTest.java | 2 +- .../AtomPollingConsumerIdleMessageTest.java | 8 +- .../component/atom/AtomPollingConsumerTest.java | 1 - .../AtomPollingConsumerWithBasicAuthTest.java | 50 ++++++++ .../atom/AtomPollingUnthrottledTest.java | 2 +- .../camel/component/atom/AtomRouteTest.java | 2 +- .../camel/component/atom/JettyTestServer.java | 125 ++++++++++++++++++ .../component/atom/UpdatedDateFilterTest.java | 2 +- components/camel-rss/pom.xml | 127 +++++++++++-------- .../component/rss/RssEntryPollingConsumer.java | 7 +- .../camel/component/rss/RssPollingConsumer.java | 7 +- .../apache/camel/component/rss/RssUtils.java | 21 +++ .../camel/component/rss/JettyTestServer.java | 127 +++++++++++++++++++ ...ssEntryPollingConsumerWithBasicAuthTest.java | 58 +++++++++ .../RssPollingConsumerWithBasicAuthTest.java | 49 +++++++ 23 files changed, 676 insertions(+), 100 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-atom/pom.xml b/components/camel-atom/pom.xml index 605fd63..8d477c4 100644 --- a/components/camel-atom/pom.xml +++ b/components/camel-atom/pom.xml @@ -48,6 +48,10 @@ <artifactId>camel-core</artifactId> </dependency> <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + </dependency> + <dependency> <groupId>org.apache.abdera</groupId> <artifactId>abdera-core</artifactId> <version>${abdera-version}</version> @@ -67,10 +71,6 @@ </exclusions> </dependency> <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </dependency> - <dependency> <groupId>org.apache.abdera</groupId> <artifactId>abdera-parser</artifactId> <version>${abdera-version}</version> @@ -113,7 +113,6 @@ </exclusion> </exclusions> </dependency> - <dependency> <groupId>org.apache.ws.commons.axiom</groupId> <artifactId>axiom-api</artifactId> @@ -182,7 +181,7 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test</artifactId> <scope>test</scope> </dependency> <dependency> @@ -192,7 +191,24 @@ </dependency> <dependency> <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>${jetty8-version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-security</artifactId> + <version>${jetty8-version}</version> <scope>test</scope> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java b/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java index 10d7980..8566884 100644 --- a/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java +++ b/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java @@ -25,36 +25,39 @@ import org.apache.abdera.parser.ParseException; import org.apache.camel.Processor; import org.apache.camel.component.feed.EntryFilter; import org.apache.camel.component.feed.FeedEntryPollingConsumer; +import org.apache.camel.util.ObjectHelper; /** * Consumer to poll atom feeds and return each entry from the feed step by step. - * - * @version */ public class AtomEntryPollingConsumer extends FeedEntryPollingConsumer { private Document<Feed> document; public AtomEntryPollingConsumer(AtomEndpoint endpoint, Processor processor, boolean filter, Date lastUpdate, boolean throttleEntries) { super(endpoint, processor, filter, lastUpdate, throttleEntries); - } - + } + private Document<Feed> getDocument() throws IOException, ParseException { if (document == null) { - document = AtomUtils.parseDocument(endpoint.getFeedUri()); + if (ObjectHelper.isEmpty(endpoint.getUsername()) || ObjectHelper.isEmpty(endpoint.getPassword())) { + document = AtomUtils.parseDocument(endpoint.getFeedUri()); + } else { + document = AtomUtils.parseDocument(endpoint.getFeedUri(), endpoint.getUsername(), endpoint.getPassword()); + } Feed root = document.getRoot(); if (endpoint.isSortEntries()) { sortEntries(root); - } - list = root.getEntries(); + } + list = root.getEntries(); entryIndex = list.size() - 1; } return document; } - + protected void sortEntries(Feed feed) { feed.sortEntriesByUpdated(true); } - + @Override protected void populateList(Object feed) throws ParseException, IOException { // list is populated already in the createFeed method @@ -69,7 +72,7 @@ public class AtomEntryPollingConsumer extends FeedEntryPollingConsumer { protected void resetList() { document = null; } - + @Override protected EntryFilter createEntryFilter(Date lastUpdate) { return new UpdatedDateFilter(lastUpdate); http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java b/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java index 1631aca..536e153 100644 --- a/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java +++ b/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java @@ -22,11 +22,10 @@ import org.apache.abdera.model.Document; import org.apache.abdera.model.Feed; import org.apache.camel.Processor; import org.apache.camel.component.feed.FeedPollingConsumer; +import org.apache.camel.util.ObjectHelper; /** * Consumer to poll atom feeds and return the full feed. - * - * @version */ public class AtomPollingConsumer extends FeedPollingConsumer { @@ -36,7 +35,12 @@ public class AtomPollingConsumer extends FeedPollingConsumer { @Override protected Object createFeed() throws IOException { - Document<Feed> document = AtomUtils.parseDocument(endpoint.getFeedUri()); + Document<Feed> document; + if (ObjectHelper.isEmpty(endpoint.getUsername()) || ObjectHelper.isEmpty(endpoint.getPassword())) { + document = AtomUtils.parseDocument(endpoint.getFeedUri()); + } else { + document = AtomUtils.parseDocument(endpoint.getFeedUri(), endpoint.getUsername(), endpoint.getPassword()); + } return document.getRoot(); } } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java b/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java index cd422f3..f6e9b2c 100644 --- a/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java +++ b/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomUtils.java @@ -18,6 +18,7 @@ package org.apache.camel.component.atom; import java.io.IOException; import java.io.InputStream; +import java.net.HttpURLConnection; import java.net.URL; import org.apache.abdera.Abdera; @@ -25,6 +26,7 @@ import org.apache.abdera.model.Document; import org.apache.abdera.model.Feed; import org.apache.abdera.parser.ParseException; import org.apache.abdera.parser.Parser; +import org.apache.commons.codec.binary.Base64; /** * Atom utilities. @@ -46,12 +48,25 @@ public final class AtomUtils { * 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 + * @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 parseInputStream(in); + } + + public static Document<Feed> parseDocument(String uri, String username, String password) throws IOException { + URL feedUrl = new URL(uri); + HttpURLConnection httpcon = (HttpURLConnection) feedUrl.openConnection(); + String encoding = Base64.encodeBase64String(username.concat(":").concat(password).getBytes()); + httpcon.setRequestProperty("Authorization", "Basic " + encoding); + InputStream in = httpcon.getInputStream(); + return parseInputStream(in); + } + + private static Document<Feed> parseInputStream(InputStream in) throws ParseException { Parser parser = getAtomParser(); // set the thread context loader with the ParserClassLoader ClassLoader old = Thread.currentThread().getContextClassLoader(); @@ -61,7 +76,6 @@ public final class AtomUtils { } finally { Thread.currentThread().setContextClassLoader(old); } - } } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java b/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java index fd8cc80..28fe337 100644 --- a/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java +++ b/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java @@ -47,6 +47,10 @@ public abstract class FeedEndpoint extends DefaultPollingEndpoint { private boolean sortEntries; @UriParam(defaultValue = "true") private boolean throttleEntries = true; + @UriParam + private String username; + @UriParam + private String password; public FeedEndpoint() { } @@ -208,6 +212,36 @@ public abstract class FeedEndpoint extends DefaultPollingEndpoint { public boolean isThrottleEntries() { return this.throttleEntries; } + + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * Sets the username to be used for basic authentication + * @param username the username to set + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * Sets the password to be used for basic authentication + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + } // Implementation methods //------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerTest.java index ad03c51..7c97c46 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerTest.java @@ -17,7 +17,6 @@ package org.apache.camel.component.atom; import java.text.SimpleDateFormat; - import javax.naming.Context; import org.apache.camel.builder.RouteBuilder; @@ -59,13 +58,13 @@ public class AtomEntryPollingConsumerTest extends CamelTestSupport { jndi.bind("myDate", df.parse("2007-11-13 14:35:00 +0100")); return jndi; } - + protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("atom:file:src/test/data/feed.atom?splitEntries=true&consumer.delay=500").to("mock:result1"); - from("atom:file:src/test/data/feed.atom?splitEntries=true&filter=false&consumer.delay=500").to("mock:result2"); + from("atom:file:src/test/data/feed.atom?splitEntries=true&filter=false&consumer.delay=500").to("mock:result2"); from("atom:file:src/test/data/feed.atom?splitEntries=true&filter=true&lastUpdate=#myDate&consumer.delay=500").to("mock:result3"); } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerWithBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerWithBasicAuthTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerWithBasicAuthTest.java new file mode 100644 index 0000000..022fa09 --- /dev/null +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntryPollingConsumerWithBasicAuthTest.java @@ -0,0 +1,51 @@ +/** + * 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 org.apache.camel.builder.RouteBuilder; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +public class AtomEntryPollingConsumerWithBasicAuthTest extends AtomEntryPollingConsumerTest { + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("atom:http://localhost:" + JettyTestServer.getInstance().port + "/?splitEntries=true&consumer.delay=500&username=camel&password=camelPass") + .to("mock:result1"); + + from("atom:http://localhost:" + JettyTestServer.getInstance().port + "/?splitEntries=true&filter=false&consumer.delay=500&username=camel&password=camelPass") + .to("mock:result2"); + + from("atom:http://localhost:" + JettyTestServer.getInstance().port + "/?splitEntries=true&filter=true&lastUpdate=#myDate&consumer.delay=500&username=camel&password=camelPass") + .to("mock:result3"); + } + }; + } + + @BeforeClass + public static void startServer() { + JettyTestServer.getInstance().startServer(); + } + + @AfterClass + public static void stopServer() { + JettyTestServer.getInstance().stopServer(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java index 95a94f7..e0c9552 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java @@ -17,7 +17,6 @@ package org.apache.camel.component.atom; import java.util.Date; - import javax.naming.Context; import org.apache.abdera.model.Entry; @@ -32,7 +31,7 @@ import org.junit.Test; public class AtomEntrySortTest extends CamelTestSupport { @Test - public void testSortedEntries() throws Exception { + public void testSortedEntries() throws Exception { MockEndpoint mock = getMockEndpoint("mock:sorted"); mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate")); mock.expectedMessageCount(10); @@ -41,21 +40,21 @@ public class AtomEntrySortTest extends CamelTestSupport { } @Test - public void testUnSortedEntries() throws Exception { + public void testUnSortedEntries() throws Exception { MockEndpoint mock = getMockEndpoint("mock:unsorted"); mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate")); mock.expectedMessageCount(10); mock.setResultWaitTime(2000L); mock.assertIsNotSatisfied(2000L); - } - + } + @Override protected Context createJndiContext() throws Exception { JndiContext jndi = new JndiContext(); jndi.bind("myBean", new MyBean()); return jndi; } - + protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { @@ -64,11 +63,11 @@ public class AtomEntrySortTest extends CamelTestSupport { } }; } - + public static class MyBean { public Date getPubDate(@Body Object body) { Entry syndEntry = (Entry) body; - return syndEntry.getUpdated(); + return syndEntry.getUpdated(); } } } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomHttpNoCamelParametersTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomHttpNoCamelParametersTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomHttpNoCamelParametersTest.java index ce51282..6d8bfc2 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomHttpNoCamelParametersTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomHttpNoCamelParametersTest.java @@ -20,7 +20,7 @@ import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; /** - * @version + * @version */ public class AtomHttpNoCamelParametersTest extends CamelTestSupport { http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java index dee5ec4..4dc8542 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerIdleMessageTest.java @@ -26,7 +26,7 @@ import org.junit.Test; * sendEmptyMessageWhenIdle property is set and a polling event yields no results. */ public class AtomPollingConsumerIdleMessageTest extends CamelTestSupport { - + @Test public void testConsumeIdleMessages() throws Exception { Thread.sleep(110); @@ -36,13 +36,13 @@ public class AtomPollingConsumerIdleMessageTest extends CamelTestSupport { assertTrue(mock.getExchanges().get(0).getIn().getBody() == null); assertTrue(mock.getExchanges().get(1).getIn().getBody() == null); } - + protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("atom:file:src/test/data/empty-feed.atom?splitEntries=true&consumer.delay=50&consumer.initialDelay=0" - + "&feedHeader=false&sendEmptyMessageWhenIdle=true") - .to("mock:result"); + + "&feedHeader=false&sendEmptyMessageWhenIdle=true") + .to("mock:result"); } }; } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java index 2824a23..ff00c29 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java @@ -19,7 +19,6 @@ package org.apache.camel.component.atom; import java.util.List; import org.apache.abdera.model.Feed; - import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.builder.RouteBuilder; http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerWithBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerWithBasicAuthTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerWithBasicAuthTest.java new file mode 100644 index 0000000..c28083e --- /dev/null +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerWithBasicAuthTest.java @@ -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.atom; + +import org.apache.camel.builder.RouteBuilder; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +public class AtomPollingConsumerWithBasicAuthTest extends AtomPollingConsumerTest { + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("atom:http://localhost:" + JettyTestServer.getInstance().port + "/?splitEntries=false&username=camel&password=camelPass") + .to("mock:result"); + + // this is a bit weird syntax that normally is not used using the feedUri parameter + from("atom:?feedUri=http://localhost:" + JettyTestServer.getInstance().port + "/&splitEntries=false&username=camel&password=camelPass") + .to("mock:result2"); + } + }; + } + + @BeforeClass + public static void startServer() { + JettyTestServer.getInstance().startServer(); + } + + @AfterClass + public static void stopServer() { + JettyTestServer.getInstance().stopServer(); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingUnthrottledTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingUnthrottledTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingUnthrottledTest.java index 6708cc8..bad5f60 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingUnthrottledTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingUnthrottledTest.java @@ -22,7 +22,7 @@ import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; /** - * @version + * @version */ public class AtomPollingUnthrottledTest extends CamelTestSupport { http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomRouteTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomRouteTest.java index 2aaa7ae..daffb72 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomRouteTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomRouteTest.java @@ -28,7 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * @version + * @version */ public class AtomRouteTest extends CamelTestSupport { private static final Logger LOG = LoggerFactory.getLogger(AtomRouteTest.class); http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/JettyTestServer.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/JettyTestServer.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/JettyTestServer.java new file mode 100644 index 0000000..81ac513 --- /dev/null +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/JettyTestServer.java @@ -0,0 +1,125 @@ +/** + * 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.File; +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.io.FileUtils; +import org.eclipse.jetty.security.ConstraintMapping; +import org.eclipse.jetty.security.ConstraintSecurityHandler; +import org.eclipse.jetty.security.HashLoginService; +import org.eclipse.jetty.security.SecurityHandler; +import org.eclipse.jetty.security.authentication.BasicAuthenticator; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.security.Constraint; +import org.eclipse.jetty.util.security.Credential; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.fail; + +public final class JettyTestServer { + + private static final Logger LOG = LoggerFactory.getLogger(JettyTestServer.class); + private static JettyTestServer instance; + + public int port; + private Server server; + + private JettyTestServer() { + } + + public void startServer() { + server = new Server(0); + + ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS); + servletContext.setSecurityHandler(basicAuth("camel", "camelPass", "Private!")); + servletContext.setContextPath("/"); + server.setHandler(servletContext); + servletContext.addServlet(new ServletHolder(new MyHttpServlet()), "/*"); + try { + server.start(); + } catch (Exception ex) { + LOG.error("Could not start Server!", ex); + fail(ex.getLocalizedMessage()); + } + port = server.getConnectors()[0].getLocalPort(); + } + + public void stopServer() { + if (server != null) { + try { + server.stop(); + } catch (Exception ex) { + LOG.warn("Server doesn't stop normal...", ex); + } finally { + server = null; + port = 0; + } + } + } + + private SecurityHandler basicAuth(String username, String password, String realm) { + + HashLoginService l = new HashLoginService(); + l.putUser(username, Credential.getCredential(password), new String[]{"user"}); + l.setName(realm); + + Constraint constraint = new Constraint(); + constraint.setName(Constraint.__BASIC_AUTH); + constraint.setRoles(new String[]{"user"}); + constraint.setAuthenticate(true); + + ConstraintMapping cm = new ConstraintMapping(); + cm.setConstraint(constraint); + cm.setPathSpec("/*"); + + ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); + csh.setAuthenticator(new BasicAuthenticator()); + csh.setRealmName("myrealm"); + csh.addConstraintMapping(cm); + csh.setLoginService(l); + + return csh; + + } + + public static JettyTestServer getInstance() { + if (instance == null) { + instance = new JettyTestServer(); + } + return instance; + } + + private class MyHttpServlet extends HttpServlet { + + private static final long serialVersionUID = 5594945031962091041L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.getWriter().write(FileUtils.readFileToString(new File("src/test/data/feed.atom"))); + } + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-atom/src/test/java/org/apache/camel/component/atom/UpdatedDateFilterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/UpdatedDateFilterTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/UpdatedDateFilterTest.java index e0096ea..3b20d6f 100644 --- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/UpdatedDateFilterTest.java +++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/UpdatedDateFilterTest.java @@ -57,5 +57,5 @@ public class UpdatedDateFilterTest extends Assert { } } } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-rss/pom.xml b/components/camel-rss/pom.xml index f9a3f56..42c1c6f 100644 --- a/components/camel-rss/pom.xml +++ b/components/camel-rss/pom.xml @@ -16,64 +16,81 @@ limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> - <parent> - <artifactId>components</artifactId> - <groupId>org.apache.camel</groupId> - <version>2.16-SNAPSHOT</version> - </parent> + <parent> + <artifactId>components</artifactId> + <groupId>org.apache.camel</groupId> + <version>2.16-SNAPSHOT</version> + </parent> - <artifactId>camel-rss</artifactId> - <packaging>bundle</packaging> - <name>Camel :: RSS</name> - <description>Camel RSS support</description> + <artifactId>camel-rss</artifactId> + <packaging>bundle</packaging> + <name>Camel :: RSS</name> + <description>Camel RSS support</description> - <properties> - <camel.osgi.export.pkg>org.apache.camel.component.rss.*;${camel.osgi.version},org.apache.camel.dataformat.rss.*</camel.osgi.export.pkg> - <camel.osgi.export.service> - org.apache.camel.spi.ComponentResolver;component=rss, - org.apache.camel.spi.DataFormatResolver;dataformat=rss - </camel.osgi.export.service> - </properties> + <properties> + <camel.osgi.export.pkg>org.apache.camel.component.rss.*;${camel.osgi.version},org.apache.camel.dataformat.rss.*</camel.osgi.export.pkg> + <camel.osgi.export.service> + org.apache.camel.spi.ComponentResolver;component=rss, + org.apache.camel.spi.DataFormatResolver;dataformat=rss + </camel.osgi.export.service> + </properties> - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-atom</artifactId> - <exclusions> - <exclusion> - <groupId>org.apache.abdera</groupId> - <artifactId>abdera-extensions-main</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>rome</groupId> - <artifactId>rome</artifactId> - <version>${rome-version}</version> - </dependency> - - <!-- test dependencies --> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-atom</artifactId> + <exclusions> + <exclusion> + <groupId>org.apache.abdera</groupId> + <artifactId>abdera-extensions-main</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + <version>${rome-version}</version> + </dependency> + <!-- test dependencies --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>${jetty8-version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-security</artifactId> + <version>${jetty8-version}</version> + <scope>test</scope> + </dependency> + </dependencies> + </project> http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java b/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java index 1789afe..7af6de9 100644 --- a/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java +++ b/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java @@ -23,6 +23,7 @@ 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.FeedEntryPollingConsumer; +import org.apache.camel.util.ObjectHelper; /** * Consumer to poll RSS feeds and return each entry from the feed step by step. @@ -51,7 +52,11 @@ public class RssEntryPollingConsumer extends FeedEntryPollingConsumer { @Override protected Object createFeed() throws Exception { - return RssUtils.createFeed(endpoint.getFeedUri(), RssEntryPollingConsumer.class.getClassLoader()); + if ( ObjectHelper.isEmpty(endpoint.getUsername()) || ObjectHelper.isEmpty(endpoint.getPassword())) { + return RssUtils.createFeed(endpoint.getFeedUri(), RssEntryPollingConsumer.class.getClassLoader()); + } else { + return RssUtils.createFeed(endpoint.getFeedUri(), endpoint.getUsername(), endpoint.getPassword(), RssEntryPollingConsumer.class.getClassLoader()); + } } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java b/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java index 77899fe..0f4e216 100644 --- a/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java +++ b/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssPollingConsumer.java @@ -18,6 +18,7 @@ package org.apache.camel.component.rss; import org.apache.camel.Processor; import org.apache.camel.component.feed.FeedPollingConsumer; +import org.apache.camel.util.ObjectHelper; /** * Consumer to poll RSS feeds and return the full feed. @@ -30,7 +31,11 @@ public class RssPollingConsumer extends FeedPollingConsumer { @Override protected Object createFeed() throws Exception { - return RssUtils.createFeed(endpoint.getFeedUri()); + if ( ObjectHelper.isEmpty(endpoint.getUsername()) || ObjectHelper.isEmpty(endpoint.getPassword())) { + return RssUtils.createFeed(endpoint.getFeedUri()); + } else { + return RssUtils.createFeed(endpoint.getFeedUri(), endpoint.getUsername(), endpoint.getPassword()); + } } } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssUtils.java ---------------------------------------------------------------------- diff --git a/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssUtils.java b/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssUtils.java index d45f4ec..1796d9b 100644 --- a/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssUtils.java +++ b/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssUtils.java @@ -22,6 +22,8 @@ import java.net.URL; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.io.SyndFeedInput; import com.sun.syndication.io.XmlReader; +import java.net.HttpURLConnection; +import org.apache.commons.codec.binary.Base64; public final class RssUtils { @@ -44,4 +46,23 @@ public final class RssUtils { Thread.currentThread().setContextClassLoader(tccl); } } + + public static SyndFeed createFeed(String feedUri, String username, String password) throws Exception { + return createFeed(feedUri, username, password, Thread.currentThread().getContextClassLoader()); + } + + public static SyndFeed createFeed(String feedUri, String username, String password, ClassLoader classLoader) throws Exception { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(classLoader); + URL feedUrl = new URL(feedUri); + HttpURLConnection httpcon = (HttpURLConnection) feedUrl.openConnection(); + String encoding = Base64.encodeBase64String(username.concat(":").concat(password).getBytes()); + httpcon.setRequestProperty("Authorization", "Basic " + encoding); + SyndFeedInput input = new SyndFeedInput(); + return input.build(new XmlReader(httpcon)); + } finally { + Thread.currentThread().setContextClassLoader(tccl); + } + } } http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/src/test/java/org/apache/camel/component/rss/JettyTestServer.java ---------------------------------------------------------------------- diff --git a/components/camel-rss/src/test/java/org/apache/camel/component/rss/JettyTestServer.java b/components/camel-rss/src/test/java/org/apache/camel/component/rss/JettyTestServer.java new file mode 100644 index 0000000..c85bbab --- /dev/null +++ b/components/camel-rss/src/test/java/org/apache/camel/component/rss/JettyTestServer.java @@ -0,0 +1,127 @@ +/** + * 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.io.File; +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.FileUtils; +import org.eclipse.jetty.security.ConstraintMapping; +import org.eclipse.jetty.security.ConstraintSecurityHandler; +import org.eclipse.jetty.security.HashLoginService; +import org.eclipse.jetty.security.SecurityHandler; +import org.eclipse.jetty.security.authentication.BasicAuthenticator; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.security.Constraint; +import org.eclipse.jetty.util.security.Credential; +import static org.junit.Assert.fail; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Alexander Friedrichs + */ +public class JettyTestServer { + + private static final Logger LOG = LoggerFactory.getLogger(JettyTestServer.class); + private static JettyTestServer _INSTANCE; + + private Server server; + public int port; + + private JettyTestServer() { + } + + public void startServer() { + server = new Server(0); + + ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS); + servletContext.setSecurityHandler(basicAuth("camel", "camelPass", "Private!")); + servletContext.setContextPath("/"); + server.setHandler(servletContext); + servletContext.addServlet(new ServletHolder(new MyHttpServlet()), "/*"); + try { + server.start(); + } catch (Exception ex) { + LOG.error("Could not start Server!", ex); + fail(ex.getLocalizedMessage()); + } + port = server.getConnectors()[0].getLocalPort(); + } + + public void stopServer() { + if (server != null) { + try { + server.stop(); + } catch (Exception ex) { + LOG.warn("Server doesn't stop normal...", ex); + } finally { + server = null; + port = 0; + } + } + } + + private SecurityHandler basicAuth(String username, String password, String realm) { + + HashLoginService l = new HashLoginService(); + l.putUser(username, Credential.getCredential(password), new String[]{"user"}); + l.setName(realm); + + Constraint constraint = new Constraint(); + constraint.setName(Constraint.__BASIC_AUTH); + constraint.setRoles(new String[]{"user"}); + constraint.setAuthenticate(true); + + ConstraintMapping cm = new ConstraintMapping(); + cm.setConstraint(constraint); + cm.setPathSpec("/*"); + + ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); + csh.setAuthenticator(new BasicAuthenticator()); + csh.setRealmName("myrealm"); + csh.addConstraintMapping(cm); + csh.setLoginService(l); + + return csh; + + } + + public static JettyTestServer getInstance() { + if (_INSTANCE == null) { + _INSTANCE = new JettyTestServer(); + } + return _INSTANCE; + } + + private class MyHttpServlet extends HttpServlet { + + private static final long serialVersionUID = 5594945031962091041L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + resp.getWriter().write(FileUtils.readFileToString(new File("src/test/data/rss20.xml"))); + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntryPollingConsumerWithBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntryPollingConsumerWithBasicAuthTest.java b/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntryPollingConsumerWithBasicAuthTest.java new file mode 100644 index 0000000..ba742bc --- /dev/null +++ b/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntryPollingConsumerWithBasicAuthTest.java @@ -0,0 +1,58 @@ +/** + * 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.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * @author Alexander Friedrichs + */ +public class RssEntryPollingConsumerWithBasicAuthTest extends CamelTestSupport { + + @Test + public void testListOfEntriesIsSplitIntoPieces() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:result"); + mock.expectedMessageCount(10); + mock.assertIsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("rss:http://localhost:"+JettyTestServer.getInstance().port+"/?splitEntries=true&sortEntries=true&consumer.delay=100&username=camel&password=camelPass").to("mock:result"); + } + }; + } + + @BeforeClass + public static void startServer() { + JettyTestServer.getInstance().startServer(); + } + + @AfterClass + public static void stopServer() { + JettyTestServer.getInstance().stopServer(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/52fdb92d/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithBasicAuthTest.java b/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithBasicAuthTest.java new file mode 100644 index 0000000..fba5d8d --- /dev/null +++ b/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssPollingConsumerWithBasicAuthTest.java @@ -0,0 +1,49 @@ +/** + * 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.builder.RouteBuilder; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * + * @author Alexander Friedrichs + */ +public class RssPollingConsumerWithBasicAuthTest extends RssPollingConsumerTest { + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("rss:http://localhost:"+JettyTestServer.getInstance().port+"/?splitEntries=false&username=camel&password=camelPass").to("mock:result"); + } + }; + } + + @BeforeClass + public static void startServer() { + JettyTestServer.getInstance().startServer(); + } + + @AfterClass + public static void stopServer() { + JettyTestServer.getInstance().stopServer(); + } + +}