Coverage Report - org.apache.commons.feedparser.test.TestFeedParser
 
Classes in this File Line Coverage Branch Coverage Complexity
TestFeedParser
0%
0/15
N/A
1.167
TestFeedParser$1
0%
0/6
N/A
1.167
 
 1  
 /*
 2  
  * Copyright 1999,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.feedparser.test;
 18  
 
 19  
 import junit.framework.TestCase;
 20  
 
 21  
 import org.apache.commons.feedparser.DefaultFeedDirectoryParserListener;
 22  
 import org.apache.commons.feedparser.FeedParser;
 23  
 import org.apache.commons.feedparser.FeedParserException;
 24  
 import org.apache.commons.feedparser.FeedParserFactory;
 25  
 import org.apache.commons.feedparser.FeedParserListener;
 26  
 import org.apache.commons.feedparser.FeedParserState;
 27  
 import org.apache.commons.feedparser.network.ResourceRequest;
 28  
 import org.apache.commons.feedparser.network.ResourceRequestFactory;
 29  
 
 30  
 /**
 31  
  *
 32  
  * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
 33  
  * @version $Id: TestFeedParser.java 373622 2006-01-30 22:53:00Z mvdb $
 34  
  */
 35  
 public class TestFeedParser extends TestCase {
 36  
 
 37  
     public TestFeedParser( String name ) throws Exception {
 38  0
         super( name );
 39  0
     }
 40  
 
 41  
     public void testParseOPML() throws Exception {
 42  
 
 43  0
         String resource = "http://weblog.infoworld.com/udell/gems/mySubscriptions.opml";
 44  
         
 45  0
         FeedParser parser = FeedParserFactory.newFeedParser();
 46  
 
 47  0
         FeedParserListener listener = new DefaultFeedDirectoryParserListener() {
 48  
 
 49  
                 public void onItem( FeedParserState state,
 50  
                                     String title,
 51  
                                     String weblog,
 52  
                                     String description,
 53  
                                     String feed ) throws FeedParserException {
 54  
 
 55  0
                     System.out.println( "title" + title );
 56  0
                     System.out.println( "feed: " + feed );
 57  
                     
 58  0
                 }
 59  
 
 60  0
                 public void onItemEnd() {}
 61  
 
 62  0
                 public void finished() {}
 63  
                 
 64  
             };
 65  
         
 66  0
         listener.setContext( this );
 67  
         
 68  0
         ResourceRequest request = ResourceRequestFactory.getResourceRequest( resource );
 69  
         
 70  0
         parser.parse( listener, request.getInputStream(), resource );
 71  
             
 72  0
     }
 73  
 
 74  
     public static void main( String[] args ) {
 75  
 
 76  
         try { 
 77  
 
 78  0
             TestFeedParser test = new TestFeedParser( null );
 79  
 
 80  
             //test.testGetWeblogLinkForResource();
 81  0
             test.testParseOPML();
 82  
             
 83  0
         } catch ( Throwable t ) {
 84  
             
 85  0
             t.printStackTrace();
 86  
             
 87  0
         }
 88  
         
 89  0
     }
 90  
 
 91  
 }
 92