| 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.io.BufferedReader; |
| 20 | |
import java.io.InputStreamReader; |
| 21 | |
import java.net.URL; |
| 22 | |
import java.net.URLConnection; |
| 23 | |
|
| 24 | |
import junit.framework.TestCase; |
| 25 | |
|
| 26 | |
import org.apache.commons.feedparser.FeedList; |
| 27 | |
import org.apache.commons.feedparser.locate.BlogServiceDiscovery; |
| 28 | |
import org.apache.commons.feedparser.locate.FeedLocator; |
| 29 | |
import org.apache.commons.feedparser.locate.FeedReference; |
| 30 | |
import org.apache.commons.feedparser.locate.ProbeLocator; |
| 31 | |
import org.apache.commons.feedparser.locate.blogservice.AOLJournal; |
| 32 | |
import org.apache.commons.feedparser.locate.blogservice.BlogService; |
| 33 | |
import org.apache.commons.feedparser.locate.blogservice.Blogger; |
| 34 | |
import org.apache.commons.feedparser.locate.blogservice.Blosxom; |
| 35 | |
import org.apache.commons.feedparser.locate.blogservice.GreyMatter; |
| 36 | |
import org.apache.commons.feedparser.locate.blogservice.LiveJournal; |
| 37 | |
import org.apache.commons.feedparser.locate.blogservice.PMachine; |
| 38 | |
import org.apache.commons.feedparser.locate.blogservice.RadioUserland; |
| 39 | |
import org.apache.commons.feedparser.locate.blogservice.TextAmerica; |
| 40 | |
import org.apache.commons.feedparser.locate.blogservice.TextPattern; |
| 41 | |
import org.apache.commons.feedparser.locate.blogservice.Typepad; |
| 42 | |
import org.apache.commons.feedparser.locate.blogservice.Unknown; |
| 43 | |
import org.apache.commons.feedparser.locate.blogservice.WordPress; |
| 44 | |
import org.apache.commons.feedparser.locate.blogservice.Xanga; |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public class TestProbeLocator extends TestCase { |
| 52 | 0 | public static boolean NO_ATOM_FEED = false; |
| 53 | 0 | public static boolean HAS_ATOM_FEED = true; |
| 54 | |
|
| 55 | 0 | public static boolean NO_RSS_FEED = false; |
| 56 | 0 | public static boolean HAS_RSS_FEED = true; |
| 57 | |
|
| 58 | |
public TestProbeLocator(String name) throws Exception { |
| 59 | 0 | super(name); |
| 60 | 0 | ProbeLocator.AGGRESIVE_PROBING_ENABLED = true; |
| 61 | 0 | ProbeLocator.BLOG_SERVICE_PROBING_ENABLED = true; |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
public static void main( String[] args ) throws Exception { |
| 65 | 0 | TestProbeLocator test = new TestProbeLocator( null ); |
| 66 | |
|
| 67 | 0 | test.testBlogger(); |
| 68 | 0 | test.testLiveJournal(); |
| 69 | 0 | test.testDiaryLand(); |
| 70 | 0 | test.testMovableType(); |
| 71 | 0 | test.testXanga(); |
| 72 | 0 | test.testWordPress(); |
| 73 | 0 | test.testAOLJournal(); |
| 74 | 0 | test.testTypePad(); |
| 75 | 0 | test.testGreyMatter(); |
| 76 | 0 | test.testPMachine(); |
| 77 | |
|
| 78 | 0 | test.testRadioUserland(); |
| 79 | 0 | test.testTextPattern(); |
| 80 | 0 | test.testTextAmerica(); |
| 81 | 0 | } |
| 82 | |
|
| 83 | |
public void testBlogger() throws Exception { |
| 84 | 0 | System.out.println("\nTesting Blogger..."); |
| 85 | 0 | testSite( "http://edpro.blogspot.com/", |
| 86 | |
new Blogger(), |
| 87 | |
1, |
| 88 | |
new String[] { FeedReference.ATOM_MEDIA_TYPE }, |
| 89 | |
new String[] { "http://edpro.blogspot.com/atom.xml" }, |
| 90 | |
HAS_ATOM_FEED, |
| 91 | |
"http://edpro.blogspot.com/atom.xml", |
| 92 | |
NO_RSS_FEED, |
| 93 | |
null ); |
| 94 | |
|
| 95 | 0 | testSite("http://carolinascl.blogspot.com/", new Blogger(), 1, |
| 96 | |
new String[] { FeedReference.ATOM_MEDIA_TYPE }, |
| 97 | |
new String[] { "http://carolinascl.blogspot.com/atom.xml" }, |
| 98 | |
HAS_ATOM_FEED, "http://carolinascl.blogspot.com/atom.xml", |
| 99 | |
NO_RSS_FEED, null); |
| 100 | |
|
| 101 | 0 | testSite("http://azizindia.blogspot.com/", new Blogger(), 1, |
| 102 | |
new String[] { FeedReference.ATOM_MEDIA_TYPE }, |
| 103 | |
new String[] { "http://azizindia.blogspot.com/atom.xml" }, |
| 104 | |
HAS_ATOM_FEED, "http://azizindia.blogspot.com/atom.xml", |
| 105 | |
NO_RSS_FEED, null); |
| 106 | |
|
| 107 | |
|
| 108 | 0 | testSite("http://davebarry.blogspot.com/", new Blogger(), 0, |
| 109 | |
new String[] { }, |
| 110 | |
new String[] { }, |
| 111 | |
NO_ATOM_FEED, null, |
| 112 | |
NO_RSS_FEED, null); |
| 113 | 0 | } |
| 114 | |
|
| 115 | |
public void testLiveJournal() throws Exception { |
| 116 | 0 | System.out.println("\nTesting LiveJournal..."); |
| 117 | 0 | testSite("http://www.livejournal.com/community/indiexiankids/", |
| 118 | |
new LiveJournal(), 2, |
| 119 | |
new String[] { |
| 120 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 121 | |
FeedReference.RSS_MEDIA_TYPE |
| 122 | |
}, |
| 123 | |
new String[] { |
| 124 | |
"http://www.livejournal.com/community/indiexiankids/data/atom", |
| 125 | |
"http://www.livejournal.com/community/indiexiankids/data/rss" |
| 126 | |
}, |
| 127 | |
HAS_ATOM_FEED, "http://www.livejournal.com/community/indiexiankids/data/atom", |
| 128 | |
HAS_RSS_FEED, "http://www.livejournal.com/community/indiexiankids/data/rss"); |
| 129 | |
|
| 130 | 0 | testSite("http://www.livejournal.com/community/ajoyforever/", |
| 131 | |
new LiveJournal(), 2, |
| 132 | |
new String[] { |
| 133 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 134 | |
FeedReference.RSS_MEDIA_TYPE |
| 135 | |
}, |
| 136 | |
new String[] { |
| 137 | |
"http://www.livejournal.com/community/ajoyforever/data/atom", |
| 138 | |
"http://www.livejournal.com/community/ajoyforever/data/rss" |
| 139 | |
}, |
| 140 | |
HAS_ATOM_FEED, "http://www.livejournal.com/community/ajoyforever/data/atom", |
| 141 | |
HAS_RSS_FEED, "http://www.livejournal.com/community/ajoyforever/data/rss"); |
| 142 | |
|
| 143 | 0 | testSite("http://www.livejournal.com/users/_jb_/12332.html", |
| 144 | |
new LiveJournal(), 2, |
| 145 | |
new String[] { |
| 146 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 147 | |
FeedReference.RSS_MEDIA_TYPE |
| 148 | |
}, |
| 149 | |
new String[] { |
| 150 | |
"http://www.livejournal.com/users/_jb_/data/atom", |
| 151 | |
"http://www.livejournal.com/users/_jb_/data/rss" |
| 152 | |
}, |
| 153 | |
HAS_ATOM_FEED, "http://www.livejournal.com/users/_jb_/data/atom", |
| 154 | |
HAS_RSS_FEED, "http://www.livejournal.com/users/_jb_/data/rss"); |
| 155 | 0 | } |
| 156 | |
|
| 157 | |
public void testDiaryLand() throws Exception { |
| 158 | 0 | System.out.println("\nTesting DiaryLand... No tests currently"); |
| 159 | |
|
| 160 | 0 | } |
| 161 | |
|
| 162 | |
public void testMovableType() throws Exception { |
| 163 | 0 | System.out.println("\nTesting MovableType... No tests currently"); |
| 164 | |
|
| 165 | 0 | } |
| 166 | |
|
| 167 | |
public void testXanga() throws Exception { |
| 168 | 0 | System.out.println("\nTesting Xanga..."); |
| 169 | 0 | testSite("http://www.xanga.com/home.aspx?user=lithium98", |
| 170 | |
new Xanga(), 1, |
| 171 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 172 | |
new String[] { "http://www.xanga.com/rss.aspx?user=lithium98" }, |
| 173 | |
NO_ATOM_FEED, null, |
| 174 | |
HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=lithium98"); |
| 175 | |
|
| 176 | 0 | testSite("http://www.xanga.com/home.aspx?user=ChUnSA_86", |
| 177 | |
new Xanga(), 1, |
| 178 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 179 | |
new String[] { "http://www.xanga.com/rss.aspx?user=ChUnSA_86" }, |
| 180 | |
NO_ATOM_FEED, null, |
| 181 | |
HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=ChUnSA_86"); |
| 182 | |
|
| 183 | 0 | testSite("http://www.xanga.com/home.aspx?user=wdfphillz", |
| 184 | |
new Xanga(), 1, |
| 185 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 186 | |
new String[] { "http://www.xanga.com/rss.aspx?user=wdfphillz" }, |
| 187 | |
NO_ATOM_FEED, null, |
| 188 | |
HAS_RSS_FEED, "http://www.xanga.com/rss.aspx?user=wdfphillz"); |
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
|
| 193 | |
|
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | 0 | } |
| 200 | |
|
| 201 | |
public void testWordPress() throws Exception { |
| 202 | 0 | System.out.println("\nTesting WordPress..."); |
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
|
| 212 | |
|
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
|
| 220 | |
|
| 221 | |
|
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | 0 | testSite("http://holmes.hgen.pitt.edu/~dweeks/wordpress/", |
| 240 | |
new WordPress(), 3, |
| 241 | |
new String[] { |
| 242 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 243 | |
FeedReference.RSS_MEDIA_TYPE, |
| 244 | |
FeedReference.RSS_MEDIA_TYPE |
| 245 | |
}, |
| 246 | |
new String[] { |
| 247 | |
"http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-atom.php", |
| 248 | |
"http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-rss2.php", |
| 249 | |
"http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-rss.php" |
| 250 | |
}, |
| 251 | |
HAS_ATOM_FEED, "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-atom.php", |
| 252 | |
HAS_RSS_FEED, "http://holmes.hgen.pitt.edu/~dweeks/wordpress/wp-rss2.php"); |
| 253 | 0 | } |
| 254 | |
|
| 255 | |
public void testAOLJournal() throws Exception { |
| 256 | 0 | System.out.println("\nTesting AOL Journal..."); |
| 257 | |
|
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | 0 | testProbeLocator( |
| 266 | |
"http://journals.aol.com/redhdka/BrandNewDay/", |
| 267 | |
new AOLJournal(), 1, |
| 268 | |
new String[] { |
| 269 | |
FeedReference.RSS_MEDIA_TYPE |
| 270 | |
}, |
| 271 | |
new String[] { |
| 272 | |
"http://journals.aol.com/redhdka/BrandNewDay/rss.xml" |
| 273 | |
}, |
| 274 | |
NO_ATOM_FEED, null, |
| 275 | |
HAS_RSS_FEED, "http://journals.aol.com/redhdka/BrandNewDay/rss.xml"); |
| 276 | 0 | testFeedLocator( |
| 277 | |
"http://journals.aol.com/redhdka/BrandNewDay/", |
| 278 | |
new AOLJournal(), 2, |
| 279 | |
new String[] { |
| 280 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 281 | |
FeedReference.RSS_MEDIA_TYPE |
| 282 | |
}, |
| 283 | |
new String[] { |
| 284 | |
"http://journals.aol.com/redhdka/BrandNewDay/atom.xml", |
| 285 | |
"http://journals.aol.com/redhdka/BrandNewDay/rss.xml" |
| 286 | |
}, |
| 287 | |
HAS_ATOM_FEED, "http://journals.aol.com/redhdka/BrandNewDay/atom.xml", |
| 288 | |
HAS_RSS_FEED, "http://journals.aol.com/redhdka/BrandNewDay/rss.xml"); |
| 289 | |
|
| 290 | 0 | testProbeLocator( |
| 291 | |
"http://journals.aol.com/goldenchildnc/GCS/", |
| 292 | |
new AOLJournal(), 1, |
| 293 | |
new String[] { |
| 294 | |
FeedReference.RSS_MEDIA_TYPE |
| 295 | |
}, |
| 296 | |
new String[] { |
| 297 | |
"http://journals.aol.com/goldenchildnc/GCS/rss.xml" |
| 298 | |
}, |
| 299 | |
NO_ATOM_FEED, null, |
| 300 | |
HAS_RSS_FEED, "http://journals.aol.com/goldenchildnc/GCS/rss.xml"); |
| 301 | 0 | testFeedLocator( |
| 302 | |
"http://journals.aol.com/goldenchildnc/GCS/", |
| 303 | |
new AOLJournal(), 2, |
| 304 | |
new String[] { |
| 305 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 306 | |
FeedReference.RSS_MEDIA_TYPE |
| 307 | |
}, |
| 308 | |
new String[] { |
| 309 | |
"http://journals.aol.com/goldenchildnc/GCS/atom.xml", |
| 310 | |
"http://journals.aol.com/goldenchildnc/GCS/rss.xml" |
| 311 | |
}, |
| 312 | |
HAS_ATOM_FEED, "http://journals.aol.com/goldenchildnc/GCS/atom.xml", |
| 313 | |
HAS_RSS_FEED, "http://journals.aol.com/goldenchildnc/GCS/rss.xml"); |
| 314 | |
|
| 315 | |
|
| 316 | 0 | testProbeLocator( |
| 317 | |
"http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/", |
| 318 | |
new AOLJournal(), 1, |
| 319 | |
new String[] { |
| 320 | |
FeedReference.RSS_MEDIA_TYPE |
| 321 | |
}, |
| 322 | |
new String[] { |
| 323 | |
"http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/rss.xml" |
| 324 | |
}, |
| 325 | |
NO_ATOM_FEED, null, |
| 326 | |
HAS_RSS_FEED, "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/rss.xml"); |
| 327 | 0 | testFeedLocator( |
| 328 | |
"http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/", |
| 329 | |
new AOLJournal(), 2, |
| 330 | |
new String[] { |
| 331 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 332 | |
FeedReference.RSS_MEDIA_TYPE |
| 333 | |
}, |
| 334 | |
new String[] { |
| 335 | |
"http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/atom.xml", |
| 336 | |
"http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/rss.xml" |
| 337 | |
}, |
| 338 | |
HAS_ATOM_FEED, "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/atom.xml", |
| 339 | |
HAS_RSS_FEED, "http://journals.aol.com/mkgninja/MelissasMisunderstandingsofLife/rss.xml"); |
| 340 | 0 | } |
| 341 | |
|
| 342 | |
public void testTypePad() throws Exception { |
| 343 | 0 | System.out.println("\nTesting TypePad..."); |
| 344 | |
|
| 345 | |
|
| 346 | |
|
| 347 | |
|
| 348 | 0 | testSite("http://lynikers.typepad.com/", |
| 349 | |
new Typepad(), 0, |
| 350 | |
new String[] { }, |
| 351 | |
new String[] { }, |
| 352 | |
HAS_ATOM_FEED, "http://lynikers.typepad.com/on_buck_lake/atom.xml", |
| 353 | |
HAS_RSS_FEED, "http://lynikers.typepad.com/on_buck_lake/index.rdf"); |
| 354 | |
|
| 355 | |
|
| 356 | |
|
| 357 | 0 | testSite("http://emmeke.typepad.com/", |
| 358 | |
new Typepad(), 0, |
| 359 | |
new String[] { }, |
| 360 | |
new String[] { }, |
| 361 | |
NO_ATOM_FEED, null, |
| 362 | |
HAS_RSS_FEED, "http://emmeke.typepad.com/blog/index.rdf"); |
| 363 | |
|
| 364 | 0 | testSite("http://www.prettypolitical.com/", |
| 365 | |
new Typepad(), 2, |
| 366 | |
new String[] { |
| 367 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 368 | |
FeedReference.RSS_MEDIA_TYPE |
| 369 | |
}, |
| 370 | |
new String[] { |
| 371 | |
"http://www.prettypolitical.com/atom.xml", |
| 372 | |
"http://www.prettypolitical.com/index.rdf" |
| 373 | |
}, |
| 374 | |
HAS_ATOM_FEED, "http://www.prettypolitical.com/atom.xml", |
| 375 | |
HAS_RSS_FEED, "http://www.prettypolitical.com/index.rdf"); |
| 376 | 0 | } |
| 377 | |
|
| 378 | |
public void testGreyMatter() throws Exception { |
| 379 | 0 | System.out.println("\nTesting GreyMatter..."); |
| 380 | |
|
| 381 | 0 | testSite("http://www.chattbike.com/gilligan/", |
| 382 | |
new GreyMatter(), 0, |
| 383 | |
new String[] { }, |
| 384 | |
new String[] { }, |
| 385 | |
NO_ATOM_FEED, null, |
| 386 | |
NO_RSS_FEED, null); |
| 387 | |
|
| 388 | |
|
| 389 | 0 | testSite("http://www.electricedge.com/greymatter/", |
| 390 | |
new GreyMatter(), 0, |
| 391 | |
new String[] { }, |
| 392 | |
new String[] { }, |
| 393 | |
NO_ATOM_FEED, null, |
| 394 | |
NO_RSS_FEED, null); |
| 395 | 0 | } |
| 396 | |
|
| 397 | |
public void testPMachine() throws Exception { |
| 398 | 0 | System.out.println("\nTesting PMachine..."); |
| 399 | 0 | testSite("http://bamph.com", |
| 400 | |
new Unknown(), 1, |
| 401 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 402 | |
new String[] { "http://bamph.com/index.xml" }, |
| 403 | |
NO_ATOM_FEED, null, |
| 404 | |
HAS_RSS_FEED, "http://bamph.com/index.xml"); |
| 405 | |
|
| 406 | 0 | testSite("http://bucsfishingreport.com/pMachine/weblog.php", |
| 407 | |
new PMachine(), 1, |
| 408 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 409 | |
new String[] { "http://bucsfishingreport.com/pMachine/index.xml" }, |
| 410 | |
NO_ATOM_FEED, null, |
| 411 | |
HAS_RSS_FEED, "http://bucsfishingreport.com/pMachine/index.xml"); |
| 412 | |
|
| 413 | 0 | testSite("http://www.simplekindoflife.com/pMachine/weblog.php", |
| 414 | |
new PMachine(), 1, |
| 415 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 416 | |
new String[] { "http://www.simplekindoflife.com/pMachine/index.xml" }, |
| 417 | |
NO_ATOM_FEED, null, |
| 418 | |
HAS_RSS_FEED, "http://www.simplekindoflife.com/pMachine/index.xml"); |
| 419 | |
|
| 420 | 0 | testSite("http://www.mondfish.net/pmachine/weblog.php", |
| 421 | |
new PMachine(), 1, |
| 422 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 423 | |
new String[] { "http://www.mondfish.net/pmachine/index.xml" }, |
| 424 | |
NO_ATOM_FEED, null, |
| 425 | |
HAS_RSS_FEED, "http://www.mondfish.net/pmachine/index.xml"); |
| 426 | 0 | } |
| 427 | |
|
| 428 | |
public void testBlosxom() throws Exception { |
| 429 | 0 | System.out.println("\nTesting Blosxom..."); |
| 430 | 0 | testSite("http://mikemason.ca/", |
| 431 | |
new Blosxom(), 1, |
| 432 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 433 | |
new String[] { "http://mikemason.ca/index.rss" }, |
| 434 | |
NO_ATOM_FEED, null, |
| 435 | |
HAS_RSS_FEED, "http://mikemason.ca/index.rss"); |
| 436 | |
|
| 437 | |
|
| 438 | |
|
| 439 | |
|
| 440 | |
|
| 441 | |
|
| 442 | |
|
| 443 | |
|
| 444 | |
|
| 445 | |
|
| 446 | |
|
| 447 | |
|
| 448 | |
|
| 449 | |
|
| 450 | |
|
| 451 | |
|
| 452 | |
|
| 453 | |
|
| 454 | |
|
| 455 | |
|
| 456 | |
|
| 457 | |
|
| 458 | 0 | testSite("http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi", |
| 459 | |
new Blosxom(), 1, |
| 460 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 461 | |
new String[] { "http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi/index.rss" }, |
| 462 | |
NO_ATOM_FEED, null, |
| 463 | |
HAS_RSS_FEED, "http://www.bitbucketheaven.com/cgi-bin/blosxom.cgi/index.rss"); |
| 464 | 0 | } |
| 465 | |
|
| 466 | |
public void testRadioUserland() throws Exception { |
| 467 | 0 | System.out.println("\nTesting Radio Userland..."); |
| 468 | 0 | testSite("http://radio.weblogs.com/0131722/", |
| 469 | |
new RadioUserland(), 1, |
| 470 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 471 | |
new String[] { "http://radio.weblogs.com/0131722/rss.xml" }, |
| 472 | |
NO_ATOM_FEED, null, |
| 473 | |
HAS_RSS_FEED, "http://radio.weblogs.com/0131722/rss.xml"); |
| 474 | |
|
| 475 | 0 | testSite("http://radio.weblogs.com/0131724/", |
| 476 | |
new RadioUserland(), 1, |
| 477 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 478 | |
new String[] { "http://radio.weblogs.com/0131724/rss.xml" }, |
| 479 | |
NO_ATOM_FEED, null, |
| 480 | |
HAS_RSS_FEED, "http://radio.weblogs.com/0131724/rss.xml"); |
| 481 | |
|
| 482 | 0 | testSite("http://radio.weblogs.com/0131734/", |
| 483 | |
new RadioUserland(), 1, |
| 484 | |
new String[] { FeedReference.RSS_MEDIA_TYPE }, |
| 485 | |
new String[] { "http://radio.weblogs.com/0131734/rss.xml" }, |
| 486 | |
NO_ATOM_FEED, null, |
| 487 | |
HAS_RSS_FEED, "http://radio.weblogs.com/0131734/rss.xml"); |
| 488 | 0 | } |
| 489 | |
|
| 490 | |
public void testTextPattern() throws Exception { |
| 491 | 0 | System.out.println("\nTesting TextPattern..."); |
| 492 | 0 | testSite("http://www.digitalmediaminute.com/", |
| 493 | |
new TextPattern(), 2, |
| 494 | |
new String[] { |
| 495 | |
FeedReference.ATOM_MEDIA_TYPE, |
| 496 | |
FeedReference.RSS_MEDIA_TYPE |
| 497 | |
}, |
| 498 | |
new String[] { |
| 499 | |
"http://www.digitalmediaminute.com/?atom=1", |
| 500 | |
"http://www.digitalmediaminute.com/?rss=1" |
| 501 | |
}, |
| 502 | |
HAS_ATOM_FEED, "http://www.digitalmediaminute.com/?atom=1", |
| 503 | |
HAS_RSS_FEED, "http://www.digitalmediaminute.com/?rss=1"); |
| 504 | 0 | } |
| 505 | |
|
| 506 | |
public void testTextAmerica() throws Exception { |
| 507 | 0 | System.out.println("\nTesting TextAmerica..."); |
| 508 | 0 | testSite("http://morganwebb.textamerica.com/", |
| 509 | |
new TextAmerica(), 1, |
| 510 | |
new String[] { |
| 511 | |
FeedReference.RSS_MEDIA_TYPE |
| 512 | |
}, |
| 513 | |
new String[] { |
| 514 | |
"http://morganwebb.textamerica.com/rss.aspx" |
| 515 | |
}, |
| 516 | |
NO_ATOM_FEED, null, |
| 517 | |
HAS_RSS_FEED, "http://morganwebb.textamerica.com/rss.aspx"); |
| 518 | |
|
| 519 | 0 | testSite("http://northlan.textamerica.com/", |
| 520 | |
new TextAmerica(), 1, |
| 521 | |
new String[] { |
| 522 | |
FeedReference.RSS_MEDIA_TYPE |
| 523 | |
}, |
| 524 | |
new String[] { |
| 525 | |
"http://northlan.textamerica.com/rss.aspx" |
| 526 | |
}, |
| 527 | |
NO_ATOM_FEED, null, |
| 528 | |
HAS_RSS_FEED, "http://northlan.textamerica.com/rss.aspx"); |
| 529 | |
|
| 530 | 0 | testSite("http://mycamphone.textamerica.com/", |
| 531 | |
new TextAmerica(), 1, |
| 532 | |
new String[] { |
| 533 | |
FeedReference.RSS_MEDIA_TYPE |
| 534 | |
}, |
| 535 | |
new String[] { |
| 536 | |
"http://mycamphone.textamerica.com/rss.aspx" |
| 537 | |
}, |
| 538 | |
NO_ATOM_FEED, null, |
| 539 | |
HAS_RSS_FEED, "http://mycamphone.textamerica.com/rss.aspx"); |
| 540 | 0 | } |
| 541 | |
|
| 542 | |
|
| 543 | |
protected String getContent(String resource) throws Exception { |
| 544 | |
|
| 545 | |
|
| 546 | |
|
| 547 | 0 | URL resourceURL = new URL(resource); |
| 548 | 0 | URLConnection con = resourceURL.openConnection(); |
| 549 | 0 | con.connect(); |
| 550 | 0 | BufferedReader in = new BufferedReader(new InputStreamReader(con |
| 551 | |
.getInputStream())); |
| 552 | 0 | StringBuffer results = new StringBuffer(); |
| 553 | 0 | String line = null; |
| 554 | |
|
| 555 | 0 | while ((line = in.readLine()) != null) { |
| 556 | 0 | results.append(line); |
| 557 | |
} |
| 558 | |
|
| 559 | 0 | return results.toString(); |
| 560 | |
} |
| 561 | |
|
| 562 | |
private void testSite(String resource, BlogService correctBlogService, |
| 563 | |
int numberOfFeeds, String feedType[], |
| 564 | |
String feedURL[], boolean hasAtomFeed, |
| 565 | |
String atomFeedURL, boolean hasRSSFeed, |
| 566 | |
String rssFeedURL) throws Exception { |
| 567 | 0 | System.out.println("Testing " + resource + "..."); |
| 568 | |
|
| 569 | 0 | testProbeLocator(resource, correctBlogService, numberOfFeeds, |
| 570 | |
feedType, feedURL, hasAtomFeed, |
| 571 | |
atomFeedURL, hasRSSFeed, rssFeedURL); |
| 572 | |
|
| 573 | |
|
| 574 | 0 | testFeedLocator(resource, correctBlogService, numberOfFeeds, |
| 575 | |
feedType, feedURL, hasAtomFeed, |
| 576 | |
atomFeedURL, hasRSSFeed, rssFeedURL); |
| 577 | 0 | } |
| 578 | |
|
| 579 | |
private FeedList testProbeLocator(String resource, BlogService correctBlogService, |
| 580 | |
int numberOfFeeds, String feedType[], |
| 581 | |
String feedURL[], boolean hasAtomFeed, |
| 582 | |
String atomFeedURL, boolean hasRSSFeed, |
| 583 | |
String rssFeedURL) throws Exception { |
| 584 | 0 | String content = getContent(resource); |
| 585 | 0 | assertNotNull(content); |
| 586 | |
|
| 587 | 0 | BlogService blogService = BlogServiceDiscovery.discover(resource, content); |
| 588 | 0 | assertEquals(correctBlogService, blogService); |
| 589 | |
|
| 590 | 0 | FeedList list = new FeedList(); |
| 591 | 0 | ProbeLocator.locate(resource, content, list); |
| 592 | 0 | assertEquals(numberOfFeeds, list.size()); |
| 593 | |
|
| 594 | 0 | FeedReference[] feeds = (FeedReference[])list.toArray(new FeedReference[list.size()]); |
| 595 | 0 | assertEquals(numberOfFeeds, feeds.length); |
| 596 | |
|
| 597 | 0 | for (int i = 0; i < feeds.length; i++) { |
| 598 | 0 | assertEquals(FeedReference.METHOD_PROBE_DISCOVERY, feeds[i].method); |
| 599 | 0 | assertNull(null, feeds[i].title); |
| 600 | 0 | assertEquals(feedType[i], feeds[i].type); |
| 601 | 0 | assertEquals(feedURL[i], feeds[i].resource); |
| 602 | |
} |
| 603 | |
|
| 604 | 0 | return list; |
| 605 | |
} |
| 606 | |
|
| 607 | |
private FeedList testFeedLocator( String resource, |
| 608 | |
BlogService correctBlogService, |
| 609 | |
int numberOfFeeds, |
| 610 | |
String feedType[], |
| 611 | |
String feedURL[], |
| 612 | |
boolean hasAtomFeed, |
| 613 | |
String atomFeedURL, |
| 614 | |
boolean hasRSSFeed, |
| 615 | |
String rssFeedURL ) throws Exception { |
| 616 | |
|
| 617 | 0 | FeedList list = FeedLocator.locate( resource ); |
| 618 | 0 | FeedReference atomFeed = list.getAdAtomFeed(); |
| 619 | 0 | FeedReference rssFeed = list.getAdRSSFeed(); |
| 620 | 0 | if (hasAtomFeed) { |
| 621 | 0 | assertNotNull(atomFeed); |
| 622 | 0 | assertEquals(FeedReference.ATOM_MEDIA_TYPE, atomFeed.type); |
| 623 | 0 | assertEquals(atomFeedURL, atomFeed.resource); |
| 624 | |
} |
| 625 | |
else |
| 626 | 0 | assertNull(atomFeed); |
| 627 | |
|
| 628 | 0 | if (hasRSSFeed) { |
| 629 | 0 | assertNotNull(rssFeed); |
| 630 | 0 | assertEquals(FeedReference.RSS_MEDIA_TYPE, rssFeed.type); |
| 631 | 0 | assertEquals(rssFeedURL, rssFeed.resource); |
| 632 | |
} |
| 633 | |
else |
| 634 | 0 | assertNull(rssFeed); |
| 635 | |
|
| 636 | 0 | return list; |
| 637 | |
} |
| 638 | |
} |