aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-rss/src
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2008-04-15 03:06:55 +0000
committerMaria Odea B. Ching <oching@apache.org>2008-04-15 03:06:55 +0000
commit5920685d00fa92bceca8df956bc0235a11bc47bb (patch)
treeedc4ef2fe7fa8b5320220df5877fae796e171554 /archiva-modules/archiva-web/archiva-rss/src
parent328422ab7300a091bb7573821e35b05ac5d3d74a (diff)
downloadarchiva-5920685d00fa92bceca8df956bc0235a11bc47bb.tar.gz
archiva-5920685d00fa92bceca8df956bc0235a11bc47bb.zip
-added additional test case for RssFeedGenerator
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@648105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-rss/src')
-rw-r--r--archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java80
1 files changed, 73 insertions, 7 deletions
diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
index 388f24f5b..c8eb0c192 100644
--- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
+++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java
@@ -35,7 +35,7 @@ public class RssFeedGeneratorTest
extends PlexusInSpringTestCase
{
private RssFeedGenerator generator;
-
+
public void setUp()
throws Exception
{
@@ -46,14 +46,14 @@ public class RssFeedGeneratorTest
File outputDir = new File( getBasedir(), "/target/test-classes/rss-feeds" );
outputDir.mkdir();
}
-
- public void testGenerateFeed()
+
+ public void testNewFeed()
throws Exception
- {
+ {
generator.setRssDirectory( getBasedir() + "/target/test-classes/rss-feeds/" );
-
+
List<RssFeedEntry> entries = new ArrayList<RssFeedEntry>();
- RssFeedEntry entry = new RssFeedEntry( "Item 1", "http://rss-2.0-test-feed.com");
+ RssFeedEntry entry = new RssFeedEntry( "Item 1", "http://rss-2.0-test-feed.com" );
entry.setDescription( "RSS 2.0 feed item 1." );
entry.setGuid( "http://rss-2.0-test-feed.com/item1" );
@@ -84,7 +84,73 @@ public class RssFeedGeneratorTest
"<channel><item><title>Item 1</title></item><item><title>Item 2</title></item>"
+ "<item><title>Item 3</title></item></channel>";
XMLAssert.assertXpathsEqual( "//channel/item/title", expectedItem1, "//channel/item/title", generatedContent );
+
+ outputFile.deleteOnExit();
+ }
+
+ public void testUpdateFeed()
+ throws Exception
+ {
+ generator.setRssDirectory( getBasedir() + "/target/test-classes/rss-feeds/" );
+
+ List<RssFeedEntry> entries = new ArrayList<RssFeedEntry>();
+ RssFeedEntry entry = new RssFeedEntry( "Item 1", "http://rss-2.0-test-feed.com" );
+
+ entry.setDescription( "RSS 2.0 feed item 1." );
+ entry.setGuid( "http://rss-2.0-test-feed.com/item1" );
+ entries.add( entry );
+
+ entry = new RssFeedEntry( "Item 2", "http://rss-2.0-test-feed.com" );
+ entry.setDescription( "RSS 2.0 feed item 2." );
+ entry.setGuid( "http://rss-2.0-test-feed.com/item2" );
+ entries.add( entry );
+
+ generator.generateFeed( "Test Feed", "http://localhost:8080/archiva", "The test feed from Archiva.", entries,
+ "generated-test-update-rss2.0-feed.xml" );
+
+ File outputFile = new File( getBasedir(), "/target/test-classes/rss-feeds/generated-test-update-rss2.0-feed.xml" );
+ String generatedContent = FileUtils.readFileToString( outputFile );
+
+ XMLAssert.assertXpathEvaluatesTo( "Test Feed", "//channel/title", generatedContent );
+ XMLAssert.assertXpathEvaluatesTo( "http://localhost:8080/archiva", "//channel/link", generatedContent );
+ XMLAssert.assertXpathEvaluatesTo( "The test feed from Archiva.", "//channel/description", generatedContent );
+ XMLAssert.assertXpathEvaluatesTo( "en-us", "//channel/language", generatedContent );
+
+ String expectedItem1 =
+ "<channel><item><title>Item 1</title></item><item><title>Item 2</title></item></channel>";
+
+ XMLAssert.assertXpathsEqual( "//channel/item/title", expectedItem1, "//channel/item/title", generatedContent );
+
+ //update existing rss feed
+ entries = new ArrayList<RssFeedEntry>();
+ entry = new RssFeedEntry( "Item 3", "http://rss-2.0-test-feed.com" );
+
+ entry.setDescription( "RSS 2.0 feed item 3." );
+ entry.setGuid( "http://rss-2.0-test-feed.com/item4" );
+ entries.add( entry );
+
+ entry = new RssFeedEntry( "Item 4", "http://rss-2.0-test-feed.com" );
+ entry.setDescription( "RSS 2.0 feed item 4." );
+ entry.setGuid( "http://rss-2.0-test-feed.com/item5" );
+ entries.add( entry );
+
+ generator.generateFeed( "Test Feed", "http://localhost:8080/archiva", "The test feed from Archiva.", entries,
+ "generated-test-update-rss2.0-feed.xml" );
+
+ outputFile = new File( getBasedir(), "/target/test-classes/rss-feeds/generated-test-update-rss2.0-feed.xml" );
+ generatedContent = FileUtils.readFileToString( outputFile );
+
+ XMLAssert.assertXpathEvaluatesTo( "Test Feed", "//channel/title", generatedContent );
+ XMLAssert.assertXpathEvaluatesTo( "http://localhost:8080/archiva", "//channel/link", generatedContent );
+ XMLAssert.assertXpathEvaluatesTo( "The test feed from Archiva.", "//channel/description", generatedContent );
+ XMLAssert.assertXpathEvaluatesTo( "en-us", "//channel/language", generatedContent );
+
+ expectedItem1 =
+ "<channel><item><title>Item 1</title></item><item><title>Item 2</title></item>"
+ + "<item><title>Item 3</title></item><item><title>Item 4</title></item></channel>";
+ XMLAssert.assertXpathsEqual( "//channel/item/title", expectedItem1, "//channel/item/title", generatedContent );
outputFile.deleteOnExit();
}
-}
+
+} \ No newline at end of file