001 /* 002 * Copyright 1999,2004 The Apache Software Foundation. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.apache.commons.feedparser.test; 018 019 import java.util.Iterator; 020 021 import junit.framework.TestCase; 022 023 import org.apache.commons.feedparser.FeedList; 024 import org.apache.commons.feedparser.locate.FeedLocator; 025 026 /** 027 * 028 * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a> 029 * @version $Id: TestFeedLocator.java 373622 2006-01-30 22:53:00Z mvdb $ 030 */ 031 public class TestFeedLocator extends TestCase { 032 protected String feedparserHome; 033 034 public TestFeedLocator( String name ) throws Exception { 035 super( name ); 036 037 feedparserHome = System.getProperty("feedparser.home", "."); 038 // these come in as forward slashes, even on Windows, because of Ant, 039 // so it is safe to check them as / rather than File.separator 040 // Brad Neuberg 041 if (feedparserHome.endsWith("/") == false) 042 feedparserHome = feedparserHome + "/"; 043 } 044 045 private void doTest( String resource ) throws Exception { 046 047 System.out.println( "resource: " + resource ); 048 049 FeedList l = FeedLocator.locate( resource ); 050 051 Iterator it = l.iterator(); 052 053 // See if no links were found 054 assertTrue("No links were found for " + resource, it.hasNext()); 055 System.out.println( "Atom: " + l.getAdAtomFeed() ); 056 System.out.println( "RSS: " + l.getAdRSSFeed() ); 057 058 } 059 060 public void test1() throws Exception { 061 String path = "file:" + feedparserHome; 062 063 doTest( path + "tests/locate/locate1.html" ); 064 doTest( path + "tests/locate/locate2.html" ); 065 doTest( path + "tests/locate/locate3.html" ); 066 doTest( path + "tests/locate/locate4.html" ); 067 //doTest( path + "tests/locate/locate5.html" ); 068 doTest( path + "tests/locate/locate6.html" ); 069 doTest( path + "tests/locate/locate7.html" ); 070 doTest( path + "tests/locate/locate10.html" ); 071 } 072 073 public static void main( String[] args ) throws Exception { 074 075 TestFeedLocator test = new TestFeedLocator( null ); 076 077 //test.testGetWeblogLinkForResource(); 078 test.test1(); 079 080 } 081 082 } 083