? compile ? lib ? log4j.xml ? textamerica.patch Index: src/java/org/apache/commons/feedparser/FeedList.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FeedList.java,v retrieving revision 1.2 diff -u -B -r1.2 FeedList.java --- src/java/org/apache/commons/feedparser/FeedList.java 20 Aug 2004 21:44:06 -0000 1.2 +++ src/java/org/apache/commons/feedparser/FeedList.java 23 Sep 2004 00:19:16 -0000 @@ -104,6 +104,12 @@ setAdRSSFeed( ref ); } + + public void clear() { + super.clear(); + this.adAtomFeed = null; + this.adRSSFeed = null; + } } Index: src/java/org/apache/commons/feedparser/locate/BlogService.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/BlogService.java,v retrieving revision 1.1 diff -u -B -r1.1 BlogService.java --- src/java/org/apache/commons/feedparser/locate/BlogService.java 31 Aug 2004 23:57:31 -0000 1.1 +++ src/java/org/apache/commons/feedparser/locate/BlogService.java 23 Sep 2004 00:19:16 -0000 @@ -23,48 +23,63 @@ * @author BradNeuberg */ public class BlogService { - public static BlogService UNKNOWN = new BlogService(0); - public static BlogService DIARYLAND = new BlogService(1); - public static BlogService AOL_JOURNAL = new BlogService(2); - public static BlogService PMACHINE = new BlogService(3); - public static BlogService TEXTPATTERN = new BlogService(4); + public static BlogService UNKNOWN = new BlogService(0, false); + public static BlogService DIARYLAND = new BlogService(1, true); + public static BlogService AOL_JOURNAL = new BlogService(2, true); + public static BlogService PMACHINE = new BlogService(3, true); + public static BlogService TEXTPATTERN = new BlogService(4, true); /* FIXME: We can't detect Manila sites right now. */ - public static BlogService MANILA = new BlogService(5); - public static BlogService TYPEPAD = new BlogService(6); - public static BlogService RADIO_USERLAND = new BlogService(7); - public static BlogService LIVEJOURNAL = new BlogService(8); - public static BlogService WORDPRESS = new BlogService(9); + public static BlogService MANILA = new BlogService(5, true); + public static BlogService TYPEPAD = new BlogService(6, true); + public static BlogService RADIO_USERLAND = new BlogService(7, true); + public static BlogService LIVEJOURNAL = new BlogService(8, true); + public static BlogService WORDPRESS = new BlogService(9, true); /* FIXME: We can't detect iBlog sites right now. */ - public static BlogService IBLOG = new BlogService(10); - public static BlogService XANGA = new BlogService(11); - public static BlogService BLOSXOM = new BlogService(12); - public static BlogService BLOGGER = new BlogService(13); - public static BlogService MOVABLE_TYPE = new BlogService(14); + public static BlogService IBLOG = new BlogService(10, true); + public static BlogService XANGA = new BlogService(11, true); + public static BlogService BLOSXOM = new BlogService(12, true); + public static BlogService BLOGGER = new BlogService(13, true); + public static BlogService MOVABLE_TYPE = new BlogService(14, true); /** FIXME: No way to detect Expression Engine weblogs right now. */ - public static BlogService EXPRESSION_ENGINE = new BlogService(15); - public static BlogService GREYMATTER = new BlogService(16); + public static BlogService EXPRESSION_ENGINE = new BlogService(15, true); + public static BlogService GREYMATTER = new BlogService(16, true); + public static BlogService TEXTAMERICA = new BlogService(17, false); /** The type of BlogService this is, such as BlogService.BLOSXOM. */ private int type; + /** Whether we can trust the results of this blog service's autodiscovery + * links; for example, TextAmerica returns invalid autodiscovery results. + */ + private boolean hasValidAutodiscovery = false; + /** A private constructor to help us do type-safe enumeration. Only called * from within this class. */ - private BlogService(int type) { + private BlogService(int type, boolean hasValidAutodiscovery) { this.type = type; + this.hasValidAutodiscovery = hasValidAutodiscovery; } public int getType() { return type; } + /** Returns hether we can trust the results of this blog service's + * autodiscovery links. For example, TextAmerica returns invalid + * autodiscovery results. + */ + public boolean hasValidAutodiscovery() { + return hasValidAutodiscovery; + } + public String toString() { // use reflection to get the type string; useful so we don't have to // maintain a list of types here. Since this is only used for debugging // purposes its okay to use reflection. try { Field fields[] = getClass().getDeclaredFields(); - BlogService compareMe = new BlogService(type); + BlogService compareMe = new BlogService(type, hasValidAutodiscovery); for (int i = 0; i < fields.length; i++) { // make sure we are dealing with one of our BlogService constants if (fields[i].getType().equals(this.getClass())) { @@ -91,7 +106,9 @@ BlogService compareMe = (BlogService)obj; - return compareMe.getType() == this.type; + // we don't need to check the hasValidAutodiscovery value since equality + // is determined only by the type + return (compareMe.getType() == this.type); } public int hashCode() { Index: src/java/org/apache/commons/feedparser/locate/BlogServiceDiscovery.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/BlogServiceDiscovery.java,v retrieving revision 1.1 diff -u -B -r1.1 BlogServiceDiscovery.java --- src/java/org/apache/commons/feedparser/locate/BlogServiceDiscovery.java 31 Aug 2004 23:57:31 -0000 1.1 +++ src/java/org/apache/commons/feedparser/locate/BlogServiceDiscovery.java 23 Sep 2004 00:19:16 -0000 @@ -113,6 +113,9 @@ else if (isTextPattern(resource, content)) { return BlogService.TEXTPATTERN; } + else if (isTextAmerica(resource, content)) { + return BlogService.TEXTAMERICA; + } else { return BlogService.UNKNOWN; } @@ -261,6 +264,14 @@ Matcher blosxomMatcher = blosxomPattern.matcher(content); results = blosxomMatcher.find(); + + return results; + } + + protected static boolean isTextAmerica( String resource, String content ) { + boolean results = false; + + results = containsDomain(resource, "textamerica.com"); return results; } Index: src/java/org/apache/commons/feedparser/locate/FeedLocator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedLocator.java,v retrieving revision 1.19 diff -u -B -r1.19 FeedLocator.java --- src/java/org/apache/commons/feedparser/locate/FeedLocator.java 2 Sep 2004 00:36:25 -0000 1.19 +++ src/java/org/apache/commons/feedparser/locate/FeedLocator.java 23 Sep 2004 00:19:16 -0000 @@ -88,10 +88,8 @@ //this failed... try probe location. This is more reliable than //LinkLocation but requires a few more HTTP gets. - if ( list.size() == 0 ) { - log.info( "Using ProbeLocator..." ); - ProbeLocator.locate( resource, content, list ); - } + log.info( "Using ProbeLocator..." ); + ProbeLocator.locate( resource, content, list ); return list; @@ -133,17 +131,17 @@ Iterator it = l.iterator(); if ( it.hasNext() == false ) { - System.out.println( "NO LINKS FOUND" ); + log.info( "NO LINKS FOUND" ); } - System.out.println( " FIXME: (debug): AD RSS: " + l.getAdRSSFeed() ); - System.out.println( " FIXME: (debug): AD Atom: " + l.getAdAtomFeed() ); + log.info( " FIXME: (debug): AD RSS: " + l.getAdRSSFeed() ); + log.info( " FIXME: (debug): AD Atom: " + l.getAdAtomFeed() ); while ( it.hasNext() ) { FeedReference ref = (FeedReference)it.next(); - System.out.println( ref.resource ); + log.info( ref.resource ); } Index: src/java/org/apache/commons/feedparser/locate/ProbeLocator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/ProbeLocator.java,v retrieving revision 1.12 diff -u -B -r1.12 ProbeLocator.java --- src/java/org/apache/commons/feedparser/locate/ProbeLocator.java 14 Sep 2004 01:32:04 -0000 1.12 +++ src/java/org/apache/commons/feedparser/locate/ProbeLocator.java 23 Sep 2004 00:19:17 -0000 @@ -101,7 +101,8 @@ { new FeedReference("atom.xml", FeedReference.ATOM_MEDIA_TYPE) }; FeedReference aolJournalLocations[] = - { new FeedReference("rss.xml", FeedReference.RSS_MEDIA_TYPE) }; + { new FeedReference("atom.xml", FeedReference.ATOM_MEDIA_TYPE), + new FeedReference("rss.xml", FeedReference.RSS_MEDIA_TYPE) }; FeedReference pmachineLocations[] = { new FeedReference("index.xml", FeedReference.RSS_MEDIA_TYPE) }; @@ -138,6 +139,9 @@ FeedReference xangaLocations[] = { new FeedReference("rss.aspx?user=", FeedReference.RSS_MEDIA_TYPE) }; + FeedReference textAmericaLocations[] = + { new FeedReference("rss.aspx", FeedReference.RSS_MEDIA_TYPE) }; + FeedReference unknownLocations[] = { new FeedReference("atom.xml",FeedReference.ATOM_MEDIA_TYPE), new FeedReference("index.rss", FeedReference.RSS_MEDIA_TYPE), @@ -166,6 +170,7 @@ probeMapping.put( BlogService.IBLOG, iBlogLocations ); probeMapping.put( BlogService.XANGA, xangaLocations); probeMapping.put( BlogService.UNKNOWN, unknownLocations ); + probeMapping.put( BlogService.TEXTAMERICA, textAmericaLocations ); } /** @@ -175,12 +180,21 @@ public static final List locate( String resource, String content, FeedList list ) throws Exception { + // determine what blog service we are dealing with + BlogService blogService = BlogServiceDiscovery.discover( resource, content ); + + // fail-fast if we already have some results and if we determine that + // we can trust the results (TextAmerica has invalid autodiscovery, + // for example) + if ( list.size() > 0 && blogService.hasValidAutodiscovery() ) + return list; + else if ( blogService.hasValidAutodiscovery() == false ) { + // clear out the list so far since we can't trust the results + list.clear(); + } + if ( BLOG_SERVICE_PROBING_ENABLED || AGGRESIVE_PROBING_ENABLED ) { - - // determine what blog service we are dealing with - - BlogService blogService = BlogServiceDiscovery.discover( resource, content ); - + String baseFeedPath = getFeedPath( resource ); FeedReference mapping[] = null; @@ -207,6 +221,7 @@ log.info( "pathToTest = " + pathToTest ); if ( feedExists( pathToTest ) ) { + log.info("Feed exists"); FeedReference feedReference = new FeedReference( pathToTest, mapping[i].type ); feedReference.method = FeedReference.METHOD_PROBE_DISCOVERY; @@ -333,9 +348,8 @@ public static void main( String[] args ) throws Exception { - System.out.println( "asdf" ); - System.out.println( getFeedPath( "http://foo.com/bar?cat=dog" ) ); - System.out.println( getFeedPath( "http://foo.com/bar?cat=dog#adf" ) ); + log.info( getFeedPath( "http://foo.com/bar?cat=dog" ) ); + log.info( getFeedPath( "http://foo.com/bar?cat=dog#adf" ) ); } @@ -355,6 +369,7 @@ request.getContentLength(); long response = request.getResponseCode(); + log.info("response="+response); return response == 200; } Index: src/java/org/apache/commons/feedparser/test/TestProbeLocator.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/test/TestProbeLocator.java,v retrieving revision 1.4 diff -u -B -r1.4 TestProbeLocator.java --- src/java/org/apache/commons/feedparser/test/TestProbeLocator.java 5 Sep 2004 22:01:33 -0000 1.4 +++ src/java/org/apache/commons/feedparser/test/TestProbeLocator.java 23 Sep 2004 00:19:17 -0000 @@ -31,1351 +31,552 @@ * @version $Id: TestProbeLocator.java,v 1.4 2004/09/05 22:01:33 burton Exp $ */ public class TestProbeLocator extends TestCase { - - public TestProbeLocator( String name ) throws Exception { - super( name ); + public static boolean NO_ATOM_FEED = false; + public static boolean HAS_ATOM_FEED = true; + + public static boolean NO_RSS_FEED = false; + public static boolean HAS_RSS_FEED = true; + + public TestProbeLocator(String name) throws Exception { + super(name); ProbeLocator.AGGRESIVE_PROBING_ENABLED = true; ProbeLocator.BLOG_SERVICE_PROBING_ENABLED = true; + } + + public static void main( String[] args ) throws Exception { + TestProbeLocator test = new TestProbeLocator( null ); + test.testBlogger(); + test.testLiveJournal(); + test.testDiaryLand(); + test.testMovableType(); + test.testXanga(); + test.testWordPress(); + test.testAOLJournal(); + test.testTypePad(); + test.testGreyMatter(); + test.testPMachine(); + test.testBlosxom(); + test.testRadioUserland(); + test.testTextPattern(); + test.testTextAmerica(); } - public void testBlogger() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference atomFeed, rssFeed; - - // This site should have one Atom feed - resource = "http://edpro.blogspot.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOGGER); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "atom.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "atom.xml"); - - // This site should have one Atom feed - resource = "http://carolinascl.blogspot.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOGGER); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "atom.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "atom.xml"); - - // This site should have one Atom feed - resource = "http://azizindia.blogspot.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOGGER); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "atom.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "atom.xml"); + public void testBlogger() throws Exception { + System.out.println("\nTesting Blogger..."); + testSite("http://edpro.blogspot.com/", BlogService.BLOGGER, 1, + new String[] { FeedReference.ATOM_MEDIA_TYPE }, + new String[] { "http://edpro.blogspot.com/atom.xml" }, + HAS_ATOM_FEED, "http://edpro.blogspot.com/atom.xml", + NO_RSS_FEED, null); + + testSite("http://carolinascl.blogspot.com/", BlogService.BLOGGER, 1, + new String[] { FeedReference.ATOM_MEDIA_TYPE }, + new String[] { "http://carolinascl.blogspot.com/atom.xml" }, + HAS_ATOM_FEED, "http://carolinascl.blogspot.com/atom.xml", + NO_RSS_FEED, null); + + testSite("http://azizindia.blogspot.com/", BlogService.BLOGGER, 1, + new String[] { FeedReference.ATOM_MEDIA_TYPE }, + new String[] { "http://azizindia.blogspot.com/atom.xml" }, + HAS_ATOM_FEED, "http://azizindia.blogspot.com/atom.xml", + NO_RSS_FEED, null); // This site has no blogs - resource = "http://davebarry.blogspot.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOGGER); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 0); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNull(rssFeed); + testSite("http://davebarry.blogspot.com/", BlogService.BLOGGER, 0, + new String[] { }, + new String[] { }, + NO_ATOM_FEED, null, + NO_RSS_FEED, null); } - + public void testLiveJournal() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have an Atom feed and an RSS feed - resource = "http://www.livejournal.com/community/indiexiankids/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.LIVEJOURNAL); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 2); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 2); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "data/atom"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, resource + "data/rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "data/atom"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "data/rss"); - - // This site should have an Atom feed and an RSS feed - resource = "http://www.livejournal.com/community/ajoyforever/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.LIVEJOURNAL); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 2); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 2); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "data/atom"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, resource + "data/rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "data/atom"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "data/rss"); - - // This site should have an Atom feed and an RSS feed - resource = "http://www.livejournal.com/users/_jb_/12332.html"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.LIVEJOURNAL); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 2); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 2); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://www.livejournal.com/users/_jb_/data/atom"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, "http://www.livejournal.com/users/_jb_/data/rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, "http://www.livejournal.com/users/_jb_/data/atom"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://www.livejournal.com/users/_jb_/data/rss"); + System.out.println("\nTesting LiveJournal..."); + testSite("http://www.livejournal.com/community/indiexiankids/", + BlogService.LIVEJOURNAL, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://www.livejournal.com/community/indiexiankids/data/atom", + "http://www.livejournal.com/community/indiexiankids/data/rss" + }, + HAS_ATOM_FEED, "http://www.livejournal.com/community/indiexiankids/data/atom", + HAS_RSS_FEED, "http://www.livejournal.com/community/indiexiankids/data/rss"); + + testSite("http://www.livejournal.com/community/ajoyforever/", + BlogService.LIVEJOURNAL, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://www.livejournal.com/community/ajoyforever/data/atom", + "http://www.livejournal.com/community/ajoyforever/data/rss" + }, + HAS_ATOM_FEED, "http://www.livejournal.com/community/ajoyforever/data/atom", + HAS_RSS_FEED, "http://www.livejournal.com/community/ajoyforever/data/rss"); + + testSite("http://www.livejournal.com/users/_jb_/12332.html", + BlogService.LIVEJOURNAL, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://www.livejournal.com/users/_jb_/data/atom", + "http://www.livejournal.com/users/_jb_/data/rss" + }, + HAS_ATOM_FEED, "http://www.livejournal.com/users/_jb_/data/atom", + HAS_RSS_FEED, "http://www.livejournal.com/users/_jb_/data/rss"); } - + public void testDiaryLand() throws Exception { + System.out.println("\nTesting DiaryLand..."); // FIXME: Test this } - + public void testMovableType() throws Exception { + System.out.println("\nTesting MovableType..."); // FIXME: Test this } - - public void testXanga() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - -// // This site should have an RSS feed -// resource = "http://www.xanga.com/home.aspx?user=lithium98"; -// content = getContent(resource); -// assertNotNull(content); -// blogService = BlogServiceDiscovery.discover(resource, content); -// assertEquals(blogService, BlogService.XANGA); -// list = new FeedList(); -// ProbeLocator.locate(resource, content, list); -// assertEquals(list.size(), 1); -// feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); -// assertEquals(feeds.length, 1); -// assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); -// assertNull(feeds[0].title, null); -// assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); -// assertEquals(feeds[0].resource, "http://www.xanga.com/rss.aspx?user=lithium98"); -// /* test through the FeedLocator */ -// list = FeedLocator.locate(resource); -// atomFeed = list.getAdAtomFeed(); -// rssFeed = list.getAdRSSFeed(); -// assertNull(atomFeed); -// assertNotNull(rssFeed); -// assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); -// assertEquals(rssFeed.resource, "http://www.xanga.com/rss.aspx?user=lithium98"); - -// // This site should have an RSS feed -// resource = "http://www.xanga.com/home.aspx?user=ChUnSA_86"; -// content = getContent(resource); -// assertNotNull(content); -// blogService = BlogServiceDiscovery.discover(resource, content); -// assertEquals(blogService, BlogService.XANGA); -// list = new FeedList(); -// ProbeLocator.locate(resource, content, list); -// assertEquals(list.size(), 1); -// feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); -// assertEquals(feeds.length, 1); -// assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); -// assertNull(feeds[0].title, null); -// assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); -// assertEquals(feeds[0].resource, "http://www.xanga.com/rss.aspx?user=ChUnSA_86"); -// /* test through the FeedLocator */ -// list = FeedLocator.locate(resource); -// atomFeed = list.getAdAtomFeed(); -// rssFeed = list.getAdRSSFeed(); -// assertNull(atomFeed); -// assertNotNull(rssFeed); -// assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); -// assertEquals(rssFeed.resource, "http://www.xanga.com/rss.aspx?user=ChUnSA_86"); - -// // This site should have an RSS feed -// resource = "http://www.xanga.com/home.aspx?user=wdfphillz"; -// content = getContent(resource); -// assertNotNull(content); -// blogService = BlogServiceDiscovery.discover(resource, content); -// assertEquals(blogService, BlogService.XANGA); -// list = new FeedList(); -// ProbeLocator.locate(resource, content, list); -// assertEquals(list.size(), 1); -// feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); -// assertEquals(feeds.length, 1); -// assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); -// assertNull(feeds[0].title, null); -// assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); -// assertEquals(feeds[0].resource, "http://www.xanga.com/rss.aspx?user=wdfphillz"); -// /* test through the FeedLocator */ -// list = FeedLocator.locate(resource); -// atomFeed = list.getAdAtomFeed(); -// rssFeed = list.getAdRSSFeed(); -// assertNull(atomFeed); -// assertNotNull(rssFeed); -// assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); -// assertEquals(rssFeed.resource, "http://www.xanga.com/rss.aspx?user=wdfphillz"); - - // This site should have an RSS feed - - resource = "http://xanga.com/home.aspx?user=joe"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.XANGA); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://www.xanga.com/rss.aspx?user=lithium98"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://www.xanga.com/rss.aspx?user=lithium98"); - - // This site should have an RSS feed - resource = "http://www.xanga.com/home.aspx?user=ChUnSA_86"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.XANGA); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://www.xanga.com/rss.aspx?user=ChUnSA_86"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://www.xanga.com/rss.aspx?user=ChUnSA_86"); - - // This site should have an RSS feed - resource = "http://www.xanga.com/home.aspx?user=wdfphillz"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.XANGA); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://www.xanga.com/rss.aspx?user=wdfphillz"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://www.xanga.com/rss.aspx?user=wdfphillz"); + public void testXanga() throws Exception { + System.out.println("\nTesting Xanga..."); + testSite("http://www.xanga.com/home.aspx?user=lithium98", + BlogService.XANGA, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.xanga.com/rss.aspx?user=lithium98" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=lithium98"); + + testSite("http://www.xanga.com/home.aspx?user=ChUnSA_86", + BlogService.XANGA, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.xanga.com/rss.aspx?user=ChUnSA_86" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=ChUnSA_86"); + + testSite("http://www.xanga.com/home.aspx?user=wdfphillz", + BlogService.XANGA, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.xanga.com/rss.aspx?user=wdfphillz" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=wdfphillz"); - // This site should have an RSS feed // FIXME: We should be able to pass this test when we // expand resources inside of the Feed Parser; we don't // currently do this yet, Brad Neuberg, bkn3@columbia.edu - /*resource = "http://xanga.com/home.aspx?user=joe"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.XANGA); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://xanga.com/rss.aspx?user=joe");*/ - /* test through the FeedLocator */ - /*list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://xanga.com/rss.aspx?user=joe");*/ - } - - public FeedList test( String resource, - BlogService service, - int numFeeds ) throws Exception { - - ResourceRequest request = ResourceRequestFactory.getResourceRequest( resource ); - - String content = request.getInputStreamAsString(); - resource = request.getResource(); - - System.out.println( "resource: " + resource ); - - assertNotNull(content); - - BlogService s = BlogServiceDiscovery.discover( resource, content ); - - assertEquals( s, service ); - - FeedList list = new FeedList(); - ProbeLocator.locate(resource, content, list); - - assertEquals( list.size(), numFeeds ); - - System.out.println( "list: " + list ); - - return list; - - } - - public static void main( String[] args ) throws Exception { - - TestProbeLocator test = new TestProbeLocator( null ); - - test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - /*test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType();*/ - //test.testXanga(); - /*test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern();*/ + /*testSite("http://xanga.com/home.aspx?user=joe", + BlogService.XANGA, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.xanga.com/rss.aspx?user=joe" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=joe");*/ } public void testWordPress() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have an Atom feed and two RSS feeds - resource = "http://synflood.at/blog/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.WORDPRESS); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 3); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 3); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "wp-atom.php"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, resource + "wp-rss2.php"); - assertEquals(feeds[2].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[2].title, null); - assertEquals(feeds[2].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[2].resource, resource + "wp-rss.php"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "wp-atom.php"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "wp-rss2.php"); - - // This site should have an Atom feed and two RSS feeds - resource = "http://holmes.hgen.pitt.edu/~dweeks/wordpress/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.WORDPRESS); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 3); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 3); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "wp-atom.php"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, resource + "wp-rss2.php"); - assertEquals(feeds[2].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[2].title, null); - assertEquals(feeds[2].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[2].resource, resource + "wp-rss.php"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "wp-atom.php"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "wp-rss2.php"); + System.out.println("\nTesting WordPress..."); + testSite("http://synflood.at/blog/", + BlogService.WORDPRESS, 3, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://synflood.at/blog/wp-atom.php", + "http://synflood.at/blog/wp-rss2.php", + "http://synflood.at/blog/wp-rss.php" + }, + HAS_ATOM_FEED, "http://synflood.at/blog/wp-atom.php", + HAS_RSS_FEED, "http://synflood.at/blog/wp-rss2.php"); + + testSite("http://holmes.hgen.pitt.edu/~dweeks/wordpress/", + BlogService.WORDPRESS, 3, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-atom.php", + "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-rss2.php", + "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-rss.php" + }, + HAS_ATOM_FEED, "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-atom.php", + HAS_RSS_FEED, "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-rss2.php"); } - + public void testAOLJournal() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have a single RSS feed - resource = "http://journals.aol.com/redhdka/BrandNewDay/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.AOL_JOURNAL); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "rss.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://journals.aol.com/redhdka/brandnewday/rss.xml"); - - // This site should have a single RSS feed - resource = "http://journals.aol.com/goldenchildnc/GCS/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.AOL_JOURNAL); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "rss.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://journals.aol.com/goldenchildnc/gcs/rss.xml"); - - // This site should have a single RSS feed - resource = "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.AOL_JOURNAL); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "rss.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://journals.aol.com/mkgninja/melissasmisunderstandingsoflife/rss.xml"); + System.out.println("\nTesting AOL Journal..."); + /* AOL recently turned on experimental Atom support, but it is still + buggy; it turns out we can "see" it through autodiscovery but not + through aggresive link probing, since their server returns a 500 + HTTP internal server error if we do a HEAD request. For this + reason we have to divide our testing between the probe locator + and feed locator because they give different results for this + kind of blog service currently. + */ + testProbeLocator( + "http://journals.aol.com/redhdka/BrandNewDay/", + BlogService.AOL_JOURNAL, 1, + new String[] { + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://journals.aol.com/redhdka/BrandNewDay/rss.xml" + }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://journals.aol.com/redhdka/brandnewday/rss.xml"); + testFeedLocator( + "http://journals.aol.com/redhdka/BrandNewDay/", + BlogService.AOL_JOURNAL, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://journals.aol.com/redhdka/BrandNewDay/atom.xml", + "http://journals.aol.com/redhdka/BrandNewDay/rss.xml" + }, + HAS_ATOM_FEED, "http://journals.aol.com/redhdka/brandnewday/atom.xml", + HAS_RSS_FEED, "http://journals.aol.com/redhdka/brandnewday/rss.xml"); + + testProbeLocator( + "http://journals.aol.com/goldenchildnc/GCS/", + BlogService.AOL_JOURNAL, 1, + new String[] { + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://journals.aol.com/goldenchildnc/GCS/rss.xml" + }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://journals.aol.com/goldenchildnc/GCS/rss.xml"); + testFeedLocator( + "http://journals.aol.com/goldenchildnc/GCS/", + BlogService.AOL_JOURNAL, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://journals.aol.com/goldenchildnc/gcs/atom.xml", + "http://journals.aol.com/goldenchildnc/gcs/rss.xml" + }, + HAS_ATOM_FEED, "http://journals.aol.com/goldenchildnc/gcs/atom.xml", + HAS_RSS_FEED, "http://journals.aol.com/goldenchildnc/gcs/rss.xml"); + + + testProbeLocator( + "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/", + BlogService.AOL_JOURNAL, 1, + new String[] { + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/rss.xml" + }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/rss.xml"); + testFeedLocator( + "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/", + BlogService.AOL_JOURNAL, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://journals.aol.com/mkgninja/melissasmisunderstandingsoflife/atom.xml", + "http://journals.aol.com/mkgninja/melissasmisunderstandingsoflife/rss.xml" + }, + HAS_ATOM_FEED, "http://journals.aol.com/mkgninja/melissasmisunderstandingsoflife/atom.xml", + HAS_RSS_FEED, "http://journals.aol.com/mkgninja/melissasmisunderstandingsoflife/rss.xml"); } - - public void testTypePad() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; + public void testTypePad() throws Exception { + System.out.println("\nTesting TypePad..."); // This site has no feed that we can link probe for (it's in a different - // location then usual) - resource = "http://lynikers.typepad.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.TYPEPAD); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 0); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - // we get a feed here, because this site correctly uses autodiscovery - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, "http://lynikers.typepad.com/on_buck_lake/atom.xml"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://lynikers.typepad.com/on_buck_lake/index.rdf"); - + // location then usual). + // However, we get a feed when we go through the FeedParser since + // the site has autodiscovery + testSite("http://lynikers.typepad.com/", + BlogService.TYPEPAD, 0, + new String[] { }, + new String[] { }, + HAS_ATOM_FEED, "http://lynikers.typepad.com/on_buck_lake/atom.xml", + HAS_RSS_FEED, "http://lynikers.typepad.com/on_buck_lake/index.rdf"); + // This site has no feed that we can link probe for (it's in a different - // location then usual) - resource = "http://emmeke.typepad.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.TYPEPAD); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 0); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - // we get a feed here, because this site correctly uses autodiscovery - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://emmeke.typepad.com/blog/index.rdf"); - - // This site should have an Atom feed and one RSS feed - resource = "http://www.prettypolitical.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.TYPEPAD); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 2); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 2); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "atom.xml"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, resource + "index.rdf"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "atom.xml"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "index.rdf"); + // location then usual). + testSite("http://emmeke.typepad.com/", + BlogService.TYPEPAD, 0, + new String[] { }, + new String[] { }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://emmeke.typepad.com/blog/index.rdf"); + + testSite("http://www.prettypolitical.com/", + BlogService.TYPEPAD, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://www.prettypolitical.com/atom.xml", + "http://www.prettypolitical.com/index.rdf" + }, + HAS_ATOM_FEED, "http://www.prettypolitical.com/atom.xml", + HAS_RSS_FEED, "http://www.prettypolitical.com/index.rdf"); } - - public void testGreyMatter() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; + public void testGreyMatter() throws Exception { + System.out.println("\nTesting GreyMatter..."); // No feeds supported - resource = "http://www.chattbike.com/gilligan/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.GREYMATTER); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 0); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNull(rssFeed); - - // No feeds supported - resource = "http://www.electricedge.com/greymatter/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.GREYMATTER); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 0); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNull(rssFeed); - } - - public void testPMachine() throws Exception { - FeedList list = null; - String resource = null, content = null; - - // This site should have a single RSS feed - resource = "http://bamph.com"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.UNKNOWN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bamph.com/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bamph.com/index.xml"); - - // This site should have a single RSS feed - resource = "http://bamph.com"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.UNKNOWN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bamph.com/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bamph.com/index.xml"); - - // This site should have a single RSS feed - resource = "http://bamph.com"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.UNKNOWN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bamph.com/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bamph.com/index.xml"); - - // This site should have a single RSS feed - resource = "http://bamph.com"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.UNKNOWN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bamph.com/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bamph.com/index.xml"); - - // This site should have a single RSS feed - resource = "http://bamph.com"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.UNKNOWN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bamph.com/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bamph.com/index.xml"); - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have a single RSS feed - resource = "http://bucsfishingreport.com/pMachine/weblog.php"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.PMACHINE); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bucsfishingreport.com/pMachine/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bucsfishingreport.com/pMachine/index.xml"); - - // This site should have a single RSS feed - resource = "http://www.simplekindoflife.com/pMachine/weblog.php"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.PMACHINE); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://www.simplekindoflife.com/pMachine/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://www.simplekindoflife.com/pMachine/index.xml"); - - // This site should have a single RSS feed - resource = "http://www.mondfish.net/pmachine/weblog.php"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.PMACHINE); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://www.mondfish.net/pmachine/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://www.mondfish.net/pmachine/index.xml"); - - // This site should have a single RSS feed - resource = "http://bamph.com"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.UNKNOWN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, "http://bamph.com/index.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, "http://bamph.com/index.xml"); - } - - public void testBlosxom() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have a single RSS feed - resource = "http://mikemason.ca/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOSXOM); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "index.rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "index.rss"); - - // This site should have a single RSS feed - resource = "http://www.foobargeek.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOSXOM); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "index.rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - public static void main( String[] args ) throws Exception { + testSite("http://www.chattbike.com/gilligan/", + BlogService.GREYMATTER, 0, + new String[] { }, + new String[] { }, + NO_ATOM_FEED, null, + NO_RSS_FEED, null); - TestProbeLocator test = new TestProbeLocator( null ); - - /*test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 );*/ - - test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType(); - test.testXanga(); - test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern(); + // No feeds supported + testSite("http://www.electricedge.com/greymatter/", + BlogService.GREYMATTER, 0, + new String[] { }, + new String[] { }, + NO_ATOM_FEED, null, + NO_RSS_FEED, null); } - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "index.rss"); - - // This site should have a single RSS feed - resource = "http://www.pipetree.com/qmacro/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOSXOM); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "index.rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - public static void main( String[] args ) throws Exception { - - TestProbeLocator test = new TestProbeLocator( null ); - /*test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 );*/ - - test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType(); - test.testXanga(); - test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern(); + public void testPMachine() throws Exception { + System.out.println("\nTesting PMachine..."); + testSite("http://bamph.com", + BlogService.UNKNOWN, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://bamph.com/index.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://bamph.com/index.xml"); + + testSite("http://bucsfishingreport.com/pMachine/weblog.php", + BlogService.PMACHINE, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://bucsfishingreport.com/pMachine/index.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://bucsfishingreport.com/pMachine/index.xml"); + + testSite("http://www.simplekindoflife.com/pMachine/weblog.php", + BlogService.PMACHINE, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.simplekindoflife.com/pMachine/index.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.simplekindoflife.com/pMachine/index.xml"); + + testSite("http://www.mondfish.net/pmachine/weblog.php", + BlogService.PMACHINE, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.mondfish.net/pmachine/index.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.mondfish.net/pmachine/index.xml"); } - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - // gets a different location - assertEquals(rssFeed.resource, "http://www.pipetree.com/qmacro/xml"); - - // This site should have a single RSS feed - resource = "http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.BLOSXOM); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "/index.rss"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - public static void main( String[] args ) throws Exception { - - TestProbeLocator test = new TestProbeLocator( null ); - /*test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 );*/ - - test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType(); - test.testXanga(); - test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern(); - } - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - // gets a different location - assertEquals(rssFeed.resource, resource + "/index.rss"); + public void testBlosxom() throws Exception { + System.out.println("\nTesting Blosxom..."); + testSite("http://mikemason.ca/", + BlogService.BLOSXOM, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://mikemason.ca/index.rss" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://mikemason.ca/index.rss"); + + testSite("http://www.foobargeek.com/", + BlogService.BLOSXOM, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.foobargeek.com/index.rss" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.foobargeek.com/index.rss"); + + // The FeedParser gets a different location for the XML file then + // through the aggresive prober for this feed + testSite("http://www.pipetree.com/qmacro/", + BlogService.BLOSXOM, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.pipetree.com/qmacro/index.rss" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.pipetree.com/qmacro/xml"); + + testSite("http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi", + BlogService.BLOSXOM, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi/index.rss" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi/index.rss"); } public void testRadioUserland() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have a single RSS feed - resource = "http://radio.weblogs.com/0131722/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.RADIO_USERLAND); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - public static void main( String[] args ) throws Exception { - - TestProbeLocator test = new TestProbeLocator( null ); - - /*test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 );*/ - - test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType(); - test.testXanga(); - test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern(); - } - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "rss.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "rss.xml"); - - // This site should have a single RSS feed - resource = "http://radio.weblogs.com/0131724/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.RADIO_USERLAND); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - public static void main( String[] args ) throws Exception { - - TestProbeLocator test = new TestProbeLocator( null ); - - /*test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 );*/ - - test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType(); - test.testXanga(); - test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern(); - } - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "rss.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "rss.xml"); - - // This site should have a single RSS feed - resource = "http://radio.weblogs.com/0131734/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.RADIO_USERLAND); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 1); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 1); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "rss.xml"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "rss.xml"); + System.out.println("\nTesting Radio Userland..."); + testSite("http://radio.weblogs.com/0131722/", + BlogService.RADIO_USERLAND, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://radio.weblogs.com/0131722/rss.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://radio.weblogs.com/0131722/rss.xml"); + + testSite("http://radio.weblogs.com/0131724/", + BlogService.RADIO_USERLAND, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://radio.weblogs.com/0131724/rss.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://radio.weblogs.com/0131724/rss.xml"); + + testSite("http://radio.weblogs.com/0131734/", + BlogService.RADIO_USERLAND, 1, + new String[] { FeedReference.RSS_MEDIA_TYPE }, + new String[] { "http://radio.weblogs.com/0131734/rss.xml" }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://radio.weblogs.com/0131734/rss.xml"); } public void testTextPattern() throws Exception { - FeedList list = null; - String resource = null, content = null; - BlogService blogService = null; - FeedReference feeds[] = null; - FeedReference rssFeed, atomFeed; - - // This site should have an Atom feed and one RSS feed - resource = "http://www.digitalmediaminute.com/"; - content = getContent(resource); - assertNotNull(content); - blogService = BlogServiceDiscovery.discover(resource, content); - assertEquals(blogService, BlogService.TEXTPATTERN); - list = new FeedList(); - ProbeLocator.locate(resource, content, list); - assertEquals(list.size(), 2); - feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); - assertEquals(feeds.length, 2); - assertEquals(feeds[0].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[0].title, null); - assertEquals(feeds[0].type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(feeds[0].resource, resource + "?atom=1"); - assertEquals(feeds[1].method, FeedReference.METHOD_PROBE_DISCOVERY); - assertNull(feeds[1].title, null); - assertEquals(feeds[1].type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(feeds[1].resource, resource + "?rss=1"); - /* test through the FeedLocator */ - list = FeedLocator.locate(resource); - atomFeed = list.getAdAtomFeed(); - rssFeed = list.getAdRSSFeed(); - assertNotNull(atomFeed); - assertNotNull(rssFeed); - assertEquals(atomFeed.type, FeedReference.ATOM_MEDIA_TYPE); - assertEquals(atomFeed.resource, resource + "?atom=1"); - assertEquals(rssFeed.type, FeedReference.RSS_MEDIA_TYPE); - assertEquals(rssFeed.resource, resource + "?rss=1"); + System.out.println("\nTesting TextPattern..."); + testSite("http://www.digitalmediaminute.com/", + BlogService.TEXTPATTERN, 2, + new String[] { + FeedReference.ATOM_MEDIA_TYPE, + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://www.digitalmediaminute.com/?atom=1", + "http://www.digitalmediaminute.com/?rss=1" + }, + HAS_ATOM_FEED, "http://www.digitalmediaminute.com/?atom=1", + HAS_RSS_FEED, "http://www.digitalmediaminute.com/?rss=1"); + } + + public void testTextAmerica() throws Exception { + System.out.println("\nTesting TextAmerica..."); + testSite("http://morganwebb.textamerica.com/", + BlogService.TEXTAMERICA, 1, + new String[] { + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://morganwebb.textamerica.com/rss.aspx" + }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://morganwebb.textamerica.com/rss.aspx"); + + testSite("http://northlan.textamerica.com/", + BlogService.TEXTAMERICA, 1, + new String[] { + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://northlan.textamerica.com/rss.aspx" + }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://northlan.textamerica.com/rss.aspx"); + + testSite("http://mycamphone.textamerica.com/", + BlogService.TEXTAMERICA, 1, + new String[] { + FeedReference.RSS_MEDIA_TYPE + }, + new String[] { + "http://mycamphone.textamerica.com/rss.aspx" + }, + NO_ATOM_FEED, null, + HAS_RSS_FEED, "http://mycamphone.textamerica.com/rss.aspx"); } - + /** Grabs all the content for a weblog for testing purposes. */ protected String getContent(String resource) throws Exception { - //FIXME: use the IO package from NewsMonster forfor this. - + //FIXME: use the IO package from NewsMonster for this. + URL resourceURL = new URL(resource); URLConnection con = resourceURL.openConnection(); con.connect(); - BufferedReader in = new BufferedReader( - new InputStreamReader(con.getInputStream())); + BufferedReader in = new BufferedReader(new InputStreamReader(con + .getInputStream())); StringBuffer results = new StringBuffer(); String line = null; - - while ( (line = in.readLine()) != null) { + + while ((line = in.readLine()) != null) { results.append(line); } - + return results.toString(); } - - public static void main( String[] args ) throws Exception { - - TestProbeLocator test = new TestProbeLocator( null ); - - /*test.test( "http://xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 ); - - test.test( "http://www.xanga.com/home.aspx?user=joe", - BlogService.XANGA, - 1 );*/ - - test.testBlogger(); - test.testLiveJournal(); - test.testDiaryLand(); - test.testMovableType(); - test.testXanga(); - test.testWordPress(); - test.testAOLJournal(); - test.testTypePad(); - test.testGreyMatter(); - test.testPMachine(); - test.testBlosxom(); - test.testRadioUserland(); - test.testTextPattern(); + + private void testSite(String resource, BlogService correctBlogService, + int numberOfFeeds, String feedType[], + String feedURL[], boolean hasAtomFeed, + String atomFeedURL, boolean hasRSSFeed, + String rssFeedURL) throws Exception { + System.out.println("Testing " + resource + "..."); + /* Test through the probe locator */ + testProbeLocator(resource, correctBlogService, numberOfFeeds, + feedType, feedURL, hasAtomFeed, + atomFeedURL, hasRSSFeed, rssFeedURL); + + /* Test through the FeedLocator */ + testFeedLocator(resource, correctBlogService, numberOfFeeds, + feedType, feedURL, hasAtomFeed, + atomFeedURL, hasRSSFeed, rssFeedURL); + } + + private void testProbeLocator(String resource, BlogService correctBlogService, + int numberOfFeeds, String feedType[], + String feedURL[], boolean hasAtomFeed, + String atomFeedURL, boolean hasRSSFeed, + String rssFeedURL) throws Exception { + String content = getContent(resource); + assertNotNull(content); + + BlogService blogService = BlogServiceDiscovery.discover(resource, content); + assertEquals(correctBlogService, blogService); + + FeedList list = new FeedList(); + ProbeLocator.locate(resource, content, list); + assertEquals(numberOfFeeds, list.size()); + + FeedReference[] feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); + assertEquals(numberOfFeeds, feeds.length); + + for (int i = 0; i < feeds.length; i++) { + assertEquals(FeedReference.METHOD_PROBE_DISCOVERY, feeds[i].method); + assertNull(null, feeds[i].title); + assertEquals(feedType[i], feeds[i].type); + assertEquals(feedURL[i], feeds[i].resource); + } + } + + private void testFeedLocator(String resource, BlogService correctBlogService, + int numberOfFeeds, String feedType[], + String feedURL[], boolean hasAtomFeed, + String atomFeedURL, boolean hasRSSFeed, + String rssFeedURL) throws Exception { + FeedList list = FeedLocator.locate(resource); + FeedReference atomFeed = list.getAdAtomFeed(); + FeedReference rssFeed = list.getAdRSSFeed(); + if (hasAtomFeed) { + assertNotNull(atomFeed); + assertEquals(FeedReference.ATOM_MEDIA_TYPE, atomFeed.type); + assertEquals(atomFeedURL, atomFeed.resource); + } + else + assertNull(atomFeed); + + if (hasRSSFeed) { + assertNotNull(rssFeed); + assertEquals(FeedReference.RSS_MEDIA_TYPE, rssFeed.type); + assertEquals(rssFeedURL, rssFeed.resource); + } + else + assertNull(rssFeed); } }