1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.commons.feedparser.test; |
18 | |
|
19 | |
import java.util.Iterator; |
20 | |
|
21 | |
import junit.framework.TestCase; |
22 | |
|
23 | |
import org.apache.commons.feedparser.FeedList; |
24 | |
import org.apache.commons.feedparser.locate.FeedLocator; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class TestFeedLocator extends TestCase { |
32 | |
protected String feedparserHome; |
33 | |
|
34 | |
public TestFeedLocator( String name ) throws Exception { |
35 | 0 | super( name ); |
36 | |
|
37 | 0 | feedparserHome = System.getProperty("feedparser.home", "."); |
38 | |
|
39 | |
|
40 | |
|
41 | 0 | if (feedparserHome.endsWith("/") == false) |
42 | 0 | feedparserHome = feedparserHome + "/"; |
43 | 0 | } |
44 | |
|
45 | |
private void doTest( String resource ) throws Exception { |
46 | |
|
47 | 0 | System.out.println( "resource: " + resource ); |
48 | |
|
49 | 0 | FeedList l = FeedLocator.locate( resource ); |
50 | |
|
51 | 0 | Iterator it = l.iterator(); |
52 | |
|
53 | |
|
54 | 0 | assertTrue("No links were found for " + resource, it.hasNext()); |
55 | 0 | System.out.println( "Atom: " + l.getAdAtomFeed() ); |
56 | 0 | System.out.println( "RSS: " + l.getAdRSSFeed() ); |
57 | |
|
58 | 0 | } |
59 | |
|
60 | |
public void test1() throws Exception { |
61 | 0 | String path = "file:" + feedparserHome; |
62 | |
|
63 | 0 | doTest( path + "tests/locate/locate1.html" ); |
64 | 0 | doTest( path + "tests/locate/locate2.html" ); |
65 | 0 | doTest( path + "tests/locate/locate3.html" ); |
66 | 0 | doTest( path + "tests/locate/locate4.html" ); |
67 | |
|
68 | 0 | doTest( path + "tests/locate/locate6.html" ); |
69 | 0 | doTest( path + "tests/locate/locate7.html" ); |
70 | 0 | doTest( path + "tests/locate/locate10.html" ); |
71 | 0 | } |
72 | |
|
73 | |
public static void main( String[] args ) throws Exception { |
74 | |
|
75 | 0 | TestFeedLocator test = new TestFeedLocator( null ); |
76 | |
|
77 | |
|
78 | 0 | test.test1(); |
79 | |
|
80 | 0 | } |
81 | |
|
82 | |
} |
83 | |
|