KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > rss > test > TestRss


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5
6 package org.exoplatform.portlets.rss.test;
7
8 import java.util.*;
9 import java.io.InputStream JavaDoc ;
10 import java.net.URL JavaDoc ;
11 import org.exoplatform.portlets.rss.component.*;
12 import org.exoplatform.test.BasicTestCase;
13
14 //import org.apache.commons.digester.rss.RSSDigester;
15
//import org.apache.commons.digester.rss.Channel;
16
//import org.apache.commons.digester.rss.Item;
17
/*
18  * Thu, Jun 05, 2003 @
19  * @author: Tuan Nguyen
20  * @version: $Id: TestRss.java,v 1.2 2004/04/10 17:21:35 tuan08 Exp $
21  * @since: 0.0
22  * @email: tuan08@yahoo.com
23  */

24 public class TestRss extends BasicTestCase {
25   
26   public TestRss(String JavaDoc name) {
27     super(name);
28   }
29
30   protected void setUp() throws Exception JavaDoc {
31   }
32
33   protected void tearDown() throws Exception JavaDoc {
34   }
35
36   protected int getTestNumber() {
37     return 1 ;
38   }
39   /*
40   public void testRssChannel() throws Exception {
41     Channel channel = null;
42     try {
43       RSSDigester digester = new RSSDigester();
44       digester.setDebug(999) ;
45       //channel = (Channel) digester.parse("file:./src/exo/portal/portlets/rss/test/Rss.xml");
46       URL url = new URL("http://sourceforge.net/export/rss2_projsummary.php?group_id=62218");
47       //URL url = new URL("http://headlines.internet.com/internetnews/fina-news/news.rss");
48       System.out.println("size = " + url.openStream().available());
49       channel = (Channel) digester.parse(url.openStream());
50       System.out.println("Channel " + channel);
51       System.out.println("Rating : " + channel.getRating());
52       System.out.println("Publish Date : " + channel.getPubDate());
53       System.out.println("Description : " + channel.getDescription());
54       Item[] items = channel.getItems() ;
55       for (int i = 0; i < items.length ; i++) {
56         System.out.println("Title : " + items[i].getTitle());
57         System.out.println("Description : " + items[i].getDescription());
58         System.out.println("Link : " + items[i].getLink());
59         
60       }
61     } catch (Exception ex) {
62       ex.printStackTrace();
63     }
64   }
65   */

66
67   public void testRssChannel() throws Exception JavaDoc {
68     Channel channel = Channel.parse("http://headlines.internet.com/internetnews/fina-news/news.rss") ;
69     System.out.println("title : " + channel.getTitle());
70     System.out.println("link : " + channel.getLink());
71     System.out.println("Description : " + channel.getDescription());
72     Item[] items = channel.getItems() ;
73     for (int i = 0; i < items.length ; i++) {
74       System.out.println("Title : " + items[i].getTitle());
75       System.out.println("Description : " + items[i].getDescription());
76       System.out.println("Link : " + items[i].getLink());
77
78     }
79   }
80
81   public String JavaDoc getDescription() {
82     return "Test Rss" ;
83   }
84 }
85
86
Popular Tags